]> git.sur5r.net Git - contagged/blobdiff - template.php
PHP5 notice cleanups
[contagged] / template.php
index 06fe3d0cebdeacbc4482d4e47cfda46c5dfeb3e4..f0fe1fa75a86a94523c6435bef2bd56b0fa17638 100644 (file)
@@ -8,16 +8,23 @@ function tpl_std(){
   global $lang;
   global $conf;
 
-  $smarty->assign('user',$_SESSION[ldapab][username]);
-  $smarty->assign('binddn',$_SESSION[ldapab][binddn]);
-  if(!empty($_SESSION[ldapab][lastlocation])){
-    $smarty->assign('home',$_SESSION[ldapab][lastlocation]);
+  if(empty($_SESSION['ldapab']['username'])){
+    $_SESSION['ldapab']['username'] = '';
+  }
+  if(empty($_SESSION['ldapab']['binddn'])){
+    $_SESSION['ldapab']['binddn'] = '';
+  }
+
+  $smarty->assign('user',$_SESSION['ldapab']['username']);
+  $smarty->assign('binddn',$_SESSION['ldapab']['binddn']);
+  if(!empty($_SESSION['ldapab']['lastlocation'])){
+    $smarty->assign('home',$_SESSION['ldapab']['lastlocation']);
   }else{
      $smarty->assign('home','index.php');
   }
   $smarty->assign('conf',$conf);
   $smarty->assign('lang',$lang);
-  $smarty->assign('dfexample',$dfexample);
+  //$smarty->assign('dfexample',$dfexample);
 }
 
 /**
@@ -28,11 +35,11 @@ function tpl_entry($in){
   global $smarty;
   global $conf;
   $entries = namedentries();
-
+  $out=array();
 
   //handle named entries
   foreach(array_keys($entries) as $key){
-    if($in[$key]){
+    if(!empty($in[$key])){
       if(is_array($in[$key])){
         $out[$entries[$key]] = $in[$key][0];
       }else{
@@ -42,25 +49,28 @@ function tpl_entry($in){
   }
 
   //set the type
-  $out['dn']        = normalize_dn($out['dn']);
-  $conf[publicbook] = normalize_dn($conf[publicbook]);
+  if (empty($out['dn'])) { $out['dn']=''; }
+  $out['dn']          = normalize_dn($out['dn']);
+  $conf['publicbook'] = normalize_dn($conf['publicbook']);
   if($out['dn']){
-    if(strstr($out['dn'],$conf[publicbook])){
-      $out[type] = 'public';
+    if(strstr($out['dn'],$conf['publicbook'])){
+      $out['type'] = 'public';
     }else{
-      $out[type] = 'private';
+      $out['type'] = 'private';
     }
   }
 
-  //mail entries are handled special
+  //mail entries are handled specially
+  if (empty($in['mail'])) { $in['mail']=''; }
   $out['mail'] = $in['mail'];
-  if ($conf[extended]){
-    //handle marker special in extended mode
+  if ($conf['extended']){
+    //handle marker specially in extended mode
+    if (empty($in['marker'])) { $in['marker']=''; }
     $out['marker'] = $in['marker'];
     if(is_array($in['marker'])) $out['markers'] = join(', ',$in['marker']);
   }
-  if ($conf[openxchange]){
-    //handle categories special in openxchange mode
+  if ($conf['openxchange']){
+    //handle categories specially in openxchange mode
     $out['categories'] = $in['OXUserCategories'];
   }
 
@@ -97,24 +107,26 @@ function tpl_markers(){
   global $LDAP_CON;
   global $smarty;
 
-  if(!$conf[extended]) return;
+  if(!$conf['extended']) return;
 
   $markers = array();
 
-  $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=inetOrgPerson",array("marker"));
+  $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=inetOrgPerson",array("marker"));
   $result1 = ldap_get_binentries($LDAP_CON, $sr);
   //check users private addressbook
-  if(!empty($_SESSION[ldapab][binddn])){
+  if(!empty($_SESSION['ldapab']['binddn'])){
     $sr = @ldap_list($LDAP_CON,
-                    $conf[privatebook].','.$_SESSION[ldapab][binddn],
+                    $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
                     "ObjectClass=inetOrgPerson",array("marker"));
     $result2 = ldap_get_binentries($LDAP_CON, $sr);
+  }else{
+    $result2 = '';
   }
-  $result = array_merge($result1,$result2);
+  $result = array_merge((array)$result1,(array)$result2);
 
   if(count($result)){
     foreach ($result as $entry){
-      if(count($entry['marker'])){
+      if(!empty($entry['marker']) && count($entry['marker'])){
         foreach($entry['marker'] as $marker){
           array_push($markers, $marker);
         }
@@ -137,21 +149,21 @@ function tpl_orgs(){
 
   $orgs = array();
 
-  $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=inetOrgPerson",array("o"));
+  $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=inetOrgPerson",array("o"));
   $result1 = ldap_get_binentries($LDAP_CON, $sr);
   //check users private addressbook
-  if(!empty($_SESSION[ldapab][binddn])){
+  if(!empty($_SESSION['ldapab']['binddn'])){
     $sr = @ldap_list($LDAP_CON,
-                    $conf[privatebook].','.$_SESSION[ldapab][binddn],
+                    $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
                     "ObjectClass=inetOrgPerson",array("o"));
     $result2 = ldap_get_binentries($LDAP_CON, $sr);
   }
-  $result = array_merge($result1,$result2);
+  $result = array_merge((array)$result1,(array)$result2);
 
   if(count($result)){
     foreach ($result as $entry){
-      if(!empty($entry[o][0])){
-        array_push($orgs, $entry[o][0]);
+      if(!empty($entry['o'][0])){
+        array_push($orgs, $entry['o'][0]);
       }
     }
   }
@@ -168,20 +180,20 @@ function tpl_categories(){
   global $LDAP_CON;
   global $smarty;
 
-  if(!$conf[openxchange]) return;
+  if(!$conf['openxchange']) return;
 
   $categories = array();
 
-  $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=OXUserObject",array("OXUserCategories"));
+  $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=OXUserObject",array("OXUserCategories"));
   $result1 = ldap_get_binentries($LDAP_CON, $sr);
   //check users private addressbook
-  if(!empty($_SESSION[ldapab][binddn])){
+  if(!empty($_SESSION['ldapab']['binddn'])){
     $sr = @ldap_list($LDAP_CON,
-                    $conf[privatebook].','.$_SESSION[ldapab][binddn],
+                    $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
                     "ObjectClass=OXUserObject",array("OXUserCategories"));
     $result2 = ldap_get_binentries($LDAP_CON, $sr);
   }
-  $result = array_merge($result1,$result2);
+  $result = array_merge((array)$result1,(array)$result2);
 
   if(count($result)){
     foreach ($result as $entry){
@@ -206,20 +218,20 @@ function tpl_timezone(){
   global $LDAP_CON;
   global $smarty;
 
-  if(!$conf[openxchange]) return;
+  if(!$conf['openxchange']) return;
 
   $timezone = array();
 
-  $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=OXUserObject",array("OXTimeZone"));
+  $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=OXUserObject",array("OXTimeZone"));
   $result1 = ldap_get_binentries($LDAP_CON, $sr);
   //check users private addressbook
-  if(!empty($_SESSION[ldapab][binddn])){
+  if(!empty($_SESSION['ldapab']['binddn'])){
     $sr = @ldap_list($LDAP_CON,
-                    $conf[privatebook].','.$_SESSION[ldapab][binddn],
+                    $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
                     "ObjectClass=OXUserObject",array("OXTimeZone"));
     $result2 = ldap_get_binentries($LDAP_CON, $sr);
   }
-  $result = array_merge($result1,$result2);
+  $result = array_merge((array)$result1,(array)$result2);
 
   if(count($result)){
     foreach ($result as $entry){
@@ -244,20 +256,20 @@ function tpl_country(){
   global $LDAP_CON;
   global $smarty;
 
-  if(!$conf[openxchange]) return;
+  if(!$conf['openxchange']) return;
 
   $country = array();
 
-  $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=OXUserObject",array("userCountry"));
+  $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=OXUserObject",array("userCountry"));
   $result1 = ldap_get_binentries($LDAP_CON, $sr);
   //check users private addressbook
-  if(!empty($_SESSION[ldapab][binddn])){
+  if(!empty($_SESSION['ldapab']['binddn'])){
     $sr = @ldap_list($LDAP_CON,
-                    $conf[privatebook].','.$_SESSION[ldapab][binddn],
+                    $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
                     "ObjectClass=OXUserObject",array("userCountry"));
     $result2 = ldap_get_binentries($LDAP_CON, $sr);
   }
-  $result = array_merge($result1,$result2);
+  $result = array_merge((array)$result1,(array)$result2);
 
   if(count($result)){
     foreach ($result as $entry){