From: Michael M Slusarz Date: Thu, 9 Jul 2009 18:57:21 +0000 (-0600) Subject: Catch Horde_Exceptions X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=174e1a168a032b0f7313994ae95befa7b939f932;p=horde.git Catch Horde_Exceptions --- diff --git a/chora/lib/Chora.php b/chora/lib/Chora.php index 370978dcf..6e53d7bf8 100644 --- a/chora/lib/Chora.php +++ b/chora/lib/Chora.php @@ -41,8 +41,9 @@ class Chora { global $acts, $defaultActs, $where, $atdir, $fullname, $sourceroot; - $GLOBALS['sourceroots'] = Horde::loadConfiguration('sourceroots.php', 'sourceroots'); - if (is_a($GLOBALS['sourceroots'], 'PEAR_Error')) { + try { + $GLOBALS['sourceroots'] = Horde::loadConfiguration('sourceroots.php', 'sourceroots'); + } catch (Horde_Exception $e) { $GLOBALS['notification']->push($GLOBALS['sourceroots']); $GLOBALS['sourceroots'] = array(); } diff --git a/folks/edit/friends/invite.php b/folks/edit/friends/invite.php index 3ce7ad76f..14e84114f 100644 --- a/folks/edit/friends/invite.php +++ b/folks/edit/friends/invite.php @@ -29,14 +29,14 @@ $v = &$form->addVariable(_("Subject"), 'subject', 'text', true); $v->setDefault(sprintf(_("%s Invited to join %s."), ucfirst(Horde_Auth::getAuth()), $registry->get('name', 'horde'))); $v = &$form->addVariable(_("Body"), 'body', 'longtext', true); -$body = Horde::loadConfiguration('invite.php', 'body', 'folks'); -if ($body instanceof PEAR_Error) { - $body = $body->getMessage(); -} else { +try { + $body = Horde::loadConfiguration('invite.php', 'body', 'folks'); $body = sprintf($body, $registry->get('name', 'horde'), Folks::getUrlFor('user', Horde_Auth::getAuth(), true), Horde::applicationUrl('account/signup.php', true), Horde_Auth::getAuth()); +} catch (Horde_Exception $e) { + $body = $body->getMessage(); } $v->setDefault($body); @@ -60,4 +60,4 @@ require FOLKS_TEMPLATES . '/edit/header.php'; require FOLKS_TEMPLATES . '/edit/invite.php'; require FOLKS_TEMPLATES . '/edit/footer.php'; -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/edit/password.php b/folks/edit/password.php index 465dfc079..f29ae36d3 100644 --- a/folks/edit/password.php +++ b/folks/edit/password.php @@ -54,7 +54,6 @@ do { // Check some password policy $password_policy = Horde::loadConfiguration('password_policy.php', 'password_policy', 'folks'); if (is_array($password_policy)) { - // Check max/min lengths if specified in the backend config. if (isset($password_policy['minLength']) && strlen($info['new']) < $password_policy['minLength']) { diff --git a/folks/lib/Driver.php b/folks/lib/Driver.php index 3f5309f65..7fd0f6f2a 100644 --- a/folks/lib/Driver.php +++ b/folks/lib/Driver.php @@ -62,13 +62,12 @@ class Folks_Driver { /** * Load VFS Backend + * + * @throws Horde_Exception */ protected function _loadVFS() { $v_params = Horde::getVFSConfig('images'); - if ($v_params instanceof PEAR_Error) { - return $v_params; - } return VFS::singleton($v_params['type'], $v_params['params']); } diff --git a/folks/lib/Folks.php b/folks/lib/Folks.php index 0e9c5f5c8..cd2509a6b 100644 --- a/folks/lib/Folks.php +++ b/folks/lib/Folks.php @@ -44,12 +44,11 @@ class Folks { */ static function getCountries() { - $result = Horde::loadConfiguration('countries.php', 'countries', 'folks'); - if ($result instanceof PEAR_Error) { + try { + return Horde::loadConfiguration('countries.php', 'countries', 'folks'); + } catch (Horde_Exception $e) return Horde_Nls::getCountryISO(); } - - return $result; } /** diff --git a/imp/acl.php b/imp/acl.php index 34d812fed..539ba5203 100644 --- a/imp/acl.php +++ b/imp/acl.php @@ -134,11 +134,11 @@ try { $canEdit = $ACLDriver->canEdit($folder, $_SESSION['imp']['uniquser']); require_once 'Horde/Prefs/UI.php'; -$result = Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp'); -if (is_a($result, 'PEAR_Error')) { - Horde::fatal($result, __FILE__, __LINE__); +try { + extract(Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp')); +} catch (Horde_Exception $e) { + Horde::fatal($e, __FILE__, __LINE__); } -extract($result); $app = 'imp'; $chunk = Horde_Util::nonInputVar('chunk'); diff --git a/imp/config/prefs.php.dist b/imp/config/prefs.php.dist index 6bc462015..ad1c190cd 100644 --- a/imp/config/prefs.php.dist +++ b/imp/config/prefs.php.dist @@ -656,8 +656,7 @@ $_prefs['sending_charset'] = array( 'locked' => false, 'shared' => true, 'type' => 'enum', - 'enum' => array_merge(array('' => _("Default")), - $GLOBALS['nls']['encodings']), + 'enum' => array_merge(array('' => _("Default")), Horde_Nls::$config['encodings']), 'desc' => _("Your default charset for sending messages:")); // Select widget for the 'default_encrypt' preference @@ -938,8 +937,7 @@ $_prefs['default_msg_charset'] = array( 'shared' => false, 'type' => 'enum', 'enum' => array_merge( - array('' => _("Default (US-ASCII)")), - $GLOBALS['nls']['encodings'] + array('' => _("Default (US-ASCII)")), Horde_Nls::$config['encodings'] ), 'desc' => _("The default charset for messages with no charset information:"), 'help' => 'prefs-default_msg_charset'); diff --git a/imp/fetchmailprefs.php b/imp/fetchmailprefs.php index f8286c4dc..a8e27a00b 100644 --- a/imp/fetchmailprefs.php +++ b/imp/fetchmailprefs.php @@ -88,11 +88,11 @@ case 'fetchmail_prefs_delete': } require_once 'Horde/Prefs/UI.php'; -$result = Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp'); -if (is_a($result, 'PEAR_Error')) { - Horde::fatal($result, __FILE__, __LINE__); +try { + extract(Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp')); +} catch (Horde_Exception $e) { + Horde::fatal($e, __FILE__, __LINE__); } -extract($result); $app = 'imp'; $chunk = Horde_Util::nonInputVar('chunk'); diff --git a/imp/filterprefs.php b/imp/filterprefs.php index c109721d7..4cafcc443 100644 --- a/imp/filterprefs.php +++ b/imp/filterprefs.php @@ -12,11 +12,11 @@ require_once dirname(__FILE__) . '/lib/base.php'; require_once 'Horde/Prefs/UI.php'; -$result = Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp'); -if (is_a($result, 'PEAR_Error')) { - Horde::fatal($result, __FILE__, __LINE__); +try { + extract(Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp')); +} catch (Horde_Exception $e) { + Horde::fatal($e, __FILE__, __LINE__); } -extract($result); /* Are preferences locked? */ $login_locked = $prefs->isLocked('filter_on_login') || empty($_SESSION['imp']['filteravail']); diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index 267066602..7e0118190 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -493,12 +493,12 @@ class IMP_Compose $headers->addUserAgentHeader(); /* Tack on any site-specific headers. */ - $headers_result = Horde::loadConfiguration('header.php', '_header'); - if (!is_a($headers_result, 'PEAR_Error')) { + try { + $headers_result = Horde::loadConfiguration('header.php', '_header'); foreach ($headers_result as $key => $val) { $headers->addHeader(trim($key), Horde_String::convertCharset(trim($val), Horde_Nls::getCharset(), $charset)); } - } + } catch (Horde_Exception $e) {} if ($conf['sentmail']['driver'] != 'none') { $sentmail = IMP_Sentmail::factory(); diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index ce7dc6ef3..5d78a9f63 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -130,7 +130,7 @@ class IMP $result = $registry->call('contacts/import', array(array('name' => $newName, 'email' => $newAddress), 'array', $prefs->getValue('add_source'))); - if (is_a($result, 'PEAR_Error')) { + if ($result instanceof PEAR_Error) { throw new Horde_Exception($result); } @@ -140,7 +140,7 @@ class IMP $escapeName = htmlspecialchars($newName, ENT_COMPAT, Horde_Nls::getCharset()); error_reporting($old_error); - return (!empty($contact_link) && !is_a($contact_link, 'PEAR_Error')) + return (!empty($contact_link) && !$contact_link instanceof PEAR_Error) ? Horde::link(Horde::url($contact_link), sprintf(_("Go to address book entry of \"%s\""), $newName)) . $escapeName . '' : $escapeName; } @@ -233,7 +233,7 @@ class IMP $tasklists = $GLOBALS['registry']->call('tasks/listTasklists', array(false, PERMS_EDIT)); - if (!is_a($tasklists, 'PEAR_Error') && count($tasklists)) { + if (!$tasklists instanceof PEAR_Error && count($tasklists)) { $text .= '' . "\n"; foreach ($tasklists as $id => $tasklist) { @@ -251,7 +251,7 @@ class IMP $notepads = $GLOBALS['registry']->call('notes/listNotepads', array(false, PERMS_EDIT)); - if (!is_a($notepads, 'PEAR_Error') && count($notepads)) { + if (!$notepads instanceof PEAR_Error && count($notepads)) { $text .= '' . "\n"; foreach ($notepads as $id => $notepad) { diff --git a/imp/lib/Imap.php b/imp/lib/Imap.php index a7e9af040..1d9e647a1 100644 --- a/imp/lib/Imap.php +++ b/imp/lib/Imap.php @@ -86,9 +86,10 @@ class IMP_Imap */ static public function loadServerConfig($server = null) { - $servers = Horde::loadConfiguration('servers.php', 'servers', 'imp'); - if (is_a($servers, 'PEAR_Error')) { - Horde::logMessage($servers, __FILE__, __LINE__, PEAR_LOG_ERR); + try { + $servers = Horde::loadConfiguration('servers.php', 'servers', 'imp'); + } catch (Horde_Exception $e) { + Horde::logMessage($e, __FILE__, __LINE__, PEAR_LOG_ERR); return false; } diff --git a/imp/lib/Imple/SpellChecker.php b/imp/lib/Imple/SpellChecker.php index 61cf34bba..7617ae43e 100644 --- a/imp/lib/Imple/SpellChecker.php +++ b/imp/lib/Imple/SpellChecker.php @@ -78,10 +78,10 @@ class IMP_Imple_SpellChecker extends IMP_Imple } /* Add local dictionary words. */ - $result = Horde::loadConfiguration('spelling.php', 'ignore_list'); - if (!is_a($result, 'PEAR_Error')) { + try { + $result = Horde::loadConfiguration('spelling.php', 'ignore_list'); $spellArgs['localDict'] = $result; - } + } catch (Horde_Exception $e) {} if (!empty($args['html'])) { $spellArgs['html'] = true; diff --git a/imp/login.php b/imp/login.php index f87cf0a30..915908a90 100644 --- a/imp/login.php +++ b/imp/login.php @@ -348,5 +348,7 @@ IMP::addInlineScript(array( echo $t->fetch(IMP_TEMPLATES . '/login/login.html'); -Horde::loadConfiguration('motd.php', null, null, true); +try { + Horde::loadConfiguration('motd.php', null, null, true); +} catch (Horde_Exception $e) {} require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/imp/pgp.php b/imp/pgp.php index 9b93c1805..e83023f75 100644 --- a/imp/pgp.php +++ b/imp/pgp.php @@ -302,11 +302,11 @@ try { $notification->push($e); } -$result = Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp'); -if (is_a($result, 'PEAR_Error')) { - Horde::fatal($result, __FILE__, __LINE__); +try { + extract(Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp')); +} catch (Horde_Exception $e) { + Horde::fatal($e, __FILE__, __LINE__); } -extract($result); require_once 'Horde/Prefs/UI.php'; $app = 'imp'; diff --git a/imp/smime.php b/imp/smime.php index f1239d2a3..8ebe52efc 100644 --- a/imp/smime.php +++ b/imp/smime.php @@ -219,11 +219,11 @@ try { $notification->push($e); } -$result = Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp'); -if (is_a($result, 'PEAR_Error')) { - Horde::fatal($result, __FILE__, __LINE__); +try { + extract(Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp')); +} catch (Horde_Exception $e) { + Horde::fatal($e, __FILE__, __LINE__); } -extract($result); require_once 'Horde/Prefs/UI.php'; $app = 'imp'; diff --git a/imp/stationery.php b/imp/stationery.php index efd354266..4b5bddc11 100644 --- a/imp/stationery.php +++ b/imp/stationery.php @@ -95,11 +95,11 @@ if ($stationery['t'] == 'html') { /* Show the header. */ require_once 'Horde/Prefs/UI.php'; -$result = Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp'); -if (is_a($result, 'PEAR_Error')) { - Horde::fatal($result, __FILE__, __LINE__); +try { + extract(Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp')); +} catch (Horde_Exception $e) { + Horde::fatal($e, __FILE__, __LINE__); } -extract($result); $app = 'imp'; $chunk = Horde_Util::nonInputVar('chunk'); diff --git a/kronolith/pref_api.php b/kronolith/pref_api.php index 663985092..795a75c26 100644 --- a/kronolith/pref_api.php +++ b/kronolith/pref_api.php @@ -34,14 +34,10 @@ require_once $appbase . '/lib/base.php'; $pref = Horde_Util::getFormData('pref'); if (!$pref) { $_prefs = array(); - if (is_callable(array('Horde', 'loadConfiguration'))) { - $result = Horde::loadConfiguration('prefs.php', array('_prefs'), $app); - if (is_a($result, 'PEAR_Error')) { - exit; - } - extract($result); - } elseif (file_exists($appbase . '/config/prefs.php')) { - require $appbase . '/config/prefs.php'; + try { + extract(Horde::loadConfiguration('prefs.php', array('_prefs'), $app)); + } catch (Horde_Exception $e) { + Horde::fatal($e, __FILE__, __LINE__); } echo '