Code

ACL changes:
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 20 Apr 2007 12:02:35 +0000 (12:02 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 20 Apr 2007 12:02:35 +0000 (12:02 +0000)
Management -> Added functionality to remove acl roles. This is currently not working, roles can't be deleted right now.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6154 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/acl/class_aclManagement.inc
plugins/admin/acl/class_aclRole.inc
plugins/admin/acl/remove.tpl

index 429cdeab40e40f7555840a97c9e66d771c880673..7eb673fa27a91fb24ea274731dd9478ddbaee509 100644 (file)
@@ -56,7 +56,7 @@ class aclManagement extends plugin
     /* Call parent execute */
     plugin::execute();
 
-    $_SESSION['LOCK_VARS_TO_USE'] = array("/^list/","/^id_/");
+    $_SESSION['LOCK_VARS_TO_USE'] = array("/^list/","/^id_/","/^list_acl_role_del/");
 
     $smarty       = get_smarty();                 // Smarty instance
     $s_action     = "";                           // Contains the action to be taken
@@ -199,6 +199,71 @@ class aclManagement extends plugin
     }
 
 
+    /********************
+      Delete entry requested, display confirm dialog
+     ********************/
+
+    /* Remove acl was requested */
+    if ($s_action=="del_role"){
+
+      /* Get 'dn' from posted acl */
+      $this->dn= $this->list[trim($s_entry)]['dn'];
+
+      /* Check permissions */
+      if(preg_match("/d/",$this->ui->get_permissions($this->dn,"aclroles/aclrole"))){
+
+        /* Check locking, save current plugin in 'back_plugin', so
+           the dialog knows where to return. */
+        if (($acl= get_lock($this->dn)) != ""){
+          return(gen_locked_message ($acl, $this->dn));
+        }
+
+        /* Lock the current entry, so nobody will edit it during deletion */
+        add_lock ($this->dn, $this->ui->dn);
+        $smarty->assign("info", sprintf(_("You're about to delete the acl %s."), @LDAP::fix($this->dn)));
+        $smarty->assign("is_role",true);
+  
+        return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
+      } else {
+
+        /* Obviously the acl isn't allowed to delete. Show message and
+           clean session. */
+        print_red (_("You are not allowed to delete this acl!"));
+      }
+    }
+
+
+    /********************
+      Delete entry confirmed 
+     ********************/
+
+    /* Confirmation for deletion has been passed. Acl should be deleted. */
+    if (isset($_POST['delete_acl_role_confirmed'])){
+
+      /* Check permissions */
+      if(preg_match("/d/",$this->ui->get_permissions($this->dn,"aclroles/aclrole"))){
+
+        /* Delete request is permitted, perform LDAP action */
+        $this->acltabs= new aclroletab($this->config, NULL,$this->dn);
+        $this->acltabs->delete();
+        gosa_log ("ACL role object '".$this->dn."' has been removed");
+        unset ($this->acltabs);
+        $this->acltabs= NULL;
+      } else {
+
+        /* Normally this shouldn't be reached, send some extra
+           logs to notify the administrator */
+        print_red (_("You are not allowed to delete this acl role!"));
+
+        if(isset($this->ui->uid)){
+          gosa_log ("Warning: '".$this->ui->uid."' tried to trick acl role deletion.");
+        }
+      }
+
+      /* Remove lock file after successfull deletion */
+      del_lock ($this->dn);
+    }
+
     /********************
       Delete entry requested, display confirm dialog
      ********************/
@@ -221,6 +286,7 @@ class aclManagement extends plugin
         /* Lock the current entry, so nobody will edit it during deletion */
         add_lock ($this->dn, $this->ui->dn);
         $smarty->assign("info", sprintf(_("You're about to delete the acl %s."), @LDAP::fix($this->dn)));
+        $smarty->assign("is_role",false);
         return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
       } else {
 
index 0b318d0626f7d68849871833680bb91255b7d3c4..76878da0c51e5aa90625c236ef813b9bc49ee5d8 100644 (file)
@@ -905,6 +905,7 @@ class aclrole extends plugin
 
   function remove_from_parent()
   {
+    echo "Role should be deleted here- What happens with assigned roles ... ";
   }
 
   function save_object()
index 047b2adc9ee88fbf3ef946a64950d49288a39d75..0b5323df4c7e08647afac83497f0a29f4e3c354c 100755 (executable)
 </p>
 
 <p class="plugbottom">
+{if $is_role}
+  <input type=submit name="delete_acl_role_confirmed" value="{t}Delete{/t}">
+  &nbsp;
+  <input type=submit name="delete_acl_role_cancel" value="{t}Cancel{/t}">
+{else}
   <input type=submit name="delete_acl_confirm" value="{t}Delete{/t}">
   &nbsp;
   <input type=submit name="delete_acl_cancel" value="{t}Cancel{/t}">
+{/if}
 </p>