From: Michael M Slusarz Date: Tue, 9 Feb 2010 04:22:23 +0000 (-0700) Subject: Remove move PEAR_Error usage in IMP X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=cd624150e5fa2d0f3aa6edcc966d7d588f14a1c9;p=horde.git Remove move PEAR_Error usage in IMP --- diff --git a/framework/Prefs/lib/Horde/Prefs/Identity.php b/framework/Prefs/lib/Horde/Prefs/Identity.php index 2ec6083d0..98959a56c 100644 --- a/framework/Prefs/lib/Horde/Prefs/Identity.php +++ b/framework/Prefs/lib/Horde/Prefs/Identity.php @@ -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); } /** diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index 734f493d9..c5d661d68 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -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 . ''; + } + } 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 . '' - : $escapeName; + return $escapeName; } /** diff --git a/imp/lib/Maillog.php b/imp/lib/Maillog.php index ecde038ee..e682c3949 100644 --- a/imp/lib/Maillog.php +++ b/imp/lib/Maillog.php @@ -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)); } /** diff --git a/imp/lib/Prefs/Identity.php b/imp/lib/Prefs/Identity.php index eb6896252..21ef3d949 100644 --- a/imp/lib/Prefs/Identity.php +++ b/imp/lib/Prefs/Identity.php @@ -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; } /** diff --git a/imp/smime.php b/imp/smime.php index 19163c083..924bb7137 100644 --- a/imp/smime.php +++ b/imp/smime.php @@ -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')) {