]> git.sur5r.net Git - contagged/commitdiff
changed multifield character from * to _
authorAndreas Gohr <gohr@cosmocode.de>
Wed, 16 May 2007 11:10:30 +0000 (13:10 +0200)
committerAndreas Gohr <gohr@cosmocode.de>
Wed, 16 May 2007 11:10:30 +0000 (13:10 +0200)
darcs-hash:20070516111030-6e07b-690dfdbe1729002589da0f891dde7ea05dba413c.gz

ajax.php
entry.php
fields.php
functions.php
index.php
tags.php
template.php
templates/entry_show.tpl

index e26031bfe4bc3e036551446b65883738e667a165..73101807035813425cec9ee6f64cdef14fea60a3 100644 (file)
--- a/ajax.php
+++ b/ajax.php
@@ -18,16 +18,17 @@ if(!empty($_REQUEST['taglookup'])){
 function ajax_addnote($dn,$note){
   global $conf;
   global $LDAP_CON;
+  global $FIELDS;
 
   // fetch the existing note
-  $result = ldap_search($LDAP_CON,$dn,'(objectClass=inetOrgPerson)',array('description'));
+  $result = ldap_search($LDAP_CON,$dn,'(objectClass=inetOrgPerson)',array($FIELDS['note']));
   if(ldap_count_entries($LDAP_CON,$result)){
     $result = ldap_get_binentries($LDAP_CON, $result);
   }
-  $note = $note."\n\n".$result[0]['description'][0];
+  $note = $note."\n\n".$result[0][$FIELDS['note']][0];
   $note = preg_replace("!\n\n\n+!","\n\n",$note);
 
-  $entry['description'] = $note;
+  $entry[$FIELDS['note']] = $note;
   ldap_modify($LDAP_CON,$dn,$entry);
 
 
@@ -41,14 +42,15 @@ function ajax_addnote($dn,$note){
 function ajax_settags($dn,$tags){
   global $conf;
   global $LDAP_CON;
-  if(!$conf['extended']) return;
+  global $FIELDS;
+  if(!$FIELDS['_marker']) return;
 
   $tags = explode(',',$tags);
   $tags = array_map('trim',$tags);
   $tags = array_unique($tags);
   $tags = array_diff($tags, array('')); //strip empty ones
 
-  $entry['marker'] = $tags;
+  $entry[$FIELDS['_marker']] = $tags;
   ldap_mod_replace($LDAP_CON,$dn,$entry);
 
   foreach ($tags as $tag){
@@ -67,18 +69,18 @@ function ajax_settags($dn,$tags){
 function ajax_taglookup($tag){
   global $conf;
   global $LDAP_CON;
-  if(!$conf['extended']) return;
+  if(!$FIELDS['_marker']) return;
 
   $search = ldap_filterescape($tag);
-  $filter = "(&(objectClass=contactPerson)(marker=$search*))";
-  $result = ldap_queryabooks($filter,'marker');
+  $filter = "(&(objectClass=inetOrgPerson)('.$FIELDS['_marker'].'=$search*))";
+  $result = ldap_queryabooks($filter,$FIELDS['_marker']);
 
   if(!count($result)) return;
 
   $tags = array();
   foreach ($result as $entry){
-    if(count($entry['marker'])){
-      foreach($entry['marker'] as $marker){
+    if(count($entry[$FIELDS['_marker']])){
+      foreach($entry[$FIELDS['_marker']] as $marker){
         if(preg_match('/^'.preg_quote($tag,'/').'/i',$marker)){
           array_push($tags, strtolower($marker));
         }
index eaeedbadecbb37b0dded5c5ebb68420cbee9d951..ec73909242f0d362b93c6fd239f78dbace847c25 100644 (file)
--- a/entry.php
+++ b/entry.php
@@ -30,7 +30,7 @@
     unset($_REQUEST['entry']['markers']);
 
     foreach(array_keys($_REQUEST['entry']) as $field){
-        if($FIELDS['*'.$field]){
+        if($FIELDS['_'.$field]){
             // entry has to be handled as array -> clean it up (trim, unique, sort)
             $_REQUEST['entry'][$field] = array_map('trim',$_REQUEST['entry'][$field]);
             $_REQUEST['entry'][$field] = array_unique($_REQUEST['entry'][$field]);
index a87efa08c4b036406700839a7efbc5a6c9c5b9aa..f5ee6629c56f231a6590231138c6205683f1e0ec 100644 (file)
@@ -40,7 +40,7 @@ $FIELDS = array(
     'url'          => 'labeledURI',
     'note'         => 'description',
     'manager'      => 'manager',                     // aka. key account
-    '*mail'        => 'mail',
+    '_mail'        => 'mail',
 );
 
 /**
@@ -49,7 +49,7 @@ $FIELDS = array(
  */
 $OCLASSES[] = 'contactPerson';
 $FIELDS['anniversary']  = 'anniversary';
-$FIELDS['*marker']      = 'marker';                  // aka. tags
+$FIELDS['_marker']      = 'marker';                  // aka. tags
 
 /**
  * If the open exchange schema is used the following fields
@@ -60,11 +60,30 @@ $OCLASSES[] = 'OXUserObject';
 $FIELDS['country']          = 'userCountry';
 $FIELDS['birthday']         = 'birthDay';
 $FIELDS['ipphone']          = 'IPPhone';
-$FIELDS['*marker']          = 'OXUserCategories';
+$FIELDS['_marker']          = 'OXUserCategories';
 $FIELDS['instantmessenger'] = 'OXUserInstantMessenger';
 $FIELDS['timezone']         = 'OXTimeZone';
 $FIELDS['position']         = 'OXUserPosition';
 $FIELDS['certificate']      = 'relClientCert';
+$FIELDS['domain']           = 'domain';
+*/
+
+/**
+ * If the Evolution schema is used the following fields
+ * and object classes are added
+ */
+/* comment in if you want to use it
+$OCLASSES[] = 'evolutionPerson';
+$OCLASSES[] = 'officePerson';
+$FIELDS['department'] = 'ou';
+$FIELDS['state']      = 'st';
+$FIELDS['country']    = 'c';
+$FIELDS['direct']     = 'primaryPhone';
+$FIELDS['swithboard'] = 'companyPhone';
+$FIELDS['note']       = 'note';
+$FIELDS['manager']    = 'seeAlso';
+$FIELDS['birthday']   = 'birthDate';
+$FIELDS['spouse']     = 'spouseName';
 */
 
 
index c8de36794bee140bda2545bd99687486ef08cfe8..671fca402a873b55017460f1544669b31bdb898b 100644 (file)
@@ -222,12 +222,12 @@ function prepare_ldap_entry($in){
     if($FIELDS[$key]){
         // normal mapped field
         $out[$FIELDS[$key]][] = $value;
-    }elseif($FIELDS["*$key"]){
+    }elseif($FIELDS["_$key"]){
         // mapped multi field
         if(is_array($value)){
-            $out[$FIELDS["*$key"]] = $value;
+            $out[$FIELDS["_$key"]] = $value;
         }else{
-            $out[$FIELDS["*$key"]][] = $value; //shouldn't happen, but to be sure
+            $out[$FIELDS["_$key"]][] = $value; //shouldn't happen, but to be sure
         }
     }else{
         // no mapping found - assume it to be a LDAP attribute (shouldn't happen)
index 43ae1b0b47963bf2ec62d151d270dbb336eef8d9..01eeb47de25cf70c1c2ac6ad742709ecaa5f25be 100644 (file)
--- a/index.php
+++ b/index.php
       $marker = explode(',',$marker);
       foreach($marker as $m){
         $m = trim($m);
-        $ldapfilter .= '('.$FIELDS['*marker'].'='.$m.')';
+        $ldapfilter .= '('.$FIELDS['_marker'].'='.$m.')';
       }
       $ldapfilter .= ')';
     }elseif(!empty($search)){
index da161203ba55de6f3bae558b9749ae37bbf5f966..a1af7a98031a8db312d63b3cbb246ed9b8cdd2e4 100644 (file)
--- a/tags.php
+++ b/tags.php
     global $FIELDS;
     if(!$conf['extended']) return;
 
-    $result = ldap_queryabooks('(objectClass=inetOrgPerson)',$FIELDS['*marker']);
+    $result = ldap_queryabooks('(objectClass=inetOrgPerson)',$FIELDS['_marker']);
 
     $max = 0;
     $min = 999999999;
     $tags = array();
     foreach ($result as $entry){
-      if(!empty($entry[$FIELDS['*marker']]) && count($entry[$FIELDS['*marker']])){
-        foreach($entry[$FIELDS['*marker']] as $marker){
+      if(!empty($entry[$FIELDS['_marker']]) && count($entry[$FIELDS['_marker']])){
+        foreach($entry[$FIELDS['_marker']] as $marker){
           $marker = strtolower($marker);
           if (empty($tags[$marker])) { $tags[$marker]=0; }
           $tags[$marker] += 1;
index 03be9a9449b94fe1f6595599bb8840e85febcd41..5c74ed374b3df9e461ab7ac9e6f13f0d096200fd 100644 (file)
@@ -43,8 +43,8 @@ function tpl_entry($in){
   foreach($RFIELDS as $key => $name){
     if(empty($in[$key])) continue;
 
-    // keep arrays for starred fields
-    if($name{0} == '*'){
+    // keep arrays for multi fields
+    if($name{0} == '_'){
         $name  = substr($name,1);
         if(is_array($in[$key])){
             $out[$name] = $in[$key];
index ed68a4d113b7a55addc8a804b05aec3693256091..fe5c2d5760f02ea2aed0e64898fe260920e95c6e 100644 (file)
         </table>
       </dd></dl>
       {/if}
-              
+
       {if $conf.extended}
         {include file="extended_show.tpl"}
       {/if}