Code

Some acl management implementations, not finished yet
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 13 Dec 2006 10:59:21 +0000 (10:59 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 13 Dec 2006 10:59:21 +0000 (10:59 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5375 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/acl/class_aclManagement.inc
plugins/admin/acl/class_divListACL.inc
plugins/admin/acl/main.inc
plugins/admin/acl/remove.tpl

index 0fd131321f821bd4ca3c9963ecfbb1150e15dfbf..d21419fdb12b2bb7b764f46754fd47f296f42bce 100644 (file)
@@ -31,6 +31,7 @@ class aclManagement extends plugin
   var $acl                  = "";
   var $DivListACL           = NULL;
 
+
   function aclManagement($config, $ui)
   {
     /* Save configuration for internal use */
@@ -47,17 +48,19 @@ class aclManagement extends plugin
     /* Call parent execute */
     plugin::execute();
 
+    $_SESSION['LOCK_VARS_TO_USE'] = array("/^list_acl_edit/","/^list_acl_del/","/list_edit_entry/","/^id_/");
+
     $smarty       = get_smarty();                 // Smarty instance
     $s_action     = "";                           // Contains the action to be taken
     $s_entry      = "";                           // The value for s_action
 
     /* Edit entry button pressed? */
-    if( isset($_GET['act']) && $_GET['act'] == "edit_entry" ){
+    if( isset($_GET['act']) && $_GET['act'] == "list_edit_entry" ){
       $s_action= "edit";
       $s_entry= validate($_GET['id']);
     }
 
-    $types = array("del"=>"acl_del","edit"=>"acl_edit");
+    $types = array("del"=>"^list_acl_del","edit"=>"^list_acl_edit");
 
     /* Test relevant POST values */  
     foreach($_POST as $key => $val){
@@ -83,6 +86,7 @@ class aclManagement extends plugin
       $s_tab= "generic";
     }
 
+
     /********************
       Edit existing entry 
      ********************/
@@ -95,18 +99,16 @@ class aclManagement extends plugin
       /* Check locking, save current plugin in 'back_plugin', so
          the dialog knows where to return. */
       if (($acl= get_lock($this->dn)) != ""){
-        $_SESSION['LOCK_VARS_TO_USE'] = array("/^acl_edit/","/^acl_del/","/^id_/");
         return(gen_locked_message ($acl, $this->dn));
       }
 
       /* Lock the current entry, so everyone will get the above dialog */
       add_lock ($this->dn, $this->ui->dn);
 
-      /* Set up the ACL's for this 'dn' */
-      $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
-
       /* Register acltabs to trigger edit dialog */ 
-      $this->acltabs= new acl($this->config, $this->dn);
+      $this->acltabs= new acl($this->config, NULL,$this->dn);
+      $this->acltabs-> set_acl_base($this->dn);
+      $this->acltabs-> set_acl_category("acl");
 
       /* Switch tab, if it was requested by user */
       $this->acltabs->current = $s_tab;
@@ -119,9 +121,13 @@ class aclManagement extends plugin
     /********************
       Edit canceled 
      ********************/
+    if(isset($_POST['delete_lock'])){
+      del_lock ($this->dn);
+      unset($_SESSION['objectinfo']);
+    }
 
     /* Reset all relevant data, if we get a _cancel request */
-    if (isset($_POST['edit_cancel']) || isset($_POST['cancel_new_acl'])){
+    if (isset($_POST['edit_cancel'])){
       if (isset($this->acltabs)){
         del_lock ($this->dn);
         unset ($this->acltabs);
@@ -141,16 +147,13 @@ class aclManagement extends plugin
       /* Get 'dn' from posted acl */
       $this->dn= $this->list[trim($s_entry)]['dn'];
 
-      /* Load permissions for selected 'dn' and check if
-         we're allowed to remove this 'dn' */
-      $acl      = get_permissions ($this->dn, $this->ui->subtreeACL);
-      $this->acl= get_module_permission($acl, "acl", $this->dn);
-      if (chkacl($this->acl, "delete") == ""){
 
+      # FIXME CHECK ACLs here 
+      if(1 == 1 ){ 
         /* Check locking, save current plugin in 'back_plugin', so
            the dialog knows where to return. */
         if (($acl= get_lock($this->dn)) != ""){
-          $_SESSION['LOCK_VARS_TO_USE'] = array("/^acl_edit/","/^acl_del/","/^id_/");
+          $_SESSION['LOCK_VARS_TO_USE'] = array("/^list_acl_edit/","/^list_acl_del/","/^id_/");
           return(gen_locked_message ($acl, $this->dn));
         }
 
@@ -179,7 +182,7 @@ class aclManagement extends plugin
       if (chkacl($this->acl, "delete") == ""){
 
         /* Delete request is permitted, perform LDAP action */
-        $this->acltabs= new acl($this->config, $this->dn);
+        $this->acltabs= new acl($this->config, NULL,$this->dn);
         $this->acltabs->delete ();
         gosa_log ("ACL object '".$this->dn."' has been removed");
         unset ($this->acltabs);
@@ -217,7 +220,7 @@ class aclManagement extends plugin
     /* Finish acl edit is triggered by the tabulator dialog, so
        the acl wants to save edited data. Check and save at this
        point. */
-    if ((isset($_POST['submit_new_acl']) || isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->acltabs->config))){
+    if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->acltabs->config))){
 
       /* Check tabs, will feed message array */
       $this->acltabs->last= $this->acltabs->current;
@@ -259,22 +262,30 @@ class aclManagement extends plugin
 
     /* Show tab dialog if object is present */
     if(isset($this->acltabs->config)){
+      
+      /* Save object */
+      $this->acltabs->save_object();
       $display= $this->acltabs->execute();
 
       /* Don't show buttons if tab dialog requests this */
-#      if(isset($this->acltabs->by_object)){
-#        if (!$this->acltabs->dialog){
-#          $display.= "<p style=\"text-align:right\">\n";
-#          $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
-#          $display.= "&nbsp;\n";
-#          if ($this->dn != "new"){
-#            $display.= "<input type=submit name=\"edit_apply\" value=\""._("Apply")."\">\n";
-#            $display.= "&nbsp;\n";
-#          }
-#          $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
-#          $display.= "</p>";
-#        }
-#      }
+      if(isset($this->acltabs)){
+
+        /* Skip displaying save/cancel if there is a sub dialog open */
+        if (!$this->acltabs->dialog){
+          $display.= "<p style=\"text-align:right\">\n";
+          $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
+          $display.= "&nbsp;\n";
+
+          /* Skip Apply if it is a new entry */
+          #if ($this->dn != "new"){
+          #  $display.= "<input type=submit name=\"edit_apply\" value=\""._("Apply")."\">\n";
+          #  $display.= "&nbsp;\n";
+          #}
+
+          $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
+          $display.= "</p>";
+        }
+      }
       return ($display);
     }
     
index bf2d2ef94a48dfe2001da362be18c59f0876d051..ec12ec85617f7d1c3c4bdd1e1fbf70c26f457c2a 100644 (file)
@@ -17,7 +17,7 @@ class divListACL extends MultiSelectWindow
 
   var $parent             ;
   var $ui                 ;
-
+  var $action_col_size;
   
 
   function divListACL ($config,$parent)
@@ -41,13 +41,13 @@ class divListACL extends MultiSelectWindow
     $this->EnableCloseButton(false);
     $this->EnableSaveButton (false);
 
-    /* Dynamic action col, depending on snapshot icons */
-    $action_col_size = 80;
+    /* Dynamic action col */
+    $this->action_col_size = 45;
 
     /* set Page header */
     $this->AddHeader(array("string"=>"&nbsp;",          "attach"=>"style='width:20px;'"));
     $this->AddHeader(array("string"=>_("Summary")));
-    $this->AddHeader(array("string"=>_("Actions"),      "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"));
+    $this->AddHeader(array("string"=>_("Actions"),      "attach" => "style='width:".$this->action_col_size."px;border-right:0px;text-align:right;'"));
 
     /* Set dynamically filter checkboxes */
     $this->set_filter_objectclasses();   
@@ -87,7 +87,6 @@ class divListACL extends MultiSelectWindow
       " <input class='center' type='image' src='images/list_reload.png' align='middle' 
       title='"._("Reload list")."' name='submit_department' alt='".        _("Submit")."'>&nbsp;".
       " <img   class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
-    $listhead .= $this->get_snapshot_header($this->selectedBase);
     $listhead .=  
       _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
       " <input class='center' type='image' src='images/list_submit.png' align='middle' 
@@ -107,19 +106,18 @@ class divListACL extends MultiSelectWindow
   function setEntries($list)
   {
     $list_left_icon = "<img src='images/select_acl.png' alt='"._("Acl")."'>";
-    $editlink       = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
+    $editlink       = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=list_edit_entry'>%s</a>";
 
     foreach($list as $key => $acl_entry){
 
       $action = "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."'     
-        name='acl_edit_%KEY%' title='"._("Edit system")."'>";
-      $action.= $this->GetSnapShotActions($acl_entry['dn']);
+        name='list_acl_edit_%KEY%' title='"._("Edit system")."'>";
       $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."' 
-        name='acl_del_%KEY%' title='"._("Delete system")."'>";
+        name='list_acl_del_%KEY%' title='"._("Delete system")."'>";
 
       $field1 = array("string" => $list_left_icon, "attach"=> "style='text-align:center;width:20px;'");
       $field2 = array("string" => sprintf($editlink,$key,htmlentities(utf8_decode($acl_entry['dn'])))."&nbsp;","attach" => "");
-      $field3 = array("string" => preg_replace("/%KEY%/",$key,$action), "attach"=> "style='text-align:center;width:80px;border-right:0px;'");
+      $field3 = array("string" => preg_replace("/%KEY%/",$key,$action), "attach"=> "style='text-align:center;width:".$this->action_col_size."px;border-right:0px;'");
       $this->AddElement(array($field1,$field2,$field3));
     }
   }
index b02543c41845d7da4516ba87ceef9e6716d2f713..bea89a962e18dd08e508973c2d4aeb18bbf57212 100644 (file)
@@ -54,5 +54,4 @@ if (!isset($_SESSION['macl']) || (isset($_GET['reset']) && $_GET['reset'] == 1))
        $display.= $output;
        $_SESSION['macl']= $macl;
 }
-
 ?>
index dd2160e34913783285f8443e1f42f19d750f347d..047b2adc9ee88fbf3ef946a64950d49288a39d75 100755 (executable)
@@ -11,7 +11,7 @@
 </p>
 
 <p class="plugbottom">
-<!--  <input type=submit name="delete_terminal_confirm" value="{t}Delete{/t}">-->
+  <input type=submit name="delete_acl_confirm" value="{t}Delete{/t}">
   &nbsp;
-  <input type=submit name="delete_cancel" value="{t}Cancel{/t}">
+  <input type=submit name="delete_acl_cancel" value="{t}Cancel{/t}">
 </p>