From 0870233509109611971b71ec8626c617eadf732c Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 13 Jul 2009 11:02:44 -0600 Subject: [PATCH] Horde::callHook() now throws a Horde_Exception --- babel/config/hooks.php.dist | 4 ++-- folks/config/hooks.php.dist | 16 ++++++---------- folks/lib/Driver.php | 8 ++------ imp/compose-dimp.php | 3 +-- imp/compose-mimp.php | 3 +-- imp/compose.php | 3 +-- imp/lib/Compose.php | 28 ++++++++++++++++++++-------- imp/lib/Folder.php | 24 ++++++++++++++---------- imp/lib/IMP.php | 18 ++++++++++++++++-- imp/lib/Identity/imp.php | 5 +++-- imp/lib/Imap.php | 8 ++++++-- imp/lib/Imap/Tree.php | 14 +++++++++----- imp/lib/MIMP.php | 5 +---- imp/lib/Session.php | 8 ++------ imp/lib/Spam.php | 4 +++- imp/lib/Views/ListMessages.php | 8 ++++++-- imp/lib/Views/ShowMessage.php | 17 +++++++++++------ imp/mailbox.php | 13 +++++++------ imp/message-dimp.php | 3 +-- imp/message-mimp.php | 3 +-- imp/message.php | 3 +-- imp/templates/chunks/compose.php | 3 +-- imp/templates/javascript_defs_dimp.php | 2 +- ingo/filters.php | 20 ++++++++++++++------ ingo/lib/Storage.php | 8 ++++---- ingo/rule.php | 20 ++++++++++++++------ ingo/scripts/ingo-postfix-policyd | 5 ++++- koward/www/horde/config/hooks.php.dist | 1 - kronolith/data.php | 20 ++++++++++++++------ kronolith/edit.php | 10 +++++++--- kronolith/new.php | 10 +++++++--- 31 files changed, 180 insertions(+), 117 deletions(-) delete mode 100644 koward/www/horde/config/hooks.php.dist diff --git a/babel/config/hooks.php.dist b/babel/config/hooks.php.dist index 57602d196..f67eae5be 100644 --- a/babel/config/hooks.php.dist +++ b/babel/config/hooks.php.dist @@ -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(); diff --git a/folks/config/hooks.php.dist b/folks/config/hooks.php.dist index 3bb13de07..634c38c03 100644 --- a/folks/config/hooks.php.dist +++ b/folks/config/hooks.php.dist @@ -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'; diff --git a/folks/lib/Driver.php b/folks/lib/Driver.php index 2e2f45ed1..34e05eea3 100644 --- a/folks/lib/Driver.php +++ b/folks/lib/Driver.php @@ -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; } } diff --git a/imp/compose-dimp.php b/imp/compose-dimp.php index 24571602e..e028375bf 100644 --- a/imp/compose-dimp.php +++ b/imp/compose-dimp.php @@ -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(); diff --git a/imp/compose-mimp.php b/imp/compose-mimp.php index 4c32b49b2..db4bad13e 100644 --- a/imp/compose-mimp.php +++ b/imp/compose-mimp.php @@ -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(); diff --git a/imp/compose.php b/imp/compose.php index 1fe00d294..13e22cb10 100644 --- a/imp/compose.php +++ b/imp/compose.php @@ -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; diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index f9bc893d6..93cca28db 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -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; diff --git a/imp/lib/Folder.php b/imp/lib/Folder.php index 3be1009fd..add8d707f 100644 --- a/imp/lib/Folder.php +++ b/imp/lib/Folder.php @@ -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; diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index d02e64c81..f3b352b18 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -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; + } + } + } diff --git a/imp/lib/Identity/imp.php b/imp/lib/Identity/imp.php index 355974cc5..ca2f41b7e 100644 --- a/imp/lib/Identity/imp.php +++ b/imp/lib/Identity/imp.php @@ -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; diff --git a/imp/lib/Imap.php b/imp/lib/Imap.php index 1d9e647a1..4ac07b2fc 100644 --- a/imp/lib/Imap.php +++ b/imp/lib/Imap.php @@ -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? diff --git a/imp/lib/Imap/Tree.php b/imp/lib/Imap/Tree.php index a23a422af..ef48daeb9 100644 --- a/imp/lib/Imap/Tree.php +++ b/imp/lib/Imap/Tree.php @@ -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']])) { diff --git a/imp/lib/MIMP.php b/imp/lib/MIMP.php index d65c1ff49..85f91bb31 100644 --- a/imp/lib/MIMP.php +++ b/imp/lib/MIMP.php @@ -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"); } diff --git a/imp/lib/Session.php b/imp/lib/Session.php index 24fad3b2f..887ff262e 100644 --- a/imp/lib/Session.php +++ b/imp/lib/Session.php @@ -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. */ diff --git a/imp/lib/Spam.php b/imp/lib/Spam.php index f485090e6..de88842e6 100644 --- a/imp/lib/Spam.php +++ b/imp/lib/Spam.php @@ -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) { diff --git a/imp/lib/Views/ListMessages.php b/imp/lib/Views/ListMessages.php index 3ededb29a..82b0d1086 100644 --- a/imp/lib/Views/ListMessages.php +++ b/imp/lib/Views/ListMessages.php @@ -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; diff --git a/imp/lib/Views/ShowMessage.php b/imp/lib/Views/ShowMessage.php index 2ca98eace..44e2213f9 100644 --- a/imp/lib/Views/ShowMessage.php +++ b/imp/lib/Views/ShowMessage.php @@ -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) { diff --git a/imp/mailbox.php b/imp/mailbox.php index f6365f521..f8e6a0a4f 100644 --- a/imp/mailbox.php +++ b/imp/mailbox.php @@ -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( diff --git a/imp/message-dimp.php b/imp/message-dimp.php index 21069516f..a8d7bbb8f 100644 --- a/imp/message-dimp.php +++ b/imp/message-dimp.php @@ -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( diff --git a/imp/message-mimp.php b/imp/message-mimp.php index e7f2c3530..f878ad878 100644 --- a/imp/message-mimp.php +++ b/imp/message-mimp.php @@ -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']) { diff --git a/imp/message.php b/imp/message.php index b76162d50..8f5772c8e 100644 --- a/imp/message.php +++ b/imp/message.php @@ -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)); diff --git a/imp/templates/chunks/compose.php b/imp/templates/chunks/compose.php index a825f53cb..64261efdd 100644 --- a/imp/templates/chunks/compose.php +++ b/imp/templates/chunks/compose.php @@ -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. diff --git a/imp/templates/javascript_defs_dimp.php b/imp/templates/javascript_defs_dimp.php index 8f249ad78..b7893b3a5 100644 --- a/imp/templates/javascript_defs_dimp.php +++ b/imp/templates/javascript_defs_dimp.php @@ -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() diff --git a/ingo/filters.php b/ingo/filters.php index 424a1f0d5..786ec331c 100644 --- a/ingo/filters.php +++ b/ingo/filters.php @@ -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; diff --git a/ingo/lib/Storage.php b/ingo/lib/Storage.php index 0e9a9ce29..c6274827f 100644 --- a/ingo/lib/Storage.php +++ b/ingo/lib/Storage.php @@ -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() diff --git a/ingo/rule.php b/ingo/rule.php index 423e51ce4..c783c9422 100644 --- a/ingo/rule.php +++ b/ingo/rule.php @@ -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)); diff --git a/ingo/scripts/ingo-postfix-policyd b/ingo/scripts/ingo-postfix-policyd index a52cf0ddc..efae71a1d 100755 --- a/ingo/scripts/ingo-postfix-policyd +++ b/ingo/scripts/ingo-postfix-policyd @@ -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 index b3d9bbc7f..000000000 --- a/koward/www/horde/config/hooks.php.dist +++ /dev/null @@ -1 +0,0 @@ -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; diff --git a/kronolith/edit.php b/kronolith/edit.php index 28c6ab85b..3291072dc 100644 --- a/kronolith/edit.php +++ b/kronolith/edit.php @@ -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; diff --git a/kronolith/new.php b/kronolith/new.php index 996467ad2..92d546518 100644 --- a/kronolith/new.php +++ b/kronolith/new.php @@ -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'), -- 2.11.0