4 * assigns some standard variables to smarty templates
11 $smarty->assign('user',$_SESSION[ldapab][username]);
12 $smarty->assign('binddn',$_SESSION[ldapab][binddn]);
13 if(!empty($_SESSION[ldapab][lastlocation])){
14 $smarty->assign('home',$_SESSION[ldapab][lastlocation]);
16 $smarty->assign('home','index.php');
18 $smarty->assign('conf',$conf);
19 $smarty->assign('lang',$lang);
20 $smarty->assign('dfexample',$dfexample);
24 * assigns all the interesting data from an ldap result to
27 function tpl_entry($in){
30 $entries = namedentries();
33 //handle named entries
34 foreach(array_keys($entries) as $key){
36 if(is_array($in[$key])){
37 $out[$entries[$key]] = $in[$key][0];
39 $out[$entries[$key]] = $in[$key];
45 $out['dn'] = normalize_dn($out['dn']);
46 $conf[publicbook] = normalize_dn($conf[publicbook]);
48 if(strstr($out['dn'],$conf[publicbook])){
49 $out[type] = 'public';
51 $out[type] = 'private';
55 //mail entries are handled special
56 $out['mail'] = $in['mail'];
58 //handle marker special in extended mode
59 $out['marker'] = $in['marker'];
63 utf8_decode_array($out);
69 $smarty->assign('entry',$out);
73 * assigns the last LDAP error to the template
75 function tpl_ldaperror($message=""){
77 global $__LDAPERROR__;
79 $errno = ldap_errno($LDAP_CON);
81 $__LDAPERROR__ .= ldap_err2str($errno);
83 $__LDAPERROR__ .= "($message)";
85 $__LDAPERROR__ .= '\n';
87 $smarty->assign("LDAPERRORS",$__LDAPERROR__);
91 * assigns all markers to the template
93 function tpl_markers(){
98 if(!$conf[extended]) return;
102 $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=inetOrgPerson",array("marker"));
103 $result1 = ldap_get_binentries($LDAP_CON, $sr);
104 //check users private addressbook
105 if(!empty($_SESSION[ldapab][binddn])){
106 $sr = @ldap_list($LDAP_CON,
107 $conf[privatebook].','.$_SESSION[ldapab][binddn],
108 "ObjectClass=inetOrgPerson",array("marker"));
109 $result2 = ldap_get_binentries($LDAP_CON, $sr);
111 $result = array_merge($result1,$result2);
114 foreach ($result as $entry){
115 if(count($entry['marker'])){
116 foreach($entry['marker'] as $marker){
117 array_push($markers, $marker);
122 $markers = array_unique($markers);
123 sort($markers,SORT_STRING);
125 utf8_decode_array($markers);
126 $smarty->assign('markers',$markers);
130 * Assigns all distinct organization names to the template
139 $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=inetOrgPerson",array("o"));
140 $result1 = ldap_get_binentries($LDAP_CON, $sr);
141 //check users private addressbook
142 if(!empty($_SESSION[ldapab][binddn])){
143 $sr = @ldap_list($LDAP_CON,
144 $conf[privatebook].','.$_SESSION[ldapab][binddn],
145 "ObjectClass=inetOrgPerson",array("o"));
146 $result2 = ldap_get_binentries($LDAP_CON, $sr);
148 $result = array_merge($result1,$result2);
151 foreach ($result as $entry){
152 if(!empty($entry[o][0])){
153 array_push($orgs, $entry[o][0]);
157 $orgs = array_unique($orgs);
158 sort($orgs,SORT_STRING);
159 utf8_decode_array($orgs);
160 $smarty->assign('orgs',$orgs);