Code

First layout adaptions
[gosa.git] / plugins / admin / ogroups / class_ogroup.inc
index 86c96ae95abf749cd163644350b7e4dee8b98b4a..3b7751fc7fe420296b99b1d888344967c9a9a654 100644 (file)
@@ -83,22 +83,18 @@ class ogroup extends plugin
      $this->base = $_SESSION['ogroupfilter']['depselect'];
     }
 
+     /* set permissions */
+    $ui= get_userinfo();
+    $acl= get_permissions ($ui->dn, $ui->subtreeACL);
+    $this->acl= get_module_permission($acl, "ogroup", $ui->dn);
+
+
     /* Load member data */
     $this->reload();
   }
 
-  function execute()
-  {
-    /* 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 */
+  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];
@@ -121,6 +117,49 @@ 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();
@@ -485,6 +524,16 @@ class ogroup extends plugin
       $new_dn= $this->dn;
     }
 
+
+    $ldap = $this->config->get_ldap_link();
+    if($this->dn != $new_dn){
+      $ldap->cat ($new_dn);
+    }
+    
+    if($ldap->count() !=0){
+      $message[]= _("There is already an object with this cn.");
+    } 
+
     $ui= get_userinfo();
     $acl= get_permissions ($new_dn, $ui->subtreeACL);
     $acl= get_module_permission($acl, "group", $new_dn);
@@ -497,11 +546,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!");