/* Get the list of forums. */
$forums_list = $forums->getForums(0, true, $sort_by, $sort_dir, true, $forum_start, $forums_per_page);
if ($forums_list instanceof PEAR_Error) {
- Horde::fatal($forums_list, __FILE__, __LINE__);
+ throw new Horde_Exception($forums_list);
} elseif (empty($forums_list)) {
$forums_count = 0;
} else {
/**
* Attempts to open a persistent connection to the SQL server.
*
- * @return boolean True on success; exits (Horde::fatal()) on error.
+ * @return boolean True on success.
+ * @throws Horde_Exception
*/
private function _connect()
{
$this->_write_db = MDB2::factory($this->_params);
if ($this->_write_db instanceof PEAR_Error) {
- Horde::fatal($this->_write_db, __FILE__, __LINE__);
+ throw new Horde_Exception($this->_write_db);
}
if (!empty($params['splitread'])) {
$params = array_merge($this->_params, $this->_params['read']);
$this->_db = MDB2::factory($this->_params);
if ($this->_db instanceof PEAR_Error) {
- Horde::fatal($this->_db, __FILE__, __LINE__);
+ throw new Horde_Exception($this->_db);
}
} else {
/* Default to the same DB handle for the writer too. */
$this->_db->loadModule('Extended');
if ($this->_db instanceof PEAR_Error) {
- Horde::fatal($this->_db, __FILE__, __LINE__);
+ throw new Horde_Exception($this->_db);
}
$this->_db->setFetchMode(MDB2_FETCHMODE_ASSOC);
// Get forum title
$threads = Agora_Messages::singleton($scope, $forum_id);
if ($threads instanceof PEAR_Error) {
- Horde::fatal($threads, __FILE__, __LINE__);
+ throw new Horde_Exception($threads);
}
if ($scope == 'agora') {
$forum_array = $threads->getForum();
if ($forum_array instanceof PEAR_Error) {
- Horde::fatal($forum_array, __FILE__, __LINE__);
+ throw new Horde_Exception($forum_array);
}
$title = sprintf(_("Threads in %s"), $forum_array['forum_name']);
} else {
$title = $registry->callByPackage($scope, 'commentCallback', array($forum_name, 'title'));
if ($title instanceof PEAR_Error) {
- Horde::fatal($title, __FILE__, __LINE__);
+ throw new Horde_Exception($title);
}
$title = sprintf(_("Comments on %s"), $title);
}
/* Sanity checks, perms etc... */
if (empty($image_id)) {
- Horde::fatal(_("An error has occured retrieving the image. Details have been logged."), __FILE__, __LINE__, true);
+ throw new Ansel_Exception(_("An error has occured retrieving the image. Details have been logged."));
}
$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery);
*
* @access private
*
- * @return boolean True on success; exits (Horde::fatal()) on error.
+ * @return boolean True on success.
+ * @throws Beatnik_Exception
*
* @access private
*/
$this->_LDAP = ldap_connect($this->_params['hostspec'], $port);
if (!$this->_LDAP) {
- Horde::fatal("Unable to connect to LDAP server $hostname on $port", __FILE__, __LINE__);
+ throw new Beatnik_Exception("Unable to connect to LDAP server $hostname on $port");
}
$res = ldap_set_option($this->_LDAP, LDAP_OPT_PROTOCOL_VERSION, $this->_params['version']);
if ($res === false) {
// Allocate a global VFS object
$GLOBALS['gollem_vfs'] = Gollem::getVFSOb($_SESSION['gollem']['backend_key']);
if (is_a($GLOBALS['gollem_vfs'], 'PEAR_Error')) {
- Horde::fatal($GLOBALS['gollem_vfs']);
+ throw new Horde_Exception($GLOBALS['gollem_vfs']);
}
$valid = $GLOBALS['gollem_vfs']->checkCredentials();
if ($vars->exists('deliverable_id')) {
$deliverable = $hermes->driver->getDeliverableByID($vars->get('deliverable_id'));
if (is_a($deliverable, 'PEAR_Error')) {
- Horde::fatal($deliverable, __FILE__, __LINE__);
+ throw new Hermes_Exception($deliverable);
}
foreach ($deliverable as $name => $value) {
$deliverables = $hermes->driver->listDeliverables(array('client_id' => $vars->get('client_id')));
if (is_a($deliverables, 'PEAR_Error')) {
- Horde::fatal($deliverables, __FILE__, __LINE__);
+ throw new Hermes_Exception($deliverables);
}
$tree = $GLOBALS['injector']->getInstance('Horde_Tree')->getTree('deliverables', 'Javascript');
// Make sure we have a charset parameter. Value could also be null.
if (!array_key_exists('charset', $params)) {
- Horde::fatal('Incomplete configuration.');
+ throw new Horde_Exception('Incomplete configuration');
}
Please note that `array_key_exists()`_ is a performance hit (25%-100%) and
$tpl = Horde_Util::getFormData('template', 'default');
if (empty($_covers[$tpl])) {
- Horde::fatal(_("The requested Cover Page does not exist."), __FILE__, __LINE__);
+ throw new Horde_Exception(_("The requested Cover Page does not exist."));
}
/* Load Form Actions */
if (class_exists($class)) {
$hylax = new $class($params);
return $hylax;
- } else {
- Horde::fatal(PEAR::raiseError(sprintf(_("No such backend \"%s\" found"), $driver)), __FILE__, __LINE__);
}
+
+ throw new Horde_Exception(sprintf(_("No such backend \"%s\" found"), $driver));
}
/**
*
* @return Hylax_Image The newly created concrete Hylax_Image instance, or
* false on an error.
+ * @throws Horde_Exception
*/
function &factory($driver, $params = array())
{
if (class_exists($class)) {
$image = &new $class($params);
return $image;
- } else {
- Horde::fatal(PEAR::raiseError(sprintf(_("No such backend \"%s\" found"), $driver)), __FILE__, __LINE__);
+ }
+
+ throw new Horde_Exception(sprintf(_("No such backend \"%s\" found"), $driver));
}
}
* Constructor
*
* @param array $params Any parameters needed for this storage driver.
- * @throws VFS_Exception
+ * @throws Horde_Exception
*/
function Hylax_Storage($params)
{
$this->_params = $params;
-
- /* Set up the VFS storage. */
- if (!isset($GLOBALS['conf']['vfs']['type'])) {
- Horde::fatal(_("You must configure a VFS backend to use Hylax."), __FILE__, __LINE__);
- }
-
$this->_vfs = $GLOBALS['injector']->getInstance('Horde_Vfs')->getVfs();
}
*
* @return Hylax_Storage The newly created concrete Hylax_Storage
* instance, or false on error.
+ * @throws Horde_Exception
*/
function &factory($driver, $params = array())
{
if (class_exists($class)) {
$storage = new $class($params);
return $storage;
- } else {
- Horde::fatal(PEAR::raiseError(sprintf(_("No such backend \"%s\" found"), $driver)), __FILE__, __LINE__);
}
+
+ throw new Horde_Exception(sprintf(_("No such backend \"%s\" found"), $driver));
}
/**
/* Set up some variables. */
$channel_id = $vars->get('channel_id');
$channel = $news->getChannel($channel_id);
-if (is_a($channel, 'PEAR_Error')) {
- Horde::fatal($channel, __FILE__, __LINE__);
+if ($channel instanceof PEAR_Error) {
+ throw new Jonah_Exception($channel);
}
$channel_name = $channel['channel_name'];
$ids = preg_split('/:/', $channel['channel_url'], -1, PREG_SPLIT_NO_EMPTY);
// Change source if the symbol isn't from the current source.
$symbolSource = $index->getSourceBySymbol($ident);
if (!$symbolSource) {
- Horde::fatal(_("Symbol not found"), __FILE__, __LINE__);
+ throw new Horde_Exception(_("Symbol not found"));
}
if ($symbolSource != $sourceid) {
$source = $sources[$symbolSource];
if ($quickText = Horde_Util::getPost('quickText')) {
$result = $registry->tasks->quickAdd($quickText);
- if ($result) {
- if (count($result) == 1) {
- $notification->push(_("Added one task"), 'horde.success');
- } else {
- $notification->push(sprintf(_("Added %s tasks"), count($result)), 'horde.success');
- }
- Horde::applicationUrl('list.php', true)->redirect();
+ if (!$result) {
+ throw new Nag_Exception($result);
}
- Horde::fatal($result);
+
+ if (count($result) == 1) {
+ $notification->push(_("Added one task"), 'horde.success');
+ } else {
+ $notification->push(sprintf(_("Added %s tasks"), count($result)), 'horde.success');
+ }
+
+ Horde::applicationUrl('list.php', true)->redirect();
}
while ($task = $tasks->each()) {
$values = array($owner, $task->id, $task->tasklist);
$result = $db->execute($sth, $values);
- if (is_a($result, 'PEAR_Error')) {
- Horde::fatal($result, __FILE__, __LINE__);
+ if ($result instanceof PEAR_Error) {
+ throw new Nag_Exception($result);
}
}
}
$prefs->getValue('altsortby'),
null,
1);
-if (is_a($tasks, 'PEAR_Error')) {
- Horde::fatal($tasks);
+if ($tasks instanceof PEAR_Error) {
+ throw new Nag_Exception($tasks);
}
$search_pattern = '/^' . preg_quote($search, '/') . '/i';
*
* @return mixed The newly created concrete Passwd_Driver
* instance, or false on an error.
+ * @throws Passwd_Exception
*/
function factory($driver, $params = array())
{
$class = 'Passwd_Driver_' . $driver;
if (class_exists($class)) {
return new $class($params);
- } else {
- Horde::fatal(PEAR::raiseError(sprintf(_("No such backend \"%s\" found."), $driver)), __FILE__, __LINE__);
}
+
+ throw new Passwd_Exception(sprintf(_("No such backend \"%s\" found."), $driver));
}
}
/**
* Attempts to open a connection to the LDAP server.
*
- * @return boolean True on success; exits (Horde::fatal()) on error.
+ * @return boolean True on success.
+ * @throws Shout_Exception
*
* @access private
*/
if (empty($folderId) && $registry->getAuth()) {
$folderId = $trean_shares->getId($registry->getAuth());
$folder = &$trean_shares->getFolder($folderId);
- if (is_a($folder, 'PEAR_Error')) {
+ if ($folder instanceof PEAR_Error) {
/* Can't redirect back to browse since that would set up a loop. */
- Horde::fatal($folder, __FILE__, __LINE__, true);
+ throw new Horde_Exception($folder);
}
} elseif (empty($folderId)) {
/* We're accessing Trean as a guest, try to get a folder to browse */
}
} else {
$folder = &$trean_shares->getFolder($folderId);
- if (is_a($folder, 'PEAR_Error')) {
+ if ($folder instanceof PEAR_Error) {
/* Can't redirect back to browse since that would set up a loop. */
- Horde::fatal($folder, __FILE__, __LINE__, true);
+ throw new Horde_Exception($folder);
}
/* Make sure user has permission to view this folder. */
// Create db and share instances.
$GLOBALS['trean_db'] = Trean::getDb();
- if (is_a($GLOBALS['trean_db'], 'PEAR_Error')) {
- Horde::fatal($GLOBALS['trean_db'], __FILE__, __LINE__, false);
+ if ($GLOBALS['trean_db'] instanceof PEAR_Error) {
+ throw new Horde_Exception($GLOBALS['trean_db']);
}
$GLOBALS['trean_shares'] = new Trean_Bookmarks();
global $conf, $registry;
if (empty($conf['datatree']['driver'])) {
- Horde::fatal('You must configure a DataTree backend to use Trean.', __FILE__, __LINE__);
+ throw new Horde_Exception('You must configure a DataTree backend to use Trean.');
}
$driver = $conf['datatree']['driver'];
}
$folder = &$GLOBALS['trean_shares']->newFolder($GLOBALS['registry']->getAuth(), array('name' => sprintf(_("%s's Bookmarks"), $name)));
$result = $GLOBALS['trean_shares']->addFolder($folder);
- if (is_a($result, 'PEAR_Error')) {
- Horde::fatal($result, __FILE__, __LINE__);
+ if ($result instanceof PEAR_Error) {
+ throw new Horde_Exception($result);
}
}
}
*
* @return Vilma_Driver The newly created concrete Vilma_Driver instance,
* or false on error.
+ * @throws Vilma_Exception
*/
function factory($driver = null, $params = null)
{
$class = 'Vilma_Driver_' . $driver;
if (class_exists($class)) {
return new $class($params);
- } else {
- Horde::fatal(PEAR::raiseError(sprintf(_("No such backend \"%s\" found"), $driver)), __FILE__, __LINE__);
}
+
+ throw new Vilma_Exception(sprintf(_("No such backend \"%s\" found"), $driver));
}
/**
$this->_ldap = ldap_connect($this->_ldapparams['ldaphost'], $port);
if (!$this->_ldap) {
- Horde::fatal("Unable to connect to LDAP server $hostname on $port",
- __FILE__, __LINE__);
- }
- $res = ldap_set_option($this->_ldap, LDAP_OPT_PROTOCOL_VERSION,
- $this->_ldapparams['version']);
+ throw new Vilma_Exception("Unable to connect to LDAP server $hostname on $port");
+ }
+ $res = ldap_set_option($this->_ldap, LDAP_OPT_PROTOCOL_VERSION,
+ $this->_ldapparams['version']);
if (!$res) {
return PEAR::raiseError(_("Unable to set LDAP protocol version"));
}
// First, add the type
$tid = $whups_driver->addType($vars->get('name'),
$vars->get('description'));
- if (is_a($tid, 'PEAR_Error')) {
- Horde::fatal($tid, __FILE__, __LINE__);
+ if ($tid instanceof PEAR_Error) {
+ throw new Horde_Exception($tid);
}
_open();
$tpl = Horde_Util::getFormData('template');
if (empty($_templates[$tpl])) {
- Horde::fatal(_("The requested template does not exist."), __FILE__, __LINE__);
+ throw new Horde_Exception(_("The requested template does not exist."));
}
if ($_templates[$tpl]['type'] != 'searchresults') {
- Horde::fatal(_("This is not a search results template."), __FILE__, __LINE__);
+ throw new Horde_Exception(_("This is not a search results template."));
}
// Fetch all unresolved tickets assigned to the current user.
if ($form->validate($vars, true)) {
$form->getInfo($vars, $info);
$tickets = $whups_driver->getTicketsByProperties($info);
- if (is_a($tickets, 'PEAR_Error')) {
- Horde::fatal($tickets, __FILE__, __LINE__);
+ if ($tickets instanceof PEAR_Error) {
+ throw new Horde_Exception($tickets);
}
Whups::sortTickets($tickets, 'date_updated', 'desc');
} else {
- Horde::fatal(_("Invalid search"), __FILE__, __LINE__);
+ throw new Horde_Exception(_("Invalid search"));
}
$count = 0;
$notification->push(_("You don't have permission to view this page."),
'horde.error');
if ($page->pageName() == 'WikiHome') {
- Horde::fatal(_("You don't have permission to view this page."), __FILE__, __LINE__);
+ throw new Horde_Exception(_("You don't have permission to view this page."));
}
Wicked::url('WikiHome', true)->redirect();
}
$notification->push(_("You don't have permission to view this page."),
'horde.error');
if ($page->pageName() == 'WikiHome') {
- Horde::fatal(_("You don't have permission to view this page."), __FILE__, __LINE__);
+ throw new Horde_Exception(_("You don't have permission to view this page."));
}
Wicked::url('WikiHome', true)->redirect();
}