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
152 $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=inetOrgPerson",array("o"));
153 $result1 = ldap_get_binentries($LDAP_CON, $sr);
154 //check users private addressbook
155 if(!empty($_SESSION['ldapab']['binddn'])){
156 $sr = @ldap_list($LDAP_CON,
157 $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
158 "ObjectClass=inetOrgPerson",array("o"));
159 $result2 = ldap_get_binentries($LDAP_CON, $sr);
161 $result = array_merge((array)$result1,(array)$result2);
164 foreach ($result as $entry){
165 if(!empty($entry['o'][0])){
166 array_push($orgs, $entry['o'][0]);
170 $orgs = array_unique($orgs);
171 sort($orgs,SORT_STRING);
172 $smarty->assign('orgs',$orgs);
176 * assigns all categories to the template
178 function tpl_categories(){
183 if(!$conf['openxchange']) return;
185 $categories = array();
187 $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=OXUserObject",array("OXUserCategories"));
188 $result1 = ldap_get_binentries($LDAP_CON, $sr);
189 //check users private addressbook
190 if(!empty($_SESSION['ldapab']['binddn'])){
191 $sr = @ldap_list($LDAP_CON,
192 $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
193 "ObjectClass=OXUserObject",array("OXUserCategories"));
194 $result2 = ldap_get_binentries($LDAP_CON, $sr);
196 $result = array_merge((array)$result1,(array)$result2);
199 foreach ($result as $entry){
200 if(count($entry['OXUserCategories'])){
201 foreach($entry['OXUserCategories'] as $category){
202 array_push($categories, $category);
207 $categories = array_unique($categories);
208 sort($categories,SORT_STRING);
210 $smarty->assign('categories',$categories);
214 * assigns all timezones to the template
216 function tpl_timezone(){
221 if(!$conf['openxchange']) return;
225 $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=OXUserObject",array("OXTimeZone"));
226 $result1 = ldap_get_binentries($LDAP_CON, $sr);
227 //check users private addressbook
228 if(!empty($_SESSION['ldapab']['binddn'])){
229 $sr = @ldap_list($LDAP_CON,
230 $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
231 "ObjectClass=OXUserObject",array("OXTimeZone"));
232 $result2 = ldap_get_binentries($LDAP_CON, $sr);
234 $result = array_merge((array)$result1,(array)$result2);
237 foreach ($result as $entry){
238 if(count($entry['OXTimeZone'])){
239 foreach($entry['OXTimeZone'] as $tz){
240 array_push($timezone, $tz);
245 $timezone = array_unique($timezone);
246 sort($timezone,SORT_STRING);
248 $smarty->assign('timezone',$timezone);
252 * assigns all countries to the template
254 function tpl_country(){
259 if(!$conf['openxchange']) return;
263 $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=OXUserObject",array("userCountry"));
264 $result1 = ldap_get_binentries($LDAP_CON, $sr);
265 //check users private addressbook
266 if(!empty($_SESSION['ldapab']['binddn'])){
267 $sr = @ldap_list($LDAP_CON,
268 $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
269 "ObjectClass=OXUserObject",array("userCountry"));
270 $result2 = ldap_get_binentries($LDAP_CON, $sr);
272 $result = array_merge((array)$result1,(array)$result2);
275 foreach ($result as $entry){
276 if(count($entry['userCountry'])){
277 foreach($entry['userCountry'] as $c){
278 array_push($country, $c);
283 $country = array_unique($country);
284 sort($country,SORT_STRING);
286 $smarty->assign('country',$country);