X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=ajax.php;h=7e16b2f362d974e83880650600bb9ebea1739c09;hb=664038cd66746a147e0b71b31a7f9bc1d6a27d3b;hp=fafe45a8a5fc39fa06931f350943dae5ee881fb7;hpb=439e00339297df6cd512cb876b6ba6cf3af1f4f7;p=contagged diff --git a/ajax.php b/ajax.php index fafe45a..7e16b2f 100644 --- a/ajax.php +++ b/ajax.php @@ -1,15 +1,20 @@ '; + echo htmlspecialchars($tag); + echo ' '; + } + } +} + /** * Find all tags (markers) starting with the given * string */ function ajax_taglookup($tag){ + header('Content-Type: text/xml; charset=utf-8'); global $conf; global $LDAP_CON; - if(!$conf[extended]) return; + global $FIELDS; + 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)); } @@ -89,11 +131,53 @@ function ajax_taglookup($tag){ $tags = array_unique($tags); sort($tags,SORT_STRING); - print ''; + echo ''.NL; +} + +/** + * Do a simple lookup in any simple field + */ +function ajax_lookup($field,$search){ + header('Content-Type: text/xml; charset=utf-8'); + global $conf; + global $LDAP_CON; + global $FIELDS; + + if(!$FIELDS[$field]) return; + $field = $FIELDS[$field]; + + $search = ldap_filterescape($search); + $filter = "(&(objectClass=inetOrgPerson)($field=$search*))"; + $result = ldap_queryabooks($filter,$field); + if(!count($result)) return; + + $items = array(); + foreach ($result as $entry){ + if(isset($entry[$field]) && !empty($entry[$field])){ + $items[] = $entry[$field][0]; + } + } + + $items = array_unique($items); + sort($items,SORT_STRING); + + echo ''.NL; + echo ''.NL; + foreach($items as $out){ + echo ''.NL; + echo ''.htmlspecialchars($out).''.NL; + echo ''.htmlspecialchars($out).''.NL; + echo ''.NL; + } + echo ''.NL; } ?>