From: Michael M Slusarz Date: Fri, 10 Jul 2009 21:52:25 +0000 (-0600) Subject: Track Horde_Registry changes X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=bd23015e57f302b8c55627095b50e04335309793;p=horde.git Track Horde_Registry changes --- diff --git a/babel/lib/base.php b/babel/lib/base.php index 008024f3b..db363b6db 100644 --- a/babel/lib/base.php +++ b/babel/lib/base.php @@ -29,11 +29,13 @@ $notification->attach('status'); /* Registry. */ $registry = Horde_Registry::singleton(); -if (is_a(($pushed = $registry->pushApp('babel', !defined('AUTH_HANDLER'))), 'PEAR_Error')) { - if ($pushed->getCode() == 'permission_denied') { +try { + $registry->pushApp('babel', !defined('AUTH_HANDLER')); +} catch (Horde_Exception $e) { + if ($e->getCode() == 'permission_denied') { Horde::authenticationFailureRedirect(); } - Horde::fatal($pushed, __FILE__, __LINE__, false); + Horde::fatal($e, __FILE__, __LINE__, false); } $conf = &$GLOBALS['conf']; diff --git a/chora/lib/base.php b/chora/lib/base.php index cd02a84a7..40c0a0838 100644 --- a/chora/lib/base.php +++ b/chora/lib/base.php @@ -31,11 +31,13 @@ require_once HORDE_BASE . '/lib/core.php'; // Registry $registry = Horde_Registry::singleton(); -if (is_a(($pushed = $registry->pushApp('chora', !defined('AUTH_HANDLER'))), 'PEAR_Error')) { - if ($pushed->getCode() == 'permission_denied') { +try { + $registry->pushApp('chora', !defined('AUTH_HANDLER')); +} catch (Horde_Exception $e) { + if ($e->getCode() == 'permission_denied') { Horde::authenticationFailureRedirect(); } - Horde::fatal($pushed, __FILE__, __LINE__, false); + Horde::fatal($e, __FILE__, __LINE__, false); } $conf = &$GLOBALS['conf']; define('CHORA_TEMPLATES', $registry->get('templates')); diff --git a/crumb/lib/Forms/AddClient.php b/crumb/lib/Forms/AddClient.php index 85426a7b8..2cad2a2de 100644 --- a/crumb/lib/Forms/AddClient.php +++ b/crumb/lib/Forms/AddClient.php @@ -22,15 +22,16 @@ class Horde_Form_AddClient extends Horde_Form 'assign' => _("Assign Existing")); $action = &Horde_Form_Action::factory('reload'); - + $select = &$this->addVariable(_("Contact Information"), 'chooseContact', 'enum', true, false, null, array($addOrPick, true)); $select->setAction($action); $select->setOption('trackchange', true); if ($vars->get('chooseContact') == 'create') { - $turbaform = $GLOBALS['registry']->call('contacts/getAddClientForm', array(&$vars)); - if (is_a($turbaform, 'PEAR_Error')) { - Horde::logMessage($addform, __FILE__, __LINE__, PEAR_LOG_ERR); + try { + $turbaform = $GLOBALS['registry']->call('contacts/getAddClientForm', array(&$vars)); + } catch (Horde_Exception $e) { + Horde::logMessage($e, __FILE__, __LINE__, PEAR_LOG_ERR); $notification->push(_("An internal error has occurred. Details have beenlogged for the administrator.")); $addform = null; } @@ -53,9 +54,10 @@ class Horde_Form_AddClient extends Horde_Form $select->setOption('trackchange', true); if ($vars->get('chooseQueue') == 'create') { - $whupsform = $GLOBALS['registry']->call('tickets/getAddQueueForm', array(&$vars)); - if (is_a($whupsform, 'PEAR_Error')) { - Horde::logMessage($addform, __FILE__, __LINE__, PEAR_LOG_ERR); + try { + $whupsform = $GLOBALS['registry']->call('tickets/getAddQueueForm', array(&$vars)); + } catch (Horde_Exception $e) { + Horde::logMessage($e, __FILE__, __LINE__, PEAR_LOG_ERR); $notification->push(_("An internal error has occurred. Details have been logged for the administrator.")); $addform = null; } diff --git a/crumb/lib/base.php b/crumb/lib/base.php index c562d9e73..6a7a23f2f 100644 --- a/crumb/lib/base.php +++ b/crumb/lib/base.php @@ -10,7 +10,7 @@ * need, and sets up objects that all scripts use. * * @author Ben Klang - * + * */ // Check for a prior definition of HORDE_BASE (perhaps by an auto_prepend_file @@ -24,11 +24,13 @@ require_once HORDE_BASE . '/lib/core.php'; // Registry. $registry = Horde_Registry::singleton(); -if (is_a(($pushed = $registry->pushApp('crumb', !defined('AUTH_HANDLER'))), 'PEAR_Error')) { - if ($pushed->getCode() == 'permission_denied') { +try { + $registry->pushApp('crumb', !defined('AUTH_HANDLER')); +} catch (Horde_Exception $e) { + if ($e->getCode() == 'permission_denied') { Horde::authenticationFailureRedirect(); } - Horde::fatal($pushed, __FILE__, __LINE__, false); + Horde::fatal($e, __FILE__, __LINE__, false); } $conf = &$GLOBALS['conf']; @define('CRUMB_TEMPLATES', $registry->get('templates')); diff --git a/fima/lib/base.php b/fima/lib/base.php index fc77e3b1e..ea8b8e57d 100644 --- a/fima/lib/base.php +++ b/fima/lib/base.php @@ -27,11 +27,13 @@ if ($session_control == 'none') { $registry = Horde_Registry::singleton(); } -if (is_a(($pushed = $registry->pushApp('fima', !defined('AUTH_HANDLER'))), 'PEAR_Error')) { - if ($pushed->getCode() == 'permission_denied') { +try { + $registry->pushApp('fima', !defined('AUTH_HANDLER')); +} catch (Horde_Exception $e) { + if ($e->getCode() == 'permission_denied') { Horde::authenticationFailureRedirect(); } - Horde::fatal($pushed, __FILE__, __LINE__, false); + Horde::fatal($e, __FILE__, __LINE__, false); } $conf = &$GLOBALS['conf']; @define('FIMA_TEMPLATES', $registry->get('templates')); diff --git a/folks/edit/comments.php b/folks/edit/comments.php index b9b2fb3bc..51b75e29d 100644 --- a/folks/edit/comments.php +++ b/folks/edit/comments.php @@ -46,18 +46,17 @@ if (!$form->isSubmitted()) { if (Horde_Util::getFormData('submitbutton') == _("Delete all current comments")) { - $result = $registry->call('forums/deleteForum', array('folks', Horde_Auth::getAuth())); - if ($result instanceof PEAR_Error) { - $notification->push($result); - } else { + try { + $registry->call('forums/deleteForum', array('folks', Horde_Auth::getAuth())); $result = $folks_driver->updateComments(Horde_Auth::getAuth(), true); if ($result instanceof PEAR_Error) { $notification->push($result); } else { $notification->push(_("Comments deleted successfuly"), 'horde.success'); } + } catch (Horde_Exception $e) { + $notification->push($e); } - } else { // Update forum status @@ -67,9 +66,10 @@ if (!$form->isSubmitted()) { $info = array('author' => Horde_Auth::getAuth(), 'forum_name' => Horde_Auth::getAuth(), 'forum_moderated' => ($profile['user_comments'] == 'moderate')); - $result = $registry->call('forums/saveFrom', array('folks', '', $info)); - if ($result instanceof PEAR_Error) { - $notification->push($result); + try { + $registry->call('forums/saveFrom', array('folks', '', $info)); + } catch (Horde_Exception $e) { + $notification->push($e); } } @@ -92,11 +92,10 @@ $form->renderActive(null, null, null, 'post'); if ($profile['user_comments'] == 'moderate') { echo '
'; - $result = $registry->call('forums/moderateForm', array('folks')); - if ($result instanceof PEAR_Error) { - echo $result->getMessage(); - } else { - echo $result; + try { + echo $registry->call('forums/moderateForm', array('folks')); + } catch (Horde_Exception $e) { + echo $e->getMessage(); } } diff --git a/folks/edit/edit.php b/folks/edit/edit.php index eb1c70bdd..60badf636 100644 --- a/folks/edit/edit.php +++ b/folks/edit/edit.php @@ -34,16 +34,16 @@ $v->setDefault('SI'); $form->addVariable(_("Homepage"), 'user_url', 'text', false); if ($registry->hasMethod('video/listVideos')) { - $result = $registry->call('video/listVideos', array(array('author' => Horde_Auth::getAuth()), 0, 100)); - if ($result instanceof PEAR_Error) { - $notification->push($result); - } else { + try { + $result = $registry->call('video/listVideos', array(array('author' => Horde_Auth::getAuth()), 0, 100)); $videos = array(); foreach ($result as $video_id => $video) { $videos[$video_id] = $video['video_title'] . ' - ' . Folks::format_date($video['video_created']); } $video_link = '' . _("Upload a new video") . ''; $form->addVariable(_("Video"), 'user_video', 'enum', false, false, $video_link, array($videos, _("--- Select ---"))); + } catch (Horde_Exception $e) { + $notification->push($e); } } diff --git a/folks/edit/facebook.php b/folks/edit/facebook.php index 8c07177a2..9220ce503 100644 --- a/folks/edit/facebook.php +++ b/folks/edit/facebook.php @@ -25,9 +25,10 @@ if (!$conf['facebook']['enabled']) { } // Load horde central block -$block = $registry->call('horde/blockContent', array('horde', 'fb_summary')); -if ($block instanceof PEAR_Error) { - $notification->push($block); +try { + $block = $registry->call('horde/blockContent', array('horde', 'fb_summary')); +} catch (Horde_Exception $e) { + $notification->push($e); header('Location: ' . Horde::applicationUrl('user.php')); exit; } @@ -39,4 +40,4 @@ echo $tabs->render('facebook'); echo $block; -require $registry->get('templates', 'horde') . '/common-footer.inc'; \ No newline at end of file +require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/folks/lib/Auth/folks.php b/folks/lib/Auth/folks.php index 334b8d892..9a8449df5 100644 --- a/folks/lib/Auth/folks.php +++ b/folks/lib/Auth/folks.php @@ -63,6 +63,7 @@ class Folks_Auth_Folks extends Horde_Auth_Application * @param string $userId User ID for which to check * * @return boolean Whether or not $userId already exists. + * @throws Horde_Exception */ public function exists($userId) { diff --git a/folks/lib/Block/my_comments.php b/folks/lib/Block/my_comments.php index 2016c842f..e5c210d8e 100644 --- a/folks/lib/Block/my_comments.php +++ b/folks/lib/Block/my_comments.php @@ -56,11 +56,12 @@ class Horde_Block_folks_my_comments extends Horde_Block { . '' . _("Title") . '' . '' . _("User") . ''; - $threads = $GLOBALS['registry']->call('forums/getThreadsByForumOwner', - array(Horde_Auth::getAuth(), 'message_timestamp', 1, false, - 'folks', 0, $this->_params['limit'])); - if ($threads instanceof PEAR_Error) { - return $threads->getMessage(); + try { + $threads = $GLOBALS['registry']->call('forums/getThreadsByForumOwner', + array(Horde_Auth::getAuth(), 'message_timestamp', 1, false, + 'folks', 0, $this->_params['limit'])); + } catch (Horde_Exception $e) { + return $e->getMessage(); } $url = Folks::getUrlFor('user', Horde_Auth::getAuth()); @@ -76,4 +77,4 @@ class Horde_Block_folks_my_comments extends Horde_Block { $GLOBALS['cache']->set($cache_key, $html); return $html; } -} \ No newline at end of file +} diff --git a/folks/lib/Driver.php b/folks/lib/Driver.php index 7fd0f6f2a..2e2f45ed1 100644 --- a/folks/lib/Driver.php +++ b/folks/lib/Driver.php @@ -498,10 +498,7 @@ class Folks_Driver { // Delete comments if ($registry->hasMethod('forums/deleteForum')) { - $comments = $registry->call('forums/deleteForum', array('folks', $user)); - if ($comments instanceof PEAR_Error) { - return $comments; - } + $registry->call('forums/deleteForum', array('folks', $user)); } // Delete user diff --git a/folks/lib/Notification/letter.php b/folks/lib/Notification/letter.php index 9569127c5..dda4a3aee 100644 --- a/folks/lib/Notification/letter.php +++ b/folks/lib/Notification/letter.php @@ -74,10 +74,6 @@ class Folks_Notification_letter extends Folks_Notification { public function notifyFriends($user, $subject, $body, $attachments = array()) { $friends = $GLOBALS['registry']->call('users/getFriends'); - if ($friends instanceof PEAR_Error) { - return $friends; - } - return $this->notify($friends, $subject, $body, $attachments); } } diff --git a/folks/lib/Notification/mail.php b/folks/lib/Notification/mail.php index 388144788..fbfa5720d 100644 --- a/folks/lib/Notification/mail.php +++ b/folks/lib/Notification/mail.php @@ -100,10 +100,6 @@ class Folks_Notification_mail extends Folks_Notification { public function notifyFriends($user, $subject, $body, $attachments = array()) { $friends = $GLOBALS['registry']->call('users/getFriends'); - if ($friends instanceof PEAR_Error) { - return $friends; - } - return $this->notify($friends, $subject, $body, $attachments); } } diff --git a/folks/lib/Notification/tickets.php b/folks/lib/Notification/tickets.php index bc6fe948c..caa302af1 100644 --- a/folks/lib/Notification/tickets.php +++ b/folks/lib/Notification/tickets.php @@ -59,9 +59,6 @@ class Folks_Notification_tickets extends Folks_Notification { 'user_email' => $this->_getUserFromAddr())); $ticket_id = $registry->call('tickets/addTicket', array($info)); - if ($ticket_id instanceof PEAR_Error) { - return $ticket_id; - } if (empty($attachments) || !$registry->hasMethod('tickets/addAttachment')) { @@ -74,9 +71,6 @@ class Folks_Notification_tickets extends Folks_Notification { array('ticket_id' => $ticket_id, 'name' => $attachment['name'], 'data' => file_get_contents($attachment['file']))); - if ($result instanceof PEAR_Error) { - return $result; - } } return true; diff --git a/folks/lib/base.php b/folks/lib/base.php index 847ba3866..b3d65d87d 100644 --- a/folks/lib/base.php +++ b/folks/lib/base.php @@ -19,11 +19,13 @@ require_once HORDE_BASE . '/lib/core.php'; // Registry. $registry = Horde_Registry::singleton(); -if (($pushed = $registry->pushApp('folks', !defined('AUTH_HANDLER'))) instanceof PEAR_Error) { - if ($pushed->getCode() == 'permission_denied') { +try { + $registry->pushApp('folks', !defined('AUTH_HANDLER')); +} catch (Horde_Exception $e) { + if ($e->getCode() == 'permission_denied') { Horde::authenticationFailureRedirect(); } - Horde::fatal($pushed, __FILE__, __LINE__, false); + Horde::fatal($e, __FILE__, __LINE__, false); } $conf = &$GLOBALS['conf']; define('FOLKS_TEMPLATES', $registry->get('templates')); diff --git a/folks/templates/services/services.php b/folks/templates/services/services.php index e89627312..fc6f406dc 100644 --- a/folks/templates/services/services.php +++ b/folks/templates/services/services.php @@ -3,13 +3,12 @@ echo '

' . $title . '

'; foreach ($apps as $app => $name) { - $page = $registry->getInitialPage($app); - if ($page instanceof PEAR_Error) { - continue; - } - echo ''; -} \ No newline at end of file + try { + $page = $registry->getInitialPage($app); + echo ''; + } catch (Horde_Exception $e) {} +} diff --git a/framework/Model/lib/Horde/Form/VarRenderer/Xhtml.php b/framework/Model/lib/Horde/Form/VarRenderer/Xhtml.php index e0f2453bb..68ec1e3fa 100644 --- a/framework/Model/lib/Horde/Form/VarRenderer/Xhtml.php +++ b/framework/Model/lib/Horde/Form/VarRenderer/Xhtml.php @@ -954,8 +954,9 @@ EOT; // Get rid of the trailing @ (when no host is included in // the email address). $address = str_replace('@>', '>', $address); - $mail_link = $GLOBALS['registry']->call('mail/compose', array(array('to' => addslashes($address)))); - if (is_a($mail_link, 'PEAR_Error')) { + try { + $mail_link = $GLOBALS['registry']->call('mail/compose', array(array('to' => addslashes($address)))); + } catch (Horde_Exception $e) { $mail_link = 'mailto:' . urlencode($address); } diff --git a/imp/compose.php b/imp/compose.php index 8a279519c..1fe00d294 100644 --- a/imp/compose.php +++ b/imp/compose.php @@ -545,23 +545,25 @@ case 'selectlist_process': if (!empty($select_id) && $registry->hasMethod('files/selectlistResults') && $registry->hasMethod('files/returnFromSelectlist')) { - $filelist = $registry->call('files/selectlistResults', array($select_id)); - if ($filelist && !is_a($filelist, 'PEAR_Error')) { - $i = 0; - foreach ($filelist as $val) { - $data = $registry->call('files/returnFromSelectlist', array($select_id, $i++)); - if ($data && !is_a($data, 'PEAR_Error')) { - $part = new Horde_Mime_Part(); - $part->setName(reset($val)); - $part->setContents($data); - try { - $imp_compose->addMIMEPartAttachment($part); - } catch (IMP_Compose_Exception $e) { - $notification->push($e, 'horde.error'); + try { + $filelist = $registry->call('files/selectlistResults', array($select_id)); + if ($filelist) { + $i = 0; + foreach ($filelist as $val) { + $data = $registry->call('files/returnFromSelectlist', array($select_id, $i++)); + if ($data) { + $part = new Horde_Mime_Part(); + $part->setName(reset($val)); + $part->setContents($data); + try { + $imp_compose->addMIMEPartAttachment($part); + } catch (IMP_Compose_Exception $e) { + $notification->push($e, 'horde.error'); + } } } } - } + } catch (Horde_Exception $e) {} } break; @@ -1151,9 +1153,10 @@ if ($redirect) { } if ($_SESSION['imp']['file_upload']) { $localeinfo = Horde_Nls::getLocaleInfo(); - if ($GLOBALS['registry']->hasMethod('files/selectlistLink')) { - $res = $GLOBALS['registry']->call('files/selectlistLink', array(_("Attach Files"), 'widget', 'compose', true)); - $t->set('selectlistlink', (is_a($res, 'PEAR_Error')) ? null : $res); + try { + $t->set('selectlistlink', $GLOBALS['registry']->call('files/selectlistLink', array(_("Attach Files"), 'widget', 'compose', true))); + } catch (Horde_Exception $e) { + $t->set('selectlistlink', null); } $t->set('maxattachsize', !$imp_compose->maxAttachmentSize()); if (!$t->get('maxattachsize')) { diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index 7e0118190..6423fcf47 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -753,7 +753,14 @@ class IMP_Compose foreach ($r_array as $recipient) { $emails[] = $recipient['mailbox'] . '@' . $recipient['host']; } - $results = $registry->call('contacts/search', array($emails, array($abook), array($abook => array('email')))); + + try { + $results = $registry->call('contacts/search', array($emails, array($abook), array($abook => array('email')))); + } catch (Horde_Exception $e) { + Horde::logMessage($e); + $notification->push(_("Could not save recipients.")); + return; + } foreach ($r_array as $recipient) { /* Skip email addresses that already exist in the add_source. */ @@ -776,13 +783,13 @@ class IMP_Compose } $name = Horde_Mime::decode($name); - $result = $registry->call('contacts/import', array(array('name' => $name, 'email' => $recipient['mailbox'] . '@' . $recipient['host']), 'array', $abook)); - if (is_a($result, 'PEAR_Error')) { - if ($result->getCode() == 'horde.error') { - $notification->push($result, $result->getCode()); - } - } else { + try { + $registry->call('contacts/import', array(array('name' => $name, 'email' => $recipient['mailbox'] . '@' . $recipient['host']), 'array', $abook)); $notification->push(sprintf(_("Entry \"%s\" was successfully added to the address book"), $name), 'horde.success'); + } catch (Horde_Exception $e) { + if ($e->getCode() == 'horde.error') { + $notification->push($e, $e->getCode()); + } } } } @@ -2283,9 +2290,10 @@ class IMP_Compose return; } - $vcard = $GLOBALS['registry']->call('contacts/ownVCard'); - if (is_a($vcard, 'PEAR_Error')) { - throw new IMP_Compose_Exception($vcard); + try { + $vcard = $GLOBALS['registry']->call('contacts/ownVCard'); + } catch (Horde_Exception $e) { + throw new IMP_Compose_Exception($e); } $part = new Horde_Mime_Part(); @@ -2482,11 +2490,14 @@ class IMP_Compose static public function getAddressList($search = '') { $sparams = IMP_Compose::getAddressSearchParams(); - $res = $GLOBALS['registry']->call('contacts/search', array($search, $sparams['sources'], $sparams['fields'], true)); - if (is_a($res, 'PEAR_Error')) { - Horde::logMessage($res, __FILE__, __LINE__, PEAR_LOG_ERR); + try { + $res = $GLOBALS['registry']->call('contacts/search', array($search, $sparams['sources'], $sparams['fields'], true)); + } catch (Horde_Exception $e) { + Horde::logMessage($e, __FILE__, __LINE__, PEAR_LOG_ERR); return array(); - } elseif (!count($res)) { + } + + if (!count($res)) { return array(); } diff --git a/imp/lib/Crypt/Pgp.php b/imp/lib/Crypt/Pgp.php index b079d820d..1c77857ba 100644 --- a/imp/lib/Crypt/Pgp.php +++ b/imp/lib/Crypt/Pgp.php @@ -134,10 +134,7 @@ class IMP_Crypt_Pgp extends Horde_Crypt_Pgp } catch (Horde_Exception $e) {} /* Add key to the user's address book. */ - $result = $GLOBALS['registry']->call('contacts/addField', array($sig['email'], $sig['name'], self::PUBKEY_FIELD, $public_key, $GLOBALS['prefs']->getValue('add_source'))); - if (is_a($result, 'PEAR_Error')) { - throw new Horde_Exception($result); - } + $GLOBALS['registry']->call('contacts/addField', array($sig['email'], $sig['name'], self::PUBKEY_FIELD, $public_key, $GLOBALS['prefs']->getValue('add_source'))); } return $key_info; @@ -184,37 +181,35 @@ class IMP_Crypt_Pgp extends Horde_Crypt_Pgp /* Try retrieving by e-mail only first. */ $params = IMP_Compose::getAddressSearchParams(); - $result = $GLOBALS['registry']->call('contacts/getField', array($address, self::PUBKEY_FIELD, $params['sources'], false, true)); - - /* TODO: Retrieve by ID. */ + try { + $result = $GLOBALS['registry']->call('contacts/getField', array($address, self::PUBKEY_FIELD, $params['sources'], false, true)); + } catch (Horde_Exception $e) { + /* TODO: Retrieve by ID. */ - /* See if the address points to the user's public key. */ - if (is_a($result, 'PEAR_Error')) { + /* See if the address points to the user's public key. */ require_once 'Horde/Identity.php'; $identity = Identity::singleton(array('imp', 'imp')); $personal_pubkey = $this->getPersonalPublicKey(); if (!empty($personal_pubkey) && $identity->hasAddress($address)) { $result = $personal_pubkey; - } - } - - /* Try retrieving via a PGP public keyserver. */ - if (empty($options['noserver']) && is_a($result, 'PEAR_Error')) { - try { - $result = $this->getFromPublicKeyserver($keyid, $address); - - /* If there is a cache driver configured and a cache object - * exists, store the retrieved public key in the cache. */ - if (is_object($cache)) { - $cache->set("PGPpublicKey_" . $address . $keyid, $result, 3600); + } elseif (empty($options['noserver'])) { + try { + $result = $this->getFromPublicKeyserver($keyid, $address); + + /* If there is a cache driver configured and a cache + * object exists, store the retrieved public key in the + * cache. */ + if (is_object($cache)) { + $cache->set("PGPpublicKey_" . $address . $keyid, $result, 3600); + } + } catch (Horde_Exception $e) { + /* Return now, if no public key found at all. */ + Horde::logMessage('PGPpublicKey: ' . $e->getMessage(), __FILE__, __LINE__, PEAR_LOG_DEBUG); + throw new Horde_Exception(sprintf(_("Could not retrieve public key for %s."), $address)); } - } catch (Horde_Exception $e) {} - } - - /* Return now, if no public key found at all. */ - if (is_a($result, 'PEAR_Error')) { - Horde::logMessage('PGPpublicKey: ' . $result->getMessage(), __FILE__, __LINE__, PEAR_LOG_DEBUG); - throw new Horde_Exception(sprintf(_("Could not retrieve public key for %s."), $address)); + } else { + $result = ''; + } } /* If more than one public key is returned, just return the first in @@ -240,12 +235,7 @@ class IMP_Crypt_Pgp extends Horde_Crypt_Pgp return array(); } - $res = $GLOBALS['registry']->call('contacts/getAllAttributeValues', array(self::PUBKEY_FIELD, $params['sources'])); - if (is_a($res, 'PEAR_Error')) { - throw new Horde_Exception($res); - } - - return $res; + return $GLOBALS['registry']->call('contacts/getAllAttributeValues', array(self::PUBKEY_FIELD, $params['sources'])); } /** @@ -258,12 +248,7 @@ class IMP_Crypt_Pgp extends Horde_Crypt_Pgp public function deletePublicKey($email) { $params = IMP_Compose::getAddressSearchParams(); - $res = $GLOBALS['registry']->call('contacts/deleteField', array($email, self::PUBKEY_FIELD, $params['sources'])); - if (is_a($res, 'PEAR_Error')) { - throw new Horde_Exception($res); - } - - return $res; + return $GLOBALS['registry']->call('contacts/deleteField', array($email, self::PUBKEY_FIELD, $params['sources'])); } /** diff --git a/imp/lib/Crypt/Smime.php b/imp/lib/Crypt/Smime.php index 07a8f5b6d..0b3392ee8 100644 --- a/imp/lib/Crypt/Smime.php +++ b/imp/lib/Crypt/Smime.php @@ -125,10 +125,7 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime throw new Horde_Exception(_("Not a valid public key.")); } - $result = $GLOBALS['registry']->call('contacts/addField', array($email, $name, self::PUBKEY_FIELD, $cert, $GLOBALS['prefs']->getValue('add_source'))); - if (is_a($result, 'PEAR_Error')) { - throw new Horde_Exception($result); - } + $GLOBALS['registry']->call('contacts/addField', array($email, $name, self::PUBKEY_FIELD, $cert, $GLOBALS['prefs']->getValue('add_source'))); } /** @@ -166,17 +163,19 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime public function getPublicKey($address) { $params = IMP_Compose::getAddressSearchParams(); - $key = $GLOBALS['registry']->call('contacts/getField', array($address, self::PUBKEY_FIELD, $params['sources'], false, true)); - /* See if the address points to the user's public key. */ - if (is_a($key, 'PEAR_Error')) { + try { + $key = $GLOBALS['registry']->call('contacts/getField', array($address, self::PUBKEY_FIELD, $params['sources'], false, true)); + } catch (Horde_Exception $e) { + /* See if the address points to the user's public key. */ require_once 'Horde/Identity.php'; $identity = Identity::singleton(array('imp', 'imp')); $personal_pubkey = $this->getPersonalPublicKey(); if (!empty($personal_pubkey) && $identity->hasAddress($address)) { return $personal_pubkey; } - throw new Horde_Exception($key); + + throw $e; } /* If more than one public key is returned, just return the first in @@ -197,12 +196,7 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime if (empty($params['sources'])) { return array(); } - $result = $GLOBALS['registry']->call('contacts/getAllAttributeValues', array(self::PUBKEY_FIELD, $params['sources'])); - if (is_a($result, 'PEAR_Error')) { - throw new Horde_Exception($result); - } - - return $result; + return $GLOBALS['registry']->call('contacts/getAllAttributeValues', array(self::PUBKEY_FIELD, $params['sources'])); } /** @@ -215,10 +209,7 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime public function deletePublicKey($email) { $params = IMP_Compose::getAddressSearchParams(); - $result = $GLOBALS['registry']->call('contacts/deleteField', array($email, self::PUBKEY_FIELD, $params['sources'])); - if (is_a($result, 'PEAR_Error')) { - throw new Horde_Exception($result); - } + $GLOBALS['registry']->call('contacts/deleteField', array($email, self::PUBKEY_FIELD, $params['sources'])); } /** diff --git a/imp/lib/Filter.php b/imp/lib/Filter.php index 1bcabb06b..bb94a351f 100644 --- a/imp/lib/Filter.php +++ b/imp/lib/Filter.php @@ -27,6 +27,7 @@ class IMP_Filter * Runs the filters if they are able to be applied manually. * * @param string $mbox The mailbox to apply the filters to. + * @throws Horde_Exception */ public function filter($mbox) { @@ -52,6 +53,7 @@ class IMP_Filter * notification message? * * @return boolean True if the messages(s) were deleted. + * @throws Horde_Exception */ public function blacklistMessage($indices, $show_link = true) { @@ -79,6 +81,7 @@ class IMP_Filter * notification message? * * @return boolean True if the messages(s) were whitelisted. + * @throws Horde_Exception */ public function whitelistMessage($indices, $show_link = true) { @@ -98,6 +101,7 @@ class IMP_Filter * notification message? * * @return boolean True on success. + * @throws Horde_Exception */ protected function _processBWlist($indices, $descrip, $reg1, $reg2, $link) { diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index d63d54535..d02e64c81 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -127,12 +127,7 @@ class IMP $newName = $newAddress; } - $result = $registry->call('contacts/import', - array(array('name' => $newName, 'email' => $newAddress), - 'array', $prefs->getValue('add_source'))); - if ($result instanceof PEAR_Error) { - throw new Horde_Exception($result); - } + $result = $registry->call('contacts/import', array(array('name' => $newName, 'email' => $newAddress), 'array', $prefs->getValue('add_source'))); $contact_link = $registry->link('contacts/show', array('uid' => $result, 'source' => $prefs->getValue('add_source'))); @@ -230,37 +225,38 @@ class IMP /* Add the list of editable tasklists to the list. */ if (!empty($options['inc_tasklists']) && !empty($_SESSION['imp']['tasklistavail'])) { - $tasklists = $GLOBALS['registry']->call('tasks/listTasklists', - array(false, PERMS_EDIT)); + try { + $tasklists = $GLOBALS['registry']->call('tasks/listTasklists', array(false, PERMS_EDIT)); - if (!$tasklists instanceof PEAR_Error && count($tasklists)) { - $text .= '' . "\n"; + if (count($tasklists)) { + $text .= '' . "\n"; - foreach ($tasklists as $id => $tasklist) { - $text .= sprintf('%s', - '_tasklist_' . $id, - Horde_Text_Filter::filter($tasklist->get('name'), 'space2html', array('charset' => Horde_Nls::getCharset(), 'encode' => true)), - "\n"); + foreach ($tasklists as $id => $tasklist) { + $text .= sprintf('%s', + '_tasklist_' . $id, + Horde_Text_Filter::filter($tasklist->get('name'), 'space2html', array('charset' => Horde_Nls::getCharset(), 'encode' => true)), + "\n"); + } } - } + } catch (Horde_Exception $e) {} } /* Add the list of editable notepads to the list. */ if (!empty($options['inc_notepads']) && !empty($_SESSION['imp']['notepadavail'])) { - $notepads = $GLOBALS['registry']->call('notes/listNotepads', - array(false, PERMS_EDIT)); - - if (!$notepads instanceof PEAR_Error && count($notepads)) { - $text .= '' . "\n"; - - foreach ($notepads as $id => $notepad) { - $text .= sprintf('%s', - '_notepad_' . $id, - Horde_Text_Filter::filter($notepad->get('name'), 'space2html', array('charset' => Horde_Nls::getCharset(), 'encode' => true)), - "\n"); + try { + $notepads = $GLOBALS['registry']->call('notes/listNotepads', array(false, PERMS_EDIT)); + if (count($notepads)) { + $text .= '' . "\n"; + + foreach ($notepads as $id => $notepad) { + $text .= sprintf('%s', + '_notepad_' . $id, + Horde_Text_Filter::filter($notepad->get('name'), 'space2html', array('charset' => Horde_Nls::getCharset(), 'encode' => true)), + "\n"); + } } - } + } catch (Horde_Exception $e) {} } return $text; diff --git a/imp/lib/Message.php b/imp/lib/Message.php index f9ae2f8b9..b68125db7 100644 --- a/imp/lib/Message.php +++ b/imp/lib/Message.php @@ -319,7 +319,7 @@ class IMP_Message * created. * @param string $action Either 'copy' or 'move'. * @param mixed $indices See IMP::parseIndicesList(). - * @param string $type The object type to create, defaults to task. + * @param string $type The object type to create ('note' or 'task'). * * @return boolean True if successful, false if not. */ @@ -378,13 +378,21 @@ class IMP_Message $vTodo->setAttribute('PRIORITY', '3'); /* Get the list of editable tasklists. */ - $lists = $registry->call('tasks/listTasklists', - array(false, PERMS_EDIT)); + try { + $lists = $registry->call('tasks/listTasklists', array(false, PERMS_EDIT)); + } catch (Horde_Exception $e) { + $lists = null; + $notification->push($e, $e->getCode()); + } /* Attempt to add the new vTodo item to the requested * tasklist. */ - $res = $registry->call('tasks/import', - array($vTodo, 'text/calendar', $list)); + try { + $res = $registry->call('tasks/import', array($vTodo, 'text/calendar', $list)); + } catch (Horde_Exception $e) { + $res = null; + $notification->push($e, $e->getCode()); + } break; case 'note': @@ -394,53 +402,60 @@ class IMP_Message $vNote->setAttribute('BODY', $subject . "\n". $body); /* Get the list of editable notepads. */ - $lists = $registry->call('notes/listNotepads', - array(false, PERMS_EDIT)); + try { + $lists = $registry->call('notes/listNotepads', array(false, PERMS_EDIT)); + } catch (Horde_Exception $e) { + $lists = null; + $notification->push($e, $e->getCode()); + } /* Attempt to add the new vNote item to the requested * notepad. */ - $res = $registry->call('notes/import', - array($vNote, 'text/x-vnote', $list)); + try { + $res = $registry->call('notes/import', array($vNote, 'text/x-vnote', $list)); + } catch (Horde_Exception $e) { + $res = null; + $notification->push($e, $e->getCode()); + } break; } - if (is_a($res, 'PEAR_Error')) { - $notification->push($res, $res->getCode()); - } elseif (!$res) { - switch ($type) { - case 'task': - $notification->push(_("An unknown error occured while creating the new task."), 'horde.error'); - break; - - case 'note': - $notification->push(_("An unknown error occured while creating the new note."), 'horde.error'); - break; - } - } else { - $name = '"' . htmlspecialchars($subject) . '"'; - - /* Attempt to convert the object name into a hyperlink. */ - switch ($type) { - case 'task': - $link = $registry->link('tasks/show', - array('uid' => $res)); - break; - case 'note': - if ($registry->hasMethod('notes/show')) { - $link = $registry->link('notes/show', - array('uid' => $res)); - } else { - $link = false; + if (!is_null($res)) { + if (!$res) { + switch ($type) { + case 'task': + $notification->push(_("An unknown error occured while creating the new task."), 'horde.error'); + break; + + case 'note': + $notification->push(_("An unknown error occured while creating the new note."), 'horde.error'); + break; } - break; - } - if ($link && !is_a($link, 'PEAR_Error')) { - $name = sprintf('%s', - Horde::url($link), - $name); + } elseif (!is_null($lists)) { + $name = '"' . htmlspecialchars($subject) . '"'; + + /* Attempt to convert the object name into a + * hyperlink. */ + try { + switch ($type) { + case 'task': + $link = $registry->link('tasks/show', array('uid' => $res)); + break; + + case 'note': + $link = $registry->hasMethod('notes/show') + ? $registry->link('notes/show', array('uid' => $res)) + : false; + break; + } + + if ($link) { + $name = sprintf('%s', Horde::url($link), $name); + } + + $notification->push(sprintf(_("%s was successfully added to \"%s\"."), $name, htmlspecialchars($lists[$list]->get('name'))), 'horde.success', array('content.raw')); + } catch (Horde_Exception $e) {} } - - $notification->push(sprintf(_("%s was successfully added to \"%s\"."), $name, htmlspecialchars($lists[$list]->get('name'))), 'horde.success', array('content.raw')); } } } diff --git a/imp/lib/Mime/Viewer/Html.php b/imp/lib/Mime/Viewer/Html.php index 37abc5c0e..38d1e9ef6 100644 --- a/imp/lib/Mime/Viewer/Html.php +++ b/imp/lib/Mime/Viewer/Html.php @@ -268,7 +268,11 @@ class IMP_Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Html $headers = $this->_params['contents']->getHeaderOb(); /* Try to get back a result from the search. */ - $res = $GLOBALS['registry']->call('contacts/getField', array(Horde_Mime_Address::bareAddress($headers->getValue('from')), '__key', $params['sources'], false, true)); - return is_a($res, 'PEAR_Error') ? false : count($res); + try { + $res = $GLOBALS['registry']->call('contacts/getField', array(Horde_Mime_Address::bareAddress($headers->getValue('from')), '__key', $params['sources'], false, true)); + return count($res); + } catch (Horde_Exception $e) { + return false; + } } } diff --git a/imp/lib/Mime/Viewer/Itip.php b/imp/lib/Mime/Viewer/Itip.php index 701e5322c..1c95b6d1b 100644 --- a/imp/lib/Mime/Viewer/Itip.php +++ b/imp/lib/Mime/Viewer/Itip.php @@ -100,11 +100,11 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver // vEvent cancellation. if ($registry->hasMethod('calendar/delete')) { $guid = $components[$key]->getAttribute('UID'); - $event = $registry->call('calendar/delete', array('guid' => $guid)); - if (is_a($event, 'PEAR_Error')) { - $msgs[] = array('error', _("There was an error deleting the event:") . ' ' . $event->getMessage()); - } else { + try { + $registry->call('calendar/delete', array('guid' => $guid)); $msgs[] = array('success', _("Event successfully deleted.")); + } catch (Horde_Exception $e) { + $msgs[] = array('error', _("There was an error deleting the event:") . ' ' . $e->getMessage()); } } else { $msgs[] = array('warning', _("This action is not supported.")); @@ -114,11 +114,11 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver case 'update': // vEvent reply. if ($registry->hasMethod('calendar/updateAttendee')) { - $event = $registry->call('calendar/updateAttendee', array('response' => $components[$key], 'sender' => $params[0]->getFromAddress())); - if (is_a($event, 'PEAR_Error')) { - $msgs[] = array('error', _("There was an error updating the event:") . ' ' . $event->getMessage()); - } else { + try { + $event = $registry->call('calendar/updateAttendee', array('response' => $components[$key], 'sender' => $params[0]->getFromAddress())); $msgs[] = array('success', _("Respondent Status Updated.")); + } catch (Horde_Exception $e) { + $msgs[] = array('error', _("There was an error updating the event:") . ' ' . $e->getMessage()); } } else { $msgs[] = array('warning', _("This action is not supported.")); @@ -138,32 +138,34 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver $handled = false; $guid = $components[$key]->getAttribute('UID'); // Check if this is an update. - if ($registry->hasMethod('calendar/export') && - !is_a($registry->call('calendar/export', array($guid, 'text/calendar')), 'PEAR_Error')) { + try { + $registry->call('calendar/export', array($guid, 'text/calendar'); + // Try to update in calendar. if ($registry->hasMethod('calendar/replace')) { - $result = $registry->call('calendar/replace', array('uid' => $guid, 'content' => $components[$key], 'contentType' => $this->mime_part->getType())); - if (is_a($result, 'PEAR_Error')) { - // Could be a missing permission. - $msgs[] = array('warning', _("There was an error updating the event:") . ' ' . $result->getMessage() . '. ' . _("Trying to import the event instead.")); - } else { + try { + $registry->call('calendar/replace', array('uid' => $guid, 'content' => $components[$key], 'contentType' => $this->mime_part->getType())); $handled = true; $url = Horde::url($registry->link('calendar/show', array('uid' => $guid))); $msgs[] = array('success', _("The event was updated in your calendar.") . ' ' . Horde::link($url, _("View event"), null, '_blank') . Horde::img('mime/icalendar.png', _("View event"), null, $registry->getImageDir('horde')) . ''); + } catch (Horde_Exception $e) {} + // Could be a missing permission. + $msgs[] = array('warning', _("There was an error updating the event:") . ' ' . $e->getMessage() . '. ' . _("Trying to import the event instead.")); } } - } + } catch (Horde_Exception $e) {} + if (!$handled && $registry->hasMethod('calendar/import')) { // Import into calendar. $handled = true; - $guid = $registry->call('calendar/import', array('content' => $components[$key], 'contentType' => $this->mime_part->getType())); - if (is_a($guid, 'PEAR_Error')) { - $msgs[] = array('error', _("There was an error importing the event:") . ' ' . $guid->getMessage()); - } else { + try { + $guid = $registry->call('calendar/import', array('content' => $components[$key], 'contentType' => $this->mime_part->getType())); $url = Horde::url($registry->link('calendar/show', array('uid' => $guid))); $msgs[] = array('success', _("The event was added to your calendar.") . ' ' . Horde::link($url, _("View event"), null, '_blank') . Horde::img('mime/icalendar.png', _("View event"), null, $registry->getImageDir('horde')) . ''); + } catch (Horde_Exception $e) { + $msgs[] = array('error', _("There was an error importing the event:") . ' ' . $e->getMessage()); } } if (!$handled) { @@ -174,11 +176,11 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver case 'vFreebusy': // Import into Kronolith. if ($registry->hasMethod('calendar/import_vfreebusy')) { - $res = $registry->call('calendar/import_vfreebusy', array($components[$key])); - if (is_a($res, 'PEAR_Error')) { - $msgs[] = array('error', _("There was an error importing user's free/busy information:") . ' ' . $res->getMessage()); - } else { + try { + $registry->call('calendar/import_vfreebusy', array($components[$key])); $msgs[] = array('success', _("The user's free/busy information was sucessfully stored.")); + } catch (Horde_Exception $e) { + $msgs[] = array('error', _("There was an error importing user's free/busy information:") . ' ' . $e->getMessage()); } } else { $msgs[] = array('warning', _("This action is not supported.")); @@ -188,13 +190,13 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver case 'vTodo': // Import into Nag. if ($registry->hasMethod('tasks/import')) { - $guid = $registry->call('tasks/import', array($components[$key], $this->mime_part->getType())); - if (is_a($guid, 'PEAR_Error')) { - $msgs[] = array('error', _("There was an error importing the task:") . ' ' . $guid->getMessage()); - } else { + try { + $guid = $registry->call('tasks/import', array($components[$key], $this->mime_part->getType())); $url = Horde::url($registry->link('tasks/show', array('uid' => $guid))); $msgs[] = array('success', _("The task has been added to your tasklist.") . ' ' . Horde::link($url, _("View task"), null, '_blank') . Horde::img('mime/icalendar.png', _("View task"), null, $registry->getImageDir('horde')) . ''); + } catch (Horde_Exception $e) { + $msgs[] = array('error', _("There was an error importing the task:") . ' ' . $e->getMessage()); } } else { $msgs[] = array('warning', _("This action is not supported.")); @@ -621,11 +623,11 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver case 'REQUEST': // Check if this is an update. - if ($registry->hasMethod('calendar/export') && - !is_a($registry->call('calendar/export', array($vevent->getAttribute('UID'), 'text/calendar')), 'PEAR_Error')) { + try { + $registry->call('calendar/export', array($vevent->getAttribute('UID'), 'text/calendar')); $is_update = true; $desc = _("%s wants to notify you about changes of \"%s\"."); - } else { + } catch (Horde_Exception $e) { $is_update = false; // Check that you are one of the attendees here. @@ -788,50 +790,52 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver } if ($registry->hasMethod('calendar/getFbCalendars') && - $registry->hasMethod('calendar/listEvents') && - !is_a($calendars = $registry->call('calendar/getFbCalendars'), 'PEAR_Error')) { - - $vevent_allDay = true; - $vevent_start = new Horde_Date($start); - $vevent_end = new Horde_Date($end); - // Check if it's an all-day event. - if (is_array($start)) { - $vevent_end = $vevent_end->sub(1); - } else { - $vevent_allDay = false; - $time_span_start = new Horde_Date($start); - $time_span_start = $time_span_start->sub($prefs->getValue('conflict_interval') * 60); - $time_span_end = new Horde_Date($end); - $time_span_end = $time_span_end->add($prefs->getValue('conflict_interval') * 60); - } - $events = $registry->call('calendar/listEvents', array($start, $vevent_end, $calendars, false)); - - if (!is_a($events, 'PEAR_Error') && count($events)) { - $html .= '

' . _("Possible Conflicts") . '

'; - // TODO: Check if there are too many events to show. - foreach ($events as $calendar) { - foreach ($calendar as $event) { - if ($vevent_allDay || $event->isAllDay()) { - $html .= ''; - } else { - if ($event->end->compareDateTime($time_span_start) <= -1 || - $event->start->compareDateTime($time_span_end) >= 1) { - continue; - } - if ($event->end->compareDateTime($vevent_start) <= -1 || - $event->start->compareDateTime($vevent_end) >= 1) { - $html .= ''; - } else { + $registry->hasMethod('calendar/listEvents')) { + try { + $calendars = $registry->call('calendar/getFbCalendars'); + + $vevent_allDay = true; + $vevent_start = new Horde_Date($start); + $vevent_end = new Horde_Date($end); + // Check if it's an all-day event. + if (is_array($start)) { + $vevent_end = $vevent_end->sub(1); + } else { + $vevent_allDay = false; + $time_span_start = new Horde_Date($start); + $time_span_start = $time_span_start->sub($prefs->getValue('conflict_interval') * 60); + $time_span_end = new Horde_Date($end); + $time_span_end = $time_span_end->add($prefs->getValue('conflict_interval') * 60); + } + $events = $registry->call('calendar/listEvents', array($start, $vevent_end, $calendars, false)); + + if (count($events)) { + $html .= '

' . _("Possible Conflicts") . '

'; + // TODO: Check if there are too many events to show. + foreach ($events as $calendar) { + foreach ($calendar as $event) { + if ($vevent_allDay || $event->isAllDay()) { $html .= ''; + } else { + if ($event->end->compareDateTime($time_span_start) <= -1 || + $event->start->compareDateTime($time_span_end) >= 1) { + continue; + } + if ($event->end->compareDateTime($vevent_start) <= -1 || + $event->start->compareDateTime($vevent_end) >= 1) { + $html .= ''; + } else { + $html .= ''; + } } - } - $html .= ''; + $html .= ''; + } } + $html .= '
'. $event->getTitle() . '' - . $event->getTimeRange() . '
'. $event->getTitle() . '' + . $event->getTimeRange() . '
'; } - $html .= ''; - } + } catch (Horde_Exception $e) {} } if ($_SESSION['imp']['view'] != 'imp') { diff --git a/imp/lib/Session.php b/imp/lib/Session.php index f6a3ec9df..24fad3b2f 100644 --- a/imp/lib/Session.php +++ b/imp/lib/Session.php @@ -155,10 +155,11 @@ class IMP_Session $sess['file_upload'] = $GLOBALS['browser']->allowFileUploads(); /* Is the 'mail/canApplyFilters' API call available? */ - if ($registry->hasMethod('mail/canApplyFilters') && - $registry->call('mail/canApplyFilters')) { - $sess['filteravail'] = true; - } + try { + if ($registry->call('mail/canApplyFilters')) { + $sess['filteravail'] = true; + } + } catch (Horde_Exception $e) {} /* Is the 'tasks/listTasklists' call available? */ if ($conf['tasklist']['use_tasklist'] && diff --git a/imp/lib/base.php b/imp/lib/base.php index cbc3b5f85..5941794a7 100644 --- a/imp/lib/base.php +++ b/imp/lib/base.php @@ -60,11 +60,13 @@ $registry = Horde_Registry::singleton($s_ctrl); // and login pages, since those are handled below and need to fall through // to IMP-specific code. $compose_page = Horde_Util::nonInputVar('compose_page'); -if (is_a(($pushed = $registry->pushApp('imp', !(defined('AUTH_HANDLER') || $compose_page))), 'PEAR_Error')) { - if ($pushed->getCode() == 'permission_denied') { +try { + $registry->pushApp('imp', !(defined('AUTH_HANDLER') || $compose_page)); +} catch (Horde_Exception $e) { + if ($e->getCode() == 'permission_denied') { Horde::authenticationFailureRedirect(); } - Horde::fatal($pushed, __FILE__, __LINE__, false); + Horde::fatal($e, __FILE__, __LINE__, false); } $conf = &$GLOBALS['conf']; if (!defined('IMP_TEMPLATES')) { diff --git a/imp/lib/prefs.php b/imp/lib/prefs.php index 928e90888..dd4c927ba 100644 --- a/imp/lib/prefs.php +++ b/imp/lib/prefs.php @@ -242,7 +242,13 @@ function prefs_callback() } /* Make sure we have an active IMAP stream. */ -if (!$GLOBALS['registry']->call('mail/server')) { +try { + $res = $GLOBALS['registry']->call('mail/server'); +} catch (Horde_Exception $e) { + $res = false; +} + +if (!$res) { header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('redirect.php'), 'url', Horde::selfUrl(true))); exit; } diff --git a/imp/login.php b/imp/login.php index a9629d705..18d0b5163 100644 --- a/imp/login.php +++ b/imp/login.php @@ -55,7 +55,7 @@ if (!empty($_SESSION['imp']) && is_array($_SESSION['imp'])) { if ($imp_auth) { Horde_Auth::clearAuth(); @session_destroy(); - Horde::setupSessionHandler(); + $registry->setupSessionHandler(); @session_start(); } diff --git a/imp/redirect.php b/imp/redirect.php index a741d1efc..546aa6c8b 100644 --- a/imp/redirect.php +++ b/imp/redirect.php @@ -136,7 +136,7 @@ if (!is_null($imapuser) && !is_null($pass)) { if (Horde_Auth::getProvider() == 'imp') { /* Destroy any existing session on login and make sure to use a new * session ID, to avoid session fixation issues. */ - Horde::getCleanSession(); + $registry->getCleanSession(); } if (IMP_Session::createSession($imapuser, $pass, Horde_Util::getFormData('server_key', IMP_Session::getAutoLoginServer()))) { diff --git a/imp/saveimage.php b/imp/saveimage.php index 41ca2a73c..d0f8251fd 100644 --- a/imp/saveimage.php +++ b/imp/saveimage.php @@ -26,9 +26,10 @@ case 'save_image': 'data' => $mime_part->getContents(), 'type' => $mime_part->getType() ); - $res = $registry->call('images/saveImage', array(null, Horde_Util::getFormData('gallery'), $image_data)); - if (is_a($res, 'PEAR_Error')) { - $notification->push($res, 'horde.error'); + try { + $registry->call('images/saveImage', array(null, Horde_Util::getFormData('gallery'), $image_data)); + } catch (Horde_Exception $e) { + $notification->push($e, 'horde.error'); break; } Horde_Util::closeWindowJS(); diff --git a/imp/templates/prefs/sourceselect.inc b/imp/templates/prefs/sourceselect.inc index d2bce5c45..81334976f 100644 --- a/imp/templates/prefs/sourceselect.inc +++ b/imp/templates/prefs/sourceselect.inc @@ -1,8 +1,16 @@ hasMethod('contacts/sources')) { $search = IMP_Compose::getAddressSearchParams(); - $readable = $registry->call('contacts/sources'); - $writeable = $registry->call('contacts/sources', true); + try { + $readable = $registry->call('contacts/sources'); + } catch (Horde_Exception $e) { + $readable = null; + } + try { + $writeable = $registry->call('contacts/sources', true); + } catch (Horde_Exception $e) { + $writeable = null; + } $nbReadSources = count(array_keys($readable)); $nbWriteSources = count(array_keys($writeable)); @@ -21,13 +29,13 @@ if ($registry->hasMethod('contacts/sources')) { } $readSelect = ''; - if (!is_a($readable, 'PEAR_Error') && is_array($readable)) { + if (is_array($readable)) { foreach (array_diff(array_keys($readable), $search['sources']) as $source) { $readSelect .= '\n"; } } - if (!is_a($writeable, 'PEAR_Error') && is_array($writeable)) { + if (is_array($writeable)) { $writeSelect = '' . "\n"; $writeSource = ''; foreach ($writeable as $source => $name) { @@ -38,9 +46,11 @@ if ($registry->hasMethod('contacts/sources')) { } $search_fields = array(); - if (!is_a($readable, 'PEAR_Error') && is_array($readable)) { + if (is_array($readable)) { foreach (array_keys($readable) as $source) { - $search_fields[$source] = $registry->call('contacts/fields', $source); + try { + $search_fields[$source] = $registry->call('contacts/fields', $source); + } catch (Horde_Exception $e) {} } } diff --git a/ingo/lib/Ingo.php b/ingo/lib/Ingo.php index 00bc3b0f2..1bf533b5c 100644 --- a/ingo/lib/Ingo.php +++ b/ingo/lib/Ingo.php @@ -41,10 +41,9 @@ class Ingo { global $conf, $registry; - if (!empty($conf['rules']['usefolderapi']) && - $registry->hasMethod('mail/folderlist')) { - $mailboxes = $registry->call('mail/folderlist'); - if (!is_a($mailboxes, 'PEAR_Error')) { + if (!empty($conf['rules']['usefolderapi'])) { + try { + $mailboxes = $registry->call('mail/folderlist'); $createfolder = $registry->hasMethod('mail/createFolder'); $text = '