Catch Horde_Exceptions
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 9 Jul 2009 18:57:21 +0000 (12:57 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 9 Jul 2009 18:57:21 +0000 (12:57 -0600)
20 files changed:
chora/lib/Chora.php
folks/edit/friends/invite.php
folks/edit/password.php
folks/lib/Driver.php
folks/lib/Folks.php
imp/acl.php
imp/config/prefs.php.dist
imp/fetchmailprefs.php
imp/filterprefs.php
imp/lib/Compose.php
imp/lib/IMP.php
imp/lib/Imap.php
imp/lib/Imple/SpellChecker.php
imp/login.php
imp/pgp.php
imp/smime.php
imp/stationery.php
kronolith/pref_api.php
news/lib/News.php
skoli/pref_api.php

index 370978d..6e53d7b 100644 (file)
@@ -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();
         }
index 3ce7ad7..14e8411 100644 (file)
@@ -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';
index 465dfc0..f29ae36 100644 (file)
@@ -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']) {
index 3f5309f..7fd0f6f 100644 (file)
@@ -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']);
     }
index 0e9c5f5..cd2509a 100644 (file)
@@ -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;
     }
 
     /**
index 34d812f..539ba52 100644 (file)
@@ -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');
index 6bc4620..ad1c190 100644 (file)
@@ -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');
index f8286c4..a8e27a0 100644 (file)
@@ -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');
index c109721..4cafcc4 100644 (file)
 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']);
index 2670666..7e01181 100644 (file)
@@ -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();
index ce7dc6e..5d78a9f 100644 (file)
@@ -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 . '</a>'
             : $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 .= '<option value="" disabled="disabled">&nbsp;</option><option value="" disabled="disabled">- - ' . _("Task Lists") . ' - -</option>' . "\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 .= '<option value="" disabled="disabled">&nbsp;</option><option value="" disabled="disabled">- - ' . _("Notepads") . ' - -</option>' . "\n";
 
                 foreach ($notepads as $id => $notepad) {
index a7e9af0..1d9e647 100644 (file)
@@ -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;
         }
 
index 61cf34b..7617ae4 100644 (file)
@@ -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;
index f87cf0a..915908a 100644 (file)
@@ -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';
index 9b93c18..e83023f 100644 (file)
@@ -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';
index f1239d2..8ebe52e 100644 (file)
@@ -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';
index efd3542..4b5bddc 100644 (file)
@@ -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');
index 6639850..795a75c 100644 (file)
@@ -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 '<ul id="pref">';
index 6f60199..108c517 100644 (file)
@@ -226,6 +226,8 @@ class News {
 
     /**
      * Load VFS Backend
+     *
+     * @throws Horde_Exception
      */
     static public function loadVFS()
     {
@@ -236,11 +238,7 @@ class News {
         }
 
         $v_params = Horde::getVFSConfig('images');
-        if ($v_params instanceof PEAR_Error) {
-            return $v_params;
-        }
 
-        require_once 'VFS.php';
         $vfs = VFS::singleton($v_params['type'], $v_params['params']);
         return $vfs;
     }
index 182b827..dbe151e 100644 (file)
@@ -36,14 +36,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 '<ul id="pref">';