]> git.sur5r.net Git - contagged/blobdiff - inc/functions.php
fix missing space in company address
[contagged] / inc / functions.php
index f3b2ac05fac2660d67762f46e44793d5ea92059c..add970ca8bcb73c58ac51673fedb40c84698e664 100644 (file)
@@ -234,6 +234,15 @@ function prepare_ldap_entry($in){
     }
   }
 
+  // special tag handling for Thunderbird
+  if($conf['tbtaghack'] && in_array('contactPerson',$OCLASSES)){
+    if($in['marker'][0]) $out['custom1'][] = $in['marker'][0];
+    if($in['marker'][1]) $out['custom2'][] = $in['marker'][1];
+    if($in['marker'][2]) $out['custom3'][] = $in['marker'][2];
+    if($in['marker'][3]) $out['custom4'][] = $in['marker'][3];
+  }
+
+
   // add the Objectclasses
   $out['objectclass'] = $OCLASSES;
 
@@ -335,7 +344,7 @@ function ldap_store_objectclasses($dn,$classes){
   $add['objectClass'] = $set;
 
   $r = @ldap_mod_replace($LDAP_CON,$dn,$add);
-  tpl_ldaperror();
+  tpl_ldaperror('store object classes');
 
 /*  print '<pre>';
   print_r($set);
@@ -375,23 +384,37 @@ function ldap_queryabooks($filter,$types){
   $results = array();
   $result1 = array();
   $result2 = array();
+  $result3 = array();
 
   // public addressbook
-  $sr      = ldap_list($LDAP_CON,$conf['publicbook'],
-                       $filter,$types);
+  $sr      = @ldap_search($LDAP_CON,$conf['publicbook'],
+                        $filter,$types);
+  tpl_ldaperror();
   $result1 = ldap_get_binentries($LDAP_CON, $sr);
   ldap_free_result($sr);
 
   // private addressbook
-  if(!empty($_SESSION['ldapab']['binddn'])){
+  if(!empty($_SESSION['ldapab']['binddn']) && $conf['privatebook']){
     $sr      = @ldap_list($LDAP_CON,$conf['privatebook'].
                           ','.$_SESSION['ldapab']['binddn'],
                           $filter,$types);
+    if(ldap_errno($LDAP_CON) != 32) tpl_ldaperror(); // ignore missing address book
     $result2 = ldap_get_binentries($LDAP_CON, $sr);
   }
 
+  // user account entries
+  if ($conf['displayusertree']) {
+    $sr      = @ldap_list($LDAP_CON,$conf['usertree'],
+                        $filter,$types);
+    tpl_ldaperror();
+    $result3 = ldap_get_binentries($LDAP_CON, $sr);
+    ldap_free_result($sr);
+  }
+
+
+
   // return merged results
-  return array_merge((array)$result1,(array)$result2);
+  return array_merge((array)$result1,(array)$result2,(array)$result3);
 }
 
 /**
@@ -496,9 +519,31 @@ function get_fields_from_template($tpl){
             $return[] = $FIELDS[$f];
         }elseif($FIELDS["_$f"]){
             $return[] = $FIELDS["_$f"];
+        }elseif($f = 'markers'){
+            $return[] = 'marker';
         }
     }
     return $return;
 }
 
+function addCoords(&$coords, $entry, $geocoder)
+{
+    $priv = $geocoder->getPrivateCoords($entry);
+    if ($priv !== null) {
+        $priv->address = '<b>'
+            . $entry['givenname'] . ' ' . $entry['name'] . '</b><br/>'
+            . str_replace("\n", '<br/>', $entry['homestreet']);
+        $coords[] = $priv;
+    }
+
+    $busi = $geocoder->getBusinessCoords($entry);
+    if ($busi !== null) {
+        $busi->address = '<b>' . $entry['organization'] . '<br/>'
+            . $entry['givenname'] . ' ' . $entry['name'] . '</b><br/>'
+            . $entry['street'] . '<br/>'
+            . $entry['zip'] . ' ' . $entry['location'];
+        $coords[] = $busi;
+    }
+}
+
 ?>