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'];
67 utf8_decode_array($out);
73 $smarty->assign('entry',$out);
77 * assigns the last LDAP error to the template
79 function tpl_ldaperror($message=""){
81 global $__LDAPERROR__;
83 $errno = ldap_errno($LDAP_CON);
85 $__LDAPERROR__ .= ldap_err2str($errno);
87 $__LDAPERROR__ .= "($message)";
89 $__LDAPERROR__ .= '\n';
91 $smarty->assign("LDAPERRORS",$__LDAPERROR__);
95 * assigns all markers to the template
97 function tpl_markers(){
102 if(!$conf[extended]) return;
106 $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=inetOrgPerson",array("marker"));
107 $result1 = ldap_get_binentries($LDAP_CON, $sr);
108 //check users private addressbook
109 if(!empty($_SESSION[ldapab][binddn])){
110 $sr = @ldap_list($LDAP_CON,
111 $conf[privatebook].','.$_SESSION[ldapab][binddn],
112 "ObjectClass=inetOrgPerson",array("marker"));
113 $result2 = ldap_get_binentries($LDAP_CON, $sr);
115 $result = array_merge($result1,$result2);
118 foreach ($result as $entry){
119 if(count($entry['marker'])){
120 foreach($entry['marker'] as $marker){
121 array_push($markers, $marker);
126 $markers = array_unique($markers);
127 sort($markers,SORT_STRING);
129 utf8_decode_array($markers);
130 $smarty->assign('markers',$markers);
134 * Assigns all distinct organization names to the template
143 $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=inetOrgPerson",array("o"));
144 $result1 = ldap_get_binentries($LDAP_CON, $sr);
145 //check users private addressbook
146 if(!empty($_SESSION[ldapab][binddn])){
147 $sr = @ldap_list($LDAP_CON,
148 $conf[privatebook].','.$_SESSION[ldapab][binddn],
149 "ObjectClass=inetOrgPerson",array("o"));
150 $result2 = ldap_get_binentries($LDAP_CON, $sr);
152 $result = array_merge($result1,$result2);
155 foreach ($result as $entry){
156 if(!empty($entry[o][0])){
157 array_push($orgs, $entry[o][0]);
161 $orgs = array_unique($orgs);
162 sort($orgs,SORT_STRING);
163 utf8_decode_array($orgs);
164 $smarty->assign('orgs',$orgs);
168 * assigns all categories to the template
170 function tpl_categories(){
175 if(!$conf[openxchange]) return;
177 $categories = array();
179 $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=OXUserObject",array("OXUserCategories"));
180 $result1 = ldap_get_binentries($LDAP_CON, $sr);
181 //check users private addressbook
182 if(!empty($_SESSION[ldapab][binddn])){
183 $sr = @ldap_list($LDAP_CON,
184 $conf[privatebook].','.$_SESSION[ldapab][binddn],
185 "ObjectClass=OXUserObject",array("OXUserCategories"));
186 $result2 = ldap_get_binentries($LDAP_CON, $sr);
188 $result = array_merge($result1,$result2);
191 foreach ($result as $entry){
192 if(count($entry['OXUserCategories'])){
193 foreach($entry['OXUserCategories'] as $category){
194 array_push($categories, $category);
199 $categories = array_unique($categories);
200 sort($categories,SORT_STRING);
202 utf8_decode_array($categories);
203 $smarty->assign('categories',$categories);
207 * assigns all timezones to the template
209 function tpl_timezone(){
214 if(!$conf[openxchange]) return;
218 $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=OXUserObject",array("OXTimeZone"));
219 $result1 = ldap_get_binentries($LDAP_CON, $sr);
220 //check users private addressbook
221 if(!empty($_SESSION[ldapab][binddn])){
222 $sr = @ldap_list($LDAP_CON,
223 $conf[privatebook].','.$_SESSION[ldapab][binddn],
224 "ObjectClass=OXUserObject",array("OXTimeZone"));
225 $result2 = ldap_get_binentries($LDAP_CON, $sr);
227 $result = array_merge($result1,$result2);
230 foreach ($result as $entry){
231 if(count($entry['OXTimeZone'])){
232 foreach($entry['OXTimeZone'] as $tz){
233 array_push($timezone, $tz);
238 $timezone = array_unique($timezone);
239 sort($timezone,SORT_STRING);
241 utf8_decode_array($timezone);
242 $smarty->assign('timezone',$timezone);
246 * assigns all countries to the template
248 function tpl_country(){
253 if(!$conf[openxchange]) return;
257 $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=OXUserObject",array("userCountry"));
258 $result1 = ldap_get_binentries($LDAP_CON, $sr);
259 //check users private addressbook
260 if(!empty($_SESSION[ldapab][binddn])){
261 $sr = @ldap_list($LDAP_CON,
262 $conf[privatebook].','.$_SESSION[ldapab][binddn],
263 "ObjectClass=OXUserObject",array("userCountry"));
264 $result2 = ldap_get_binentries($LDAP_CON, $sr);
266 $result = array_merge($result1,$result2);
269 foreach ($result as $entry){
270 if(count($entry['userCountry'])){
271 foreach($entry['userCountry'] as $c){
272 array_push($country, $c);
277 $country = array_unique($country);
278 sort($country,SORT_STRING);
280 utf8_decode_array($country);
281 $smarty->assign('country',$country);