From: Andreas Gohr Date: Wed, 16 May 2007 11:10:30 +0000 (+0200) Subject: changed multifield character from * to _ X-Git-Tag: 0.7.1~72 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e37e9f402048983cda6227130186cd5b2d64a488;p=contagged changed multifield character from * to _ darcs-hash:20070516111030-6e07b-690dfdbe1729002589da0f891dde7ea05dba413c.gz --- diff --git a/ajax.php b/ajax.php index e26031b..7310180 100644 --- 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)); } diff --git a/entry.php b/entry.php index eaeedba..ec73909 100644 --- 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]); diff --git a/fields.php b/fields.php index a87efa0..f5ee662 100644 --- a/fields.php +++ b/fields.php @@ -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'; */ diff --git a/functions.php b/functions.php index c8de367..671fca4 100644 --- a/functions.php +++ b/functions.php @@ -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) diff --git a/index.php b/index.php index 43ae1b0..01eeb47 100644 --- a/index.php +++ b/index.php @@ -115,7 +115,7 @@ $marker = explode(',',$marker); foreach($marker as $m){ $m = trim($m); - $ldapfilter .= '('.$FIELDS['*marker'].'='.$m.')'; + $ldapfilter .= '('.$FIELDS['_marker'].'='.$m.')'; } $ldapfilter .= ')'; }elseif(!empty($search)){ diff --git a/tags.php b/tags.php index da16120..a1af7a9 100644 --- a/tags.php +++ b/tags.php @@ -15,14 +15,14 @@ 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; diff --git a/template.php b/template.php index 03be9a9..5c74ed3 100644 --- a/template.php +++ b/template.php @@ -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]; diff --git a/templates/entry_show.tpl b/templates/entry_show.tpl index ed68a4d..fe5c2d5 100644 --- a/templates/entry_show.tpl +++ b/templates/entry_show.tpl @@ -102,7 +102,7 @@ {/if} - + {if $conf.extended} {include file="extended_show.tpl"} {/if}