2 require_once('init.php');
5 header('Content-Type: text/html; charset=utf-8');
7 if($_REQUEST['taglookup']){
8 ajax_taglookup($_REQUEST['taglookup']);
9 }elseif($_REQUEST['addnote']){
10 ajax_addnote($_REQUEST['addnote'],$_REQUEST['note']);
14 * Add a note to the existing notes
16 function ajax_addnote($dn,$note){
20 // fetch the existing note
21 $result = ldap_search($LDAP_CON,$dn,'(objectClass=inetOrgPerson)',array('description'));
22 if(ldap_count_entries($LDAP_CON,$result)){
23 $result = ldap_get_binentries($LDAP_CON, $result);
25 $note = $note."\n\n".$result[0]['description'][0];
26 $note = preg_replace("!\n\n\n+!","\n\n",$note);
28 $entry['description'] = $note;
29 ldap_modify($LDAP_CON,$dn,$entry);
32 require_once(dirname(__FILE__).'/smarty/plugins/modifier.noteparser.php');
33 print smarty_modifier_noteparser($note);
37 * Find all tags (markers) starting with the given
40 function ajax_taglookup($tag){
43 if(!$conf[extended]) return;
45 $search = ldap_filterescape($tag);
46 $filter = "(&(objectClass=contactPerson)(marker=$search*))";
47 $result = ldap_queryabooks($filter,'marker');
49 if(!count($result)) return;
52 foreach ($result as $entry){
53 if(count($entry['marker'])){
54 foreach($entry['marker'] as $marker){
55 if(preg_match('/^'.preg_quote($tag,'/').'/i',$marker)){
56 array_push($tags, strtolower($marker));
62 $tags = array_unique($tags);
63 sort($tags,SORT_STRING);
66 foreach($tags as $out){
67 print '<li>'.htmlspecialchars($out).'</li>';