Horde::callHook() now throws a Horde_Exception
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 13 Jul 2009 17:02:44 +0000 (11:02 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 13 Jul 2009 19:49:22 +0000 (13:49 -0600)
31 files changed:
babel/config/hooks.php.dist
folks/config/hooks.php.dist
folks/lib/Driver.php
imp/compose-dimp.php
imp/compose-mimp.php
imp/compose.php
imp/lib/Compose.php
imp/lib/Folder.php
imp/lib/IMP.php
imp/lib/Identity/imp.php
imp/lib/Imap.php
imp/lib/Imap/Tree.php
imp/lib/MIMP.php
imp/lib/Session.php
imp/lib/Spam.php
imp/lib/Views/ListMessages.php
imp/lib/Views/ShowMessage.php
imp/mailbox.php
imp/message-dimp.php
imp/message-mimp.php
imp/message.php
imp/templates/chunks/compose.php
imp/templates/javascript_defs_dimp.php
ingo/filters.php
ingo/lib/Storage.php
ingo/rule.php
ingo/scripts/ingo-postfix-policyd
koward/www/horde/config/hooks.php.dist [deleted file]
kronolith/data.php
kronolith/edit.php
kronolith/new.php

index 57602d1..f67eae5 100644 (file)
@@ -16,10 +16,10 @@ if (!function_exists('_babel_hook_reset')) {
 
        $cmd = "rm -rf $po";
        exec("sudo $cmd");
-       
+
        $cmd = "svn update $po";
        exec("sudo $cmd");
-       
+
        if (!@file_exists($po)) {
            Translate_Display::warning(_("File doesn't exist ... ") . $po);
            Translate_Display::info();
index 3bb13de..634c38c 100644 (file)
@@ -32,11 +32,7 @@ if (!function_exists('_folks_hook_countService')) {
 
         case 'wishes':
             $result = $GLOBALS['registry']->callByPackage('genie', 'listUserItems', array($user));
-            if ($result instanceof PEAR_Error) {
-                return $result;
-            } else {
-                return count($result);
-            }
+            return count($result);
 
         case 'galleries':
             return $GLOBALS['registry']->callByPackage('ansel', 'countGalleries', array('ansel', PERMS_SHOW, $user));
@@ -286,7 +282,7 @@ if (!function_exists('_horde_hook_signup_preprocess')) {
         }
 
         if (!eregi("^[_a-z0-9-]*$", $username)) {
-            return PEAR::raiseError(_("Username can contain only alphanumeric characters, underscore and minus."));
+            throw new Horde_Exception(_("Username can contain only alphanumeric characters, underscore and minus."));
         }
 
         $_db = DB::connect($GLOBALS['conf']['sql'], true);
@@ -295,13 +291,13 @@ if (!function_exists('_horde_hook_signup_preprocess')) {
         $result = $_db->getRow($query, array($username, $info['extra']['email']), DB_FETCHMODE_ASSOC);
 
         if ($result instanceof PEAR_Error) {
-            return $result;
+            throw new Horde_Exception($result);
         } elseif (empty($result)) {
             return $info;
         } elseif ($result['user_uid'] == $username) {
-            return PEAR::raiseError(_("There is already an user registered with this username"));
+            throw new Horde_Exception(_("There is already an user registered with this username"));
         } elseif ($result['user_email'] == $info['extra']['email']) {
-            return PEAR::raiseError(_("There is already an user registered with this email"));
+            throw new Horde_Exception(_("There is already an user registered with this email"));
         }
 
         return $info;
@@ -338,7 +334,7 @@ if (!function_exists('_horde_hook_signup_addextra')) {
 
         $result = $_db->query($query, $values);
         if ($result instanceof PEAR_Error) {
-            return $result;
+            throw new Horde_Exception($result);
         }
 
         require_once $GLOBALS['registry']->get('fileroot', 'folks') . '/lib/Folks.php';
index 2e2f45e..34e05ee 100644 (file)
@@ -374,16 +374,12 @@ class Folks_Driver {
                     }
                 } else {
                     $profile['count_' . $service] = Horde::callHook('_folks_hook_countService', array($service, $user), 'folks');
-                    if ($profile['count_' . $service] instanceof PEAR_Error) {
-                        return $profile['count_' . $service];
-                    } elseif (empty($profile['count_' . $service])) {
+                    if (empty($profile['count_' . $service])) {
                         continue;
                     }
                 }
                 $profile['count_' . $service . '_list'] = Horde::callHook('_folks_hook_getService', array($service, $user), 'folks');
-                if ($profile['count_' . $service . '_list'] instanceof PEAR_Error) {
-                    return PEAR::raiseError($profile['count_' . $service . '_list']);
-                } elseif (empty($profile['count_' . $service . '_list'])) {
+                if (empty($profile['count_' . $service . '_list'])) {
                     $profile['count_' . $service] = 0;
                 }
             }
index 2457160..e028375 100644 (file)
@@ -28,8 +28,7 @@ function _removeAutoSaveDraft($index)
 require_once dirname(__FILE__) . '/lib/base.php';
 
 /* Determine if compose mode is disabled. */
-$compose_disable = !empty($conf['hooks']['disable_compose']) &&
-                   Horde::callHook('_imp_hook_disable_compose', array(), 'imp');
+$compose_disable = !IMP::canCompose();
 
 /* The headers of the message. */
 $header = array();
index 4c32b49..db4bad1 100644 (file)
@@ -56,8 +56,7 @@ if ($imp_imap->isReadOnly($sent_mail_folder)) {
 }
 
 /* Determine if compose mode is disabled. */
-$compose_disable = !empty($conf['hooks']['disable_compose']) &&
-    Horde::callHook('_imp_hook_disable_compose', array(), 'imp');
+$compose_disable = !IMP::canCompose();
 
 /* Set the current time zone. */
 Horde_Nls::setTimeZone();
index 1fe00d2..13e22cb 100644 (file)
@@ -138,8 +138,7 @@ if ($token = Horde_Util::getFormData('compose_formToken')) {
 Horde_Nls::setTimeZone();
 
 /* Determine if compose mode is disabled. */
-$compose_disable = !empty($conf['hooks']['disable_compose']) &&
-                   Horde::callHook('_imp_hook_disable_compose', array(), 'imp');
+$compose_disable = !IMP::canCompose();
 
 /* Determine if mailboxes are readonly. */
 $readonly_drafts = $readonly_sentmail = false;
index f9bc893..93cca28 100644 (file)
@@ -619,7 +619,9 @@ class IMP_Compose
 
         /* Call post-sent hook. */
         if (!empty($conf['hooks']['postsent'])) {
-            Horde::callHook('_imp_hook_postsent', array($save_msg['msg'], $headers), 'imp', null);
+            try {
+                Horde::callHook('_imp_hook_postsent', array($save_msg['msg'], $headers), 'imp');
+            } catch (Horde_Exception $e) {}
         }
 
         return $sent_saved;
@@ -668,11 +670,14 @@ class IMP_Compose
                 $recipients += isset($address['grounpname']) ? count($address['addresses']) : 1;
             }
             if ($recipients > $timelimit) {
-                $error = @htmlspecialchars(sprintf(_("You are not allowed to send messages to more than %d recipients within %d hours."), $timelimit, $conf['sentmail']['params']['limit_period']), ENT_COMPAT, Horde_Nls::getCharset());
                 if (!empty($conf['hooks']['permsdenied'])) {
-                    $error = Horde::callHook('_perms_hook_denied', array('imp:max_timelimit'), 'horde', $error);
+                    try {
+                        Horde::callHook('_perms_hook_denied', array('imp:max_timelimit'), 'horde');
+                    } catch (Horde_Exception $e) {
+                        throw new IMP_Compose_Exception($e);
+                    }
                 }
-                throw new IMP_Compose_Exception($error);
+                throw new IMP_Compose_Exception(@htmlspecialchars(sprintf(_("You are not allowed to send messages to more than %d recipients within %d hours."), $timelimit, $conf['sentmail']['params']['limit_period']), ENT_COMPAT, Horde_Nls::getCharset()));
             }
         }
 
@@ -869,11 +874,14 @@ class IMP_Compose
                     $num_recipients += count(explode(',', $recipient));
                 }
                 if ($num_recipients > $max_recipients) {
-                    $message = @htmlspecialchars(sprintf(_("You are not allowed to send messages to more than %d recipients."), $max_recipients), ENT_COMPAT, Horde_Nls::getCharset());
                     if (!empty($conf['hooks']['permsdenied'])) {
-                        $message = Horde::callHook('_perms_hook_denied', array('imp:max_recipients'), 'horde', $message);
+                        try {
+                            Horde::callHook('_perms_hook_denied', array('imp:max_recipients'), 'horde');
+                        } catch (Horde_Exception $e) {
+                            throw new IMP_Compose_Exception($e);
+                        }
                     }
-                    throw new IMP_Compose_Exception($message);
+                    throw new IMP_Compose_Exception(@htmlspecialchars(sprintf(_("You are not allowed to send messages to more than %d recipients."), $max_recipients), ENT_COMPAT, Horde_Nls::getCharset()));
                 }
             }
         }
@@ -951,7 +959,11 @@ class IMP_Compose
                 /* If there is a user defined function, call it with the
                  * current trailer as an argument. */
                 if (!empty($GLOBALS['conf']['hooks']['trailer'])) {
-                    $trailer = Horde::callHook('_imp_hook_trailer', array($trailer), 'imp');
+                    try {
+                        $trailer = Horde::callHook('_imp_hook_trailer', array($trailer), 'imp');
+                    } catch (Horde_Exception $e) {
+                        throw new IMP_Compose_Exception($e);
+                    }
                 }
 
                 $body .= $trailer;
index 3be1009..add8d70 100644 (file)
@@ -240,20 +240,24 @@ class IMP_Folder
 
         /* Check permissions. */
         if (!IMP::hasPermission('create_folders')) {
-            $old_error = error_reporting(0);
-            $message = htmlspecialchars(_("You are not allowed to create folders."), ENT_COMPAT, Horde_Nls::getCharset());
-            error_reporting($old_error);
-            if (!empty($conf['hooks']['permsdenied'])) {
-                $message = Horde::callHook('_perms_hook_denied', array('imp:create_folders'), 'horde', $message);
+            try {
+                if (!empty($conf['hooks']['permsdenied'])) {
+                    Horde::callHook('_perms_hook_denied', array('imp:create_folders'), 'horde', $message);
+                }
+                $message = @htmlspecialchars(_("You are not allowed to create folders."), ENT_COMPAT, Horde_Nls::getCharset());
+            } catch (Horde_Exception $e) {
+                $message = $e->getMessage();
             }
             $notification->push($message, 'horde.error', array('content.raw'));
             return false;
         } elseif (!IMP::hasPermission('max_folders')) {
-            $old_error = error_reporting(0);
-            $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d folders."), IMP::hasPermission('max_folders', true)), ENT_COMPAT, Horde_Nls::getCharset());
-            error_reporting($old_error);
-            if (!empty($conf['hooks']['permsdenied'])) {
-                $message = Horde::callHook('_perms_hook_denied', array('imp:max_folders'), 'horde', $message);
+            $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d folders."), IMP::hasPermission('max_folders', true)), ENT_COMPAT, Horde_Nls::getCharset());
+            try {
+                if (!empty($conf['hooks']['permsdenied'])) {
+                    Horde::callHook('_perms_hook_denied', array('imp:max_folders'), 'horde', $message);
+                }
+            } catch (Horde_Exception $e) {
+                $message = $e->getMessage();
             }
             $notification->push($message, 'horde.error', array('content.raw'));
             return false;
index d02e64c..f3b352b 100644 (file)
@@ -561,8 +561,7 @@ class IMP
             }
         }
 
-        if (empty($GLOBALS['conf']['hooks']['disable_compose']) ||
-            !Horde::callHook('_imp_hook_disable_compose', array(false), 'imp')) {
+        if (IMP::canCompose()) {
             $menu->add(self::composeLink(array('mailbox' => $GLOBALS['imp_mbox']['mailbox'])), _("_New Message"), 'compose.png');
         }
 
@@ -1794,4 +1793,19 @@ class IMP
         return self::$newUrl ? self::$newUrl : Horde::selfUrl(true);
     }
 
+    /**
+     * Determine the status of composing.
+     *
+     * @return boolean  Is compose allowed?
+     */
+    static public function canCompose()
+    {
+        try {
+            return empty($conf['hooks']['disable_compose']) ||
+                   !Horde::callHook('_imp_hook_disable_compose', array(), 'imp');
+        } catch (Horde_Exception $e) {
+            return true;
+        }
+    }
+
 }
index 355974c..ca2f41b 100644 (file)
@@ -469,8 +469,9 @@ class Identity_imp extends Identity
         }
 
         if (!empty($GLOBALS['conf']['hooks']['signature'])) {
-            $val = Horde::callHook('_imp_hook_signature', array($val),
-                                   'imp', $val);
+            try {
+                $val = Horde::callHook('_imp_hook_signature', array($val), 'imp');
+            } catch (Horde_Exception $e) {}
         }
 
         $this->_signatures[$ident] = $val;
index 1d9e647..4ac07b2 100644 (file)
@@ -242,8 +242,12 @@ class IMP_Imap
     {
         if (!isset($this->_readonly[$mailbox])) {
             /* These tests work on both regular and search mailboxes. */
-            $res = !empty($GLOBALS['conf']['hooks']['mbox_readonly']) &&
-                Horde::callHook('_imp_hook_mbox_readonly', array($mailbox), 'imp');
+            try {
+                $res = !empty($GLOBALS['conf']['hooks']['mbox_readonly']) &&
+                    Horde::callHook('_imp_hook_mbox_readonly', array($mailbox), 'imp');
+            } catch (Horde_Exception $e) {
+                $res = false;
+            }
 
             /* This check can only be done for regular IMAP mailboxes. */
             // TODO: POP3 also?
index a23a422..ef48dae 100644 (file)
@@ -401,7 +401,9 @@ class IMP_Imap_Tree
 
         if ($_SESSION['imp']['protocol'] != 'pop') {
             if (!empty($GLOBALS['conf']['hooks']['display_folder'])) {
-                $this->_setInvisible($elt, !Horde::callHook('_imp_hook_display_folder', array($elt['v']), 'imp'));
+                try {
+                    $this->_setInvisible($elt, !Horde::callHook('_imp_hook_display_folder', array($elt['v']), 'imp'));
+                } catch (Horde_Exception $e) {}
             }
 
             if ($elt['c'] != 0) {
@@ -1648,10 +1650,12 @@ class IMP_Imap_Tree
         }
 
         if (!isset($mbox_icons)) {
-            $mbox_icons = Horde::callHook('_imp_hook_mbox_icons', array(), 'imp', false);
-            if (!$mbox_icons) {
-                return false;
-            }
+            try {
+                $mbox_icons = Horde::callHook('_imp_hook_mbox_icons', array(), 'imp', false);
+                if (!$mbox_icons) {
+                    return false;
+                }
+            } catch (Horde_Exception $e) {}
         }
 
         if (isset($mbox_icons[$elt['v']])) {
index d65c1ff..85f91bb 100644 (file)
@@ -30,10 +30,7 @@ class MIMP
             $items[IMP::generateIMPUrl('mailbox-mimp.php', 'INBOX')] = _("Inbox");
         }
 
-        if (($page != 'compose') &&
-            (empty($GLOBALS['conf']['hooks']['disable_compose']) ||
-             Horde::callHook('_imp_hook_disable_compose', array(true), 'imp'))) {
-
+        if (($page != 'compose') && IMP::canCompose()) {
             $items[Horde_Util::addParameter(Horde::applicationUrl('compose-mimp.php'), 'u', uniqid(mt_rand()))] = _("New Message");
         }
 
index 24fad3b..887ff26 100644 (file)
@@ -80,12 +80,8 @@ class IMP_Session
          * necessary. */
         if (!empty($conf['hooks']['vinfo'])) {
             try {
-                $hook_user = Horde::callHook('_imp_hook_vinfo', array('username', $imapuser), 'imp');
-                if (!is_a($hook_user, 'PEAR_Error')) {
-                    $imapuser = $hook_user;
-                }
-            } catch (Horde_Exception $e) {
-            }
+                $imapuser = Horde::callHook('_imp_hook_vinfo', array('username', $imapuser), 'imp');
+            } catch (Horde_Exception $e) {}
         }
 
         /* Load the server configuration. */
index f485090..de88842 100644 (file)
@@ -94,7 +94,9 @@ class IMP_Spam
                     $to = $GLOBALS['conf'][$action]['email'];
                 } elseif (!empty($GLOBALS['conf']['hooks']['spam_email'])) {
                     /* Call the email generation hook, if requested. */
-                    $to = Horde::callHook('_imp_hook_spam_email', array($action), 'imp');
+                    try {
+                        $to = Horde::callHook('_imp_hook_spam_email', array($action), 'imp');
+                    } catch (Horde_Exception $e) {}
                 }
 
                 if ($to) {
index 3ededb2..82b0d10 100644 (file)
@@ -248,7 +248,9 @@ class IMP_Views_ListMessages
 
             /* Get all the flag information. */
             if (!empty($GLOBALS['conf']['hooks']['msglist_flags'])) {
-                $ob['flags'] = array_merge($ob['flags'], Horde::callHook('_imp_hook_msglist_flags', array($ob, 'dimp'), 'imp'));
+                try {
+                    $ob['flags'] = array_merge($ob['flags'], Horde::callHook('_imp_hook_msglist_flags', array($ob, 'dimp'), 'imp'));
+                } catch (Horde_Exception $e) {}
             }
 
             $imp_flags = IMP_Imap_Flags::singleton();
@@ -304,7 +306,9 @@ class IMP_Views_ListMessages
 
         /* Allow user to alter template array. */
         if (!empty($GLOBALS['conf']['imp']['hooks']['mailboxarray'])) {
-            $msgs = Horde::callHook('_imp_hook_mailboxarray', array($msgs, 'dimp'), 'imp');
+            try {
+                $msgs = Horde::callHook('_imp_hook_mailboxarray', array($msgs, 'dimp'), 'imp');
+            } catch (Horde_Exception $e) {}
         }
 
         return $msgs;
index 2ca98ea..44e2213 100644 (file)
@@ -18,6 +18,7 @@ class IMP_Views_ShowMessage
      *                         Horde_Mime_Address::parseAddressList().
      *
      * @return array  Array with the following keys: inner, personal, raw.
+     * @throws Horde_Exception
      */
     private function _buildAddressList($addrlist)
     {
@@ -332,13 +333,17 @@ class IMP_Views_ShowMessage
         }
 
         if ($preview && !empty($GLOBALS['conf']['dimp']['hooks']['previewview'])) {
-            $res = Horde::callHook('_imp_hook_dimp_previewview', array($result), 'imp');
-            if (!empty($res)) {
-                $result = $res[0];
-                $result['js'] = $res[1];
-            }
+            try {
+                $res = Horde::callHook('_imp_hook_dimp_previewview', array($result), 'imp');
+                if (!empty($res)) {
+                    $result = $res[0];
+                    $result['js'] = $res[1];
+                }
+            } catch (Horde_Exception $e) {}
         } elseif (!$preview && !empty($GLOBALS['conf']['dimp']['hooks']['messageview'])) {
-            $result = Horde::callHook('_imp_hook_dimp_messageview', array($result), 'imp');
+            try {
+                $result = Horde::callHook('_imp_hook_dimp_messageview', array($result), 'imp');
+            } catch (Horde_Exception $e) {}
         }
 
         if (!$preview) {
index f6365f5..f8e6a0a 100644 (file)
@@ -18,7 +18,9 @@ function _outputSummaries($msgs, $mbox)
 
     /* Allow user to alter template array. */
     if (!empty($GLOBALS['conf']['imp']['hooks']['mailboxarray'])) {
-        $msgs = Horde::callHook('_imp_hook_mailboxarray', array($msgs, 'imp'), 'imp');
+        try {
+            $msgs = Horde::callHook('_imp_hook_mailboxarray', array($msgs, 'imp'), 'imp');
+        } catch (Horde_Exception $e) {}
     }
 
     if (!isset($template)) {
@@ -559,7 +561,7 @@ if ($pageOb['msgcount']) {
         $a_template->set('whitelist', Horde::widget('#', _("Whitelist"), 'widget whitelistAction', '', '', _("_Whitelist")));
     }
 
-    if (empty($conf['hooks']['disable_compose']) || !Horde::callHook('_imp_hook_disable_compose', array(), 'imp')) {
+    if (IMP::canCompose()) {
         $a_template->set('forward', Horde::widget('#', _("Forward"), 'widget forwardAction', '', '', _("Fo_rward")));
     }
 
@@ -750,10 +752,9 @@ while (list(,$ob) = each($mbox_info['overview'])) {
 
     /* Get all the flag information. */
     if (!empty($GLOBALS['conf']['hooks']['msglist_flags'])) {
-        $flags = Horde::callHook('_imp_hook_msglist_flags', array($ob, 'imp'), 'imp');
-        if (!is_a($flags, 'PEAR_Error')) {
-            $ob['flags'] = array_merge($ob['flags'], $flags);
-        }
+        try {
+            $ob['flags'] = array_merge($ob['flags'], Horde::callHook('_imp_hook_msglist_flags', array($ob, 'imp'), 'imp'));
+        } catch (Horde_Exception $e) {}
     }
 
     $flag_parse = $imp_flags->parse(array(
index 2106951..a8d7bbb 100644 (file)
@@ -52,8 +52,7 @@ foreach (array('from', 'to', 'cc', 'bcc', 'replyTo', 'log', 'index', 'mailbox')
 }
 
 /* Determine if compose mode is disabled. */
-$disable_compose = !empty($conf['hooks']['disable_compose']) &&
-    !Horde::callHook('_imp_hook_disable_compose', array(), 'imp');
+$disable_compose = !IMP::canCompose();
 
 if (!$disable_compose) {
     $compose_args = array(
index e7f2c35..f878ad8 100644 (file)
@@ -314,8 +314,7 @@ $compose_params = array(
 );
 
 /* Add compose actions (Reply, Reply List, Reply All, Forward, Redirect). */
-if (empty($conf['hooks']['disable_compose']) ||
-    !Horde::callHook('_imp_hook_disable_compose', array(), 'imp')) {
+if (IMP::canCompose()) {
     $items = array(IMP::composeLink(array(), array('a' => 'r') + $compose_params) => _("Reply"));
 
     if ($list_info['reply_list']) {
index b76162d..8f5772c 100644 (file)
@@ -489,8 +489,7 @@ if (!IMP::$printMode) {
         }
     }
 
-    $disable_compose = !empty($conf['hooks']['disable_compose']) &&
-                       Horde::callHook('_imp_hook_disable_compose', array(), 'imp');
+    $disable_compose = !IMP::canCompose();
 
     if (!$disable_compose) {
         $a_template->set('reply', Horde::widget(IMP::composeLink(array(), array('actionID' => 'reply') + $compose_params), _("Reply"), 'widget hasmenu', '', '', _("_Reply"), true));
index a825f53..64261ef 100644 (file)
@@ -16,8 +16,7 @@ $d_read = $GLOBALS['prefs']->getValue('disposition_request_read');
 $save_attach = $GLOBALS['prefs']->getValue('save_attachments');
 
 /* Determine if compose mode is disabled. */
-$compose_disable = !empty($GLOBALS['conf']['hooks']['disable_compose']) &&
-                   Horde::callHook('_imp_hook_disable_compose', array(), 'imp');
+$compose_disable = !IMP::canCompose();
 
 // Small utility function to simplify creating dimpactions buttons.
 // As of right now, we don't show text only links.
index 8f249ad..b7893b3 100644 (file)
@@ -60,7 +60,7 @@ $code['conf'] = array_filter(array(
     'base_mbox' => IMP_Imap_Tree::BASE_ELT,
     'buffer_pages' => intval($GLOBALS['conf']['dimp']['viewport']['buffer_pages']),
     'debug' => intval(!empty($GLOBALS['conf']['dimp']['js']['debug'])),
-    'disable_compose' => intval(!empty($GLOBALS['conf']['hooks']['disable_compose']) && Horde::callHook('_imp_hook_disable_compose', array(), 'imp')),
+    'disable_compose' => !IMP::canCompose(),
     'filter_any' => intval($GLOBALS['prefs']->getValue('filter_any_mailbox')),
     'fixed_folders' => empty($GLOBALS['conf']['server']['fixed_folders'])
         ? array()
index 424a1f0..786ec33 100644 (file)
@@ -61,17 +61,25 @@ case 'rule_enable':
 
     case 'rule_copy':
         if (!Ingo::hasPermission('allow_rules')) {
-            $message = @htmlspecialchars(_("You are not allowed to create or edit custom rules."), ENT_COMPAT, Horde_Nls::getCharset());
-            if (!empty($conf['hooks']['permsdenied'])) {
-                $message = Horde::callHook('_perms_hook_denied', array('ingo:allow_rules'), 'horde', $message);
+            try {
+                if (!empty($conf['hooks']['permsdenied'])) {
+                    Horde::callHook('_perms_hook_denied', array('ingo:allow_rules'), 'horde', $message);
+                }
+                $message = @htmlspecialchars(_("You are not allowed to create or edit custom rules."), ENT_COMPAT, Horde_Nls::getCharset());
+            } catch (Horde_Exception $e) {
+                $message = $e->getMessage();
             }
             $notification->push($message, 'horde.error', array('content.raw'));
             break 2;
         } elseif (Ingo::hasPermission('max_rules') !== true &&
                   Ingo::hasPermission('max_rules') <= count($filters->getFilterList())) {
-            $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d rules."), Ingo::hasPermission('max_rules')), ENT_COMPAT, Horde_Nls::getCharset());
-            if (!empty($conf['hooks']['permsdenied'])) {
-                $message = Horde::callHook('_perms_hook_denied', array('ingo:max_rules'), 'horde', $message);
+            try {
+                if (!empty($conf['hooks']['permsdenied'])) {
+                    Horde::callHook('_perms_hook_denied', array('ingo:max_rules'), 'horde', $message);
+                }
+                $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d rules."), Ingo::hasPermission('max_rules')), ENT_COMPAT, Horde_Nls::getCharset());
+            } catch (Horde_Exception $e) {
+                $message = $e->getMessage();
             }
             $notification->push($message, 'horde.error', array('content.raw'));
             break 2;
index 0e9a9ce..c627482 100644 (file)
@@ -652,11 +652,11 @@ class Ingo_Storage_vacation extends Ingo_Storage_rule
             return $this->_addr;
         }
 
-        $addresses = Horde::callHook('_ingo_hook_vacation_addresses', array(Ingo::getUser()), 'ingo');
-        if (is_a($addresses, 'PEAR_Error')) {
-            $addresses = array();
+        try {
+            return Horde::callHook('_ingo_hook_vacation_addresses', array(Ingo::getUser()), 'ingo');
+        } catch (Horde_Exception $e) {
+            return array();
         }
-        return $addresses;
     }
 
     public function getVacationDays()
index 423e51c..c783c94 100644 (file)
@@ -15,9 +15,13 @@ require_once dirname(__FILE__) . '/lib/base.php';
 
 /* Check rule permissions. */
 if (!Ingo::hasPermission('allow_rules')) {
-    $message = @htmlspecialchars(_("You are not allowed to create or edit custom rules."), ENT_COMPAT, Horde_Nls::getCharset());
-    if (!empty($conf['hooks']['permsdenied'])) {
-        $message = Horde::callHook('_perms_hook_denied', array('ingo:allow_rules'), 'horde', $message);
+    try {
+        if (!empty($conf['hooks']['permsdenied'])) {
+            Horde::callHook('_perms_hook_denied', array('ingo:allow_rules'), 'horde');
+        }
+        $message = @htmlspecialchars(_("You are not allowed to create or edit custom rules."), ENT_COMPAT, Horde_Nls::getCharset());
+    } catch (Horde_Exception $e) {
+        $message = $e->getMessage();
     }
     $notification->push($message, 'horde.error', array('content.raw'));
     header('Location: ' . Horde::applicationUrl('filters.php', true));
@@ -166,9 +170,13 @@ default:
     if (is_null($edit_number)) {
         if (Ingo::hasPermission('max_rules') !== true &&
             Ingo::hasPermission('max_rules') <= count($filters->getFilterList())) {
-            $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d rules."), Ingo::hasPermission('max_rules')), ENT_COMPAT, Horde_Nls::getCharset());
-            if (!empty($conf['hooks']['permsdenied'])) {
-                $message = Horde::callHook('_perms_hook_denied', array('ingo:max_rules'), 'horde', $message);
+            try {
+                if (!empty($conf['hooks']['permsdenied'])) {
+                    Horde::callHook('_perms_hook_denied', array('ingo:max_rules'), 'horde');
+                }
+                $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d rules."), Ingo::hasPermission('max_rules')), ENT_COMPAT, Horde_Nls::getCharset());
+            } catch (Horde_Exception $e) {
+                $message = $e->getMessage();
             }
             $notification->push($message, 'horde.error', array('content.raw'));
             header('Location: ' . Horde::applicationUrl('filters.php', true));
index a52cf0d..efae71a 100755 (executable)
@@ -135,7 +135,10 @@ function smtpd_access_policy($query)
     if ($pos !== false) {
         $user = substr($user, 0, $pos);
     }
-    $user = Horde::callHook('_ingo_hook_smtpd_access_policy_username', $query, 'ingo', $user);
+
+    try {
+        $user = Horde::callHook('_ingo_hook_smtpd_access_policy_username', $query, 'ingo');
+    } catch (Horde_Exception $e) {}
 
     // Get $user's rules if we don't have them already.
     if (!isset($whitelists[$user])) {
diff --git a/koward/www/horde/config/hooks.php.dist b/koward/www/horde/config/hooks.php.dist
deleted file mode 100644 (file)
index b3d9bbc..0000000
+++ /dev/null
@@ -1 +0,0 @@
-<?php
index b2300da..8fcbe63 100644 (file)
@@ -35,9 +35,13 @@ $templates = array(
 );
 if (Kronolith::hasPermission('max_events') !== true &&
     Kronolith::hasPermission('max_events') <= Kronolith::countEvents()) {
-    $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), Kronolith::hasPermission('max_events')), ENT_COMPAT, Horde_Nls::getCharset());
-    if (!empty($conf['hooks']['permsdenied'])) {
-        $message = Horde::callHook('_perms_hook_denied', array('kronolith:max_events'), 'horde', $message);
+    try {
+        if (!empty($conf['hooks']['permsdenied'])) {
+            Horde::callHook('_perms_hook_denied', array('kronolith:max_events'), 'horde');
+        }
+        $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), Kronolith::hasPermission('max_events')), ENT_COMPAT, Horde_Nls::getCharset());
+    } catch (Horde_Exception $e) {
+        $message = $e->getMessage();
     }
     $notification->push($message, 'horde.warning', array('content.raw'));
     $templates[Horde_Data::IMPORT_FILE] = array(KRONOLITH_TEMPLATES . '/data/export.inc');
@@ -241,9 +245,13 @@ if (is_array($next_step)) {
 
     foreach ($next_step as $row) {
         if ($max_events !== true && $num_events >= $max_events) {
-            $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), Kronolith::hasPermission('max_events')), ENT_COMPAT, Horde_Nls::getCharset());
-            if (!empty($conf['hooks']['permsdenied'])) {
-                $message = Horde::callHook('_perms_hook_denied', array('kronolith:max_events'), 'horde', $message);
+            try {
+                if (!empty($conf['hooks']['permsdenied'])) {
+                    Horde::callHook('_perms_hook_denied', array('kronolith:max_events'), 'horde');
+                }
+                $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), Kronolith::hasPermission('max_events')), ENT_COMPAT, Horde_Nls::getCharset());
+            } catch (Horde_Exception $e) {
+                $message = $e->getMessage();
             }
             $notification->push($message, 'horde.error', array('content.raw'));
             break;
index 28c6ab8..3291072 100644 (file)
@@ -25,9 +25,13 @@ function _check_max()
 {
     if (Kronolith::hasPermission('max_events') !== true &&
         Kronolith::hasPermission('max_events') <= Kronolith::countEvents()) {
-        $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), Kronolith::hasPermission('max_events')), ENT_COMPAT, Horde_Nls::getCharset());
-        if (!empty($GLOBALS['conf']['hooks']['permsdenied'])) {
-            $message = Horde::callHook('_perms_hook_denied', array('kronolith:max_events'), 'horde', $message);
+        try {
+            if (!empty($GLOBALS['conf']['hooks']['permsdenied'])) {
+                Horde::callHook('_perms_hook_denied', array('kronolith:max_events'), 'horde');
+            }
+            $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), Kronolith::hasPermission('max_events')), ENT_COMPAT, Horde_Nls::getCharset());
+        } catch (Horde_Exception $e) {
+            $message = $e->getMessage();
         }
         $GLOBALS['notification']->push($message, 'horde.error', array('content.raw'));
         return false;
index 996467a..92d5465 100644 (file)
@@ -13,9 +13,13 @@ require dirname(__FILE__) . '/lib/base.php';
 /* Check permissions. */
 if (Kronolith::hasPermission('max_events') !== true &&
     Kronolith::hasPermission('max_events') <= Kronolith::countEvents()) {
-    $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), Kronolith::hasPermission('max_events')), ENT_COMPAT, Horde_Nls::getCharset());
-    if (!empty($conf['hooks']['permsdenied'])) {
-        $message = Horde::callHook('_perms_hook_denied', array('kronolith:max_events'), 'horde', $message);
+    try {
+        if (!empty($conf['hooks']['permsdenied'])) {
+            Horde::callHook('_perms_hook_denied', array('kronolith:max_events'), 'horde');
+        }
+        $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), Kronolith::hasPermission('max_events')), ENT_COMPAT, Horde_Nls::getCharset());
+    } catch (Horde_Exception $e) {
+        $message = $e->getMessage();
     }
     $notification->push($message, 'horde.error', array('content.raw'));
     $url = Horde_Util::addParameter($prefs->getValue('defaultview') . '.php', array('month' => Horde_Util::getFormData('month'),