[turba] Re: LDAP multiple e-mail display patches

John Dalbec jpdalbec at ysu.edu
Tue Apr 15 17:16:46 PDT 2003


Chuck Hagenbuch wrote:
> Quoting John Dalbec <jpdalbec at ysu.edu>:
> 
> 
>>I realize many of you see no need to support multiple e-mail addresses
>>since turba has distribution lists now.  

In IMP RELENG (sorry, I know it's OT), a contact with two e-mail 
addresses appears to be treated as a distribution list.  Was this 
intentional?

However, I have an LDAP
>>directory where some users have multiple valid e-mail addresses.  These
>>patches cause the addresses to be converted into separate working links
>>rather than a single link that doesn't work.  This is different from a
>>distribution list in that you only send e-mail to the address that you
>>click.
> 
> 
> If you submit this as a patch against Turba HEAD I'm sure we can get it
> committed.

Done, against last night's HEAD.
John

> 
> -chuck
> 
> --
> Charles Hagenbuch, <chuck at horde.org>
> "... It is not more light we need, but more warmth! We die of cold, not of
> darkness. It is not the night that kills, but the frost." - Miguel de
> Unamuno
> 


-------------- next part --------------
--- turba/templates/browse/contactrow.inc	Sun Mar  9 19:39:05 2003
+++ turba/templates/browse/contactrow.inc	Tue Apr 15 15:57:57 2003
@@ -6,22 +6,33 @@
     if ($ob->hasValue($column)) {
         $show[$column] = htmlspecialchars($ob->getValue($column));
         if ($GLOBALS['attributes'][$column]['type'] == 'email') {
-            // Format the address according to RFC822.
-            $mailbox_host = explode('@', $show[$column]);
-            if (!isset($mailbox_host[1])) {
-                $mailbox_host[1] = '';
+            $email_vals = explode(',', $show[$column]);
+            $email_values = false;
+            foreach ($email_vals as $email_val) {
+                $email_val = trim($email_val);
+                // Format the address according to RFC822.
+                $mailbox_host = explode('@', $email_val);
+                if (!isset($mailbox_host[1])) {
+                    $mailbox_host[1] = '';
+                }
+                $name = $ob->getValue('name');
+                require_once HORDE_BASE . '/lib/MIME.php';
+                $address = MIME::rfc822WriteAddress($mailbox_host[0], $mailbox_host[1], $name);
+                // Get rid of the trailing @ (when no host is included in the email address).
+                $address = str_replace('@>', '>', $address);
+                $mail_link = $GLOBALS['registry']->call('mail/compose', array(array('to' => addslashes($address))));
+                if (is_a($mail_link, 'PEAR_Error')) {
+                    $mail_link = 'mailto:' . urlencode($address);
+                }
+    
+                $email_value = '<a href="' . $mail_link . '">' . htmlspecialchars($email_val) . '</a>';
+                if ($email_values) {
+                    $email_values .= ', ' . $email_value;
+                } else {
+                    $email_values = $email_value;
+                }
             }
-            $name = $ob->getValue('name');
-            require_once HORDE_BASE . '/lib/MIME.php';
-            $address = MIME::rfc822WriteAddress($mailbox_host[0], $mailbox_host[1], $name);
-            // Get rid of the trailing @ (when no host is included in the email address).
-            $address = str_replace('@>', '>', $address);
-            $mail_link = $GLOBALS['registry']->call('mail/compose', array(array('to' => addslashes($address))));
-            if (is_a($mail_link, 'PEAR_Error')) {
-                $mail_link = 'mailto:' . urlencode($address);
-            }
-
-            $show[$column] = '<a href="' . $mail_link . '">' . htmlspecialchars($show[$column]) . '</a>';
+            $show[$column] = $email_values;
         }
     } else {
         $show[$column] = '&nbsp;';
-------------- next part --------------
--- turba/templates/search/row.inc	Thu Jan  2 15:42:44 2003
+++ turba/templates/search/row.inc	Tue Apr 15 16:01:31 2003
@@ -9,22 +9,33 @@
         }
         $show[$column] = htmlspecialchars($ob->getValue($column));
         if ($GLOBALS['attributes'][$column]['type'] == 'email') {
-            // Format the address according to RFC822.
-            $mailbox_host = explode('@', $show[$column]);
-            if (!isset($mailbox_host[1])) {
-                $mailbox_host[1] = '';
+            $email_vals = explode(',', $show[$column]);
+            $email_values = false;
+            foreach ($email_vals as $email_val) {
+                $email_val = trim($email_val);
+                // Format the address according to RFC822.
+                $mailbox_host = explode('@', $email_val);
+                if (!isset($mailbox_host[1])) {
+                    $mailbox_host[1] = '';
+                }
+                $name = $ob->getValue('name');
+                require_once HORDE_BASE . '/lib/MIME.php';
+                $address = MIME::rfc822WriteAddress($mailbox_host[0], $mailbox_host[1], $name);
+                // Get rid of the trailing @ (when no host is included in the email address).
+                $address = str_replace('@>', '>', $address);
+                $mail_link = $GLOBALS['registry']->call('mail/compose', array(array('to' => addslashes($address))));
+                if (is_a($mail_link, 'PEAR_Error')) {
+                    $mail_link = 'mailto:' . urlencode($address);
+                }
+    
+                $email_value = '<a href="' . $mail_link . '">' . htmlspecialchars($email_val) . '</a>';
+                if ($email_values) {
+                    $email_values .= ', ' . $email_value;
+                } else {
+                    $email_values = $email_value;
+                }
             }
-            $name = $ob->getValue('name');
-            require_once HORDE_BASE . '/lib/MIME.php';
-            $address = MIME::rfc822WriteAddress($mailbox_host[0], $mailbox_host[1], $name);
-            // Get rid of the trailing @ (when no host is included in the email address).
-            $address = str_replace('@>', '>', $address);
-            $mail_link = $GLOBALS['registry']->call('mail/compose', array(array('to' => addslashes($address))));
-            if (is_a($mail_link, 'PEAR_Error')) {
-                $mail_link = 'mailto:' . urlencode($address);
-            }
-
-            $show[$column] = '<a href="' . $mail_link . '">' . htmlspecialchars($show[$column]) . '</a>';
+            $show[$column] = $email_values;
         }
     } else {
         $show[$column] = '&nbsp;';


More information about the turba mailing list