Remove move PEAR_Error usage in IMP
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 9 Feb 2010 04:22:23 +0000 (21:22 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 9 Feb 2010 04:31:30 +0000 (21:31 -0700)
framework/Prefs/lib/Horde/Prefs/Identity.php
imp/lib/IMP.php
imp/lib/Maillog.php
imp/lib/Prefs/Identity.php
imp/smime.php

index 2ec6083..98959a5 100644 (file)
@@ -321,7 +321,6 @@ class Horde_Prefs_Identity
      *
      * @param integer $identity  The identity to verify.
      *
-     * @return bool|object  True if the properties are valid.
      * @throws Horde_Exception
      */
     public function verify($identity = null)
@@ -347,11 +346,9 @@ class Horde_Prefs_Identity
         $var = new Horde_Form_Variable('', 'replyto_addr', $email, false);
 
         /* Verify From address. */
-        if ($email->isValid($var, $vars, $this->getValue('from_addr', $identity), $error_message)) {
-            return true;
+        if (!$email->isValid($var, $vars, $this->getValue('from_addr', $identity), $error_message)) {
+            throw new Horde_Exception($error_message);
         }
-
-        throw new Horde_Exception($error_message);
     }
 
     /**
index 734f493..c5d661d 100644 (file)
@@ -104,15 +104,15 @@ class IMP
 
         $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')));
+        $escapeName = @htmlspecialchars($newName, ENT_COMPAT, Horde_Nls::getCharset());
 
-        $old_error = error_reporting(0);
-        $escapeName = htmlspecialchars($newName, ENT_COMPAT, Horde_Nls::getCharset());
-        error_reporting($old_error);
+        try {
+            if ($contact_link = $registry->link('contacts/show', array('uid' => $result, 'source' => $prefs->getValue('add_source')))) {
+                return Horde::link(Horde::url($contact_link), sprintf(_("Go to address book entry of \"%s\""), $newName)) . $escapeName . '</a>';
+            }
+        } catch (Horde_Exception $e) {}
 
-        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;
+        return $escapeName;
     }
 
     /**
index ecde038..e682c39 100644 (file)
@@ -53,14 +53,14 @@ class IMP_Maillog
                 break;
             }
 
-            $r = $history->log(self::_getUniqueHistoryId($val), $params);
-
-            /* On error, log the error message only since informing the user
-             * is just a waste of time and a potential point of confusion,
-             * especially since they most likely don't even know the message
-             * is being logged. */
-            if ($r instanceof PEAR_Error) {
-                $entry = sprintf('Could not log message details to Horde_History. Error returned: %s', $r->getMessage());
+            try {
+                $history->log(self::_getUniqueHistoryId($val), $params);
+            } catch (Horde_Exception $e) {
+                /* On error, log the error message only since informing the
+                 * user is just a waste of time and a potential point of
+                 * confusion, especially since they most likely don't even
+                 * know the message is being logged. */
+                $entry = sprintf('Could not log message details to Horde_History. Error returned: %s', $e->getMessage());
                 Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_ERR);
             }
         }
@@ -77,14 +77,7 @@ class IMP_Maillog
      */
     static public function getLog($msg_id)
     {
-        $history = Horde_History::singleton();
-
-        $res = $history->getHistory(self::_getUniqueHistoryId($msg_id));
-        if ($res instanceof PEAR_Error) {
-            throw new Horde_Exception($res);
-        }
-
-        return $res;
+        return Horde_History::singleton()->getHistory(self::_getUniqueHistoryId($msg_id));
     }
 
     /**
index eb68962..21ef3d9 100644 (file)
@@ -63,15 +63,11 @@ class Imp_Prefs_Identity extends Horde_Prefs_Identity
      *
      * @param integer $identity  The identity to verify.
      *
-     * @return boolean|object  True if the properties are valid or a PEAR_Error
-     *                         with an error description otherwise.
+     * @throws Horde_Exception
      */
     public function verify($identity = null)
     {
-        $result = parent::verify($identity);
-        if ($result instanceof PEAR_Error) {
-            return $result;
-        }
+        parent::verify($identity);
 
         if (!isset($identity)) {
             $identity = $this->_default;
@@ -83,14 +79,9 @@ class Imp_Prefs_Identity extends Horde_Prefs_Identity
         $vars = new Horde_Variables();
         $var = new Horde_Form_Variable('', 'replyto_addr', $email, false);
 
-        /* Verify From address. */
-        if (!$email->isValid($var, $vars, $this->getValue('from_addr', $identity), $error_message)) {
-            return PEAR::raiseError($error_message);
-        }
-
         /* Verify Reply-to address. */
         if (!$email->isValid($var, $vars, $this->getValue('replyto_addr', $identity), $error_message)) {
-            return PEAR::raiseError($error_message);
+            throw new Horde_Exception($error_message);
         }
 
         /* Clean up Alias, Tie-to, and BCC addresses. */
@@ -105,14 +96,12 @@ class Imp_Prefs_Identity extends Horde_Prefs_Identity
             /* Validate addresses */
             foreach ($data as $address) {
                 if (!$email->isValid($var, $vars, $address, $error_message)) {
-                    return PEAR::raiseError($error_message);
+                    throw new Horde_Exception($error_message);
                 }
             }
 
             $this->setValue($val, $data, $identity);
         }
-
-        return true;
     }
 
     /**
index 19163c0..924bb71 100644 (file)
@@ -16,7 +16,6 @@ require_once dirname(__FILE__) . '/lib/Application.php';
 Horde_Registry::appInit('imp');
 
 $imp_smime = Horde_Crypt::singleton(array('IMP', 'Smime'));
-$secure_check = Horde::isConnectionSecure();
 
 /* Run through the action handlers */
 $actionID = Horde_Util::getFormData('actionID');
@@ -197,7 +196,7 @@ if ($openssl_check && $prefs->getValue('use_smime')) {
     }
     $t->set('personalkey-help', Horde_Help::link('imp', 'smime-overview-personalkey'));
 
-    $t->set('secure_check', $secure_check instanceof PEAR_Error);
+    $t->set('secure_check', Horde::isConnectionSecure());
     if (!$t->get('secure_check')) {
         $t->set('has_key', $prefs->getValue('smime_public_key') && $prefs->getValue('smime_private_key'));
         if ($t->get('has_key')) {