Code

Replaced a couple of normalizePreg
[gosa.git] / gosa-core / plugins / admin / ogroups / class_ogroupManagement.inc
index 2add7e445c2c392a5ca463607501cdc3937540d4..978bc0c87f4f8284b4ff00386eb5dce4f18a3fc4 100644 (file)
@@ -37,6 +37,7 @@ class ogroupManagement extends plugin
   var $start_pasting_copied_objects = FALSE;
 
   var $dns = array();
+  var $acl_module   = array("ogroups");  
 
   function ogroupManagement (&$config, $dn= NULL)
   {
@@ -46,7 +47,7 @@ class ogroupManagement extends plugin
 
     /* Copy & Paste enabled ?
      */
-    if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE'] ))){
+    if ($this->config->get_cfg_value("copyPaste") == "true"){
       $this->CopyPasteHandler = new CopyPasteHandler($this->config);
     }
 
@@ -221,26 +222,40 @@ class ogroupManagement extends plugin
 
       if(count($ids)){
         $this->dns = array();
+        $disallowed = array();
         foreach($ids as $id){
-          $this->dns[$id] = $this->ogrouplist[$id]['dn'];
+          $dn = $this->ogrouplist[$id]['dn'];
+          $acl = $this->ui->get_permissions($dn, "users/user");
+          if(preg_match("/d/",$acl)){
+            $this->dns[$id] = $dn;
+          }else{
+            $disallowed[] = $dn;
+          }
         }
 
-        /* Check locks */
-        if ($user= get_multiple_locks($this->dns)){
-          return(gen_locked_message($user,$this->dns));
+        if(count($disallowed)){
+          msg_dialog::display(_("Permission"),msgPool::permDelete($disallowed),INFO_DIALOG);
         }
 
-        $dns_names = array();
-        foreach($this->dns as $dn){
-          $dns_names[] = @LDAP::fix($dn);
-        }
+        if(count($this->dns)){
 
-        add_lock ($this->dns, $this->ui->dn);
+          /* Check locks */
+          if ($user= get_multiple_locks($this->dns)){
+            return(gen_locked_message($user,$this->dns));
+          }
 
-        /* Lock the current entry, so nobody will edit it during deletion */
-        $smarty->assign("info", msgPool::deleteInfo($dns_names,_("object group")));
-        $smarty->assign("multiple", true);
-        return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
+          $dns_names = array();
+          foreach($this->dns as $dn){
+            $dns_names[] = @LDAP::fix($dn);
+          }
+
+          add_lock ($this->dns, $this->ui->dn);
+
+          /* Lock the current entry, so nobody will edit it during deletion */
+          $smarty->assign("info", msgPool::deleteInfo($dns_names,_("object group")));
+          $smarty->assign("multiple", true);
+          return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
+        }
       }
     }
 
@@ -477,7 +492,7 @@ class ogroupManagement extends plugin
 
     /* Check if there is a snapshot dialog open */
     $base = $this->DivListOGroup->selectedBase;
-    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
+    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
       return($str);
     }
 
@@ -498,7 +513,7 @@ class ogroupManagement extends plugin
   /* Return departments, that will be included within snapshot detection */
   function get_used_snapshot_bases()
   {
-    return(array(get_ou('ogroupou').$this->DivListOGroup->selectedBase));
+    return(array(get_ou('ogroupRDN').$this->DivListOGroup->selectedBase));
   }
 
   
@@ -586,9 +601,9 @@ class ogroupManagement extends plugin
     $filter= "(&(cn=$Regex)(objectClass=gosaGroupOfNames)(|$filter))";
 
     if($this->DivListOGroup->SubSearch){
-      $res= get_sub_list($filter, "ogroups",get_ou('ogroupou'), $base, array("cn","objectClass","gosaGroupObjects"), GL_SIZELIMIT | GL_SUBSEARCH);
+      $res= get_sub_list($filter, "ogroups",get_ou('ogroupRDN'), $base, array("cn","objectClass","gosaGroupObjects"), GL_SIZELIMIT | GL_SUBSEARCH);
     }else{
-      $res= get_sub_list($filter, "ogroups",get_ou('ogroupou'), get_ou('ogroupou').$base, array("cn","objectClass","gosaGroupObjects"), GL_SIZELIMIT );
+      $res= get_sub_list($filter, "ogroups",get_ou('ogroupRDN'), get_ou('ogroupRDN').$base, array("cn","objectClass","gosaGroupObjects"), GL_SIZELIMIT );
     }
 
     $this->ogrouplist= $res;
@@ -629,13 +644,20 @@ class ogroupManagement extends plugin
       return("");
     }
 
+    $ui = get_userinfo();
+
     /* Add a single entry to queue */
     if($s_action == "cut" || $s_action == "copy"){
 
       /* Cleanup object queue */
       $this->CopyPasteHandler->cleanup_queue();
       $dn = $this->ogrouplist[$s_entry]['dn'];
-      $this->CopyPasteHandler->add_to_queue($dn,$s_action,"ogrouptabs","OGROUPTABS","ogroups");
+      if($s_action == "copy" && $ui->is_copyable($dn,"ogroups","ogroup")){
+        $this->CopyPasteHandler->add_to_queue($dn,$s_action,"ogrouptabs","OGROUPTABS","ogroups");
+      }
+      if($s_action == "cut" && $ui->is_cutable($dn,"ogroups","ogroup")){
+        $this->CopyPasteHandler->add_to_queue($dn,$s_action,"ogrouptabs","OGROUPTABS","ogroups");
+      }
     }
 
 
@@ -649,10 +671,10 @@ class ogroupManagement extends plugin
       foreach($this->list_get_selected_items() as $id){
         $dn = $this->ogrouplist[$id]['dn'];
 
-        if($s_action == "copy_multiple"){
+        if($s_action == "copy_multiple" && $ui->is_copyable($dn,"ogroups","ogroup")){ 
           $this->CopyPasteHandler->add_to_queue($dn,"copy","ogrouptabs","OGROUPTABS","ogroups");
         }
-        if($s_action == "cut_multiple"){
+        if($s_action == "cut_multiple" && $ui->is_cutable($dn,"ogroups","ogroup")){
           $this->CopyPasteHandler->add_to_queue($dn,"cut","ogrouptabs","OGROUPTABS","ogroups");
         }
       }
@@ -667,8 +689,8 @@ class ogroupManagement extends plugin
     if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
 
       /* Get dialog */
-      $data = $this->CopyPasteHandler->execute();
       $this->CopyPasteHandler->SetVar("base",$this->DivListOGroup->selectedBase);
+      $data = $this->CopyPasteHandler->execute();
 
       /* Return dialog data */
       if(!empty($data)){