Code

Added mysql_persistent connections, and missing mysql_close ()
[gosa.git] / plugins / admin / ogroups / class_ogroupManagement.inc
index 80c1b5412d3adbcb056b624521233c9cb7a08fc1..1cbeb8d93517d1294329a6ab7003290c2c2c2ba2 100644 (file)
@@ -132,7 +132,6 @@ class ogroupManagement extends plugin
     /* Department changed? */
     if(isset($_POST['depselect']) && $_POST['depselect']){
       $ogroupfilter['depselect']= $_POST['depselect'];
-      $this->reload();
     }
 
     /* Start for New List Managment */
@@ -140,7 +139,6 @@ class ogroupManagement extends plugin
       $s_action="open";
       $s_entry = base64_decode($_GET['dep_id']);
       $ogroupfilter['depselect']= "".$this->config->departments[trim($s_entry)];
-      $this->reload();
     }
 
     /* If Backbutton is Posted */
@@ -154,20 +152,17 @@ class ogroupManagement extends plugin
         $ogroupfilter['depselect']= $this->config->departments["/"];
       }
       register_global("ogroupfilter", $ogroupfilter);
-      $this->reload();
     }
 
     /* Homebutton is posted */
     if($s_action=="home"){
       $ogroupfilter['depselect']=(preg_replace("/^[^,]+,/","",$this->ui->dn));
       $ogroupfilter['depselect']=(preg_replace("/^[^,]+,/","",$ogroupfilter['depselect']));
-      $this->reload();
     }
 
     /* root posted */ 
     if($s_action=="root"){
       $ogroupfilter['depselect']=($this->config->current['BASE']);
-      $this->reload();
     }
 
     // Edit if
@@ -178,13 +173,7 @@ class ogroupManagement extends plugin
 
     register_global("ogroupfilter", $ogroupfilter);
 
-    /* Prepare formular */
-    if (!isset($this->ogroup) &&
-        !isset($_POST['new_group']) &&
-        !isset($_POST['delete_group']) &&
-        !isset($_POST['select_group'])){
-      $this->reload();
-    }
+    $this->reload();
 
     /* Check for exeeded sizelimit */
     if (($message= check_sizelimit()) != ""){
@@ -394,7 +383,7 @@ name='dep_root' alt='"._("Root")."'> ".
     $empty    = "<img src='images/empty.png' style='width:16px;height:16px;' alt=''>";
 
     // List Setup
-    $divlist = new divlist();
+    $divlist = new divlist("ogroubstab");
     $divlist->SetHeader(array(
           array("string" => "&nbsp;","attach"=>"style='width:20px;'"),
           array("string" => _("Name of object groups")." / "._("Departments")),
@@ -408,7 +397,21 @@ name='dep_root' alt='"._("Root")."'>&nbsp;".
 
     foreach($this->departments as $key=> $val){
 
-      $field1 = array("string" => "<img src='images/folder.png' alt='"._("Department")."'>");
+      if(!isset($this->config->departments[trim($key)])){
+        $this->config->departments[trim($key)]="";
+      }
+
+      $non_empty="";
+      $keys= str_replace("/","\/",$key);
+      foreach($this->config->departments as $keyd=>$vald ){
+        if(preg_match("/".$keys."\/.*/",$keyd)){
+          $non_empty="full";
+        }
+      }
+
+
+
+      $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='text-align:right;border:none'");
@@ -564,7 +567,10 @@ name='dep_root' alt='"._("Root")."'>&nbsp;".
     } else {
       $filter= "(&(cn=$regex)(objectClass=gosaGroupOfNames))";
     }
-    $res= get_list($this->ui->subtreeACL, "$filter", TRUE, $base, array("*"), TRUE);
+    
+   $groups = ($this->config->current['GROUPS']);
+
+    $res= get_list($this->ui->subtreeACL, "$filter",FALSE, $groups.",".$base, array("*"), TRUE);
     $this->ogrouplist= $res;
     ksort ($this->ogrouplist);
     reset ($this->ogrouplist);
@@ -579,18 +585,34 @@ name='dep_root' alt='"._("Root")."'>&nbsp;".
     $res3 =  get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))",
                               TRUE, $base2, array("ou", "description"), TRUE);
 
+   
+
     $this->departments= array();
+    $tmp = array();
     foreach ($res3 as $value){
+      $tmp[strtolower($value['dn']).$value['dn']]=$value;
+    }
+    ksort($tmp);
+    foreach($tmp as $value){
       if($value["description"][0]!=".."){
-        $this->departments[$value['dn']]= convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
+        $this->departments[$value['dn']]=convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
       }else{
         $this->departments[$value['dn']]=$value["description"][0];
       }
     }
-
     /* END NEW LIST MANAGMENT
      */
 
+    $tmp=array();
+    foreach($this->ogrouplist as $tkey => $val ){
+      $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val;
+    }
+    ksort($tmp);
+    $this->ogrouplist=array();
+    foreach($tmp as $val){
+      $this->ogrouplist[]=$val;
+    }
+    reset ($this->ogrouplist);