From ea18c594a525d28aa5156d13cac3e24f2c9267cf Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Sat, 29 Aug 2009 14:59:06 -0400
Subject: [PATCH] - Add mail_domain to LDAP email entries without @ sign (#1485201)

---
 CHANGELOG                      |    1 +
 program/include/rcube_ldap.php |   10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index a8ed556..7eae0c4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 CHANGELOG RoundCube Webmail
 ===========================
 
+- Add mail_domain to LDAP email entries without @ sign (#1485201)
 - Fix saving empty values in LDAP contact data (#1485781)
 - Fix LDAP contact update when RDN field is changed (#1485788)
 - Fix LDAP attributes case senitivity problems (#1485830)
diff --git a/program/include/rcube_ldap.php b/program/include/rcube_ldap.php
index 3bb747b..762e6e3 100644
--- a/program/include/rcube_ldap.php
+++ b/program/include/rcube_ldap.php
@@ -570,6 +570,8 @@
    */
   function _ldap2result($rec)
   {
+    global $RCMAIL;
+
     $out = array();
     
     if ($rec['dn'])
@@ -577,8 +579,12 @@
     
     foreach ($this->fieldmap as $rf => $lf)
     {
-      if ($rec[$lf]['count'])
-        $out[$rf] = $rec[$lf][0];
+      if ($rec[$lf]['count']) {
+        if ($rf == 'email' && !strpos($rec[$lf][0], '@'))
+          $out[$rf] = sprintf('%s@%s', $rec[$lf][0] , $RCMAIL->config->mail_domain($_SESSION['imap_host']));
+        else
+          $out[$rf] = $rec[$lf][0];
+      }
     }
     
     return $out;

--
Gitblit v1.9.1