4 * assigns some standard variables to smarty templates
11 if(empty($_SESSION['ldapab']['username'])){
12 $_SESSION['ldapab']['username'] = '';
14 if(empty($_SESSION['ldapab']['binddn'])){
15 $_SESSION['ldapab']['binddn'] = '';
18 $smarty->assign('user',$_SESSION['ldapab']['username']);
19 $smarty->assign('binddn',$_SESSION['ldapab']['binddn']);
20 if(!empty($_SESSION['ldapab']['lastlocation'])){
21 $smarty->assign('home',$_SESSION['ldapab']['lastlocation']);
23 $smarty->assign('home','index.php');
25 $smarty->assign('conf',$conf);
26 $smarty->assign('lang',$lang);
27 //$smarty->assign('dfexample',$dfexample);
31 * assigns all the interesting data from an ldap result to
34 function tpl_entry($in){
37 $entries = namedentries();
40 //handle named entries
41 foreach(array_keys($entries) as $key){
42 if(!empty($in[$key])){
43 if(is_array($in[$key])){
44 $out[$entries[$key]] = $in[$key][0];
46 $out[$entries[$key]] = $in[$key];
52 if (empty($out['dn'])) { $out['dn']=''; }
53 $out['dn'] = normalize_dn($out['dn']);
54 $conf['publicbook'] = normalize_dn($conf['publicbook']);
56 if(strstr($out['dn'],$conf['publicbook'])){
57 $out['type'] = 'public';
59 $out['type'] = 'private';
63 //mail entries are handled specially
64 if (empty($in['mail'])) { $in['mail']=''; }
65 $out['mail'] = $in['mail'];
66 if ($conf['extended']){
67 //handle marker specially in extended mode
68 if (empty($in['marker'])) { $in['marker']=''; }
69 $out['marker'] = $in['marker'];
70 if(is_array($in['marker'])) $out['markers'] = join(', ',$in['marker']);
72 if ($conf['openxchange']){
73 //handle categories specially in openxchange mode
74 $out['categories'] = $in['OXUserCategories'];
81 $smarty->assign('entry',$out);
85 * assigns the last LDAP error to the template
87 function tpl_ldaperror($message=""){
89 global $__LDAPERROR__;
91 $errno = ldap_errno($LDAP_CON);
93 $__LDAPERROR__ .= ldap_err2str($errno);
95 $__LDAPERROR__ .= "($message)";
97 $__LDAPERROR__ .= '\n';
99 $smarty->assign("LDAPERRORS",$__LDAPERROR__);
103 * assigns all markers to the template
105 function tpl_markers(){
110 if(!$conf['extended']) return;
114 $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=inetOrgPerson",array("marker"));
115 $result1 = ldap_get_binentries($LDAP_CON, $sr);
116 //check users private addressbook
117 if(!empty($_SESSION['ldapab']['binddn'])){
118 $sr = @ldap_list($LDAP_CON,
119 $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
120 "ObjectClass=inetOrgPerson",array("marker"));
121 $result2 = ldap_get_binentries($LDAP_CON, $sr);
125 $result = array_merge((array)$result1,(array)$result2);
128 foreach ($result as $entry){
129 if(!empty($entry['marker']) && count($entry['marker'])){
130 foreach($entry['marker'] as $marker){
131 array_push($markers, $marker);
136 $markers = array_unique($markers);
137 sort($markers,SORT_STRING);
139 $smarty->assign('markers',$markers);
143 * Assigns all distinct organization names to the template
150 $f_entries = namedentries(true);
154 $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=inetOrgPerson",array($f_entries['organization']));
155 $result1 = ldap_get_binentries($LDAP_CON, $sr);
156 //check users private addressbook
157 if(!empty($_SESSION['ldapab']['binddn'])){
158 $sr = @ldap_list($LDAP_CON,
159 $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
160 "ObjectClass=inetOrgPerson",array($f_entries['organization']));
161 $result2 = ldap_get_binentries($LDAP_CON, $sr);
163 $result = array_merge((array)$result1,(array)$result2);
166 foreach ($result as $entry){
167 if(!empty($entry[$f_entries['organization']][0])){
168 array_push($orgs, $entry[$f_entries['organization']][0]);
172 $orgs = array_unique($orgs);
173 sort($orgs,SORT_STRING);
174 $smarty->assign('orgs',$orgs);
178 * assigns all categories to the template
180 function tpl_categories(){
185 if(!$conf['openxchange']) return;
187 $categories = array();
189 $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=OXUserObject",array("OXUserCategories"));
190 $result1 = ldap_get_binentries($LDAP_CON, $sr);
191 //check users private addressbook
192 if(!empty($_SESSION['ldapab']['binddn'])){
193 $sr = @ldap_list($LDAP_CON,
194 $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
195 "ObjectClass=OXUserObject",array("OXUserCategories"));
196 $result2 = ldap_get_binentries($LDAP_CON, $sr);
198 $result = array_merge((array)$result1,(array)$result2);
201 foreach ($result as $entry){
202 if(count($entry['OXUserCategories'])){
203 foreach($entry['OXUserCategories'] as $category){
204 array_push($categories, $category);
209 $categories = array_unique($categories);
210 sort($categories,SORT_STRING);
212 $smarty->assign('categories',$categories);
216 * assigns all timezones to the template
218 function tpl_timezone(){
223 if(!$conf['openxchange']) return;
227 $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=OXUserObject",array("OXTimeZone"));
228 $result1 = ldap_get_binentries($LDAP_CON, $sr);
229 //check users private addressbook
230 if(!empty($_SESSION['ldapab']['binddn'])){
231 $sr = @ldap_list($LDAP_CON,
232 $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
233 "ObjectClass=OXUserObject",array("OXTimeZone"));
234 $result2 = ldap_get_binentries($LDAP_CON, $sr);
236 $result = array_merge((array)$result1,(array)$result2);
239 foreach ($result as $entry){
240 if(count($entry['OXTimeZone'])){
241 foreach($entry['OXTimeZone'] as $tz){
242 array_push($timezone, $tz);
247 $timezone = array_unique($timezone);
248 sort($timezone,SORT_STRING);
250 $smarty->assign('timezone',$timezone);
254 * assigns all countries to the template
256 function tpl_country(){
261 if(!$conf['openxchange']) return;
265 $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=OXUserObject",array("userCountry"));
266 $result1 = ldap_get_binentries($LDAP_CON, $sr);
267 //check users private addressbook
268 if(!empty($_SESSION['ldapab']['binddn'])){
269 $sr = @ldap_list($LDAP_CON,
270 $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
271 "ObjectClass=OXUserObject",array("userCountry"));
272 $result2 = ldap_get_binentries($LDAP_CON, $sr);
274 $result = array_merge((array)$result1,(array)$result2);
277 foreach ($result as $entry){
278 if(count($entry['userCountry'])){
279 foreach($entry['userCountry'] as $c){
280 array_push($country, $c);
285 $country = array_unique($country);
286 sort($country,SORT_STRING);
288 $smarty->assign('country',$country);