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){
43 if(is_array($in[$key])){
44 $out[$entries[$key]] = $in[$key][0];
46 $out[$entries[$key]] = $in[$key];
52 $out['dn'] = normalize_dn($out['dn']);
53 $conf['publicbook'] = normalize_dn($conf['publicbook']);
55 if(strstr($out['dn'],$conf['publicbook'])){
56 $out['type'] = 'public';
58 $out['type'] = 'private';
62 //mail entries are handled special
63 $out['mail'] = $in['mail'];
64 if ($conf['extended']){
65 //handle marker special in extended mode
66 $out['marker'] = $in['marker'];
67 if(is_array($in['marker'])) $out['markers'] = join(', ',$in['marker']);
69 if ($conf['openxchange']){
70 //handle categories special in openxchange mode
71 $out['categories'] = $in['OXUserCategories'];
78 $smarty->assign('entry',$out);
82 * assigns the last LDAP error to the template
84 function tpl_ldaperror($message=""){
86 global $__LDAPERROR__;
88 $errno = ldap_errno($LDAP_CON);
90 $__LDAPERROR__ .= ldap_err2str($errno);
92 $__LDAPERROR__ .= "($message)";
94 $__LDAPERROR__ .= '\n';
96 $smarty->assign("LDAPERRORS",$__LDAPERROR__);
100 * assigns all markers to the template
102 function tpl_markers(){
107 if(!$conf['extended']) return;
111 $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=inetOrgPerson",array("marker"));
112 $result1 = ldap_get_binentries($LDAP_CON, $sr);
113 //check users private addressbook
114 if(!empty($_SESSION['ldapab']['binddn'])){
115 $sr = @ldap_list($LDAP_CON,
116 $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
117 "ObjectClass=inetOrgPerson",array("marker"));
118 $result2 = ldap_get_binentries($LDAP_CON, $sr);
120 $result = array_merge((array)$result1,(array)$result2);
123 foreach ($result as $entry){
124 if(count($entry['marker'])){
125 foreach($entry['marker'] as $marker){
126 array_push($markers, $marker);
131 $markers = array_unique($markers);
132 sort($markers,SORT_STRING);
134 $smarty->assign('markers',$markers);
138 * Assigns all distinct organization names to the template
147 $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=inetOrgPerson",array("o"));
148 $result1 = ldap_get_binentries($LDAP_CON, $sr);
149 //check users private addressbook
150 if(!empty($_SESSION['ldapab']['binddn'])){
151 $sr = @ldap_list($LDAP_CON,
152 $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
153 "ObjectClass=inetOrgPerson",array("o"));
154 $result2 = ldap_get_binentries($LDAP_CON, $sr);
156 $result = array_merge((array)$result1,(array)$result2);
159 foreach ($result as $entry){
160 if(!empty($entry['o'][0])){
161 array_push($orgs, $entry['o'][0]);
165 $orgs = array_unique($orgs);
166 sort($orgs,SORT_STRING);
167 $smarty->assign('orgs',$orgs);
171 * assigns all categories to the template
173 function tpl_categories(){
178 if(!$conf['openxchange']) return;
180 $categories = array();
182 $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=OXUserObject",array("OXUserCategories"));
183 $result1 = ldap_get_binentries($LDAP_CON, $sr);
184 //check users private addressbook
185 if(!empty($_SESSION['ldapab']['binddn'])){
186 $sr = @ldap_list($LDAP_CON,
187 $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
188 "ObjectClass=OXUserObject",array("OXUserCategories"));
189 $result2 = ldap_get_binentries($LDAP_CON, $sr);
191 $result = array_merge((array)$result1,(array)$result2);
194 foreach ($result as $entry){
195 if(count($entry['OXUserCategories'])){
196 foreach($entry['OXUserCategories'] as $category){
197 array_push($categories, $category);
202 $categories = array_unique($categories);
203 sort($categories,SORT_STRING);
205 $smarty->assign('categories',$categories);
209 * assigns all timezones to the template
211 function tpl_timezone(){
216 if(!$conf['openxchange']) return;
220 $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=OXUserObject",array("OXTimeZone"));
221 $result1 = ldap_get_binentries($LDAP_CON, $sr);
222 //check users private addressbook
223 if(!empty($_SESSION['ldapab']['binddn'])){
224 $sr = @ldap_list($LDAP_CON,
225 $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
226 "ObjectClass=OXUserObject",array("OXTimeZone"));
227 $result2 = ldap_get_binentries($LDAP_CON, $sr);
229 $result = array_merge((array)$result1,(array)$result2);
232 foreach ($result as $entry){
233 if(count($entry['OXTimeZone'])){
234 foreach($entry['OXTimeZone'] as $tz){
235 array_push($timezone, $tz);
240 $timezone = array_unique($timezone);
241 sort($timezone,SORT_STRING);
243 $smarty->assign('timezone',$timezone);
247 * assigns all countries to the template
249 function tpl_country(){
254 if(!$conf['openxchange']) return;
258 $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=OXUserObject",array("userCountry"));
259 $result1 = ldap_get_binentries($LDAP_CON, $sr);
260 //check users private addressbook
261 if(!empty($_SESSION['ldapab']['binddn'])){
262 $sr = @ldap_list($LDAP_CON,
263 $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
264 "ObjectClass=OXUserObject",array("userCountry"));
265 $result2 = ldap_get_binentries($LDAP_CON, $sr);
267 $result = array_merge((array)$result1,(array)$result2);
270 foreach ($result as $entry){
271 if(count($entry['userCountry'])){
272 foreach($entry['userCountry'] as $c){
273 array_push($country, $c);
278 $country = array_unique($country);
279 sort($country,SORT_STRING);
281 $smarty->assign('country',$country);