Code

Removed old menu parsing
[gosa.git] / plugins / admin / users / class_userManagement.inc
index e9460770be246ff41b49ed7e3253390bae883007..fbc3ab56b9cf4df74d5b90d7de1b40ffb2cf73f6 100644 (file)
@@ -61,6 +61,7 @@ class userManagement extends plugin
   {
        /* Call parent execute */
        plugin::execute();
+
     $smarty       = get_smarty();             // Smarty instance
     $userfilter   = get_global("userfilter"); // contains Filter Settings
     $s_action     = "";                       // Contains the action to proceed
@@ -520,7 +521,8 @@ class userManagement extends plugin
       }
 
       /* Use template if there are any of them */
-      if ((count($this->templates) && !isset($_POST['new_template']))||($s_action=="create_user_from_tpl")){
+  
+      if ((count($this->templates) && ($s_action!='new_tpl'))||($s_action=="create_user_from_tpl")){
         foreach(array("sn", "givenName", "uid", "got_uid", "templates") as $attr){
           $smarty->assign("$attr", $this->$attr);
         }
@@ -665,15 +667,15 @@ class userManagement extends plugin
 
     /* NEW LIST MANAGMENT */
     $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
-      " <input type='image' align='middle' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'>&nbsp;".
-      " <input type='image' src='images/list_root.png' align='middle' title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'>&nbsp;".
-      " <input type='image' align='middle' src='images/list_home.png' title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'>&nbsp;".
-      " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
-      " <input type='image' align='middle' src='images/list_new_user.png' title='"._("Create new user")."' alt='"._("New user")."' name='user_new'>&nbsp;".
-      " <input type='image' align='middle' src='images/list_new.png' title='"._("Create new template")."' alt='"._("New template")."' name='user_tplnew'>&nbsp;".
-      " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
+      " <input class='center' type='image' align='middle' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'>&nbsp;".
+      " <input class='center' type='image' src='images/list_root.png' align='middle' title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'>&nbsp;".
+      " <input class='center' type='image' align='middle' src='images/list_home.png' title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'>&nbsp;".
+      " <img   class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
+      " <input class='center' type='image' align='middle' src='images/list_new_user.png' title='"._("Create new user")."' alt='"._("New user")."' name='user_new'>&nbsp;".
+      " <input class='center' type='image' align='middle' src='images/list_new.png' title='"._("Create new template")."' alt='"._("New template")."' name='user_tplnew'>&nbsp;".
+      " <img   class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
       _("Current base")."&nbsp;<select name='depselect' onChange='mainform.submit()'>$options</select>".
-      " <input type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
+      " <input class='center' type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
       "</div>";
 
     $action= "<input type='image' src='images/edit.png' alt='"._("edit")."'     name='user_edit_%KEY%' title='"._("Edit user")."'>";
@@ -684,10 +686,10 @@ class userManagement extends plugin
 
     $divlist = new divlist("userstab");
     $divlist->SetHeader(array(
-          array("string" => "&nbsp;"),
-          array("string" => _("Username")." / "._("Department")),
-          array("string" => _("Properties")),
-          array("string" => _("Actions"), "attach" => "style='border:none'" )));
+          array("string" => "&nbsp;", "attach" => "style='text-align:center;width:20px;'"),
+          array("string" => _("Username")." / "._("Department"), "attach" => "style=''"),
+          array("string" => _("Properties"), "attach" => "style='width:152px;'"),
+          array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'")));
 
 
     $divlist->SetSummary(_("This table displays all users, in the selected tree."));
@@ -711,10 +713,10 @@ class userManagement extends plugin
         }
       }
 
-      $field1 = array("string" => "<img src='images/".$non_empty."folder.png' alt='department'>");
-      $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val));
-      $field3 = array("string" => "&nbsp;");
-      $field4 = array("string" => "&nbsp;", "attach" => "style='border:none'");
+      $field1 = array("string" => "<img src='images/".$non_empty."folder.png' alt='department'>", "attach" => "style='text-align:center;width:20px;'");
+      $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style=''");
+      $field3 = array("string" => "&nbsp;", "attach" => "style='width:152px;'");
+      $field4 = array("string" => "&nbsp;", "attach" => "style='width:60px;border-right:0px;text-align:right;'");
 
 
       $divlist->AddEntry(array($field1,$field2,$field3,$field4));
