Code

Group generic used template fro copy & paste now
[gosa.git] / plugins / admin / groups / class_groupGeneric.inc
index 4e235a6c8e0a9a6fecdf5e2a93d7171cfd702a7f..de07e7d4c1c6487f3bdcf5881e3cb329c23a9a0f 100644 (file)
@@ -30,6 +30,7 @@ class group extends plugin
   var $saved_gidNumber= "";
   var $oldgroupType= "";
   var $orig_dn= "";
+  var $orig_cn= "";
   var $has_mailAccount= FALSE;
   var $group_dialog= FALSE;
   var $nagios_group =FALSE;
@@ -37,6 +38,8 @@ class group extends plugin
   var $dialog;
   var $OnlyShowFirstEntries =200;
 
+  var $allowGroupsWithSameNameInOtherSubtrees = true;
+
   /* attribute list for save action */
   var $attributes= array("cn", "description", "gidNumber","memberUid","sambaGroupType","sambaSID");
   var $objectclasses= array("top", "posixGroup");
@@ -48,6 +51,7 @@ class group extends plugin
     /* Load attributes depending on the samba version */
     $this->samba3= ($config->current['SAMBAVERSION'] == 3);
     $this->orig_dn= $dn;
+    $this->orig_cn= $this->cn;
 
     /* Get member list */
     if (isset($this->attrs['memberUid'][0])){
@@ -138,7 +142,8 @@ class group extends plugin
     $gufilter= get_global('gufilter');
 
     $gufilter['SubSearchGroup'] = false;
-  
+    $gufilter['dselect'] = $_SESSION['groupfilter']['depselect'];  
+
     register_global('gufilter',$gufilter);
   
       /* Bases / Departments */
@@ -721,26 +726,42 @@ class group extends plugin
       $message[]= _("The field 'Name' contains invalid characters. Lowercase, numbers and dashes are allowed.");
     }
 
-    /* Check for used 'cn' */
-    $ldap= $this->config->get_ldap_link();
-    $ldap->cd($this->config->current['BASE']);
-    $ldap->search("(&(|(objectClass=gosaGroupOfNames)(objectClass=posixGroup))(cn=$this->cn))",array("cn"));
-    if ($ldap->count() != 0){
 
-      /* New entry? */
-      if ($this->dn == 'new'){
-        $message[]= _("Value specified as 'Name' is already used.");
+    if($this->allowGroupsWithSameNameInOtherSubtrees == true){
+
+      /* Check for used 'cn' */
+      $ldap= $this->config->get_ldap_link();
+      if(($this->cn  != $this->orig_cn) || ($this->orig_dn == "new")){
+        $ldap->cd("ou=groups,".$this->base);
+        $ldap->ls("(&(|(objectClass=gosaGroupOfNames)(objectClass=posixGroup))(cn=$this->cn))","ou=groups,".$this->base,array("cn"));
+        if ($ldap->count() != 0){
+          $message[]= _("Value specified as 'Name' is already used.");
+        }
       }
-      
-      /* Moved? */
-      elseif ($new_dn != $this->orig_dn){
-        $ldap->fetch();
-        if ($ldap->getDN() != $this->orig_dn){
+
+    }else{
+
+      /* Check for used 'cn' */
+      $ldap= $this->config->get_ldap_link();
+      $ldap->cd($this->config->current['BASE']);
+      $ldap->search("(&(|(objectClass=gosaGroupOfNames)(objectClass=posixGroup))(cn=$this->cn))",array("cn"));
+      if ($ldap->count() != 0){
+
+        /* New entry? */
+        if ($this->dn == 'new'){
           $message[]= _("Value specified as 'Name' is already used.");
         }
+
+        /* Moved? */
+        elseif ($new_dn != $this->orig_dn){
+          $ldap->fetch();
+          if ($ldap->getDN() != $this->orig_dn){
+            $message[]= _("Value specified as 'Name' is already used.");
+          }
+        }
       }
     }
-
+     
     /* Check ID */
     if ($this->force_gid == "1"){
       if (!is_id($this->gidNumber)){
@@ -788,6 +809,39 @@ class group extends plugin
     }
   }
 
+  function getCopyDialog()
+  {
+    $vars = array("cn");
+  
+    if($this ->force_gid){
+      $used = " checked ";
+      $dis  = "";
+    }else{
+      $used = "";
+      $dis  = " disabled ";
+    }
+
+    $smarty = get_smarty();
+    $smarty->assign("used",$used);
+    $smarty->assign("dis" ,$dis);
+    $smarty->assign("cn" ,$this->cn);
+    $smarty->assign("gidNumber",$this->gidNumber);
+    return($smarty->fetch(get_template_path("paste_generic.tpl",TRUE)));
+  }
+
+  function saveCopyDialog()
+  {
+    if(isset($_POST['cn'])){
+      $this->cn = $_POST['cn'];
+    }
+    if(isset($_POST['force_gid'])){
+      $this->force_gid  = 1;
+      $this->gidNumber= $_POST['gidNumber'];
+    }else{
+      $this->force_gid  = 0;
+      $this->gidNumber  = false;
+    }
+  }
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: