';
print htmlspecialchars($tag);
print ' ';
}
}
/**
* Load current tags of an entry
*/
function ajax_loadtags($dn,$type='plain'){
global $conf;
global $LDAP_CON;
global $FIELDS;
if(!$FIELDS['_marker']) return;
header('Content-Type: text/html; charset=utf-8');
$sr = ldap_search($LDAP_CON,$dn,'(objectClass=inetOrgPerson)',array($FIELDS['_marker']));
if(!ldap_count_entries($LDAP_CON,$sr)) return false;
$result = ldap_get_binentries($LDAP_CON, $sr);
$entry = $result[0];
if($type == 'plain'){
echo join(', ',(array) $entry[$FIELDS['_marker']]);
}else{
foreach ((array) $entry[$FIELDS['_marker']] as $tag){
echo '';
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;
global $FIELDS;
if(!$FIELDS['_marker']) return;
$search = ldap_filterescape($tag);
$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[$FIELDS['_marker']])){
foreach($entry[$FIELDS['_marker']] as $marker){
if(preg_match('/^'.preg_quote($tag,'/').'/i',$marker)){
array_push($tags, strtolower($marker));
}
}
}
}
$tags = array_unique($tags);
sort($tags,SORT_STRING);
echo ''.NL;
echo ''.NL;
foreach($tags as $out){
echo '- '.NL;
echo ''.htmlspecialchars($out).''.NL;
echo ''.htmlspecialchars($out).''.NL;
echo '
'.NL;
}
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;
}
?>