[dev] custom trailer patch
Atif Ghaffar
aghaffar@developer.ch
Fri, 31 May 2002 05:02:36 +0200
This is a multi-part message in MIME format.
---------------------- multipart/mixed attachment
hi,
here is a small patch to compose.php and conf.php.dist (HEAD) that
allows a possibility to call a hook for trailer.
Please review and let me know what you think.
best regards
--
Atif Ghaffar
---------------------------.
+41 78 845 31 64 ¦ tel
aghaffar@developer.ch ¦ email
http://atifghaffar.com ¦ www
8206786 ¦ icq
---------------------- multipart/mixed attachment
Index: compose.php
===================================================================
RCS file: /repository/imp/compose.php,v
retrieving revision 2.462
diff -u -r2.462 compose.php
--- compose.php 30 May 2002 22:05:14 -0000 2.462
+++ compose.php 31 May 2002 02:59:41 -0000
@@ -674,6 +674,10 @@
$trailer = "\n";
$trailer .= implode(@file(IMP_BASE . '/config/trailer.txt'), '');
$trailer = Text::expandEnvironment($trailer);
+ //if there is a user defined function. call it with current trailer as argument
+ if (!empty($conf['hooks']['trailer']) && function_exists($conf['hooks']['trailer'])) {
+ $trailer= call_user_func($conf['hooks']['trailer'], $trailer);
+ }
$message .= $trailer;
}
Index: config/conf.php.dist
===================================================================
RCS file: /repository/imp/config/conf.php.dist,v
retrieving revision 1.180
diff -u -r1.180 conf.php.dist
--- config/conf.php.dist 30 May 2002 12:02:06 -0000 1.180
+++ config/conf.php.dist 31 May 2002 02:59:41 -0000
@@ -318,6 +318,49 @@
// }
// If this is set to a function name, that function will be used
+// to modify the trailer at runtime; See
+// the 'imp_set_trailer' function below for an example.
+$conf['hooks']['trailer'] = '';
+
+/* Here is an example imp_set_trailer function to set the trailer
+ * from the system taglines file; the string "@@TAG@@" (if present in a
+ * trailer) will be replaced by the content of the file
+ * "/usr/share/tagline" (generated by the "TaRT" utility).
+ */
+// if (!function_exists('imp_set_trailer')) {
+// function imp_set_trailer ($trailer) {
+// if (preg_match('/@@TAG@@/', $trailer)) {
+// $tag = `cat /usr/share/tagline`;
+// $trailer = preg_replace('|@@TAG@@|', $tag, $trailer);
+// }
+// return $trailer;
+// }
+// }
+
+/* Here is an another example imp_set_trailer function to set the trailer
+ * from the LDAP directory for each domain. This function replaces the
+ * current trailer with the data it gets from ispmanDomainSignature
+ */
+// if (!function_exists('imp_set_trailer')) {
+// function imp_set_trailer ($trailer) {
+// $vdomain = getenv('HTTP_HOST');
+// $vdomain = preg_replace('|^.*?\.|i', '', $vdomain);
+// $vdomain = strtolower($vdomain);
+// $ldapServer = 'localhost';
+// $ldapPort = '389';
+// $searchBase = 'ispmanDomain=' . $vdomain . ",o=ispman";
+// $ds = @ldap_connect($ldapServer, $ldapPort);
+// $searchResult = @ldap_search($ds, $searchBase, 'uid=' . $vdomain);
+// $information = @ldap_get_entries($ds, $searchResult);
+// $trailer= $information[0]['ispmandomainsignature'][0];
+// ldap_close($ds);
+// return $trailer;
+// }
+// }
+
+
+
+// If this is set to a function name, that function will be used
// to get the user's fullname to use when sending mail. See
// the 'imp_set_fullname' function below for an example.
$conf['hooks']['fullname'] = '';
---------------------- multipart/mixed attachment--