No more is_a() -> use instanceof instead
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 27 Jul 2009 18:20:53 +0000 (12:20 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 27 Jul 2009 18:30:18 +0000 (12:30 -0600)
14 files changed:
imp/ajax.php
imp/attachment.php
imp/compose.php
imp/lib/Compose.php
imp/lib/Contents.php
imp/lib/Identity/imp.php
imp/lib/LoginTasks/Task/DeleteAttachmentsMonthly.php
imp/lib/Maillog.php
imp/lib/Message.php
imp/lib/Mime/Viewer/Images.php
imp/lib/Mime/Viewer/Itip.php
imp/lib/Mime/Viewer/Pdf.php
imp/pgp.php
imp/smime.php

index c4e8e94..8c16c9c 100644 (file)
@@ -562,7 +562,7 @@ case 'ShowPortal':
     $blocks = $linkTags = array();
     $css_load = array('imp' => true);
     foreach ($dimp_block_list as $title => $block) {
-        if (is_a($block['ob'], 'Horde_Block')) {
+        if ($block['ob'] instanceof Horde_Block) {
             $app = $block['ob']->getApp();
             $content = (empty($css_load[$app]) ? Horde::styleSheetLink($app, '', false) : '') . $block['ob']->getContent();
             $css_load[$app] = true;
index f3e353f..352b341 100644 (file)
@@ -55,7 +55,7 @@ if ($conf['compose']['link_attachments_notify']) {
     if ($vfsroot->exists($full_path, $file_name . '.notify')) {
         $delete_id = Horde_Util::getFormData('d');
         $read_id = $vfsroot->read($full_path, $file_name . '.notify');
-        if (is_a($read_id, 'PEAR_Error')) {
+        if ($read_id instanceof PEAR_Error) {
             Horde::logMessage($read_id, __FILE__, __LINE__, PEAR_LOG_ERR);
         } elseif ($delete_id == $read_id) {
             $vfsroot->deleteFile($full_path, $file_name);
@@ -67,7 +67,7 @@ if ($conf['compose']['link_attachments_notify']) {
         /* Create a random identifier for this file. */
         $id = uniqid(mt_rand());
         $res = $vfsroot->writeData($full_path, $file_name . '.notify', $id, true);
-        if (is_a($res, 'PEAR_Error')) {
+        if ($res instanceof PEAR_Error) {
             Horde::logMessage($res, __FILE__, __LINE__, PEAR_LOG_ERR);
         } else {
             /* Load $mail_user's preferences so that we can use their
@@ -108,7 +108,7 @@ if ($conf['compose']['link_attachments_notify']) {
 
 // Find the file's mime-type.
 $file_data = $vfsroot->read($full_path, $file_name);
-if (is_a($file_data, 'PEAR_Error')) {
+if ($file_data instanceof PEAR_Error) {
     Horde::logMessage($file_data, __FILE__, __LINE__, PEAR_LOG_ERR);
     throw new Horde_Exception(_("The specified file cannot be read."));
 }
index 15ea8e6..00626a6 100644 (file)
@@ -122,13 +122,13 @@ if ($token = Horde_Util::getFormData('compose_formToken')) {
         ? Horde_Token::factory($conf['token']['driver'], Horde::getDriverConfig('token', $conf['token']['driver']))
         : Horde_Token::factory('file');
 
-    $verified = $tokenSource->verify($token);
-    /* Notify and reset the actionID. */
-    if (is_a($verified, 'PEAR_Error')) {
-        $notification->push($verified);
-        $actionID = null;
-    } elseif (!$verified) {
-        $notification->push(_("You have already submitted this page."), 'horde.error');
+    try {
+        if (!$tokenSource->verify($token)) {
+            $notification->push(_("You have already submitted this page."), 'horde.error');
+            $actionID = null;
+        }
+    } catch (Horde_Exception $e) {
+        $notification->push($e->getMessage());
         $actionID = null;
     }
 }
index d4ef257..b0fd3c0 100644 (file)
@@ -1550,7 +1550,7 @@ class IMP_Compose
         global $conf;
 
         $res = $GLOBALS['browser']->wasFileUploaded($name, _("attachment"));
-        if (is_a($res, 'PEAR_Error')) {
+        if ($res instanceof PEAR_Error) {
             throw new IMP_Compose_Exception($res);
         }
 
@@ -1687,7 +1687,7 @@ class IMP_Compose
             $result = $vfs_file
                 ? $vfs->write(self::VFS_ATTACH_PATH, $cacheID, $data, true)
                 : $vfs->writeData(self::VFS_ATTACH_PATH, $cacheID, $data, true);
-            if (is_a($result, 'PEAR_Error')) {
+            if ($result instanceof PEAR_Error) {
                 return $result;
             }
 
@@ -2134,7 +2134,7 @@ class IMP_Compose
                 $data = file_get_contents($att->getInformation('temp_filename'));
                 $res = $vfs->writeData($fullpath, escapeshellcmd($att->getName()), $data, true);
             }
-            if (is_a($res, 'PEAR_Error')) {
+            if ($res instanceof PEAR_Error) {
                 Horde::logMessage($res, __FILE__, __LINE__, PEAR_LOG_ERR);
                 return IMP_Compose_Exception($res);
             }
@@ -2408,7 +2408,7 @@ class IMP_Compose
         $vfs = VFS::singleton($GLOBALS['conf']['vfs']['type'], Horde::getDriverConfig('vfs', $GLOBALS['conf']['vfs']['type']));
         // TODO: Garbage collection?
         $result = $vfs->writeData(self::VFS_DRAFTS_PATH, hash('md5', Horde_Util::getFormData('user')), $body, true);
-        if (is_a($result, 'PEAR_Error')) {
+        if ($result instanceof PEAR_Error) {
             return;
         }
 
@@ -2428,7 +2428,7 @@ class IMP_Compose
         $vfs = VFS::singleton($GLOBALS['conf']['vfs']['type'], Horde::getDriverConfig('vfs', $GLOBALS['conf']['vfs']['type']));
         if ($vfs->exists(self::VFS_DRAFTS_PATH, $filename)) {
             $data = $vfs->read(self::VFS_DRAFTS_PATH, $filename);
-            if (is_a($data, 'PEAR_Error')) {
+            if ($data instanceof PEAR_Error) {
                 return;
             }
             $vfs->deleteFile(self::VFS_DRAFTS_PATH, $filename);
index 196f1f6..c499771 100644 (file)
@@ -99,7 +99,7 @@ class IMP_Contents
      */
     static public function singleton($in)
     {
-        $sig = is_a($in, 'Horde_Mime_Part')
+        $sig = ($in instanceof Horde_Mime_Part)
             ? hash('md5', serialize($in))
             : $in;
 
@@ -119,7 +119,7 @@ class IMP_Contents
      */
     protected function __construct($in)
     {
-        if (is_a($in, 'Horde_Mime_Part')) {
+        if ($in instanceof Horde_Mime_Part) {
             $this->_message = $in;
         } else {
             list($this->_index, $this->_mailbox) = explode(IMP::IDX_SEP, $in);
index ea380d4..009be82 100644 (file)
@@ -68,7 +68,8 @@ class Identity_imp extends Identity
      */
     public function verify($identity = null)
     {
-        if (is_a($result = parent::verify($identity), 'PEAR_Error')) {
+        $result = parent::verify($identity);
+        if ($result instanceof PEAR_Error) {
             return $result;
         }
 
index 9a61c54..ba97c37 100644 (file)
@@ -40,7 +40,7 @@ class IMP_LoginTasks_Task_DeleteAttachmentsMonthly extends Horde_LoginTasks_Task
 
         /* Make sure cleaning is done recursively. */
         $files = $vfs->listFolder($path, null, true, false, true);
-        if (is_a($files, 'PEAR_Error') || !is_array($files)) {
+        if (($files instanceof PEAR_Error) || !is_array($files)) {
             return false;
         }
 
index ad74eb8..239fc37 100644 (file)
@@ -57,7 +57,7 @@ class IMP_Maillog
              * 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 (is_a($r, 'PEAR_Error')) {
+            if ($r instanceof PEAR_Error) {
                 $entry = sprintf('Could not log message details to Horde_History. Error returned: %s', $r->getMessage());
                 Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_ERR);
             }
@@ -78,7 +78,7 @@ class IMP_Maillog
         $history = Horde_History::singleton();
 
         $res = $history->getHistory(self::_getUniqueHistoryId($msg_id));
-        if (is_a($res, 'PEAR_Error')) {
+        if ($res instanceof PEAR_Error) {
             throw new Horde_Exception($res);
         }
 
index c48575a..1c54230 100644 (file)
@@ -522,7 +522,7 @@ class IMP_Message
 
         foreach ($partids as $partid) {
             $oldPart = $message->getPart($partid);
-            if (!is_a($oldPart, 'Horde_Mime_Part')) {
+            if (!($oldPart instanceof Horde_Mime_Part)) {
                 continue;
             }
             $newPart = new Horde_Mime_Part();
index 9ebe86f..6df5b9d 100644 (file)
@@ -260,13 +260,13 @@ EOD;
             $img = Horde_Image::factory('Gd', array('context' => $context));
         }
 
-        if (!$img || is_a($img, 'PEAR_Error')) {
+        if (!$img || ($img instanceof PEAR_Error)) {
             return false;
         }
 
         if ($load) {
             $ret = $img->loadString(1, $this->_mimepart->getContents());
-            if (is_a($ret, 'PEAR_Error')) {
+            if ($ret instanceof PEAR_Error) {
                 return false;
             }
         }
index 91f59ef..65dbe9b 100644 (file)
@@ -84,7 +84,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
 
         // Get the method type.
         $method = $vCal->getAttribute('METHOD');
-        if (is_a($method, 'PEAR_Error')) {
+        if ($method instanceof PEAR_Error) {
             $method = '';
         }
 
@@ -222,7 +222,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
 
                     // Get the organizer details.
                     $organizer = $vEvent->getAttribute('ORGANIZER');
-                    if (is_a($organizer, 'PEAR_Error')) {
+                    if ($organizer instanceof PEAR_Error) {
                         break;
                     }
                     $organizer = parse_url($organizer);
@@ -237,22 +237,22 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
 
                     $vEvent_reply = Horde_iCalendar::newComponent('vevent', $vCal);
                     $vEvent_reply->setAttribute('UID', $vEvent->getAttribute('UID'));
-                    if (!is_a($vEvent->getAttribute('SUMMARY'), 'PEAR_error')) {
+                    if (!$vEvent->getAttribute('SUMMARY') instanceof PEAR_Error)) {
                         $vEvent_reply->setAttribute('SUMMARY', $vEvent->getAttribute('SUMMARY'));
                     }
-                    if (!is_a($vEvent->getAttribute('DESCRIPTION'), 'PEAR_error')) {
+                    if (!$vEvent->getAttribute('DESCRIPTION') instanceof PEAR_Error) {
                         $vEvent_reply->setAttribute('DESCRIPTION', $vEvent->getAttribute('DESCRIPTION'));
                     }
                     $dtstart = $vEvent->getAttribute('DTSTART', true);
                     $vEvent_reply->setAttribute('DTSTART', $vEvent->getAttribute('DTSTART'), array_pop($dtstart));
-                    if (!is_a($vEvent->getAttribute('DTEND'), 'PEAR_error')) {
+                    if (!($vEvent->getAttribute('DTEND') instanceof PEAR_Error)) {
                         $dtend = $vEvent->getAttribute('DTEND', true);
                         $vEvent_reply->setAttribute('DTEND', $vEvent->getAttribute('DTEND'), array_pop($dtend));
                     } else {
                         $duration = $vEvent->getAttribute('DURATION', true);
                         $vEvent_reply->setAttribute('DURATION', $vEvent->getAttribute('DURATION'), array_pop($duration));
                     }
-                    if (!is_a($vEvent->getAttribute('SEQUENCE'), 'PEAR_error')) {
+                    if (!($vEvent->getAttribute('SEQUENCE') instanceof PEAR_Error)) {
                         $vEvent_reply->setAttribute('SEQUENCE', $vEvent->getAttribute('SEQUENCE'));
                     }
                     $vEvent_reply->setAttribute('ORGANIZER', $vEvent->getAttribute('ORGANIZER'), array_pop($organizer));
@@ -366,7 +366,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
 
                     // Get the organizer details.
                     $organizer = $vFb->getAttribute('ORGANIZER');
-                    if (is_a($organizer, 'PEAR_Error')) {
+                    if ($organizer instanceof PEAR_Error) {
                         break;
                     }
                     $organizer = parse_url($organizer);
@@ -379,13 +379,13 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
                         $endStamp = $startStamp + (60 * 24 * 3600);
                     } else {
                         $startStamp = $vFb->getAttribute('DTSTART');
-                        if (is_a($startStamp, 'PEAR_Error')) {
+                        if ($startStamp instanceof PEAR_Error) {
                             $startStamp = time();
                         }
                         $endStamp = $vFb->getAttribute('DTEND');
-                        if (is_a($endStamp, 'PEAR_Error')) {
+                        if ($endStamp instanceof PEAR_Error) {
                             $duration = $vFb->getAttribute('DURATION');
-                            if (is_a($duration, 'PEAR_Error')) {
+                            if ($duration instanceof PEAR_Error) {
                                 $endStamp = $startStamp + (60 * 24 * 3600);
                             } else {
                                 $endStamp = $startStamp + $duration;
@@ -533,7 +533,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
         }
 
         $start = $vfb->getAttribute('DTSTART');
-        if (!is_a($start, 'PEAR_Error')) {
+        if (!($start instanceof PEAR_Error)) {
             if (is_array($start)) {
                 $html .= '<p><strong>' . _("Start:") . '</strong> ' . strftime($prefs->getValue('date_format'), mktime(0, 0, 0, $start['month'], $start['mday'], $start['year'])) . '</p>';
             } else {
@@ -542,7 +542,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
         }
 
         $end = $vfb->getAttribute('DTEND');
-        if (!is_a($end, 'PEAR_Error')) {
+        if (!($end instanceof PEAR_Error)) {
             if (is_array($end)) {
                 $html .= '<p><strong>' . _("End:") . '</strong> ' . strftime($prefs->getValue('date_format'), mktime(0, 0, 0, $end['month'], $end['mday'], $end['year'])) . '</p>';
             } else {
@@ -601,7 +601,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
         $options = array();
 
         $attendees = $vevent->getAttribute('ATTENDEE');
-        if (!is_a($attendees, 'PEAR_Error') &&
+        if (!($attendees instanceof PEAR_Error) &&
             !empty($attendees) &&
             !is_array($attendees)) {
             $attendees = array($attendees);
@@ -627,7 +627,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
 
                 // Check that you are one of the attendees here.
                 $is_attendee = false;
-                if (!is_a($attendees, 'PEAR_Error') && !empty($attendees)) {
+                if (!($attendees instanceof PEAR_Error) && !empty($attendees)) {
                     $identity = Identity::singleton(array('imp', 'imp'));
                     for ($i = 0, $c = count($attendees); $i < $c; ++$i) {
                         $attendee = parse_url($attendees[$i]);
@@ -677,7 +677,8 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
             break;
 
         case 'CANCEL':
-            if (is_a($instance = $vevent->getAttribute('RECURRENCE-ID'), 'PEAR_Error')) {
+            $instance = $vevent->getAttribute('RECURRENCE-ID');
+            if ($instance instanceof PEAR_Error) {
                 $desc = _("%s has cancelled \"%s\".");
                 if ($registry->hasMethod('calendar/delete')) {
                     $options[] = '<option value="delete">' . _("Delete from my calendar") . '</option>';
@@ -692,7 +693,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
         }
 
         $summary = $vevent->getAttribute('SUMMARY');
-        if (is_a($summary, 'PEAR_Error')) {
+        if ($summary instanceof PEAR_Error) {
             $desc = sprintf($desc, htmlspecialchars($sender), _("Unknown Meeting"));
         } else {
             $desc = sprintf($desc, htmlspecialchars($sender), htmlspecialchars($summary));
@@ -705,7 +706,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
         }
 
         $start = $vevent->getAttribute('DTSTART');
-        if (!is_a($start, 'PEAR_Error')) {
+        if (!($start instanceof PEAR_Error)) {
             if (is_array($start)) {
                 $html .= '<p><strong>' . _("Start:") . '</strong> ' . strftime($prefs->getValue('date_format'), mktime(0, 0, 0, $start['month'], $start['mday'], $start['year'])) . '</p>';
             } else {
@@ -714,7 +715,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
         }
 
         $end = $vevent->getAttribute('DTEND');
-        if (!is_a($end, 'PEAR_Error')) {
+        if (!($end instanceof PEAR_Error)) {
             if (is_array($end)) {
                 $html .= '<p><strong>' . _("End:") . '</strong> ' . strftime($prefs->getValue('date_format'), mktime(0, 0, 0, $end['month'], $end['mday'], $end['year'])) . '</p>';
             } else {
@@ -723,23 +724,23 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
         }
 
         $sum = $vevent->getAttribute('SUMMARY');
-        if (!is_a($sum, 'PEAR_Error')) {
+        if (!($sum instanceof PEAR_Error)) {
             $html .= '<p><strong>' . _("Summary") . ':</strong> ' . htmlspecialchars($sum) . '</p>';
         } else {
             $html .= '<p><strong>' . _("Summary") . ':</strong> <em>' . _("None") . '</em></p>';
         }
 
         $desc = $vevent->getAttribute('DESCRIPTION');
-        if (!is_a($desc, 'PEAR_Error')) {
+        if (!($desc instanceof PEAR_Error)) {
             $html .= '<p><strong>' . _("Description") . ':</strong> ' . nl2br(htmlspecialchars($desc)) . '</p>';
         }
 
         $loc = $vevent->getAttribute('LOCATION');
-        if (!is_a($loc, 'PEAR_Error')) {
+        if (!($loc instanceof PEAR_Error)) {
             $html .= '<p><strong>' . _("Location") . ':</strong> ' . htmlspecialchars($loc) . '</p>';
         }
 
-        if (!is_a($attendees, 'PEAR_Error') && !empty($attendees)) {
+        if (!($attendees instanceof PEAR_Error) && !empty($attendees)) {
             $html .= '<h2 class="smallheader">' . _("Attendees") . '</h2>';
 
             $html .= '<table><thead class="leftAlign"><tr><th>' . _("Name") . '</th><th>' . _("Role") . '</th><th>' . _("Status") . '</th></tr></thead><tbody>';
@@ -861,7 +862,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
         $options = array();
 
         $organizer = $vtodo->getAttribute('ORGANIZER', true);
-        if (is_a($organizer, 'PEAR_Error')) {
+        if ($organizer instanceof PEAR_Error) {
             $sender = _("An unknown person");
         } else {
             if (isset($organizer[0]['CN'])) {
@@ -882,7 +883,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
         }
 
         $summary = $vtodo->getAttribute('SUMMARY');
-        if (is_a($summary, 'PEAR_Error')) {
+        if ($summary instanceof PEAR_Error) {
             $desc = sprintf($desc, htmlspecialchars($sender), _("Unknown Task"));
         } else {
             $desc = sprintf($desc, htmlspecialchars($sender), htmlspecialchars($summary));
@@ -895,26 +896,26 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
         }
 
         $priority = $vtodo->getAttribute('PRIORITY');
-        if (!is_a($priority, 'PEAR_Error')) {
+        if (!($priority instanceof PEAR_Error)) {
             $html .= '<p><strong>' . _("Priority") . ':</strong> ' . (int)$priority . '</p>';
         }
 
         $sum = $vtodo->getAttribute('SUMMARY');
-        if (!is_a($sum, 'PEAR_Error')) {
+        if (!($sum instanceof PEAR_Error)) {
             $html .= '<p><strong>' . _("Summary") . ':</strong> ' . htmlspecialchars($sum) . '</p>';
         } else {
             $html .= '<p><strong>' . _("Summary") . ':</strong> <em>' . _("None") . '</em></p>';
         }
 
         $desc = $vtodo->getAttribute('DESCRIPTION');
-        if (!is_a($desc, 'PEAR_Error')) {
+        if (!($desc instanceof PEAR_Error)) {
             $html .= '<p><strong>' . _("Description") . ':</strong> ' . nl2br(htmlspecialchars($desc)) . '</p>';
         }
 
         $attendees = $vtodo->getAttribute('ATTENDEE');
         $params = $vtodo->getAttribute('ATTENDEE', true);
 
-        if (!is_a($attendees, 'PEAR_Error') && !empty($attendees)) {
+        if (!($attendees instanceof PEAR_Error) && !empty($attendees)) {
             $html .= '<h2 class="smallheader">' . _("Attendees") . '</h2>';
             if (!is_array($attendees)) {
                 $attendees = array($attendees);
index b0a2080..8ec5a7c 100644 (file)
@@ -116,13 +116,13 @@ class IMP_Horde_Mime_Viewer_Pdf extends Horde_Mime_Viewer_Pdf
 
         $img = Horde_Image::factory('Im', array('context' => array('tmpdir' => Horde::getTempdir(),
                                                                    'convert' => $GLOBALS['conf']['image']['convert'])));
-        if (is_a($img, 'PEAR_Error')) {
+        if ($img instanceof PEAR_Error) {
             return false;
         }
 
         if ($load) {
             $ret = $img->loadString(1, $this->_mimepart->getContents());
-            if (is_a($ret, 'PEAR_Error')) {
+            if ($ret instanceof PEAR_Error) {
                 return false;
             }
         }
index 8115f1f..069af6b 100644 (file)
@@ -47,12 +47,12 @@ function _getImportKey()
     }
 
     $res = $GLOBALS['browser']->wasFileUploaded('upload_key', _("key"));
-    if (!is_a($res, 'PEAR_Error')) {
-        return file_get_contents($_FILES['upload_key']['tmp_name']);
-    } else {
+    if ($res instanceof PEAR_Error) {
         $GLOBALS['notification']->push($res, 'horde.error');
         return;
     }
+
+    return file_get_contents($_FILES['upload_key']['tmp_name']);
 }
 
 function _textWindowOutput($filename, $msg)
index db011bf..1726895 100644 (file)
@@ -36,12 +36,12 @@ function _getImportKey()
     }
 
     $res = $GLOBALS['browser']->wasFileUploaded('upload_key', _("key"));
-    if (!is_a($res, 'PEAR_Error')) {
-        return file_get_contents($_FILES['upload_key']['tmp_name']);
-    } else {
+    if ($res instanceof PEAR_Error) {
         $GLOBALS['notification']->push($res, 'horde.error');
         return;
     }
+
+    return file_get_contents($_FILES['upload_key']['tmp_name']);
 }
 
 function _actionWindow()
@@ -270,7 +270,7 @@ if ($openssl_check && $prefs->getValue('use_smime')) {
     }
     $t->set('personalkey-help', Horde_Help::link('imp', 'smime-overview-personalkey'));
 
-    $t->set('secure_check', is_a($secure_check, 'PEAR_Error'));
+    $t->set('secure_check', $secure_check instanceof PEAR_Error);
     if (!$t->get('secure_check')) {
         $t->set('has_key', $prefs->getValue('smime_public_key') && $prefs->getValue('smime_private_key'));
         if ($t->get('has_key')) {