* Constructor.
*
* @param array $params A hash containing connection parameters.
+ *
+ * @throws Horde_Exception
*/
public function __construct($params = array())
{
if (!$this->_backend->hasCapability('add') ||
!$this->_backend->hasCapability('update') ||
!$this->_backend->hasCapability('remove')) {
- Horde::fatal('Horde_Auth_Cyrus: Backend does not have required capabilites.', __FILE__, __LINE__);
+ throw new Horde_Exception('Horde_Auth_Cyrus: Backend does not have required capabilites.');
}
$this->_capabilities['list'] = $this->_backend->hasCapability('list');
/**
* Attempts to open a connection to the sql server.
*
- * @return boolean True on success; exits (Horde::fatal()) on error.
+ * @return boolean True on success.
+ * @throws Horde_Exception
*/
protected function _connect()
{
unset($params['charset']);
$this->_write_db = MDB2::factory($params);
if (is_a($this->_write_db, 'PEAR_Error')) {
- Horde::fatal($this->_write_db, __FILE__, __LINE__);
+ throw new Horde_Exception($this->_write_db);
}
/* Set DB portability options. */
$params = array_merge($params, $this->_params['read']);
$this->_db = MDB2::factory($params);
if (is_a($this->_db, 'PEAR_Error')) {
- Horde::fatal($this->_db, __FILE__, __LINE__);
+ thorw new Horde_Exception($this->_db);
}
/* Set DB portability options. */
* instantiated.
*
* @return mixed Log object on success, false if disabled.
+ * @throws Horde_Exception
*/
static public function getLogger()
{
empty($conf['log']['name']) ||
empty($conf['log']['ident']) ||
!isset($conf['log']['params'])) {
- self::fatal(new Horde_Exception('Horde is not correctly configured to log error messages. You must configure at least a text file log in horde/config/conf.php.'), __FILE__, __LINE__, false);
+ throw new Horde_Exception('Horde is not correctly configured to log error messages. You must configure at least a text file log in horde/config/conf.php.');
}
self::$_logger = Log::singleton($conf['log']['type'],
$conf['log']['name'],
$conf['log']['ident'],
$conf['log']['params']);
- if (!is_a(self::$_logger, 'Log')) {
- self::fatal(new Horde_Exception('An error has occurred. Furthermore, Horde encountered an error attempting to log this error. Please check your Horde logging configuration in horde/config/conf.php.'), __FILE__, __LINE__, false);
+ if (!self::$_logger instanceof Log) {
+ throw new Horde_Exception('An error has occurred. Furthermore, Horde encountered an error attempting to log this error. Please check your Horde logging configuration in horde/config/conf.php.');
}
return self::$_logger;
case 'login':
/* Get an Auth object. */
- try {
- $auth = Horde_Auth::singleton($GLOBALS['conf']['auth']['driver']);
- } catch (Horde_Exception $e) {
- Horde::fatal($e, __FILE__, __LINE__);
- }
+ $auth = Horde_Auth::singleton($GLOBALS['conf']['auth']['driver']);
return $auth->getLoginScreen('', $referrer ? self::selfUrl(true) : null);
case 'options':
* @param string $file The configuration file that should contain
* these settings.
* @param string $variable The name of the configuration variable.
+ *
+ * @throws Horde_Exception
*/
static public function assertDriverConfig($params, $driver, $fields,
$name = null,
$fileroot = isset($registry) ? $registry->get('fileroot') : '';
if (!is_array($params) || !count($params)) {
- self::fatal(new Horde_Exception(
+ throw new Horde_Exception(
sprintf(_("No configuration information specified for %s."), $name) . "\n\n" .
sprintf(_("The file %s should contain some %s settings."),
$fileroot . '/config/' . $file,
- sprintf("%s['%s']['params']", $variable, $driver))),
- __FILE__, __LINE__);
+ sprintf("%s['%s']['params']", $variable, $driver)));
}
foreach ($fields as $field) {
if (!isset($params[$field])) {
- self::fatal(new Horde_Exception(
+ throw new Horde_Exception(
sprintf(_("Required \"%s\" not specified in %s configuration."), $field, $name) . "\n\n" .
sprintf(_("The file %s should contain a %s setting."),
$fileroot . '/config/' . $file,
- sprintf("%s['%s']['params']['%s']", $variable, $driver, $field))),
- __FILE__, __LINE__);
+ sprintf("%s['%s']['params']['%s']", $variable, $driver, $field)));
}
}
}
* Initializes the XML parser.
*
* @return boolean Returns true on success, false on failure.
+ * @throws Horde_Exception
*/
protected function _init()
{
if (!isset($this->_parser)) {
if (!Horde_Util::extensionExists('xml')) {
- Horde::fatal(PEAR::raiseError('The XML functions are not available. Rebuild PHP with --with-xml.'), __FILE__, __LINE__, false);
+ throw new Horde_Exception('The XML functions are not available. Rebuild PHP with --with-xml.');
}
/* Create a new parser and set its default properties. */
/* Stop system if Horde is inactive. */
if ($this->applications['horde']['status'] == 'inactive') {
- Horde::fatal(_("This system is currently deactivated."), __FILE__, __LINE__);
+ throw new Horde_Exception(_("This system is currently deactivated."));
}
/* Create the global Perms object. */
/**
* Clone should never be called on this object. If it is, die.
+ *
+ * @throws Horde_Exception
*/
public function __clone()
{
- Horde::fatal('Horde_Registry objects should never be cloned.', __FILE__, __LINE__);
+ throw new Horde_Exception('Horde_Registry objects should never be cloned.');
}
/**
if (!isset($this->applications[$app]) ||
$this->applications[$app]['status'] == 'inactive' ||
($this->applications[$app]['status'] == 'admin' && !Horde_Auth::isAdmin())) {
- Horde::fatal($app . ' is not activated', __FILE__, __LINE__);
+ throw new Horde_Exception($app . ' is not activated.');
}
/* If permissions checking is requested, return an error if the
*
* The custom session handler object will be contained in the global
* 'horde_sessionhandler' variable.
+ *
+ * @throws Horde_Exception
*/
public function setupSessionHandler()
{
ini_set('session.use_only_cookies', 1);
if (!empty($conf['cookie']['domain']) &&
strpos($conf['server']['name'], '.') === false) {
- Horde::fatal('Session cookies will not work without a FQDN and with a non-empty cookie domain. Either use a fully qualified domain name like "http://www.example.com" instead of "http://example" only, or set the cookie domain in the Horde configuration to an empty value, or enable non-cookie (url-based) sessions in the Horde configuration.', __FILE__, __LINE__);
+ throw new Horde_Exception('Session cookies will not work without a FQDN and with a non-empty cookie domain. Either use a fully qualified domain name like "http://www.example.com" instead of "http://example" only, or set the cookie domain in the Horde configuration to an empty value, or enable non-cookie (url-based) sessions in the Horde configuration.');
}
}
$calls['destroy'],
$calls['gc']);
} elseif ($type != 'none') {
- try {
- $sh = Horde_SessionHandler::singleton($conf['sessionhandler']['type'], array_merge(Horde::getDriverConfig('sessionhandler', $conf['sessionhandler']['type']), array('memcache' => !empty($conf['sessionhandler']['memcache']))));
- ini_set('session.save_handler', 'user');
- session_set_save_handler(array(&$sh, 'open'),
- array(&$sh, 'close'),
- array(&$sh, 'read'),
- array(&$sh, 'write'),
- array(&$sh, 'destroy'),
- array(&$sh, 'gc'));
- $GLOBALS['horde_sessionhandler'] = $sh;
- } catch (Horde_Exception $e) {
- Horde::fatal(new Horde_Exception('Horde is unable to correctly start the custom session handler.'), __FILE__, __LINE__, false);
- }
+ $sh = Horde_SessionHandler::singleton($conf['sessionhandler']['type'], array_merge(Horde::getDriverConfig('sessionhandler', $conf['sessionhandler']['type']), array('memcache' => !empty($conf['sessionhandler']['memcache']))));
+ ini_set('session.save_handler', 'user');
+ session_set_save_handler(array(&$sh, 'open'),
+ array(&$sh, 'close'),
+ array(&$sh, 'read'),
+ array(&$sh, 'write'),
+ array(&$sh, 'destroy'),
+ array(&$sh, 'gc'));
+ $GLOBALS['horde_sessionhandler'] = $sh;
}
}
$this->_tempdir = Horde_Util::createTempDir(true, $params['temp']);
if (empty($params['program'])) {
- Horde::fatal(new Horde_Exception('The location of the GnuPG binary must be given to the Horde_Crypt_Pgp:: class.'), __FILE__, __LINE__);
+ throw new Horde_Exception('The location of the GnuPG binary must be given to the Horde_Crypt_Pgp:: class.');
}
/* Store the location of GnuPG and set common options. */
/* Check for sessionhandler object. */
if (empty($GLOBALS['horde_sessionhandler'])) {
- Horde::fatal(PEAR::raiseError('Horde is unable to load the session handler'), __FILE__, __LINE__, false);
+ throw new Horde_Exception('Horde is unable to load the session handler');
}
$type = !empty($conf['sessionhandler']['type']) ?
$conf['sessionhandler']['type'] : 'builtin';
if ($type == 'external') {
- Horde::fatal(PEAR::raiseError('Session counting is not supported in the \'external\' SessionHandler at this time.'), __FILE__, __LINE__, false);
+ throw new Horde_Exception('Session counting is not supported in the \'external\' SessionHandler at this time.');
}
$sessions = $GLOBALS['horde_sessionhandler']->getSessionsInfo();
if (is_a($sessions, 'PEAR_Error')) {
- Horde::fatal($sessions, __FILE__, __LINE__, false);
+ throw new Horde_Exception($sessions);
}
if (($argc < 2) || (($argv[1] != '-l') && ($argv[1] != '-ll'))) {