Trailer generation now controlled entirely by 'trailer' hook
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 7 Sep 2010 23:11:29 +0000 (17:11 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 7 Sep 2010 23:38:00 +0000 (17:38 -0600)
imp/config/conf.xml
imp/config/hooks.php.dist
imp/config/trailer.txt.dist [deleted file]
imp/docs/UPGRADING
imp/lib/Compose.php

index 99165a5..d4d9941 100644 (file)
  </configsection>
 
  <configtab name="compose" desc="Compose">
-  <configsection name="msg">
-   <configboolean name="append_trailer" desc="Should we append the contents of
-   imp/config/trailer.txt to the end of every message
-   sent?">true</configboolean>
-  </configsection>
-
   <configsection name="compose">
    <configboolean name="allow_receipts" desc="Can the user request a return
    receipt?">true</configboolean>
index 926731d..771bdd0 100644 (file)
@@ -231,29 +231,25 @@ class IMP_Hooks
 
 
     /**
-     * Dynamically set/alter the contents of the message trailer text.
-     *
-     * @param string $trailer  The default trailer text.
+     * Dynamically create the contents of the message trailer text.
      *
      * @return string  The trailer text to be used.
      */
-//    public function trailer($trailer)
+//    public function trailer()
 //    {
-//        // Example #1: Set the trailer from the system taglines file; the
-//        // string "%TAG%" (if present in a user's signature) will be replaced
-//        // by the content of the file "/usr/share/tagline" (generated by the
-//        // "TaRT" utility).
-//        if (preg_match('/%TAG%/', $trailer)) {
-//            $tag = `cat /usr/share/tagline`;
-//            $sig = preg_replace('|%TAG%|', $tag, $trailer);
-//        }
+//        // Example #1: Static trailer text.
+//        return "--------------------------------\n" .
+//               "This message was sent using IMP.";
 //
-//        return $trailer;
+//
+//        // Example #2: Set the trailer from the system taglines file,
+//        // located at "/usr/share/tagline" (generated by the "TaRT" utility;
+//        // See: http://sourceforge.net/projects/linuxtart/).
+//        return file_get_contents('/usr/share/tagline');
 //
 //
-//        // Example #2: Set the trailer using the LDAP directory for each
-//        // domain. This code replaces the current trailer with the data
-//        // in 'ispmanDomainSignature'.
+//        // Example #3: Set the trailer using the LDAP directory (entry
+//        // 'ispmanDomainSignature').
 //        $vdomain = Horde_String::lower(preg_replace('|^.*?\.|i', '', getenv('HTTP_HOST')));
 //        $ldapServer = 'localhost';
 //        $ldapPort = '389';
diff --git a/imp/config/trailer.txt.dist b/imp/config/trailer.txt.dist
deleted file mode 100644 (file)
index 98efd7b..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-
-----------------------------------------------------------------
-This message was sent using IMP, the Internet Messaging Program.
index 15e7517..f288197 100644 (file)
@@ -53,8 +53,8 @@ hook.
 The 'max_from_chars' and 'max_subj_chars' configuration options for the
 minimal (mimp) display have been removed.
 
-The 'cache_folders', 'limit_factor', 'prepend_header', and 'sort_limit'
-configuration options have been removed.
+The 'append_trailer', 'cache_folders', 'limit_factor', 'prepend_header', and
+'sort_limit' configuration options have been removed.
 
 
 Preferences
@@ -86,6 +86,7 @@ The following hooks have been renamed:
 *  msglist_flags hook now used to dynamically set flags on messages
 * The headers.php configuration file has been removed; setting custom headers
   is now done via the 'pre_sent' hook.
+* Setting message trailers is now done entirely within the 'trailer' hook.
 
 
 Fetchmail
index d99ac63..b68847a 100644 (file)
@@ -1052,29 +1052,16 @@ class IMP_Compose
             $body = $GLOBALS['injector']->getInstance('Horde_Text_Filter')->filter($body, 'Html2text', array('wrap' => false, 'charset' => $charset));
         }
 
-        /* Get trailer message (if any). */
-        $trailer = $trailer_file = null;
-        if (empty($options['nofinal']) &&
-            $GLOBALS['conf']['msg']['append_trailer']) {
-            if (empty($GLOBALS['conf']['vhosts'])) {
-                if (is_readable(IMP_BASE . '/config/trailer.txt')) {
-                    $trailer_file = IMP_BASE . '/config/trailer.txt';
-                }
-            } elseif (is_readable(IMP_BASE . '/config/trailer-' . $GLOBALS['conf']['server']['name'] . '.txt')) {
-                $trailer_file = IMP_BASE . '/config/trailer-' . $GLOBALS['conf']['server']['name'] . '.txt';
-            }
-
-            if (!empty($trailer_file)) {
-                $trailer = $GLOBALS['injector']->getInstance('Horde_Text_Filter')->filter("\n" . file_get_contents($trailer_file), 'environment');
-                try {
-                    $trailer = Horde::callHook('trailer', array($trailer), 'imp');
-                } catch (Horde_Exception_HookNotSet $e) {}
-
-                $body .= $trailer;
-                if (!empty($options['html'])) {
-                    $body_html .= $this->text2html($trailer);
+        /* Get trailer text (if any). */
+        if (empty($options['nofinal'])) {
+            try {
+                if ($trailer = Horde::callHook('trailer', array(), 'imp')) {
+                    $body .= $trailer;
+                    if (!empty($options['html'])) {
+                        $body_html .= $this->text2html($trailer);
+                    }
                 }
-            }
+            } catch (Horde_Exception_HookNotSet $e) {}
         }
 
         /* Set up the body part now. */