Code

Fixed acl removal
[gosa.git] / gosa-core / plugins / admin / acl / class_aclManagement.inc
index dc652a6e57861638ef49b11cc41de4c5744c1683..17f6b3faccd150f3ab45929546bb052d655fa73f 100644 (file)
@@ -27,26 +27,26 @@ class aclManagement extends management
   var $plIcon  = "plugins/acl/images/plugin.png";
 
   // Tab definition 
-  protected $tabClass = "acltab";
-  protected $tabType = "ACLTABS";
+  protected $tabClass = "aclroletab";
+  protected $tabType = "ACLROLETAB";
   protected $aclCategory = "acl";
   protected $aclPlugin   = "acl";
   protected $objectName   = "acl";
 
-  function __construct($config,$ui)
+  function __construct(&$config,$ui)
   {
     $this->config = $config;
     $this->ui = $ui;
    
-    $this->storagePoints = array(); // ACLs are attached to department containers
+    $this->storagePoints = array(get_ou("aclRoleRDN")); // ACLs are attached to department containers
+
     // Build filter
-#    if (session::global_is_set(get_class($this)."_filter")){
-#      $filter= session::global_get(get_class($this)."_filter");
-#    } else {
+    if (session::global_is_set(get_class($this)."_filter")){
+      $filter= session::global_get(get_class($this)."_filter");
+    } else {
       $filter = new filter(get_template_path("acl-filter.xml", true));
-#      $filter->setObjectStorage($this->storagePoints);
-#    }
+      $filter->setObjectStorage($this->storagePoints);
+    }
     $this->setFilter($filter);
 
     // Build headpage
@@ -62,23 +62,100 @@ class aclManagement extends management
       $this->snapHandler = new SnapshotHandler($this->config);
     }
 
-    parent::__construct($config, $ui, "acl", $headpage);
+    parent::__construct($this->config, $ui, "acl", $headpage);
+  }
+
+  function removeEntryConfirmed($action="",$target=array(),$all=array(),
+      $altTabClass="",$altTabType="",$altAclCategory="")
+  {
+    @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$target,"Entry removel confirmed!");
+
+    $headpage = $this->getHeadpage();
+    foreach($this->dns as $key => $dn){
+
+      // Check permissions, are we allowed to remove this object?
+      $acl = $this->ui->get_permissions($dn, $this->aclCategory."/".$this->aclPlugin);
+      if(preg_match("/d/",$acl)){
 
+        if($headpage->getType($dn) == "gosaRole"){
+          $tabClass = "aclroletab";
+          $tabType  = "ACLROLETAB";
+        }else{
+          $tabClass = "acltab";
+          $tabType  = "ACLTAB";
+        }
+
+        // Delete the object
+        $this->dn = $dn;
+        $this->tabObject= new $tabClass($this->config,$this->config->data['TABS'][$tabType], $this->dn, $aclCategory, true, true);
+        $this->tabObject->set_acl_base($this->dn);
+        $this->tabObject->delete ();
+        $this->tabObject->parent = &$this;
+
+        // Remove the lock for the current object.
+        del_lock($this->dn);
+      } else {
+        msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
+        new log("security","groups/".get_class($this),$dn,array(),"Tried to trick deletion.");
+      }
+    }
+
+    // Cleanup
+    $this->remove_lock();
+    $this->closeDialogs();
   }
 
-  // A filter which allows to open a department by clicking on the departments name.
-  static function filterLabel($row,$dn,$params,$ou= array(),$cn=array(),$pid=0,$base="")
+
+  function newEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
   {
-    if(!isset($ou[0])){
-      $ou = $cn[0];
-    }else{
-      $ou = $ou[0];
+    $this->skipFooter = TRUE;
+    $altTabClass = "aclroletab";
+    $altTabType = "ACLROLETAB";
+    return(management::newEntry($action,$target,$all,$altTabClass,$altTabType,$altAclCategory));
+  }
+
+  function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
+  {
+    $this->skipFooter = TRUE;
+    if(count($target) == 1){
+  
+      // Set dummy tab object...
+      $this->dn = array_pop($target);
+      $headpage = $this->getHeadpage();
+      if($headpage->getType($this->dn) == "gosaRole"){
+        $altTabClass = "aclroletab";
+        $altTabType  = "ACLROLETAB";
+      }else{
+        $altTabClass = "acltab";
+        $altTabType  = "ACLTAB";
+      }
+      return(management::editEntry($action,array($this->dn),$all,$altTabClass,$altTabType,$altAclCategory));
     }
+  }
+
+
+  function detectPostActions()
+  {
+    $action= management::detectPostActions();
+    if(isset($_POST['edit_acl'])) $action['action'] = "edit_acl";
+    if(isset($_POST['edit_role'])) $action['action'] = "edit_role";
+    return($action);
+  }
+  
+
+  // A filter which allows to open a department by clicking on the departments name.
+  static function filterLabel($row,$dn,$ou= array(),$pid=0,$base="")
+  {
+    $ou = $ou[0];
     if($dn == $base){
-      $ou =".";
+      $ou =" . ";
+    }
+    if(!preg_match("/^cn=/",$dn)){
+      $ou.="    ["._("ACL Assignment")."]";
     }
+
     $dn= LDAP::fix(func_get_arg(1));
-    return("<a href='?plug=".$_GET['plug']."&amp;PID=$pid&amp;act=listing_open_$row' title='$dn'>$ou</a>");
+    return("<a href='?plug=".$_GET['plug']."&amp;PID=$pid&amp;act=listing_edit_$row' title='$dn'>$ou</a>");
   }