@@ -767,10 +769,14 @@ class userManagement extends plugin
       /* 
         If you want to disable the status pictures, just comment out the next line
       */
-      $r_con= @mysql_pconnect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']);
-      // Check if we are  connected correctly
-      if($r_con){
-        $r_db  =  @mysql_select_db($a_SETUP['DB'],$r_con);
+      $r_con = false;
+      $r_db  = false;
+      if(is_callable("mysql_pconnect")){
+        $r_con= @mysql_pconnect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']);
+        // Check if we are  connected correctly
+        if($r_con){
+          $r_db  =  @mysql_select_db($a_SETUP['DB'],$r_con);
+        }
       }
     }
 
@@ -786,7 +792,7 @@ class userManagement extends plugin
         $fonac = preg_replace("/%title%/", "", $fonac);
 
         /* Database connection is ok ?*/
-        if($r_db){
+        if(($r_db)&&(is_callable("mysql_query"))){
           $res= @mysql_query("SELECT regseconds,name,port,ipaddr FROM ".$a_SETUP['SIP_TABLE']." WHERE (name='".$val['uid'][0]."')");
           $mysql_entry = @mysql_fetch_row($res);
           if(is_array($mysql_entry)){
@@ -860,10 +866,10 @@ class userManagement extends plugin
       }
 
       /* Create each field */
-      $field1 = array("string" => sprintf($tpl,$val['dn']),"attach"=>"style='width:20px;align:middle;'");
-      $field2 = array("string" => sprintf($editlink,$key,$display).$ip_port,"attach"=>"title='".$val['dn']."'");
-      $field3 = array("string" => $usrimg2."&nbsp;".$posix."&nbsp;".$enviro."&nbsp;".$maila."&nbsp;".$fonac."&nbsp;".$faxac."&nbsp;".$samba."&nbsp;".$s_img_create_from_template, "attach" => "style='width:155px;'");
-      $field4 = array("string" => preg_replace("/%KEY%/", "$key", $action),"attach" => "style='border:none; text-align:right;width:48px'");
+      $field1 = array("string" => sprintf($tpl,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
+      $field2 = array("string" => sprintf($editlink,$key,$display).$ip_port, "attach" => "style='' title='".$val['dn']."'");
+      $field3 = array("string" => $usrimg2."&nbsp;".$posix."&nbsp;".$enviro."&nbsp;".$maila."&nbsp;".$fonac."&nbsp;".$faxac."&nbsp;".$samba."&nbsp;".$s_img_create_from_template, "attach" => "style='width:152px;'");
+      $field4 = array("string" => preg_replace("/%KEY%/", "$key", $action),"attach" => "style='width:60px;border-right:0px;text-align:right;'");
 
       $add = array($field1,$field2,$field3,$field4);
 
@@ -912,7 +918,9 @@ class userManagement extends plugin
     $smarty->assign("alphabet", generate_alphabet());
     $smarty->assign("hint", print_sizelimit_warning());
 
-    @mysql_close($r_con);
+    if((is_callable("mysql_close"))&&($r_con)){
+      @mysql_close($r_con);
+    }
     return ($smarty->fetch(get_template_path('headpage.tpl', TRUE)));
   }
 
@@ -981,23 +989,31 @@ class userManagement extends plugin
      * We also need to search for the departments
      * So we are able to navigate like in konquerer 
      */
+
+    /* Create base to search in */
     $base2 = preg_replace("/ou=people,/i","",$base);
 
+    /* Get all departments within this subtree */
     $res3 =  get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))",
         TRUE, $base2, array("ou", "description"), TRUE);
 
     $this->departments= array();
 
+    /* Create array with results */
     $tmp = array();
     foreach ($res3 as $value){
       $tmp[strtolower($value['dn']).$value['dn']]=$value;
     }
+
+    /* Sort array */
     ksort($tmp);
+
+    /* Create result array */
     foreach($tmp as $value){
-      if($value["description"][0]!=".."){
+      if(isset($value['description'][0])){
         $this->departments[$value['dn']]=convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
       }else{
-        $this->departments[$value['dn']]=$value["description"][0];
+        $this->departments[$value['dn']]=convert_department_dn2($value['dn']);
       }
     }
     /* END NEW LIST MANAGMENT