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'];
60 if(is_array($in['marker'])) $out['markers'] = join(', ',$in['marker']);
62 if ($conf[openxchange]){
63 //handle categories special in openxchange mode
64 $out['categories'] = $in['OXUserCategories'];
71 $smarty->assign('entry',$out);
75 * assigns the last LDAP error to the template
77 function tpl_ldaperror($message=""){
79 global $__LDAPERROR__;
81 $errno = ldap_errno($LDAP_CON);
83 $__LDAPERROR__ .= ldap_err2str($errno);
85 $__LDAPERROR__ .= "($message)";
87 $__LDAPERROR__ .= '\n';
89 $smarty->assign("LDAPERRORS",$__LDAPERROR__);
93 * assigns all markers to the template
95 function tpl_markers(){
100 if(!$conf[extended]) return;
104 $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=inetOrgPerson",array("marker"));
105 $result1 = ldap_get_binentries($LDAP_CON, $sr);
106 //check users private addressbook
107 if(!empty($_SESSION[ldapab][binddn])){
108 $sr = @ldap_list($LDAP_CON,
109 $conf[privatebook].','.$_SESSION[ldapab][binddn],
110 "ObjectClass=inetOrgPerson",array("marker"));
111 $result2 = ldap_get_binentries($LDAP_CON, $sr);
113 $result = array_merge($result1,$result2);
116 foreach ($result as $entry){
117 if(count($entry['marker'])){
118 foreach($entry['marker'] as $marker){
119 array_push($markers, $marker);
124 $markers = array_unique($markers);
125 sort($markers,SORT_STRING);
127 $smarty->assign('markers',$markers);
131 * Assigns all distinct organization names to the template
140 $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=inetOrgPerson",array("o"));
141 $result1 = ldap_get_binentries($LDAP_CON, $sr);
142 //check users private addressbook
143 if(!empty($_SESSION[ldapab][binddn])){
144 $sr = @ldap_list($LDAP_CON,
145 $conf[privatebook].','.$_SESSION[ldapab][binddn],
146 "ObjectClass=inetOrgPerson",array("o"));
147 $result2 = ldap_get_binentries($LDAP_CON, $sr);
149 $result = array_merge($result1,$result2);
152 foreach ($result as $entry){
153 if(!empty($entry[o][0])){
154 array_push($orgs, $entry[o][0]);
158 $orgs = array_unique($orgs);
159 sort($orgs,SORT_STRING);
160 $smarty->assign('orgs',$orgs);
164 * assigns all categories to the template
166 function tpl_categories(){
171 if(!$conf[openxchange]) return;
173 $categories = array();
175 $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=OXUserObject",array("OXUserCategories"));
176 $result1 = ldap_get_binentries($LDAP_CON, $sr);
177 //check users private addressbook
178 if(!empty($_SESSION[ldapab][binddn])){
179 $sr = @ldap_list($LDAP_CON,
180 $conf[privatebook].','.$_SESSION[ldapab][binddn],
181 "ObjectClass=OXUserObject",array("OXUserCategories"));
182 $result2 = ldap_get_binentries($LDAP_CON, $sr);
184 $result = array_merge($result1,$result2);
187 foreach ($result as $entry){
188 if(count($entry['OXUserCategories'])){
189 foreach($entry['OXUserCategories'] as $category){
190 array_push($categories, $category);
195 $categories = array_unique($categories);
196 sort($categories,SORT_STRING);
198 $smarty->assign('categories',$categories);
202 * assigns all timezones to the template
204 function tpl_timezone(){
209 if(!$conf[openxchange]) return;
213 $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=OXUserObject",array("OXTimeZone"));
214 $result1 = ldap_get_binentries($LDAP_CON, $sr);
215 //check users private addressbook
216 if(!empty($_SESSION[ldapab][binddn])){
217 $sr = @ldap_list($LDAP_CON,
218 $conf[privatebook].','.$_SESSION[ldapab][binddn],
219 "ObjectClass=OXUserObject",array("OXTimeZone"));
220 $result2 = ldap_get_binentries($LDAP_CON, $sr);
222 $result = array_merge($result1,$result2);
225 foreach ($result as $entry){
226 if(count($entry['OXTimeZone'])){
227 foreach($entry['OXTimeZone'] as $tz){
228 array_push($timezone, $tz);
233 $timezone = array_unique($timezone);
234 sort($timezone,SORT_STRING);
236 $smarty->assign('timezone',$timezone);
240 * assigns all countries to the template
242 function tpl_country(){
247 if(!$conf[openxchange]) return;
251 $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=OXUserObject",array("userCountry"));
252 $result1 = ldap_get_binentries($LDAP_CON, $sr);
253 //check users private addressbook
254 if(!empty($_SESSION[ldapab][binddn])){
255 $sr = @ldap_list($LDAP_CON,
256 $conf[privatebook].','.$_SESSION[ldapab][binddn],
257 "ObjectClass=OXUserObject",array("userCountry"));
258 $result2 = ldap_get_binentries($LDAP_CON, $sr);
260 $result = array_merge($result1,$result2);
263 foreach ($result as $entry){
264 if(count($entry['userCountry'])){
265 foreach($entry['userCountry'] as $c){
266 array_push($country, $c);
271 $country = array_unique($country);
272 sort($country,SORT_STRING);
274 $smarty->assign('country',$country);