/**
* Return the Agora_Driver:: instance.
*
* @param string $scope Instance scope
* @param int $forum_id Forum to link to
*
* @return Agora_Driver The singleton instance.
* @throws Agora_Exception
*/
public function create($scope = 'agora', $forum_id = 0)
{
if (!isset($this->_instances[$scope])) {
$driver = $GLOBALS['conf']['threads']['split'] ? 'SplitSql' : 'Sql';
$params = Horde::getDriverConfig('sql');
$class = 'Agora_Driver_' . $driver;
if (!class_exists($class)) {
throw new Agora_Exception(sprintf('Unable to load the definition of %s.', $class));
}
$params = array('db' => $this->_injector->getInstance('Horde_Db_Adapter'), 'charset' => $params['charset']);
$driver = new $class($scope, $params);
$this->_instances[$scope] = $driver;
}
if ($forum_id) {
/* Check if there was a valid forum object to get. */
try {
$forum = $this->_instances[$scope]->getForum($forum_id);
} catch (Horde_Exception $e) {
throw new Agora_Exception($e->getMessage());
}
/* Set current forum id and forum data */
$this->_instances[$scope]->_forum = $forum;
$this->_instances[$scope]->_forum_id = (int) $forum_id;
}
return $this->_instances[$scope];
}