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'];
61 if ($conf[openxchange]){
62 //handle categories special in openxchange mode
63 $out['categories'] = $in['OXUserCategories'];
70 $smarty->assign('entry',$out);
74 * assigns the last LDAP error to the template
76 function tpl_ldaperror($message=""){
78 global $__LDAPERROR__;
80 $errno = ldap_errno($LDAP_CON);
82 $__LDAPERROR__ .= ldap_err2str($errno);
84 $__LDAPERROR__ .= "($message)";
86 $__LDAPERROR__ .= '\n';
88 $smarty->assign("LDAPERRORS",$__LDAPERROR__);
92 * assigns all markers to the template
94 function tpl_markers(){
99 if(!$conf[extended]) return;
103 $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=inetOrgPerson",array("marker"));
104 $result1 = ldap_get_binentries($LDAP_CON, $sr);
105 //check users private addressbook
106 if(!empty($_SESSION[ldapab][binddn])){
107 $sr = @ldap_list($LDAP_CON,
108 $conf[privatebook].','.$_SESSION[ldapab][binddn],
109 "ObjectClass=inetOrgPerson",array("marker"));
110 $result2 = ldap_get_binentries($LDAP_CON, $sr);
112 $result = array_merge($result1,$result2);
115 foreach ($result as $entry){
116 if(count($entry['marker'])){
117 foreach($entry['marker'] as $marker){
118 array_push($markers, $marker);
123 $markers = array_unique($markers);
124 sort($markers,SORT_STRING);
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 $smarty->assign('orgs',$orgs);
163 * assigns all categories to the template
165 function tpl_categories(){
170 if(!$conf[openxchange]) return;
172 $categories = array();
174 $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=OXUserObject",array("OXUserCategories"));
175 $result1 = ldap_get_binentries($LDAP_CON, $sr);
176 //check users private addressbook
177 if(!empty($_SESSION[ldapab][binddn])){
178 $sr = @ldap_list($LDAP_CON,
179 $conf[privatebook].','.$_SESSION[ldapab][binddn],
180 "ObjectClass=OXUserObject",array("OXUserCategories"));
181 $result2 = ldap_get_binentries($LDAP_CON, $sr);
183 $result = array_merge($result1,$result2);
186 foreach ($result as $entry){
187 if(count($entry['OXUserCategories'])){
188 foreach($entry['OXUserCategories'] as $category){
189 array_push($categories, $category);
194 $categories = array_unique($categories);
195 sort($categories,SORT_STRING);
197 $smarty->assign('categories',$categories);
201 * assigns all timezones to the template
203 function tpl_timezone(){
208 if(!$conf[openxchange]) return;
212 $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=OXUserObject",array("OXTimeZone"));
213 $result1 = ldap_get_binentries($LDAP_CON, $sr);
214 //check users private addressbook
215 if(!empty($_SESSION[ldapab][binddn])){
216 $sr = @ldap_list($LDAP_CON,
217 $conf[privatebook].','.$_SESSION[ldapab][binddn],
218 "ObjectClass=OXUserObject",array("OXTimeZone"));
219 $result2 = ldap_get_binentries($LDAP_CON, $sr);
221 $result = array_merge($result1,$result2);
224 foreach ($result as $entry){
225 if(count($entry['OXTimeZone'])){
226 foreach($entry['OXTimeZone'] as $tz){
227 array_push($timezone, $tz);
232 $timezone = array_unique($timezone);
233 sort($timezone,SORT_STRING);
235 $smarty->assign('timezone',$timezone);
239 * assigns all countries to the template
241 function tpl_country(){
246 if(!$conf[openxchange]) return;
250 $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=OXUserObject",array("userCountry"));
251 $result1 = ldap_get_binentries($LDAP_CON, $sr);
252 //check users private addressbook
253 if(!empty($_SESSION[ldapab][binddn])){
254 $sr = @ldap_list($LDAP_CON,
255 $conf[privatebook].','.$_SESSION[ldapab][binddn],
256 "ObjectClass=OXUserObject",array("userCountry"));
257 $result2 = ldap_get_binentries($LDAP_CON, $sr);
259 $result = array_merge($result1,$result2);
262 foreach ($result as $entry){
263 if(count($entry['userCountry'])){
264 foreach($entry['userCountry'] as $c){
265 array_push($country, $c);
270 $country = array_unique($country);
271 sort($country,SORT_STRING);
273 $smarty->assign('country',$country);