Code

Added priority to FAIclass selection
[gosa.git] / plugins / admin / ogroups / class_ogroup.inc
index fcf55b33988aa9e186a5a97e7cc852c2fec42780..b69b284ae968272e756dddf4a371c8f5d03be2c9 100644 (file)
@@ -78,23 +78,17 @@ class ogroup extends plugin
       }
     }
     register_global("ogfilter", $ogfilter);
+  
+    if(isset($_SESSION['ogroupfilter']['depselect'])){
+     $this->base = $_SESSION['ogroupfilter']['depselect'];
+    }
 
     /* Load member data */
     $this->reload();
   }
 
-  function execute()
-  {
-    /* Do we represent a valid group? */
-    if (!$this->is_account){
-      $display= "<img src=\"images/stop.png\" align=center>&nbsp;<b>".
-        _("This 'dn' is no object group.")."</b>";
-      return ($display);
-    }
-
-
-
-    /* Delete objects from group */
+  function AddDelMembership(){
+     /* Delete objects from group */
     if (isset($_POST['delete_membership']) && isset($_POST['members'])){
       foreach ($_POST['members'] as $value){
         $this->objects["$value"]= $this->memberList[$value];
@@ -117,6 +111,50 @@ class ogroup extends plugin
       }
       $this->reload();
     }
+  }
+
+  function execute()
+  {
+       /* Call parent execute */
+       plugin::execute();
+
+    
+    $this->reload();
+
+    /* Do we represent a valid group? */
+    if (!$this->is_account){
+      $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
+        _("This 'dn' is no object group.")."</b>";
+      return ($display);
+    }
+
+    /* Delete objects from group */
+    if (isset($_POST['delete_membership']) && isset($_POST['members'])){
+      foreach ($_POST['members'] as $value){
+        if(isset($this->memberList[$value])){
+          $this->objects["$value"]= $this->memberList[$value];
+          unset ($this->memberList["$value"]);
+          unset ($this->member["$value"]);
+          uasort ($this->objects, 'sort_list');
+          reset ($this->objects);
+        }
+      }
+      $this->reload();
+    }
+
+    /* Add objects to group */
+    if (isset($_POST['add_object_finish']) && isset($_POST['objects'])){
+      foreach ($_POST['objects'] as $value){
+        if(isset($this->objects[$value])){
+          $this->memberList["$value"]= $this->objects[$value];
+          $this->member["$value"]= $value;
+          unset ($this->objects[$value]);
+          uasort ($this->memberList, 'sort_list');
+          reset ($this->memberList);
+        }
+      }
+      $this->reload();
+    }
 
     /* Load templating engine */
     $smarty= get_smarty();
@@ -180,22 +218,17 @@ class ogroup extends plugin
         $smarty->assign("$type", $ogfilter[$type]);
       }
       $smarty->assign("hint", print_sizelimit_warning());
+      $smarty->assign("apply", apply_filter());
 
       $display= $smarty->fetch (get_template_path('ogroup_objects.tpl', TRUE, dirname(__FILE__)));
       return ($display);
     }
 
     /* Bases / Departments */
-    if ($this->dn == "new"){
-      $ui= get_userinfo();
-      $this->base= dn2base($ui->dn);
-    } else {
+   
       if (isset($_POST['base'])){
         $this->base= $_POST['base'];
-      } else {
-        $this->base= preg_replace ("/^[^,]+,[^,]+,/", "", $this->dn);
       }
-    }
 
     /* Assemble combine string */
     if ($this->gosaGroupObjects == "[]"){
@@ -240,6 +273,11 @@ class ogroup extends plugin
       $smarty->assign("$val"."ACL", chkacl($this->acl, "$val"));
     }
 
+    /* Assign ACL's */
+    foreach (array("base", "members") as $val){
+      $smarty->assign("$val"."ACL", chkacl($this->acl, "$val"));
+    }
+
     return ($smarty->fetch (get_template_path('generic.tpl', TRUE)));
   }
 
@@ -340,6 +378,10 @@ class ogroup extends plugin
       } else {
         $this->allobjects[$attrs["dn"]]= array("text" => "$name", "type" => "$type");
       }
+      $this->allobjects[$attrs["dn"]]['objectClass']  = $attrs['objectClass'];
+      if(isset($attrs['uid'])){
+        $this->allobjects[$attrs["dn"]]['uid']          = $attrs['uid'];
+      }
     }
     uasort ($this->allobjects, 'sort_list');
     reset ($this->allobjects);
@@ -489,11 +531,6 @@ class ogroup extends plugin
       $message[]= "The required field 'Name' is not set.";
     }
 
-    /* Need at least one member */
-    if (count($this->member) == 0){
-      $message[]= _("Object groups need at least one member!");
-    }
-
     /* To many different object types? */
     if (strlen($this->gosaGroupObjects) > 4){
       $message[]= _("You can combine two different object types at maximum only!");