From: Michael M Slusarz Date: Wed, 10 Mar 2010 06:19:15 +0000 (-0700) Subject: Add pre_sent hook X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=9d0a281b199a11fd8e0093f1757e82dc206b02f2;p=horde.git Add pre_sent hook --- diff --git a/imp/config/hooks.php.dist b/imp/config/hooks.php.dist index 627d86442..7b5b64c5e 100644 --- a/imp/config/hooks.php.dist +++ b/imp/config/hooks.php.dist @@ -168,6 +168,18 @@ class IMP_Hooks /** + * Perform an action before a message has been sent. + * + * @param Horde_Mime_Part $message The message content object. + * @param Horde_Mime_Headers $headers The message headers object. + */ +// function pre_sent($message, $headers) +// { +// // Do action here -- no return value from this hook. +// } + + + /** * Perform an action after a message has been sent successfully. * * @param Horde_Mime_Part $message The message content object. diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index 24c1e9eab..557dea4fe 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -2,6 +2,7 @@ v5.0-git -------- +[mms] Add hook to alter composed message details before sending. [mms] DIMP now honors the 'allow_resume_all' configuration option. [mms] Remove 'sort_limit' configuration option. [mms] Mobile view no longer supports WML output. diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index 54588f436..28af5ffa8 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -747,20 +747,6 @@ class IMP_Compose { global $conf; - /* Properly encode the addresses we're sending to. */ - try { - $email = Horde_Mime::encodeAddress($email, null, $_SESSION['imp']['maildomain']); - } catch (Horde_Mime_Exception $e) { - throw new IMP_Compose_Exception($e); - } - - /* Validate the recipient addresses. */ - try { - $result = Horde_Mime_Address::parseAddressList($email, array('defserver' => $_SESSION['imp']['maildomain'], 'validate' => true)); - } catch (Horde_Mime_Exception $e) { - return; - } - $timelimit = $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_timelimit'); if ($timelimit !== true) { if ($conf['sentmail']['driver'] == 'none') { @@ -774,14 +760,33 @@ class IMP_Compose } if ($recipients > $timelimit) { try { - $message = Horde::callHook('perms_denied', array('imp:max_timelimit')); + $error = Horde::callHook('perms_denied', array('imp:max_timelimit')); } catch (Horde_Exception_HookNotSet $e) { - $message = @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()); + $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()); } - throw new IMP_Compose_Exception($message); + throw new IMP_Compose_Exception($error); } } + /* Pass to hook to allow alteration of message details. */ + try { + Horde::callHook('pre_sent', array($message, $headers), 'imp'); + } catch (Horde_Exception_HookNotSet $e) {} + + /* Properly encode the addresses we're sending to. */ + try { + $email = Horde_Mime::encodeAddress($email, null, $_SESSION['imp']['maildomain']); + } catch (Horde_Mime_Exception $e) { + throw new IMP_Compose_Exception($e); + } + + /* Validate the recipient addresses. */ + try { + $result = Horde_Mime_Address::parseAddressList($email, array('defserver' => $_SESSION['imp']['maildomain'], 'validate' => true)); + } catch (Horde_Mime_Exception $e) { + return; + } + $mail_driver = $this->getMailDriver(); try {