Track Horde_Registry changes
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 10 Jul 2009 21:52:25 +0000 (15:52 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 13 Jul 2009 19:47:01 +0000 (13:47 -0600)
62 files changed:
babel/lib/base.php
chora/lib/base.php
crumb/lib/Forms/AddClient.php
crumb/lib/base.php
fima/lib/base.php
folks/edit/comments.php
folks/edit/edit.php
folks/edit/facebook.php
folks/lib/Auth/folks.php
folks/lib/Block/my_comments.php
folks/lib/Driver.php
folks/lib/Notification/letter.php
folks/lib/Notification/mail.php
folks/lib/Notification/tickets.php
folks/lib/base.php
folks/templates/services/services.php
framework/Model/lib/Horde/Form/VarRenderer/Xhtml.php
imp/compose.php
imp/lib/Compose.php
imp/lib/Crypt/Pgp.php
imp/lib/Crypt/Smime.php
imp/lib/Filter.php
imp/lib/IMP.php
imp/lib/Message.php
imp/lib/Mime/Viewer/Html.php
imp/lib/Mime/Viewer/Itip.php
imp/lib/Session.php
imp/lib/base.php
imp/lib/prefs.php
imp/login.php
imp/redirect.php
imp/saveimage.php
imp/templates/prefs/sourceselect.inc
ingo/lib/Ingo.php
ingo/lib/base.php
ingo/spam.php
jeta/lib/base.php
kastalia/download.php
kastalia/lib/base.php
koward/lib/Koward/Cli.php
koward/lib/Koward/Controller/Application.php
koward/lib/Koward/Controller/IndexController.php
kronolith/lib/Driver/Horde.php
kronolith/lib/FreeBusy.php
kronolith/lib/Imple/ContactAutoCompleter.php
kronolith/lib/Kronolith.php
kronolith/lib/base.php
kronolith/scripts/import_icals.php
kronolith/templates/prefs/sourceselect.inc
news/add.php
news/delete.php
news/lib/Block/my_comments.php
news/lib/News.php
news/lib/base.php
news/note.php
news/templates/news/comments.php
news/templates/news/selling.php
skoli/lib/Forms/CreateClass.php
skoli/lib/School.php
skoli/lib/Skoli.php
skoli/lib/base.php
timeobjects/lib/base.php

index 008024f..db363b6 100644 (file)
@@ -29,11 +29,13 @@ $notification->attach('status');
 /* Registry. */
 $registry = Horde_Registry::singleton();
 
-if (is_a(($pushed = $registry->pushApp('babel', !defined('AUTH_HANDLER'))), 'PEAR_Error')) {
-    if ($pushed->getCode() == 'permission_denied') {
+try {
+    $registry->pushApp('babel', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+    if ($e->getCode() == 'permission_denied') {
         Horde::authenticationFailureRedirect();
     }
-    Horde::fatal($pushed, __FILE__, __LINE__, false);
+    Horde::fatal($e, __FILE__, __LINE__, false);
 }
 
 $conf = &$GLOBALS['conf'];
index cd02a84..40c0a08 100644 (file)
@@ -31,11 +31,13 @@ require_once HORDE_BASE . '/lib/core.php';
 
 // Registry
 $registry = Horde_Registry::singleton();
-if (is_a(($pushed = $registry->pushApp('chora', !defined('AUTH_HANDLER'))), 'PEAR_Error')) {
-    if ($pushed->getCode() == 'permission_denied') {
+try {
+    $registry->pushApp('chora', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+    if ($e->getCode() == 'permission_denied') {
         Horde::authenticationFailureRedirect();
     }
-    Horde::fatal($pushed, __FILE__, __LINE__, false);
+    Horde::fatal($e, __FILE__, __LINE__, false);
 }
 $conf = &$GLOBALS['conf'];
 define('CHORA_TEMPLATES', $registry->get('templates'));
index 85426a7..2cad2a2 100644 (file)
@@ -22,15 +22,16 @@ class Horde_Form_AddClient extends Horde_Form
                            'assign' => _("Assign Existing"));
 
         $action = &Horde_Form_Action::factory('reload');
-       
+
         $select = &$this->addVariable(_("Contact Information"), 'chooseContact', 'enum', true, false, null, array($addOrPick, true));
         $select->setAction($action);
         $select->setOption('trackchange', true);
 
         if ($vars->get('chooseContact') == 'create') {
-            $turbaform = $GLOBALS['registry']->call('contacts/getAddClientForm', array(&$vars));
-            if (is_a($turbaform, 'PEAR_Error')) {
-                Horde::logMessage($addform, __FILE__, __LINE__, PEAR_LOG_ERR);
+            try {
+                $turbaform = $GLOBALS['registry']->call('contacts/getAddClientForm', array(&$vars));
+            } catch (Horde_Exception $e) {
+                Horde::logMessage($e, __FILE__, __LINE__, PEAR_LOG_ERR);
                 $notification->push(_("An internal error has occurred.  Details have beenlogged for the administrator."));
                 $addform = null;
             }
@@ -53,9 +54,10 @@ class Horde_Form_AddClient extends Horde_Form
         $select->setOption('trackchange', true);
 
         if ($vars->get('chooseQueue') == 'create') {
-            $whupsform = $GLOBALS['registry']->call('tickets/getAddQueueForm', array(&$vars));
-            if (is_a($whupsform, 'PEAR_Error')) {
-                Horde::logMessage($addform, __FILE__, __LINE__, PEAR_LOG_ERR);
+            try {
+                $whupsform = $GLOBALS['registry']->call('tickets/getAddQueueForm', array(&$vars));
+            } catch (Horde_Exception $e) {
+                Horde::logMessage($e, __FILE__, __LINE__, PEAR_LOG_ERR);
                 $notification->push(_("An internal error has occurred.  Details have been logged for the administrator."));
                 $addform = null;
             }
index c562d9e..6a7a23f 100644 (file)
@@ -10,7 +10,7 @@
  * need, and sets up objects that all scripts use.
  *
  * @author Ben Klang <ben@alkaloid.net>
- * 
+ *
  */
 
 // Check for a prior definition of HORDE_BASE (perhaps by an auto_prepend_file
@@ -24,11 +24,13 @@ require_once HORDE_BASE . '/lib/core.php';
 
 // Registry.
 $registry = Horde_Registry::singleton();
-if (is_a(($pushed = $registry->pushApp('crumb', !defined('AUTH_HANDLER'))), 'PEAR_Error')) {
-    if ($pushed->getCode() == 'permission_denied') {
+try {
+    $registry->pushApp('crumb', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+    if ($e->getCode() == 'permission_denied') {
         Horde::authenticationFailureRedirect();
     }
-    Horde::fatal($pushed, __FILE__, __LINE__, false);
+    Horde::fatal($e, __FILE__, __LINE__, false);
 }
 $conf = &$GLOBALS['conf'];
 @define('CRUMB_TEMPLATES', $registry->get('templates'));
index fc77e3b..ea8b8e5 100644 (file)
@@ -27,11 +27,13 @@ if ($session_control == 'none') {
     $registry = Horde_Registry::singleton();
 }
 
-if (is_a(($pushed = $registry->pushApp('fima', !defined('AUTH_HANDLER'))), 'PEAR_Error')) {
-    if ($pushed->getCode() == 'permission_denied') {
+try {
+    $registry->pushApp('fima', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+    if ($e->getCode() == 'permission_denied') {
         Horde::authenticationFailureRedirect();
     }
-    Horde::fatal($pushed, __FILE__, __LINE__, false);
+    Horde::fatal($e, __FILE__, __LINE__, false);
 }
 $conf = &$GLOBALS['conf'];
 @define('FIMA_TEMPLATES', $registry->get('templates'));
index b9b2fb3..51b75e2 100644 (file)
@@ -46,18 +46,17 @@ if (!$form->isSubmitted()) {
 
     if (Horde_Util::getFormData('submitbutton') == _("Delete all current comments")) {
 
-        $result = $registry->call('forums/deleteForum', array('folks', Horde_Auth::getAuth()));
-        if ($result instanceof PEAR_Error) {
-            $notification->push($result);
-        } else {
+        try {
+            $registry->call('forums/deleteForum', array('folks', Horde_Auth::getAuth()));
             $result = $folks_driver->updateComments(Horde_Auth::getAuth(), true);
             if ($result instanceof PEAR_Error) {
                 $notification->push($result);
             } else {
                 $notification->push(_("Comments deleted successfuly"), 'horde.success');
             }
+        } catch (Horde_Exception $e) {
+            $notification->push($e);
         }
-
     } else {
 
         // Update forum status
@@ -67,9 +66,10 @@ if (!$form->isSubmitted()) {
             $info = array('author' => Horde_Auth::getAuth(),
                             'forum_name' => Horde_Auth::getAuth(),
                             'forum_moderated' => ($profile['user_comments'] == 'moderate'));
-            $result = $registry->call('forums/saveFrom', array('folks', '', $info));
-            if ($result instanceof PEAR_Error) {
-                $notification->push($result);
+            try {
+                $registry->call('forums/saveFrom', array('folks', '', $info));
+            } catch (Horde_Exception $e) {
+                $notification->push($e);
             }
         }
 
@@ -92,11 +92,10 @@ $form->renderActive(null, null, null, 'post');
 
 if ($profile['user_comments'] == 'moderate') {
     echo '<br />';
-    $result = $registry->call('forums/moderateForm', array('folks'));
-    if ($result instanceof PEAR_Error) {
-        echo $result->getMessage();
-    } else {
-        echo $result;
+    try {
+        echo $registry->call('forums/moderateForm', array('folks'));
+    } catch (Horde_Exception $e) {
+        echo $e->getMessage();
     }
 }
 
index eb1c70b..60badf6 100644 (file)
@@ -34,16 +34,16 @@ $v->setDefault('SI');
 $form->addVariable(_("Homepage"), 'user_url', 'text', false);
 
 if ($registry->hasMethod('video/listVideos')) {
-    $result = $registry->call('video/listVideos', array(array('author' => Horde_Auth::getAuth()), 0, 100));
-    if ($result instanceof PEAR_Error) {
-        $notification->push($result);
-    } else {
+    try {
+        $result = $registry->call('video/listVideos', array(array('author' => Horde_Auth::getAuth()), 0, 100));
         $videos = array();
         foreach ($result as $video_id => $video) {
             $videos[$video_id] = $video['video_title'] . ' - ' . Folks::format_date($video['video_created']);
         }
         $video_link = '<a href="' .  $registry->link('video/edit') . '">' . _("Upload a new video") . '</a>';
         $form->addVariable(_("Video"), 'user_video', 'enum', false, false, $video_link, array($videos, _("--- Select ---")));
+    } catch (Horde_Exception $e) {
+        $notification->push($e);
     }
 }
 
index 8c07177..9220ce5 100644 (file)
@@ -25,9 +25,10 @@ if (!$conf['facebook']['enabled']) {
 }
 
 // Load horde central block
-$block = $registry->call('horde/blockContent', array('horde', 'fb_summary'));
-if ($block instanceof PEAR_Error) {
-    $notification->push($block);
+try {
+    $block = $registry->call('horde/blockContent', array('horde', 'fb_summary'));
+} catch (Horde_Exception $e) {
+    $notification->push($e);
     header('Location: ' . Horde::applicationUrl('user.php'));
     exit;
 }
@@ -39,4 +40,4 @@ echo $tabs->render('facebook');
 
 echo $block;
 
-require $registry->get('templates', 'horde') . '/common-footer.inc';
\ No newline at end of file
+require $registry->get('templates', 'horde') . '/common-footer.inc';
index 334b8d8..9a8449d 100644 (file)
@@ -63,6 +63,7 @@ class Folks_Auth_Folks extends Horde_Auth_Application
      * @param string $userId User ID for which to check
      *
      * @return boolean  Whether or not $userId already exists.
+     * @throws Horde_Exception
      */
     public function exists($userId)
     {
index 2016c84..e5c210d 100644 (file)
@@ -56,11 +56,12 @@ class Horde_Block_folks_my_comments extends Horde_Block {
               . '<thead><tr><th>' . _("Title") . '</th>'
               . '<th>' . _("User") . '</th></tr></thead>';
 
-        $threads = $GLOBALS['registry']->call('forums/getThreadsByForumOwner',
-                                    array(Horde_Auth::getAuth(), 'message_timestamp', 1, false,
-                                            'folks', 0, $this->_params['limit']));
-        if ($threads instanceof PEAR_Error) {
-            return $threads->getMessage();
+        try {
+            $threads = $GLOBALS['registry']->call('forums/getThreadsByForumOwner',
+                                                  array(Horde_Auth::getAuth(), 'message_timestamp', 1, false,
+                                                  'folks', 0, $this->_params['limit']));
+        } catch (Horde_Exception $e) {
+            return $e->getMessage();
         }
 
         $url = Folks::getUrlFor('user', Horde_Auth::getAuth());
@@ -76,4 +77,4 @@ class Horde_Block_folks_my_comments extends Horde_Block {
         $GLOBALS['cache']->set($cache_key, $html);
         return $html;
     }
-}
\ No newline at end of file
+}
index 7fd0f6f..2e2f45e 100644 (file)
@@ -498,10 +498,7 @@ class Folks_Driver {
 
         // Delete comments
         if ($registry->hasMethod('forums/deleteForum')) {
-            $comments = $registry->call('forums/deleteForum', array('folks', $user));
-            if ($comments instanceof PEAR_Error) {
-                return $comments;
-            }
+            $registry->call('forums/deleteForum', array('folks', $user));
         }
 
         // Delete user
index 9569127..dda4a3a 100644 (file)
@@ -74,10 +74,6 @@ class Folks_Notification_letter extends Folks_Notification {
     public function notifyFriends($user, $subject, $body, $attachments = array())
     {
         $friends = $GLOBALS['registry']->call('users/getFriends');
-        if ($friends instanceof PEAR_Error) {
-            return $friends;
-        }
-
         return $this->notify($friends, $subject, $body, $attachments);
     }
 }
index 3881447..fbfa572 100644 (file)
@@ -100,10 +100,6 @@ class Folks_Notification_mail extends Folks_Notification {
     public function notifyFriends($user, $subject, $body, $attachments = array())
     {
         $friends = $GLOBALS['registry']->call('users/getFriends');
-        if ($friends instanceof PEAR_Error) {
-            return $friends;
-        }
-
         return $this->notify($friends, $subject, $body, $attachments);
     }
 }
index bc6fe94..caa302a 100644 (file)
@@ -59,9 +59,6 @@ class Folks_Notification_tickets extends Folks_Notification {
                                     'user_email' => $this->_getUserFromAddr()));
 
         $ticket_id = $registry->call('tickets/addTicket', array($info));
-        if ($ticket_id instanceof PEAR_Error) {
-            return $ticket_id;
-        }
 
         if (empty($attachments) ||
             !$registry->hasMethod('tickets/addAttachment')) {
@@ -74,9 +71,6 @@ class Folks_Notification_tickets extends Folks_Notification {
                         array('ticket_id' => $ticket_id,
                                 'name' => $attachment['name'],
                                 'data' => file_get_contents($attachment['file'])));
-            if ($result instanceof PEAR_Error) {
-                return $result;
-            }
         }
 
         return true;
index 847ba38..b3d65d8 100644 (file)
@@ -19,11 +19,13 @@ require_once HORDE_BASE . '/lib/core.php';
 
 // Registry.
 $registry = Horde_Registry::singleton();
-if (($pushed = $registry->pushApp('folks', !defined('AUTH_HANDLER'))) instanceof PEAR_Error) {
-    if ($pushed->getCode() == 'permission_denied') {
+try {
+    $registry->pushApp('folks', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+    if ($e->getCode() == 'permission_denied') {
         Horde::authenticationFailureRedirect();
     }
-    Horde::fatal($pushed, __FILE__, __LINE__, false);
+    Horde::fatal($e, __FILE__, __LINE__, false);
 }
 $conf = &$GLOBALS['conf'];
 define('FOLKS_TEMPLATES', $registry->get('templates'));
index e896273..fc6f406 100644 (file)
@@ -3,13 +3,12 @@
 echo '<h1 class="header">' . $title . '</h1>';
 
 foreach ($apps as $app => $name) {
-    $page = $registry->getInitialPage($app);
-    if ($page instanceof PEAR_Error) {
-        continue;
-    }
-    echo '<div class="appService">' .
-            '<a href="' . $page . '">' . 
-            '<img src="' . $registry->getImageDir($app) . '/'.  $app . '.png" /> ' .
-                $name .
-                '</a></div>';
-}
\ No newline at end of file
+    try {
+        $page = $registry->getInitialPage($app);
+        echo '<div class="appService">' .
+                '<a href="' . $page . '">' .
+                '<img src="' . $registry->getImageDir($app) . '/'.  $app . '.png" /> ' .
+                    $name .
+                    '</a></div>';
+    } catch (Horde_Exception $e) {}
+}
index e0f2453..68ec1e3 100644 (file)
@@ -954,8 +954,9 @@ EOT;
             // Get rid of the trailing @ (when no host is included in
             // the email address).
             $address = str_replace('@>', '>', $address);
-            $mail_link = $GLOBALS['registry']->call('mail/compose', array(array('to' => addslashes($address))));
-            if (is_a($mail_link, 'PEAR_Error')) {
+            try {
+                $mail_link = $GLOBALS['registry']->call('mail/compose', array(array('to' => addslashes($address))));
+            } catch (Horde_Exception $e) {
                 $mail_link = 'mailto:' . urlencode($address);
             }
 
index 8a27951..1fe00d2 100644 (file)
@@ -545,23 +545,25 @@ case 'selectlist_process':
     if (!empty($select_id) &&
         $registry->hasMethod('files/selectlistResults') &&
         $registry->hasMethod('files/returnFromSelectlist')) {
-        $filelist = $registry->call('files/selectlistResults', array($select_id));
-        if ($filelist && !is_a($filelist, 'PEAR_Error')) {
-            $i = 0;
-            foreach ($filelist as $val) {
-                $data = $registry->call('files/returnFromSelectlist', array($select_id, $i++));
-                if ($data && !is_a($data, 'PEAR_Error')) {
-                    $part = new Horde_Mime_Part();
-                    $part->setName(reset($val));
-                    $part->setContents($data);
-                    try {
-                        $imp_compose->addMIMEPartAttachment($part);
-                    } catch (IMP_Compose_Exception $e) {
-                        $notification->push($e, 'horde.error');
+        try {
+            $filelist = $registry->call('files/selectlistResults', array($select_id));
+            if ($filelist) {
+                $i = 0;
+                foreach ($filelist as $val) {
+                    $data = $registry->call('files/returnFromSelectlist', array($select_id, $i++));
+                    if ($data) {
+                        $part = new Horde_Mime_Part();
+                        $part->setName(reset($val));
+                        $part->setContents($data);
+                        try {
+                            $imp_compose->addMIMEPartAttachment($part);
+                        } catch (IMP_Compose_Exception $e) {
+                            $notification->push($e, 'horde.error');
+                        }
                     }
                 }
             }
-        }
+        } catch (Horde_Exception $e) {}
     }
     break;
 
@@ -1151,9 +1153,10 @@ if ($redirect) {
     }
     if ($_SESSION['imp']['file_upload']) {
         $localeinfo = Horde_Nls::getLocaleInfo();
-        if ($GLOBALS['registry']->hasMethod('files/selectlistLink')) {
-            $res = $GLOBALS['registry']->call('files/selectlistLink', array(_("Attach Files"), 'widget', 'compose', true));
-            $t->set('selectlistlink', (is_a($res, 'PEAR_Error')) ? null : $res);
+        try {
+            $t->set('selectlistlink', $GLOBALS['registry']->call('files/selectlistLink', array(_("Attach Files"), 'widget', 'compose', true)));
+        } catch (Horde_Exception $e) {
+            $t->set('selectlistlink', null);
         }
         $t->set('maxattachsize', !$imp_compose->maxAttachmentSize());
         if (!$t->get('maxattachsize')) {
index 7e01181..6423fcf 100644 (file)
@@ -753,7 +753,14 @@ class IMP_Compose
         foreach ($r_array as $recipient) {
             $emails[] = $recipient['mailbox'] . '@' . $recipient['host'];
         }
-        $results = $registry->call('contacts/search', array($emails, array($abook), array($abook => array('email'))));
+
+        try {
+            $results = $registry->call('contacts/search', array($emails, array($abook), array($abook => array('email'))));
+        } catch (Horde_Exception $e) {
+            Horde::logMessage($e);
+            $notification->push(_("Could not save recipients."));
+            return;
+        }
 
         foreach ($r_array as $recipient) {
             /* Skip email addresses that already exist in the add_source. */
@@ -776,13 +783,13 @@ class IMP_Compose
             }
             $name = Horde_Mime::decode($name);
 
-            $result = $registry->call('contacts/import', array(array('name' => $name, 'email' => $recipient['mailbox'] . '@' . $recipient['host']), 'array', $abook));
-            if (is_a($result, 'PEAR_Error')) {
-                if ($result->getCode() == 'horde.error') {
-                    $notification->push($result, $result->getCode());
-                }
-            } else {
+            try {
+                $registry->call('contacts/import', array(array('name' => $name, 'email' => $recipient['mailbox'] . '@' . $recipient['host']), 'array', $abook));
                 $notification->push(sprintf(_("Entry \"%s\" was successfully added to the address book"), $name), 'horde.success');
+            } catch (Horde_Exception $e) {
+                if ($e->getCode() == 'horde.error') {
+                    $notification->push($e, $e->getCode());
+                }
             }
         }
     }
@@ -2283,9 +2290,10 @@ class IMP_Compose
             return;
         }
 
-        $vcard = $GLOBALS['registry']->call('contacts/ownVCard');
-        if (is_a($vcard, 'PEAR_Error')) {
-            throw new IMP_Compose_Exception($vcard);
+        try {
+            $vcard = $GLOBALS['registry']->call('contacts/ownVCard');
+        } catch (Horde_Exception $e) {
+            throw new IMP_Compose_Exception($e);
         }
 
         $part = new Horde_Mime_Part();
@@ -2482,11 +2490,14 @@ class IMP_Compose
     static public function getAddressList($search = '')
     {
         $sparams = IMP_Compose::getAddressSearchParams();
-        $res = $GLOBALS['registry']->call('contacts/search', array($search, $sparams['sources'], $sparams['fields'], true));
-        if (is_a($res, 'PEAR_Error')) {
-            Horde::logMessage($res, __FILE__, __LINE__, PEAR_LOG_ERR);
+        try {
+            $res = $GLOBALS['registry']->call('contacts/search', array($search, $sparams['sources'], $sparams['fields'], true));
+        } catch (Horde_Exception $e) {
+            Horde::logMessage($e, __FILE__, __LINE__, PEAR_LOG_ERR);
             return array();
-        } elseif (!count($res)) {
+        }
+
+        if (!count($res)) {
             return array();
         }
 
index b079d82..1c77857 100644 (file)
@@ -134,10 +134,7 @@ class IMP_Crypt_Pgp extends Horde_Crypt_Pgp
             } catch (Horde_Exception $e) {}
 
             /* Add key to the user's address book. */
-            $result = $GLOBALS['registry']->call('contacts/addField', array($sig['email'], $sig['name'], self::PUBKEY_FIELD, $public_key, $GLOBALS['prefs']->getValue('add_source')));
-            if (is_a($result, 'PEAR_Error')) {
-                throw new Horde_Exception($result);
-            }
+            $GLOBALS['registry']->call('contacts/addField', array($sig['email'], $sig['name'], self::PUBKEY_FIELD, $public_key, $GLOBALS['prefs']->getValue('add_source')));
         }
 
         return $key_info;
@@ -184,37 +181,35 @@ class IMP_Crypt_Pgp extends Horde_Crypt_Pgp
 
         /* Try retrieving by e-mail only first. */
         $params = IMP_Compose::getAddressSearchParams();
-        $result = $GLOBALS['registry']->call('contacts/getField', array($address, self::PUBKEY_FIELD, $params['sources'], false, true));
-
-        /* TODO: Retrieve by ID. */
+        try {
+            $result = $GLOBALS['registry']->call('contacts/getField', array($address, self::PUBKEY_FIELD, $params['sources'], false, true));
+        } catch (Horde_Exception $e) {
+            /* TODO: Retrieve by ID. */
 
-        /* See if the address points to the user's public key. */
-        if (is_a($result, 'PEAR_Error')) {
+            /* See if the address points to the user's public key. */
             require_once 'Horde/Identity.php';
             $identity = Identity::singleton(array('imp', 'imp'));
             $personal_pubkey = $this->getPersonalPublicKey();
             if (!empty($personal_pubkey) && $identity->hasAddress($address)) {
                 $result = $personal_pubkey;
-            }
-        }
-
-        /* Try retrieving via a PGP public keyserver. */
-        if (empty($options['noserver']) && is_a($result, 'PEAR_Error')) {
-            try {
-                $result = $this->getFromPublicKeyserver($keyid, $address);
-
-                /* If there is a cache driver configured and a cache object
-                 * exists, store the retrieved public key in the cache. */
-                if (is_object($cache)) {
-                    $cache->set("PGPpublicKey_" . $address . $keyid, $result, 3600);
+            } elseif (empty($options['noserver'])) {
+                try {
+                    $result = $this->getFromPublicKeyserver($keyid, $address);
+
+                    /* If there is a cache driver configured and a cache
+                     * object exists, store the retrieved public key in the
+                     * cache. */
+                    if (is_object($cache)) {
+                        $cache->set("PGPpublicKey_" . $address . $keyid, $result, 3600);
+                    }
+                } catch (Horde_Exception $e) {
+                    /* Return now, if no public key found at all. */
+                    Horde::logMessage('PGPpublicKey: ' . $e->getMessage(), __FILE__, __LINE__, PEAR_LOG_DEBUG);
+                    throw new Horde_Exception(sprintf(_("Could not retrieve public key for %s."), $address));
                 }
-            } catch (Horde_Exception $e) {}
-        }
-
-        /* Return now, if no public key found at all. */
-        if (is_a($result, 'PEAR_Error')) {
-            Horde::logMessage('PGPpublicKey: ' . $result->getMessage(), __FILE__, __LINE__, PEAR_LOG_DEBUG);
-            throw new Horde_Exception(sprintf(_("Could not retrieve public key for %s."), $address));
+            } else {
+                $result = '';
+            }
         }
 
         /* If more than one public key is returned, just return the first in
@@ -240,12 +235,7 @@ class IMP_Crypt_Pgp extends Horde_Crypt_Pgp
             return array();
         }
 
-        $res = $GLOBALS['registry']->call('contacts/getAllAttributeValues', array(self::PUBKEY_FIELD, $params['sources']));
-        if (is_a($res, 'PEAR_Error')) {
-            throw new Horde_Exception($res);
-        }
-
-        return $res;
+        return $GLOBALS['registry']->call('contacts/getAllAttributeValues', array(self::PUBKEY_FIELD, $params['sources']));
     }
 
     /**
@@ -258,12 +248,7 @@ class IMP_Crypt_Pgp extends Horde_Crypt_Pgp
     public function deletePublicKey($email)
     {
         $params = IMP_Compose::getAddressSearchParams();
-        $res = $GLOBALS['registry']->call('contacts/deleteField', array($email, self::PUBKEY_FIELD, $params['sources']));
-        if (is_a($res, 'PEAR_Error')) {
-            throw new Horde_Exception($res);
-        }
-
-        return $res;
+        return $GLOBALS['registry']->call('contacts/deleteField', array($email, self::PUBKEY_FIELD, $params['sources']));
     }
 
     /**
index 07a8f5b..0b3392e 100644 (file)
@@ -125,10 +125,7 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime
             throw new Horde_Exception(_("Not a valid public key."));
         }
 
-        $result = $GLOBALS['registry']->call('contacts/addField', array($email, $name, self::PUBKEY_FIELD, $cert, $GLOBALS['prefs']->getValue('add_source')));
-        if (is_a($result, 'PEAR_Error')) {
-            throw new Horde_Exception($result);
-        }
+        $GLOBALS['registry']->call('contacts/addField', array($email, $name, self::PUBKEY_FIELD, $cert, $GLOBALS['prefs']->getValue('add_source')));
     }
 
     /**
@@ -166,17 +163,19 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime
     public function getPublicKey($address)
     {
         $params = IMP_Compose::getAddressSearchParams();
-        $key = $GLOBALS['registry']->call('contacts/getField', array($address, self::PUBKEY_FIELD, $params['sources'], false, true));
 
-        /* See if the address points to the user's public key. */
-        if (is_a($key, 'PEAR_Error')) {
+        try {
+            $key = $GLOBALS['registry']->call('contacts/getField', array($address, self::PUBKEY_FIELD, $params['sources'], false, true));
+        } catch (Horde_Exception $e) {
+            /* See if the address points to the user's public key. */
             require_once 'Horde/Identity.php';
             $identity = Identity::singleton(array('imp', 'imp'));
             $personal_pubkey = $this->getPersonalPublicKey();
             if (!empty($personal_pubkey) && $identity->hasAddress($address)) {
                 return $personal_pubkey;
             }
-            throw new Horde_Exception($key);
+
+            throw $e;
         }
 
         /* If more than one public key is returned, just return the first in
@@ -197,12 +196,7 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime
         if (empty($params['sources'])) {
             return array();
         }
-        $result = $GLOBALS['registry']->call('contacts/getAllAttributeValues', array(self::PUBKEY_FIELD, $params['sources']));
-        if (is_a($result, 'PEAR_Error')) {
-            throw new Horde_Exception($result);
-        }
-
-        return $result;
+        return $GLOBALS['registry']->call('contacts/getAllAttributeValues', array(self::PUBKEY_FIELD, $params['sources']));
     }
 
     /**
@@ -215,10 +209,7 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime
     public function deletePublicKey($email)
     {
         $params = IMP_Compose::getAddressSearchParams();
-        $result = $GLOBALS['registry']->call('contacts/deleteField', array($email, self::PUBKEY_FIELD, $params['sources']));
-        if (is_a($result, 'PEAR_Error')) {
-            throw new Horde_Exception($result);
-        }
+        $GLOBALS['registry']->call('contacts/deleteField', array($email, self::PUBKEY_FIELD, $params['sources']));
     }
 
     /**
index 1bcabb0..bb94a35 100644 (file)
@@ -27,6 +27,7 @@ class IMP_Filter
      * Runs the filters if they are able to be applied manually.
      *
      * @param string $mbox  The mailbox to apply the filters to.
+     * @throws Horde_Exception
      */
     public function filter($mbox)
     {
@@ -52,6 +53,7 @@ class IMP_Filter
      *                            notification message?
      *
      * @return boolean  True if the messages(s) were deleted.
+     * @throws Horde_Exception
      */
     public function blacklistMessage($indices, $show_link = true)
     {
@@ -79,6 +81,7 @@ class IMP_Filter
      *                            notification message?
      *
      * @return boolean  True if the messages(s) were whitelisted.
+     * @throws Horde_Exception
      */
     public function whitelistMessage($indices, $show_link = true)
     {
@@ -98,6 +101,7 @@ class IMP_Filter
      *                         notification message?
      *
      * @return boolean  True on success.
+     * @throws Horde_Exception
      */
     protected function _processBWlist($indices, $descrip, $reg1, $reg2, $link)
     {
index d63d545..d02e64c 100644 (file)
@@ -127,12 +127,7 @@ class IMP
             $newName = $newAddress;
         }
 
-        $result = $registry->call('contacts/import',
-                                  array(array('name' => $newName, 'email' => $newAddress),
-                                        'array', $prefs->getValue('add_source')));
-        if ($result instanceof PEAR_Error) {
-            throw new Horde_Exception($result);
-        }
+        $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')));
 
@@ -230,37 +225,38 @@ class IMP
         /* Add the list of editable tasklists to the list. */
         if (!empty($options['inc_tasklists']) &&
             !empty($_SESSION['imp']['tasklistavail'])) {
-            $tasklists = $GLOBALS['registry']->call('tasks/listTasklists',
-                                                    array(false, PERMS_EDIT));
+            try {
+                $tasklists = $GLOBALS['registry']->call('tasks/listTasklists', array(false, PERMS_EDIT));
 
-            if (!$tasklists instanceof PEAR_Error && count($tasklists)) {
-                $text .= '<option value="" disabled="disabled">&nbsp;</option><option value="" disabled="disabled">- - ' . _("Task Lists") . ' - -</option>' . "\n";
+                if (count($tasklists)) {
+                    $text .= '<option value="" disabled="disabled">&nbsp;</option><option value="" disabled="disabled">- - ' . _("Task Lists") . ' - -</option>' . "\n";
 
-                foreach ($tasklists as $id => $tasklist) {
-                    $text .= sprintf('<option value="%s">%s</option>%s',
-                                     '_tasklist_' . $id,
-                                     Horde_Text_Filter::filter($tasklist->get('name'), 'space2html', array('charset' => Horde_Nls::getCharset(), 'encode' => true)),
-                                     "\n");
+                    foreach ($tasklists as $id => $tasklist) {
+                        $text .= sprintf('<option value="%s">%s</option>%s',
+                                         '_tasklist_' . $id,
+                                         Horde_Text_Filter::filter($tasklist->get('name'), 'space2html', array('charset' => Horde_Nls::getCharset(), 'encode' => true)),
+                                         "\n");
+                    }
                 }
-            }
+            } catch (Horde_Exception $e) {}
         }
 
         /* Add the list of editable notepads to the list. */
         if (!empty($options['inc_notepads']) &&
             !empty($_SESSION['imp']['notepadavail'])) {
-            $notepads = $GLOBALS['registry']->call('notes/listNotepads',
-                                                    array(false, PERMS_EDIT));
-
-            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) {
-                    $text .= sprintf('<option value="%s">%s</option>%s',
-                                     '_notepad_' . $id,
-                                     Horde_Text_Filter::filter($notepad->get('name'), 'space2html', array('charset' => Horde_Nls::getCharset(), 'encode' => true)),
-                                     "\n");
+            try {
+                $notepads = $GLOBALS['registry']->call('notes/listNotepads', array(false, PERMS_EDIT));
+                if (count($notepads)) {
+                    $text .= '<option value="" disabled="disabled">&nbsp;</option><option value="" disabled="disabled">- - ' . _("Notepads") . ' - -</option>' . "\n";
+
+                    foreach ($notepads as $id => $notepad) {
+                        $text .= sprintf('<option value="%s">%s</option>%s',
+                                         '_notepad_' . $id,
+                                         Horde_Text_Filter::filter($notepad->get('name'), 'space2html', array('charset' => Horde_Nls::getCharset(), 'encode' => true)),
+                                         "\n");
+                    }
                 }
-            }
+            } catch (Horde_Exception $e) {}
         }
 
         return $text;
index f9ae2f8..b68125d 100644 (file)
@@ -319,7 +319,7 @@ class IMP_Message
      *                        created.
      * @param string $action  Either 'copy' or 'move'.
      * @param mixed $indices  See IMP::parseIndicesList().
-     * @param string $type    The object type to create, defaults to task.
+     * @param string $type    The object type to create ('note' or 'task').
      *
      * @return boolean  True if successful, false if not.
      */
@@ -378,13 +378,21 @@ class IMP_Message
                     $vTodo->setAttribute('PRIORITY', '3');
 
                     /* Get the list of editable tasklists. */
-                    $lists = $registry->call('tasks/listTasklists',
-                                             array(false, PERMS_EDIT));
+                    try {
+                        $lists = $registry->call('tasks/listTasklists', array(false, PERMS_EDIT));
+                    } catch (Horde_Exception $e) {
+                        $lists = null;
+                        $notification->push($e, $e->getCode());
+                    }
 
                     /* Attempt to add the new vTodo item to the requested
                      * tasklist. */
-                    $res = $registry->call('tasks/import',
-                                           array($vTodo, 'text/calendar', $list));
+                    try {
+                        $res = $registry->call('tasks/import', array($vTodo, 'text/calendar', $list));
+                    } catch (Horde_Exception $e) {
+                        $res = null;
+                        $notification->push($e, $e->getCode());
+                    }
                     break;
 
                 case 'note':
@@ -394,53 +402,60 @@ class IMP_Message
                     $vNote->setAttribute('BODY', $subject . "\n". $body);
 
                     /* Get the list of editable notepads. */
-                    $lists = $registry->call('notes/listNotepads',
-                                             array(false, PERMS_EDIT));
+                    try {
+                        $lists = $registry->call('notes/listNotepads', array(false, PERMS_EDIT));
+                    } catch (Horde_Exception $e) {
+                        $lists = null;
+                        $notification->push($e, $e->getCode());
+                    }
 
                     /* Attempt to add the new vNote item to the requested
                      * notepad. */
-                    $res = $registry->call('notes/import',
-                                           array($vNote, 'text/x-vnote', $list));
+                    try {
+                        $res = $registry->call('notes/import', array($vNote, 'text/x-vnote', $list));
+                    } catch (Horde_Exception $e) {
+                        $res = null;
+                        $notification->push($e, $e->getCode());
+                    }
                     break;
                 }
 
-                if (is_a($res, 'PEAR_Error')) {
-                    $notification->push($res, $res->getCode());
-                } elseif (!$res) {
-                    switch ($type) {
-                    case 'task':
-                        $notification->push(_("An unknown error occured while creating the new task."), 'horde.error');
-                        break;
-
-                    case 'note':
-                        $notification->push(_("An unknown error occured while creating the new note."), 'horde.error');
-                        break;
-                    }
-                } else {
-                    $name = '"' . htmlspecialchars($subject) . '"';
-
-                    /* Attempt to convert the object name into a hyperlink. */
-                    switch ($type) {
-                    case 'task':
-                        $link = $registry->link('tasks/show',
-                                                array('uid' => $res));
-                        break;
-                    case 'note':
-                        if ($registry->hasMethod('notes/show')) {
-                            $link = $registry->link('notes/show',
-                                                    array('uid' => $res));
-                        } else {
-                            $link = false;
+                if (!is_null($res)) {
+                    if (!$res) {
+                        switch ($type) {
+                        case 'task':
+                            $notification->push(_("An unknown error occured while creating the new task."), 'horde.error');
+                            break;
+
+                        case 'note':
+                            $notification->push(_("An unknown error occured while creating the new note."), 'horde.error');
+                            break;
                         }
-                        break;
-                    }
-                    if ($link && !is_a($link, 'PEAR_Error')) {
-                        $name = sprintf('<a href="%s">%s</a>',
-                                        Horde::url($link),
-                                        $name);
+                    } elseif (!is_null($lists)) {
+                        $name = '"' . htmlspecialchars($subject) . '"';
+
+                        /* Attempt to convert the object name into a
+                         * hyperlink. */
+                        try {
+                            switch ($type) {
+                            case 'task':
+                                $link = $registry->link('tasks/show', array('uid' => $res));
+                                break;
+
+                            case 'note':
+                                $link = $registry->hasMethod('notes/show')
+                                    ? $registry->link('notes/show', array('uid' => $res))
+                                    : false;
+                                break;
+                            }
+
+                            if ($link) {
+                                $name = sprintf('<a href="%s">%s</a>', Horde::url($link), $name);
+                            }
+
+                            $notification->push(sprintf(_("%s was successfully added to \"%s\"."), $name, htmlspecialchars($lists[$list]->get('name'))), 'horde.success', array('content.raw'));
+                        } catch (Horde_Exception $e) {}
                     }
-
-                    $notification->push(sprintf(_("%s was successfully added to \"%s\"."), $name, htmlspecialchars($lists[$list]->get('name'))), 'horde.success', array('content.raw'));
                 }
             }
         }
index 37abc5c..38d1e9e 100644 (file)
@@ -268,7 +268,11 @@ class IMP_Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Html
         $headers = $this->_params['contents']->getHeaderOb();
 
         /* Try to get back a result from the search. */
-        $res = $GLOBALS['registry']->call('contacts/getField', array(Horde_Mime_Address::bareAddress($headers->getValue('from')), '__key', $params['sources'], false, true));
-        return is_a($res, 'PEAR_Error') ? false : count($res);
+        try {
+            $res = $GLOBALS['registry']->call('contacts/getField', array(Horde_Mime_Address::bareAddress($headers->getValue('from')), '__key', $params['sources'], false, true));
+            return count($res);
+        } catch (Horde_Exception $e) {
+            return false;
+        }
     }
 }
index 701e532..1c95b6d 100644 (file)
@@ -100,11 +100,11 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
                 // vEvent cancellation.
                 if ($registry->hasMethod('calendar/delete')) {
                     $guid = $components[$key]->getAttribute('UID');
-                    $event = $registry->call('calendar/delete', array('guid' => $guid));
-                    if (is_a($event, 'PEAR_Error')) {
-                        $msgs[] = array('error', _("There was an error deleting the event:") . ' ' . $event->getMessage());
-                    } else {
+                    try {
+                        $registry->call('calendar/delete', array('guid' => $guid));
                         $msgs[] = array('success', _("Event successfully deleted."));
+                    } catch (Horde_Exception $e) {
+                        $msgs[] = array('error', _("There was an error deleting the event:") . ' ' . $e->getMessage());
                     }
                 } else {
                     $msgs[] = array('warning', _("This action is not supported."));
@@ -114,11 +114,11 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
             case 'update':
                 // vEvent reply.
                 if ($registry->hasMethod('calendar/updateAttendee')) {
-                    $event = $registry->call('calendar/updateAttendee', array('response' => $components[$key], 'sender' => $params[0]->getFromAddress()));
-                    if (is_a($event, 'PEAR_Error')) {
-                        $msgs[] = array('error', _("There was an error updating the event:") . ' ' . $event->getMessage());
-                    } else {
+                    try {
+                        $event = $registry->call('calendar/updateAttendee', array('response' => $components[$key], 'sender' => $params[0]->getFromAddress()));
                         $msgs[] = array('success', _("Respondent Status Updated."));
+                    } catch (Horde_Exception $e) {
+                        $msgs[] = array('error', _("There was an error updating the event:") . ' ' . $e->getMessage());
                     }
                 } else {
                     $msgs[] = array('warning', _("This action is not supported."));
@@ -138,32 +138,34 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
                     $handled = false;
                     $guid = $components[$key]->getAttribute('UID');
                     // Check if this is an update.
-                    if ($registry->hasMethod('calendar/export') &&
-                        !is_a($registry->call('calendar/export', array($guid, 'text/calendar')), 'PEAR_Error')) {
+                    try {
+                        $registry->call('calendar/export', array($guid, 'text/calendar');
+
                         // Try to update in calendar.
                         if ($registry->hasMethod('calendar/replace')) {
-                            $result = $registry->call('calendar/replace', array('uid' => $guid, 'content' => $components[$key], 'contentType' => $this->mime_part->getType()));
-                            if (is_a($result, 'PEAR_Error')) {
-                                // Could be a missing permission.
-                                $msgs[] = array('warning', _("There was an error updating the event:") . ' ' . $result->getMessage() . '. ' . _("Trying to import the event instead."));
-                            } else {
+                            try {
+                                $registry->call('calendar/replace', array('uid' => $guid, 'content' => $components[$key], 'contentType' => $this->mime_part->getType()));
                                 $handled = true;
                                 $url = Horde::url($registry->link('calendar/show', array('uid' => $guid)));
                                 $msgs[] = array('success', _("The event was updated in your calendar.") .
                                                              '&nbsp;' . Horde::link($url, _("View event"), null, '_blank') . Horde::img('mime/icalendar.png', _("View event"), null, $registry->getImageDir('horde')) . '</a>');
+                            } catch (Horde_Exception $e) {}
+                                // Could be a missing permission.
+                                $msgs[] = array('warning', _("There was an error updating the event:") . ' ' . $e->getMessage() . '. ' . _("Trying to import the event instead."));
                             }
                         }
-                    }
+                    } catch (Horde_Exception $e) {}
+
                     if (!$handled && $registry->hasMethod('calendar/import')) {
                         // Import into calendar.
                         $handled = true;
-                        $guid = $registry->call('calendar/import', array('content' => $components[$key], 'contentType' => $this->mime_part->getType()));
-                        if (is_a($guid, 'PEAR_Error')) {
-                            $msgs[] = array('error', _("There was an error importing the event:") . ' ' . $guid->getMessage());
-                        } else {
+                        try {
+                            $guid = $registry->call('calendar/import', array('content' => $components[$key], 'contentType' => $this->mime_part->getType()));
                             $url = Horde::url($registry->link('calendar/show', array('uid' => $guid)));
                             $msgs[] = array('success', _("The event was added to your calendar.") .
                                             '&nbsp;' . Horde::link($url, _("View event"), null, '_blank') . Horde::img('mime/icalendar.png', _("View event"), null, $registry->getImageDir('horde')) . '</a>');
+                        } catch (Horde_Exception $e) {
+                            $msgs[] = array('error', _("There was an error importing the event:") . ' ' . $e->getMessage());
                         }
                     }
                     if (!$handled) {
@@ -174,11 +176,11 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
                 case 'vFreebusy':
                     // Import into Kronolith.
                     if ($registry->hasMethod('calendar/import_vfreebusy')) {
-                        $res = $registry->call('calendar/import_vfreebusy', array($components[$key]));
-                        if (is_a($res, 'PEAR_Error')) {
-                            $msgs[] = array('error', _("There was an error importing user's free/busy information:") . ' ' . $res->getMessage());
-                        } else {
+                        try {
+                            $registry->call('calendar/import_vfreebusy', array($components[$key]));
                             $msgs[] = array('success', _("The user's free/busy information was sucessfully stored."));
+                        } catch (Horde_Exception $e) {
+                            $msgs[] = array('error', _("There was an error importing user's free/busy information:") . ' ' . $e->getMessage());
                         }
                     } else {
                         $msgs[] = array('warning', _("This action is not supported."));
@@ -188,13 +190,13 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
                 case 'vTodo':
                     // Import into Nag.
                     if ($registry->hasMethod('tasks/import')) {
-                        $guid = $registry->call('tasks/import', array($components[$key], $this->mime_part->getType()));
-                        if (is_a($guid, 'PEAR_Error')) {
-                            $msgs[] = array('error', _("There was an error importing the task:") . ' ' . $guid->getMessage());
-                        } else {
+                        try {
+                            $guid = $registry->call('tasks/import', array($components[$key], $this->mime_part->getType()));
                             $url = Horde::url($registry->link('tasks/show', array('uid' => $guid)));
                             $msgs[] = array('success', _("The task has been added to your tasklist.") .
                                                          '&nbsp;' . Horde::link($url, _("View task"), null, '_blank') . Horde::img('mime/icalendar.png', _("View task"), null, $registry->getImageDir('horde')) . '</a>');
+                        } catch (Horde_Exception $e) {
+                            $msgs[] = array('error', _("There was an error importing the task:") . ' ' . $e->getMessage());
                         }
                     } else {
                         $msgs[] = array('warning', _("This action is not supported."));
@@ -621,11 +623,11 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
 
         case 'REQUEST':
             // Check if this is an update.
-            if ($registry->hasMethod('calendar/export') &&
-                !is_a($registry->call('calendar/export', array($vevent->getAttribute('UID'), 'text/calendar')), 'PEAR_Error')) {
+            try {
+                $registry->call('calendar/export', array($vevent->getAttribute('UID'), 'text/calendar'));
                 $is_update = true;
                 $desc = _("%s wants to notify you about changes of \"%s\".");
-            } else {
+            } catch (Horde_Exception $e) {
                 $is_update = false;
 
                 // Check that you are one of the attendees here.
@@ -788,50 +790,52 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver
         }
 
         if ($registry->hasMethod('calendar/getFbCalendars') &&
-            $registry->hasMethod('calendar/listEvents') &&
-            !is_a($calendars = $registry->call('calendar/getFbCalendars'), 'PEAR_Error')) {
-
-            $vevent_allDay = true;
-            $vevent_start = new Horde_Date($start);
-            $vevent_end = new Horde_Date($end);
-            // Check if it's an all-day event.
-            if (is_array($start)) {
-                $vevent_end = $vevent_end->sub(1);
-            } else {
-                $vevent_allDay = false;
-                $time_span_start = new Horde_Date($start);
-                $time_span_start = $time_span_start->sub($prefs->getValue('conflict_interval') * 60);
-                $time_span_end = new Horde_Date($end);
-                $time_span_end = $time_span_end->add($prefs->getValue('conflict_interval') * 60);
-            }
-            $events = $registry->call('calendar/listEvents', array($start, $vevent_end, $calendars, false));
-
-            if (!is_a($events, 'PEAR_Error') && count($events)) {
-                $html .= '<h2 class="smallheader">' . _("Possible Conflicts") . '</h2><table id="itipconflicts">';
-                // TODO: Check if there are too many events to show.
-                foreach ($events as $calendar) {
-                    foreach ($calendar as $event) {
-                        if ($vevent_allDay || $event->isAllDay()) {
-                            $html .= '<tr class="itipcollision">';
-                        } else {
-                            if ($event->end->compareDateTime($time_span_start) <= -1 ||
-                                $event->start->compareDateTime($time_span_end) >= 1) {
-                               continue;
-                            }
-                            if ($event->end->compareDateTime($vevent_start) <= -1 ||
-                                $event->start->compareDateTime($vevent_end) >= 1) {
-                                $html .= '<tr class="itipnearcollision">';
-                            } else {
+            $registry->hasMethod('calendar/listEvents')) {
+            try {
+                $calendars = $registry->call('calendar/getFbCalendars');
+
+                $vevent_allDay = true;
+                $vevent_start = new Horde_Date($start);
+                $vevent_end = new Horde_Date($end);
+                // Check if it's an all-day event.
+                if (is_array($start)) {
+                    $vevent_end = $vevent_end->sub(1);
+                } else {
+                    $vevent_allDay = false;
+                    $time_span_start = new Horde_Date($start);
+                    $time_span_start = $time_span_start->sub($prefs->getValue('conflict_interval') * 60);
+                    $time_span_end = new Horde_Date($end);
+                    $time_span_end = $time_span_end->add($prefs->getValue('conflict_interval') * 60);
+                }
+                $events = $registry->call('calendar/listEvents', array($start, $vevent_end, $calendars, false));
+
+                if (count($events)) {
+                    $html .= '<h2 class="smallheader">' . _("Possible Conflicts") . '</h2><table id="itipconflicts">';
+                    // TODO: Check if there are too many events to show.
+                    foreach ($events as $calendar) {
+                        foreach ($calendar as $event) {
+                            if ($vevent_allDay || $event->isAllDay()) {
                                 $html .= '<tr class="itipcollision">';
+                            } else {
+                                if ($event->end->compareDateTime($time_span_start) <= -1 ||
+                                    $event->start->compareDateTime($time_span_end) >= 1) {
+                                   continue;
+                                }
+                                if ($event->end->compareDateTime($vevent_start) <= -1 ||
+                                    $event->start->compareDateTime($vevent_end) >= 1) {
+                                    $html .= '<tr class="itipnearcollision">';
+                                } else {
+                                    $html .= '<tr class="itipcollision">';
+                                }
                             }
-                        }
 
-                        $html .= '<td>'. $event->getTitle() . '</td><td>'
-                            . $event->getTimeRange() . '</td></tr>';
+                            $html .= '<td>'. $event->getTitle() . '</td><td>'
+                                . $event->getTimeRange() . '</td></tr>';
+                        }
                     }
+                    $html .= '</table>';
                 }
-                $html .= '</table>';
-            }
+            } catch (Horde_Exception $e) {}
         }
 
         if ($_SESSION['imp']['view'] != 'imp') {
index f6a3ec9..24fad3b 100644 (file)
@@ -155,10 +155,11 @@ class IMP_Session
         $sess['file_upload'] = $GLOBALS['browser']->allowFileUploads();
 
         /* Is the 'mail/canApplyFilters' API call available? */
-        if ($registry->hasMethod('mail/canApplyFilters') &&
-            $registry->call('mail/canApplyFilters')) {
-            $sess['filteravail'] = true;
-        }
+        try {
+            if ($registry->call('mail/canApplyFilters')) {
+                $sess['filteravail'] = true;
+            }
+        } catch (Horde_Exception $e) {}
 
         /* Is the 'tasks/listTasklists' call available? */
         if ($conf['tasklist']['use_tasklist'] &&
index cbc3b5f..5941794 100644 (file)
@@ -60,11 +60,13 @@ $registry = Horde_Registry::singleton($s_ctrl);
 // and login pages, since those are handled below and need to fall through
 // to IMP-specific code.
 $compose_page = Horde_Util::nonInputVar('compose_page');
-if (is_a(($pushed = $registry->pushApp('imp', !(defined('AUTH_HANDLER') || $compose_page))), 'PEAR_Error')) {
-    if ($pushed->getCode() == 'permission_denied') {
+try {
+    $registry->pushApp('imp', !(defined('AUTH_HANDLER') || $compose_page));
+} catch (Horde_Exception $e) {
+    if ($e->getCode() == 'permission_denied') {
         Horde::authenticationFailureRedirect();
     }
-    Horde::fatal($pushed, __FILE__, __LINE__, false);
+    Horde::fatal($e, __FILE__, __LINE__, false);
 }
 $conf = &$GLOBALS['conf'];
 if (!defined('IMP_TEMPLATES')) {
index 928e908..dd4c927 100644 (file)
@@ -242,7 +242,13 @@ function prefs_callback()
 }
 
 /* Make sure we have an active IMAP stream. */
-if (!$GLOBALS['registry']->call('mail/server')) {
+try {
+    $res = $GLOBALS['registry']->call('mail/server');
+} catch (Horde_Exception $e) {
+    $res = false;
+}
+
+if (!$res) {
     header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('redirect.php'), 'url', Horde::selfUrl(true)));
     exit;
 }
index a9629d7..18d0b51 100644 (file)
@@ -55,7 +55,7 @@ if (!empty($_SESSION['imp']) && is_array($_SESSION['imp'])) {
         if ($imp_auth) {
             Horde_Auth::clearAuth();
             @session_destroy();
-            Horde::setupSessionHandler();
+            $registry->setupSessionHandler();
             @session_start();
         }
 
index a741d1e..546aa6c 100644 (file)
@@ -136,7 +136,7 @@ if (!is_null($imapuser) && !is_null($pass)) {
     if (Horde_Auth::getProvider() == 'imp') {
         /* Destroy any existing session on login and make sure to use a new
          * session ID, to avoid session fixation issues. */
-        Horde::getCleanSession();
+        $registry->getCleanSession();
     }
 
     if (IMP_Session::createSession($imapuser, $pass, Horde_Util::getFormData('server_key', IMP_Session::getAutoLoginServer()))) {
index 41ca2a7..d0f8251 100644 (file)
@@ -26,9 +26,10 @@ case 'save_image':
         'data' => $mime_part->getContents(),
         'type' => $mime_part->getType()
     );
-    $res = $registry->call('images/saveImage', array(null, Horde_Util::getFormData('gallery'), $image_data));
-    if (is_a($res, 'PEAR_Error')) {
-        $notification->push($res, 'horde.error');
+    try {
+        $registry->call('images/saveImage', array(null, Horde_Util::getFormData('gallery'), $image_data));
+    } catch (Horde_Exception $e) {
+        $notification->push($e, 'horde.error');
         break;
     }
     Horde_Util::closeWindowJS();
index d2bce5c..8133497 100644 (file)
@@ -1,8 +1,16 @@
 <?php
 if ($registry->hasMethod('contacts/sources')) {
     $search = IMP_Compose::getAddressSearchParams();
-    $readable = $registry->call('contacts/sources');
-    $writeable = $registry->call('contacts/sources', true);
+    try {
+        $readable = $registry->call('contacts/sources');
+    } catch (Horde_Exception $e) {
+        $readable = null;
+    }
+    try {
+        $writeable = $registry->call('contacts/sources', true);
+    } catch (Horde_Exception $e) {
+        $writeable = null;
+    }
 
     $nbReadSources = count(array_keys($readable));
     $nbWriteSources = count(array_keys($writeable));
@@ -21,13 +29,13 @@ if ($registry->hasMethod('contacts/sources')) {
     }
 
     $readSelect = '';
-    if (!is_a($readable, 'PEAR_Error') && is_array($readable)) {
+    if (is_array($readable)) {
         foreach (array_diff(array_keys($readable), $search['sources']) as $source) {
             $readSelect .= '<option value="' . $source . '">' . $readable[$source] . "</option>\n";
         }
     }
 
-    if (!is_a($writeable, 'PEAR_Error') && is_array($writeable)) {
+    if (is_array($writeable)) {
         $writeSelect = '<option value="">' . _("None") . '</option>' . "\n";
         $writeSource = '';
         foreach ($writeable as $source => $name) {
@@ -38,9 +46,11 @@ if ($registry->hasMethod('contacts/sources')) {
     }
 
     $search_fields = array();
-    if (!is_a($readable, 'PEAR_Error') && is_array($readable)) {
+    if (is_array($readable)) {
         foreach (array_keys($readable) as $source) {
-            $search_fields[$source] = $registry->call('contacts/fields', $source);
+            try {
+                $search_fields[$source] = $registry->call('contacts/fields', $source);
+            } catch (Horde_Exception $e) {}
         }
     }
 
index 00bc3b0..1bf533b 100644 (file)
@@ -41,10 +41,9 @@ class Ingo
     {
         global $conf, $registry;
 
-        if (!empty($conf['rules']['usefolderapi']) &&
-            $registry->hasMethod('mail/folderlist')) {
-            $mailboxes = $registry->call('mail/folderlist');
-            if (!is_a($mailboxes, 'PEAR_Error')) {
+        if (!empty($conf['rules']['usefolderapi'])) {
+            try {
+                $mailboxes = $registry->call('mail/folderlist');
                 $createfolder = $registry->hasMethod('mail/createFolder');
 
                 $text = '<select id="' . $tagname . '" name="' . $tagname . '"';
@@ -78,7 +77,7 @@ class Ingo
 
                 $text .= '</select>';
                 return $text;
-            }
+            } catch (Horde_Exception $e) {}
         }
 
         return '<input id="' . $tagname . '" name="' . $tagname . '" size="40" value="' . $value . '" />';
@@ -89,8 +88,8 @@ class Ingo
      *
      * @param string $folder  The name of the folder to create.
      *
-     * @return boolean  True on success, false if not created, PEAR_Error on
-     *                  failure.
+     * @return boolean  True on success, false if not created. PEAR_Error on
+     * @throws Horde_Exception
      */
     static public function createFolder($folder)
     {
index aa09dbb..3e45a74 100644 (file)
@@ -20,11 +20,13 @@ require_once HORDE_BASE . '/lib/core.php';
 
 // Registry.
 $registry = Horde_Registry::singleton();
-if (is_a(($pushed = $registry->pushApp('ingo', !defined('AUTH_HANDLER'))), 'PEAR_Error')) {
-    if ($pushed->getCode() == 'permission_denied') {
+try {
+    $registry->pushApp('ingo', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+    if ($e->getCode() == 'permission_denied') {
         Horde::authenticationFailureRedirect();
     }
-    Horde::fatal($pushed, __FILE__, __LINE__, false);
+    Horde::fatal($e, __FILE__, __LINE__, false);
 }
 $conf = &$GLOBALS['conf'];
 
index 7d34555..28a040c 100644 (file)
@@ -79,14 +79,16 @@ if ($form->validate($vars)) {
 
     // Create a new folder if requested.
     if ($vars->get('actionID') == 'create_folder') {
-        $result = Ingo::createFolder($vars->get('new_folder_name'));
-        if (is_string($result)) {
-            $spam->setSpamFolder($result);
-        } else {
-            $success = false;
-            if (is_a($result, 'PEAR_Error')) {
-                $notification->push($result->getMessage());
+        try {
+            $result = Ingo::createFolder($vars->get('new_folder_name'));
+            if ($result) {
+                $spam->setSpamFolder($result);
+            } else {
+                $success = false;
             }
+        } catch (Horde_Exception $e) {
+            $success = false;
+            $notification->push($e->getMessage());
         }
     } else {
         $spam->setSpamFolder($vars->get('folder'));
index c3f6d17..8eee5c9 100644 (file)
@@ -27,11 +27,13 @@ require_once HORDE_BASE . '/lib/core.php';
 
 // Registry.
 $registry = Horde_Registry::singleton();
-if (is_a(($pushed = $registry->pushApp('jeta', !defined('AUTH_HANDLER'))), 'PEAR_Error')) {
-    if ($pushed->getCode() == 'permission_denied') {
+try {
+    $registry->pushApp('jeta', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+    if ($e->getCode() == 'permission_denied') {
         Horde::authenticationFailureRedirect();
     }
-    Horde::fatal($pushed, __FILE__, __LINE__, false);
+    Horde::fatal($e, __FILE__, __LINE__, false);
 }
 
 $conf = &$GLOBALS['conf'];
index e7a9cb7..577c37b 100755 (executable)
@@ -31,11 +31,13 @@ require_once HORDE_BASE . '/lib/core.php';
 
 // Registry.
 $registry = Horde_Registry::singleton();
-if (is_a(($pushed = $registry->pushApp('kastalia', !defined('AUTH_HANDLER'))), 'PEAR_Error')) {
-    if ($pushed->getCode() == 'permission_denied') {
+try {
+    $registry->pushApp('kastalia', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+    if ($e->getCode() == 'permission_denied') {
         Horde::authenticationFailureRedirect();
     }
-    Horde::fatal($pushed, __FILE__, __LINE__, false);
+    Horde::fatal($e, __FILE__, __LINE__, false);
 }
 //################### </MANUELLER ANMELDE CHECK (WENN base.php NICHT INCLUDIERT WIRD)> ###################
 
index 46345ec..7827951 100755 (executable)
@@ -21,11 +21,13 @@ require_once HORDE_BASE . '/lib/core.php';
 
 // Registry.
 $registry = Horde_Registry::singleton();
-if (is_a(($pushed = $registry->pushApp('kastalia', !defined('AUTH_HANDLER'))), 'PEAR_Error')) {
-    if ($pushed->getCode() == 'permission_denied') {
+try {
+    $registry->pushApp('kastalia', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+    if ($e->getCode() == 'permission_denied') {
         Horde::authenticationFailureRedirect();
     }
-    Horde::fatal($pushed, __FILE__, __LINE__, false);
+    Horde::fatal($e, __FILE__, __LINE__, false);
 }
 $conf = &$GLOBALS['conf'];
 @define('KASTALIA_TEMPLATES', $registry->get('templates'));
index 3239698..33e8b52 100644 (file)
@@ -68,8 +68,10 @@ class Koward_Cli extends Horde_Controller_Request_Base
          */
         $this->_path = $registry->get('webroot', 'koward') . '/' . $args[0];
 
-        if (is_a(($pushed = $registry->pushApp('koward', false)), 'PEAR_Error')) {
-            if ($pushed->getCode() == 'permission_denied') {
+        try {
+            $registry->pushApp('koward', false);
+        } catch (Horde_Exception $e) {
+            if ($e->getCode() == 'permission_denied') {
                 echo 'Perission denied!';
                 exit;
             }
@@ -87,10 +89,12 @@ class Koward_Cli extends Horde_Controller_Request_Base
             }
         }
 
-        if (is_a(($pushed = $registry->pushApp('koward',
-                                               empty($this->auth_handler)
-                                               || $this->auth_handler != $this->params[':action'])), 'PEAR_Error')) {
-            if ($pushed->getCode() == 'permission_denied') {
+        try {
+            $registry->pushApp('koward',
+                               empty($this->auth_handler)
+                               || $this->auth_handler != $this->params[':action']);
+        } catch (Horde_Exception $e) {
+            if ($e->getCode() == 'permission_denied') {
                 header('Location: ' . $this->urlFor(array('controller' => 'index', 'action' => 'login')));
                 exit;
             }
index 4fb4e3e..d7b06e2 100644 (file)
@@ -8,10 +8,12 @@ class Koward_Controller_Application extends Horde_Controller_Base
     {
         global $registry;
 
-        if (is_a(($pushed = $registry->pushApp('koward',
-                                               empty($this->auth_handler)
-                                               || $this->auth_handler != $this->params[':action'])), 'PEAR_Error')) {
-            if ($pushed->getCode() == 'permission_denied') {
+        try {
+            $registry->pushApp('koward',
+                               empty($this->auth_handler)
+                               || $this->auth_handler != $this->params[':action']);
+        } catch (Horde_Exception $e) {
+            if ($e->getCode() == 'permission_denied') {
                 header('Location: ' . $this->urlFor(array('controller' => 'index', 'action' => 'login')));
                 exit;
             }
index f48058b..1b64887 100644 (file)
@@ -31,7 +31,7 @@ class IndexController extends Koward_Controller_Application
         if (isset($_POST['horde_user']) && isset($_POST['horde_pass'])) {
             /* Destroy any existing session on login and make sure to use a
              * new session ID, to avoid session fixation issues. */
-            Horde::getCleanSession();
+            $GLOBALS['registry']->getCleanSession();
             if ($this->koward->auth->authenticate(Horde_Util::getPost('horde_user'),
                                                   array('password' => Horde_Util::getPost('horde_pass')))) {
                 $entry = sprintf('Login success for %s [%s] to Horde',
index b0d3a00..9770b02 100644 (file)
@@ -48,6 +48,7 @@ class Kronolith_Driver_Horde extends Kronolith_Driver
      *                                   toJson() method?
      *
      * @return array  Events in the given time range.
+     * @throws Horde_Exception
      */
     public function listEvents($startDate = null, $endDate = null,
                                $showRecurrence = false, $hasAlarm = false,
@@ -59,9 +60,6 @@ class Kronolith_Driver_Horde extends Kronolith_Driver
         }
 
         $eventsList = $this->_params['registry']->call($this->api . '/listTimeObjects', array(array($category), $startDate, $endDate));
-        if (is_a($eventsList, 'PEAR_Error')) {
-            return $eventsList;
-        }
 
         if (is_null($startDate)) {
             $startDate = new Horde_Date(array('mday' => 1,
index c694afa..eab9259 100644 (file)
@@ -225,6 +225,7 @@ class Kronolith_FreeBusy {
      * @param string $email  The email address to look for.
      *
      * @return mixed  The url on success or false on failure.
+     * @throws Horde_Exception
      */
     function getUrl($email)
     {
@@ -233,13 +234,11 @@ class Kronolith_FreeBusy {
 
         $result = $GLOBALS['registry']->call('contacts/getField',
                                              array($email, 'freebusyUrl', $sources, true, true));
-        if (is_a($result, 'PEAR_Error')) {
-            return $result;
-        } elseif (is_array($result)) {
+        if (is_array($result)) {
             return array_shift($result);
-        } else {
-            return $result;
         }
+
+        return $result;
     }
 
 }
index 4eff67b..598a0b6 100644 (file)
@@ -120,9 +120,14 @@ class Kronolith_Imple_ContactAutoCompleter extends Kronolith_Imple
             }
         }
 
-        $res = $GLOBALS['registry']->call('contacts/search', array($search, $src, $fields, true));
-        if (is_a($res, 'PEAR_Error') || !count($res)) {
-            Horde::logMessage($res, __FILE__, __LINE__, PEAR_LOG_ERR);
+        try {
+            $res = $GLOBALS['registry']->call('contacts/search', array($search, $src, $fields, true));
+        } catch (Horde_Exception $e) {
+            Horde::logMessage($e, __FILE__, __LINE__, PEAR_LOG_ERR);
+            return array();
+        }
+
+        if (!count($res)) {
             return array();
         }
 
index 710bbc8..2bdb3a7 100644 (file)
@@ -1077,8 +1077,13 @@ class Kronolith
             $apis = array_unique($GLOBALS['registry']->listAPIs());
             foreach ($apis as $api) {
                 if ($GLOBALS['registry']->hasMethod($api . '/listTimeObjects')) {
-                    $categories = $GLOBALS['registry']->call($api . '/listTimeObjectCategories');
-                    if (is_a($categories, 'PEAR_Error') || !count($categories)) {
+                    try {
+                        $categories = $GLOBALS['registry']->call($api . '/listTimeObjectCategories');
+                    } catch (Horde_Exception $e) {
+                        continue;
+                    }
+
+                    if (!count($categories)) {
                         continue;
                     }
 
index 64d0969..d4dd4fe 100644 (file)
@@ -28,11 +28,13 @@ if ($session_control == 'none') {
     $registry = Horde_Registry::singleton();
 }
 
-if (is_a(($pushed = $registry->pushApp('kronolith', !defined('AUTH_HANDLER'))), 'PEAR_Error')) {
-    if ($pushed->getCode() == 'permission_denied') {
+try {
+    $registry->pushApp('kronolith', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+    if ($e->getCode() == 'permission_denied') {
         Horde::authenticationFailureRedirect();
     }
-    Horde::fatal($pushed, __FILE__, __LINE__, false);
+    Horde::fatal($e, __FILE__, __LINE__, false);
 }
 $conf = &$GLOBALS['conf'];
 define('KRONOLITH_TEMPLATES', $registry->get('templates'));
index 90be8f9..8430961 100755 (executable)
@@ -53,10 +53,10 @@ $registry = Horde_Registry::singleton();
 Horde_Auth::setAuth($user, array());
 
 // Import data.
-$result = $registry->call('calendar/import',
-                          array($ical, 'text/calendar', $cal));
-if (is_a($result, 'PEAR_Error')) {
-    $cli->fatal($result->toString());
+try {
+    $result = $registry->call('calendar/import', array($ical, 'text/calendar', $cal));
+} catch (Horde_Exception $e) {
+    $cli->fatal($e->toString());
 }
 
 $cli->message('Imported successfully ' . count($result) . ' events', 'cli.success');
index 5e661f3..afd19f3 100644 (file)
@@ -1,8 +1,16 @@
 <?php
 if ($registry->hasMethod('contacts/sources')) {
     $selected = explode("\t", $prefs->getValue('search_sources'));
-    $readable = $registry->call('contacts/sources');
-    $writeable = $registry->call('contacts/sources', true);
+    try {
+        $readable = $registry->call('contacts/sources');
+    } catch (Horde_Exception $e) {
+        $readable = null;
+    }
+    try {
+        $writeable = $registry->call('contacts/sources', true);
+    } catch (Horde_Exception $e) {
+        $writeable = null;
+    }
 
     $nbReadSources = count(array_keys($readable));
     $nbWriteSources = count(array_keys($writeable));
@@ -25,13 +33,13 @@ if ($registry->hasMethod('contacts/sources')) {
     }
 
     $readSelect = '';
-    if (!is_a($readable, 'PEAR_Error') && is_array($readable)) {
+    if (is_array($readable)) {
         foreach (array_diff(array_keys($readable), $selected) as $source) {
             $readSelect .= '<option value="' . $source . '">' . $readable[$source] . "</option>\n";
         }
     }
 
-    if (!is_a($writeable, 'PEAR_Error') && is_array($writeable)) {
+    if (is_array($writeable)) {
         $writeSelect = '<option value="">' . _("None") . '</option>' . "\n";
         $writeSource = '';
         foreach ($writeable as $source => $name) {
@@ -58,9 +66,11 @@ if ($registry->hasMethod('contacts/sources')) {
     }
 
     $search_fields = array();
-    if (!is_a($readable, 'PEAR_Error') && is_array($readable)) {
+    if (is_array($readable)) {
         foreach (array_keys($readable) as $source) {
-            $search_fields[$source] = $registry->call('contacts/fields', $source);
+            try {
+                $search_fields[$source] = $registry->call('contacts/fields', $source);
+            } catch (Horde_Exception $e) {}
         }
     }
 
index 19827d6..b4d7597 100644 (file)
@@ -234,13 +234,15 @@ if (Horde_Auth::isAdmin('news:admin')) {
     foreach ($registry->listAPIs() as $api) {
         if ($registry->hasMethod($api . '/getSellingForm')) {
             $apis[$api] = array();
-            $articles = $registry->call($api  . '/listCostObjects');
-            if ($articles instanceof PEAR_Error) {
-                $notification->push($articles);
-            } elseif (!empty($articles)) {
-                foreach ($articles[0]['objects'] as $item) {
-                    $apis[$api][$item['id']] = $item['name'];
+            try {
+                $articles = $registry->call($api  . '/listCostObjects');
+                if (!empty($articles)) {
+                    foreach ($articles[0]['objects'] as $item) {
+                        $apis[$api][$item['id']] = $item['name'];
+                    }
                 }
+            } catch (Horde_Exception $e) {
+                $notification->push($e);
             }
         }
     }
@@ -432,28 +434,29 @@ if ($form->validate()) {
         // Do we have a gallery?
         if (empty($info['gallery'])) {
             $abbr = Horde_String::substr(strip_tags($info['body'][$default_lang]['content']), 0, $conf['preview']['list_content']);
-            $result = $registry->call('images/createGallery',
-                                        array(null,
-                                                array('name' => $info['body'][$default_lang]['title'],
-                                                        'desc' => $abbr)));
-            if ($result instanceof PEAR_Error) {
-                $notification->push(_("There was an error creating gallery: ") . $result->getMessage(), 'horde.warning');
-            } else {
+            try {
+                $result = $registry->call('images/createGallery',
+                                            array(null,
+                                                    array('name' => $info['body'][$default_lang]['title'],
+                                                            'desc' => $abbr)));
                 $info['gallery'] = $result;
+            } catch (Horde_Exception $e) {
+                $notification->push(_("There was an error creating gallery: ") . $e->getMessage(), 'horde.warning');
             }
         }
 
         if (!empty($info['gallery'])) {
             $news->write_db->query('UPDATE ' . $news->prefix . ' SET gallery = ? WHERE id = ?', array($info['gallery'], $id));
             foreach ($images_uploaded as $i) {
-                $result = $registry->call('images/saveImage',
+                try {
+                    $registry->call('images/saveImage',
                                             array(null, $info['gallery'],
                                                     array('filename' => $info['picture_' . $i]['file'],
                                                             'description' => $info['caption_' . ($i == 0 ? $i . '_' . $default_lang: $i)],
                                                             'type' => $info['picture_' . $i]['type'],
                                                             'data' => file_get_contents($info['picture_' . $i]['file']))));
-                if ($result instanceof PEAR_Error) {
-                    $notification->push(_("There was an error with the uploaded image: ") . $result->getMessage(), 'horde.warning');
+                } catch (Horde_Exception $e) {
+                    $notification->push(_("There was an error with the uploaded image: ") . $e->getMessage(), 'horde.warning');
                 }
             }
         }
index a30382e..6af3c52 100644 (file)
@@ -56,9 +56,10 @@ if ($form->validate()) {
             }
         }
         if ($image['gallery']) {
-            $result = $registry->call('images/removeGallery', array(null, $image['gallery']));
-            if ($result instanceof PEAR_Error) {
-                $notification->push($result);
+            try {
+                $registry->call('images/removeGallery', array(null, $image['gallery']));
+            } catch (Horde_Exception $e) {
+                $notification->push($e);
             }
         }
 
@@ -71,9 +72,10 @@ if ($form->validate()) {
 
         // Delete forum
         if ($registry->hasMethod('forums/deleteForum')) {
-            $comments = $registry->call('forums/deleteForum', array('news', $id));
-            if ($comments instanceof PEAR_Error) {
-                $notification->push($comments);
+            try {
+                $registry->call('forums/deleteForum', array('news', $id));
+            } catch (Horde_Exception $e) {
+                $notification->push($e);
             }
         }
 
index 33a5f1c..480b1a2 100644 (file)
@@ -56,11 +56,12 @@ class Horde_Block_news_my_comments extends Horde_Block {
               . '<thead><tr><th>' . _("Title") . '</th>'
               . '<th>' . _("User") . '</th></tr></thead>';
 
-        $threads = $GLOBALS['registry']->call('forums/getThreadsByForumOwner',
-                                    array(Horde_Auth::getAuth(), 'message_timestamp', 1, false,
-                                            'news', 0, $this->_params['limit']));
-        if ($threads instanceof PEAR_Error) {
-            return $threads->getMessage();
+        try {
+            $threads = $GLOBALS['registry']->call('forums/getThreadsByForumOwner',
+                                        array(Horde_Auth::getAuth(), 'message_timestamp', 1, false,
+                                                'news', 0, $this->_params['limit']));
+        } catch (Horde_Exception $e) {
+            return $e->getMessage();
         }
 
         foreach ($threads as $message) {
@@ -75,4 +76,4 @@ class Horde_Block_news_my_comments extends Horde_Block {
         $GLOBALS['cache']->set($cache_key, $html);
         return $html;
     }
-}
\ No newline at end of file
+}
index 108c517..ed7a66e 100644 (file)
@@ -478,13 +478,11 @@ class News {
 
         $params = array(0, 'message_timestamp', 1, false, 'news', null, 0, $limit);
         $threads = $registry->call('forums/getThreads', $params);
-        if ($threads instanceof PEAR_Error) {
-            return $threads;
-        }
 
         foreach ($threads as $id => $message) {
-            $news_id = $registry->call('forums/getForumName', array('news', $message['forum_id']));
-            if ($news_id instanceof PEAR_Error) {
+            try {
+                $news_id = $registry->call('forums/getForumName', array('news', $message['forum_id']));
+            } catch (Horde_Exception $e) {
                 unset($threads[$id]);
                 continue;
             }
index 4414d06..2c7c865 100644 (file)
@@ -24,11 +24,13 @@ require_once HORDE_BASE . '/lib/core.php';
 
 // Registry.
 $registry = Horde_Registry::singleton();
-if (($pushed = $registry->pushApp('news', !defined('AUTH_HANDLER'))) instanceof PEAR_Error) {
-    if ($pushed->getCode() == 'permission_denied') {
+try {
+    $registry->pushApp('news', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+    if ($e->getCode() == 'permission_denied') {
         Horde::authenticationFailureRedirect();
     }
-    Horde::fatal($pushed, __FILE__, __LINE__, false);
+    Horde::fatal($e, __FILE__, __LINE__, false);
 }
 $conf = &$GLOBALS['conf'];
 define('NEWS_TEMPLATES', $registry->get('templates'));
index 5a1e272..4859214 100644 (file)
@@ -34,14 +34,11 @@ $vNote = &Horde_iCalendar::newComponent('vnote', $vCal);
 $vNote->setAttribute('BODY', $body);
 
 /* Attempt to add the new vNote item to the requested notepad. */
-$res = $registry->call('notes/import', array($vNote, 'text/x-vnote'));
-
-if ($res instanceof PEAR_Error) {
-    $notification->push($res);
-    header('Location: ' . News::getUrlFor('news', $id));
-    exit;
-} else {
+try {
+    $registry->call('notes/import', array($vNote, 'text/x-vnote'));
     $notification->push(_("News sucessfuly added to you notes."), 'horde.success');
     header('Location: ' . $registry->getInitialPage('mnemo'));
-    exit;
+} catch (Horde_Exception $e) {
+    $notification->push($e);
+    header('Location: ' . News::getUrlFor('news', $id));
 }
index 482f939..a200954 100644 (file)
@@ -9,9 +9,6 @@ if ($conf['comments']['allow'] != 'never' &&
                     array('message_subject' => $row['title']), $conf['comments']['comment_template']);
 
     $comments = $registry->call('forums/doComments', $params);
-    if ($comments instanceof PEAR_Error) {
-        return $comments;
-    }
 
     if (!empty($comments['threads'])) {
         echo $comments['threads'];
index 576d725..806ab1e 100644 (file)
@@ -4,11 +4,10 @@
 // schedul
 if ($row['selling']) {
     $item = explode('|', $row['selling']);
-    $sell_from = $registry->call($item[0] . '/getSellingForm', $item[1]);
-    if ($sell_from instanceof PEAR_Error) {
-        echo $sell_from->getMessage();
-    } else {
-        echo $sell_from;
+    try {
+        echo $registry->call($item[0] . '/getSellingForm', $item[1]);
+    } catch (Horde_Exception $e) {
+        echo $e->getMessage();
     }
 }
 
index 9e4768e..5c9ad4b 100644 (file)
@@ -145,7 +145,7 @@ class Skoli_CreateClassForm extends Horde_Form {
                     $this->_vars->set('contact_list_create', true);
                 }
             }
-            $this->addVariable(_("Name"), 'contact_list', 'text', false, 
+            $this->addVariable(_("Name"), 'contact_list', 'text', false,
                 $conf['addresses']['contact_list'] == 'auto' || $prefs->getValue('contact_list') == 'auto' ? true : false, _("The substitutions %c, %g or %s will be replaced automatically by the class, grade respectively semester name."));
             if (!$this->_vars->exists('contact_list')) {
                 $contactlist = $conf['addresses']['contact_list'] == 'auto' ? $conf['addresses']['contact_list_name'] : $prefs->getValue('contact_list_name');
@@ -215,15 +215,17 @@ class Skoli_CreateClassForm extends Horde_Form {
             if ($createlist) {
                 $apiargs = array(
                     'content' => array(
-                        '__type' => 'Group', 
+                        '__type' => 'Group',
                         '__members' => serialize($this->_vars->get('students')),
-                        'name' => Skoli_School::parseContactListName($this->_vars->get('contact_list'), $this->_vars, true), 
+                        'name' => Skoli_School::parseContactListName($this->_vars->get('contact_list'), $this->_vars, true),
                     ),
                     'contentType' => 'array',
                     'source' => $this->_vars->get('address_book')
                 );
-                $result = $registry->call('contacts/import', $apiargs);
-                if ($result === false || is_a($result, 'PEAR_Error')) {
+
+                try {
+                    $registry->call('contacts/import', $apiargs);
+                } catch (Horde_Exception $e) {
                     $notification->push(sprintf(_("Couldn't create the contact list \"%s\"."), $this->_vars->get('contact_list')), 'horde.warning');
                 }
             }
index 513b1a5..18eccde 100644 (file)
@@ -38,7 +38,7 @@ class Skoli_School {
             return PEAR::raiseError(sprintf(_("Error loading the school \"%s\" from template."), $schoolName));
         } else {
             $this->school = self::$schools[$schoolName];
-        }       
+        }
     }
 
     /**
@@ -92,7 +92,7 @@ class Skoli_School {
                     unset($marksformat['custom']);
                 }
                 $form->addVariable(_(ucfirst($property)), $property, 'enum', true, true, null, array($marksformat, _("Choose:")));
-            } else {    
+            } else {
                 require_once 'Horde/Form/Action.php';
                 if ($form->_vars->exists($property) && !isset($marksformat[$form->_vars->get($property)])) {
                     $form->_vars->set($property . '_custom', $form->_vars->get($property));
index ccba45b..e972bff 100644 (file)
@@ -159,7 +159,7 @@ class Skoli {
      * This function will also sort the resulting list, if requested.
      *
      * @param array $classes            An array of classes to display, a
-     *                                  single classname or null/empty to 
+     *                                  single classname or null/empty to
      *                                  display classes $GLOBALS['display_classes'].
      * @param string $sortby_student    The field by which to sort
      *                                  (SKOLI_SORT_PRIORITY, SKOLI_SORT_NAME
@@ -270,11 +270,10 @@ class Skoli {
             'source' => $addressbook,
             'objectId' => $id
         );
-        $result = $registry->call('contacts/getContact', $apiargs);
-        if ($result === false || is_a($result, 'PEAR_Error')) {
+        try {
+            $student = $registry->call('contacts/getContact', $apiargs);
+        } catch (Horde_Exception $e) {
             $notification->push(sprintf(_("Couldn't create the contact list \"%s\"."), $this->_vars->get('contact_list')), 'horde.info');
-        } else {
-           $student = $result;
         }
         return $student;
     }
index 196676b..78654c2 100644 (file)
@@ -19,11 +19,13 @@ require_once HORDE_BASE . '/lib/core.php';
 
 // Registry.
 $registry = Horde_Registry::singleton();
-if (is_a(($pushed = $registry->pushApp('skoli', !defined('AUTH_HANDLER'))), 'PEAR_Error')) {
-    if ($pushed->getCode() == 'permission_denied') {
+try {
+    $registry->pushApp('skoli', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+    if ($e->getCode() == 'permission_denied') {
         Horde::authenticationFailureRedirect();
     }
-    Horde::fatal($pushed, __FILE__, __LINE__, false);
+    Horde::fatal($e, __FILE__, __LINE__, false);
 }
 $conf = &$GLOBALS['conf'];
 @define('SKOLI_TEMPLATES', $registry->get('templates'));
index cfc7361..7b194b4 100644 (file)
@@ -30,11 +30,13 @@ if ($session_control == 'none') {
     $registry = Horde_Registry::singleton();
 }
 
-if (is_a(($pushed = $registry->pushApp('timeobjects', !defined('AUTH_HANDLER'))), 'PEAR_Error')) {
-    if ($pushed->getCode() == 'permission_denied') {
+try {
+    $registry->pushApp('timeobjects', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+    if ($e->getCode() == 'permission_denied') {
         Horde::authenticationFailureRedirect();
     }
-    Horde::fatal($pushed, __FILE__, __LINE__, false);
+    Horde::fatal($e, __FILE__, __LINE__, false);
 }
 
 if (!defined('TIMEOBJECTS_BASE')) {