Code

Updated ACL
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 17 Jul 2008 09:04:51 +0000 (09:04 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 17 Jul 2008 09:04:51 +0000 (09:04 +0000)
-Updated ACL handling for Hooks && profiles

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

gosa-plugins/fai/admin/fai/class_faiHook.inc
gosa-plugins/fai/admin/fai/class_faiHookEntry.inc
gosa-plugins/fai/admin/fai/class_faiProfile.inc
gosa-plugins/fai/admin/fai/faiHookEntry.tpl

index eb9d837fef25a8301bbd6cbf0c5f7967c9130974..6dbbf3ad326ce2b2f363e0f5f653273b1265d8a5 100644 (file)
@@ -44,12 +44,6 @@ class faiHook extends plugin
     if($dn != "new"){
       $this->dn =$dn;
     
-      /* Get FAIstate
-       */
-      if(isset($this->attrs['FAIstate'][0])){
-        $this->FAIstate = $this->attrs['FAIstate'][0];
-      }
-
       /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry)
        */
       $ldap     = $this->config->get_ldap_link();
@@ -174,6 +168,7 @@ class faiHook extends plugin
         }
 
         $this->dialog= new $this->subClassName($this->config,$this->dn,$obj);
+        $this->dialog->FAIstate = $this->FAIstate;
         $this->dialog->set_acl_base($this->acl_base_for_current_object($obj['dn']));
         $this->dialog->set_acl_category("fai");
 
@@ -218,6 +213,7 @@ class faiHook extends plugin
           $obj  = $this->get_object_attributes($obj,$this->sub_Load_Later);
         }
         $this->dialog= new $this->subClassName($this->config,$this->dn,$obj);
+        $this->dialog->FAIstate = $this->FAIstate;
         $this->dialog->acl = $this->acl;
         session::set('objectinfo',$obj['dn']);
         $this->dialog->parent = &$this;
@@ -233,6 +229,7 @@ class faiHook extends plugin
       $c_dn = $this->acl_base_for_current_object($this->dn);
       $this->dialog= new $this->subClassName($this->config,"new");
       $this->dialog->set_acl_base($c_dn);
+      $this->dialog->FAIstate = $this->FAIstate;
       $this->dialog->set_acl_category("fai");
       $this->dialog->parent = &$this;
       $this->is_dialog=true;
index fd983aecaf50d8859f5cdf5b8985c687f15a1557..2fcff5700f066bb83405e6d4f740d552236d8506 100644 (file)
@@ -31,11 +31,6 @@ class faiHookEntry extends plugin
         $oname = $name;
         $this->$oname=$value;
       }
-
-      if(isset($this->attrs['FAIstate'][0])){
-        $this->FAIstate = $this->attrs['FAIstate'][0];
-      }
-
     }elseif(is_array($object)){
       if(count($object)){
         $this->orig_cn= $object['cn'];
@@ -110,10 +105,7 @@ class faiHookEntry extends plugin
 
     $tmp = $this->plInfo();
     foreach($tmp['plProvidedAcls'] as $name => $translated){
-      $acl = $this->getacl($name);
-      if($this->FAIstate == "freezed"){
-        $acl = preg_replace("/w/","",$acl);
-      }
+      $acl = $this->getacl($name, preg_match("/freeze/",$this->FAIstate));
       $smarty->assign($name."ACL",$acl);
     }
    
@@ -122,6 +114,7 @@ class faiHookEntry extends plugin
     }else{
       $smarty->assign("FAIscript" , htmlentities($this->FAIscript));
     }
+    $smarty->assign("freeze" , preg_match("/freeze/",$this->FAIstate));
     $display.= $smarty->fetch(get_template_path('faiHookEntry.tpl', TRUE));
     return($display);
   }
index b7792ca1004cdbafab82373cb82e1faed394ff9e..9465d1e4b94be81f6388a1845a35e3b246743320 100644 (file)
@@ -40,10 +40,6 @@ class faiProfile extends plugin
       }
     }
 
-    if(isset($this->attrs['FAIstate'][0])){
-      $this->FAIstate = $this->attrs['FAIstate'][0];
-    }
-
     /* Sort assigned classes */ 
     if(is_array($tmp2)){
       foreach($tmp2 as $class){
@@ -214,64 +210,66 @@ class faiProfile extends plugin
 
     /* Remove class name From list */
     $sort_once = false;
-    foreach($_POST as $name => $post){
-      if(preg_match("/DEL_/i",$name) && $this->acl_is_writeable("FAIclass")){
-        $s_action = "delete";
-        $s_entry  = preg_replace("/DEL_/","",$name);
-        $s_entry  = base64_decode(preg_replace("/_.*$/","",$s_entry));
-      }elseif(preg_match("/Add_class/i",$name)&& $this->acl_is_writeable("FAIclass")){
-        $s_action  = "add";
-      }elseif(preg_match("/DelClass/i",$name) && $this->acl_is_writeable("FAIclass")){
-        $s_action  = "delete";
-        $s_entry = $_POST['FAIclass'];
-      }elseif(preg_match("/AddClass/i",$name) && $this->acl_is_writeable("FAIclass")){
-        $s_action  = "add";
-      }
+    if(!preg_match("/freeze/",$this->FAIstate)){
+      foreach($_POST as $name => $post){
+        if(preg_match("/DEL_/i",$name) && $this->acl_is_writeable("FAIclass")){
+          $s_action = "delete";
+          $s_entry  = preg_replace("/DEL_/","",$name);
+          $s_entry  = base64_decode(preg_replace("/_.*$/","",$s_entry));
+        }elseif(preg_match("/Add_class/i",$name)&& $this->acl_is_writeable("FAIclass")){
+          $s_action  = "add";
+        }elseif(preg_match("/DelClass/i",$name) && $this->acl_is_writeable("FAIclass")){
+          $s_action  = "delete";
+          $s_entry = $_POST['FAIclass'];
+        }elseif(preg_match("/AddClass/i",$name) && $this->acl_is_writeable("FAIclass")){
+          $s_action  = "add";
+        }
 
-      /* Check if a list element should be pushed one position up */
-      if((preg_match("/sortup_/",$name))&&(!$sort_once) && $this->acl_is_writeable("FAIclass")){
-        $sort_once = true;
-        $val = preg_replace("/sortup_/","",$name);
-        $val = preg_replace("/_.*$/","",$val);
-        $val = base64_decode($val);
-        $this->catUp($val);
-      }
-      
-      /* Check if a list element should be pushed one position down */
-      if((preg_match("/sortdown_/",$name))&&(!$sort_once) && $this->acl_is_writeable("FAIclass")){
-        $sort_once = true;
-        $val = preg_replace("/sortdown_/","",$name);
-        $val = preg_replace("/_.*$/","",$val);
-        $val = base64_decode($val);
-        $this->catDown($val);
-      }
+        /* Check if a list element should be pushed one position up */
+        if((preg_match("/sortup_/",$name))&&(!$sort_once) && $this->acl_is_writeable("FAIclass")){
+          $sort_once = true;
+          $val = preg_replace("/sortup_/","",$name);
+          $val = preg_replace("/_.*$/","",$val);
+          $val = base64_decode($val);
+          $this->catUp($val);
+        }
 
-    }
+        /* Check if a list element should be pushed one position down */
+        if((preg_match("/sortdown_/",$name))&&(!$sort_once) && $this->acl_is_writeable("FAIclass")){
+          $sort_once = true;
+          $val = preg_replace("/sortdown_/","",$name);
+          $val = preg_replace("/_.*$/","",$val);
+          $val = base64_decode($val);
+          $this->catDown($val);
+        }
 
-    if($s_action == "delete" && $this->acl_is_writeable("FAIclass")){
-      unset($this->FAIclasses[$s_entry]);
-    }
+      }
 
-    if($s_action == "add" && $this->acl_is_writeable("FAIclass")){
-      $this->dialog = new faiProfileEntry($this->config,$this->dn,$this->FAIclasses,$this->parent->parent->fai_release);
-      $this->is_dialog  =true;
-    }
+      if($s_action == "delete" && $this->acl_is_writeable("FAIclass")){
+        unset($this->FAIclasses[$s_entry]);
+      }
 
-    /* Save Dialog */
-    if(isset($_POST['SaveSubObject'])){
-      $this->dialog->save_object();
-      $msgs= $this->dialog->check();
-      if(count($msgs)){
-        msg_dialog::display(_("Error"), $msgs, ERROR_DIALOG);
-      }else{
-        $ret = $this->dialog->save();
-        foreach($ret as $class){
-          $this->FAIclasses[$class] =$class; 
+      if($s_action == "add" && $this->acl_is_writeable("FAIclass")){
+        $this->dialog = new faiProfileEntry($this->config,$this->dn,$this->FAIclasses,$this->parent->parent->fai_release);
+        $this->is_dialog  =true;
+      }
+
+      /* Save Dialog */
+      if(isset($_POST['SaveSubObject'])){
+        $this->dialog->save_object();
+        $msgs= $this->dialog->check();
+        if(count($msgs)){
+          msg_dialog::display(_("Error"), $msgs, ERROR_DIALOG);
+        }else{
+          $ret = $this->dialog->save();
+          foreach($ret as $class){
+            $this->FAIclasses[$class] =$class; 
+          }
+          $this->is_dialog=false;
+          unset($this->dialog);
+          $this->dialog=FALSE;
+          //ksort($this->FAIclasses);
         }
-        $this->is_dialog=false;
-        unset($this->dialog);
-        $this->dialog=FALSE;
-        //ksort($this->FAIclasses);
       }
     }
 
@@ -330,6 +328,8 @@ class faiProfile extends plugin
       }
     }
 
+    $smarty->assign("freeze", preg_match("/freeze/i",$this->FAIstate));
+
     $smarty->assign("FAIclasses"  ,$this->FAIclasses);
     $smarty->assign("divlist"     ,$divlist->DrawList());
 
@@ -352,7 +352,7 @@ class faiProfile extends plugin
 
     $tmp = $this->plInfo();
     foreach($tmp['plProvidedAcls'] as $name => $translated){
-      $smarty->assign($name."ACL",$this->getacl($name));
+      $smarty->assign($name."ACL",$this->getacl($name, preg_match("/freeze/",$this->FAIstate)));
     }
 
     $display.= $smarty->fetch(get_template_path('faiProfile.tpl', TRUE));
@@ -375,7 +375,9 @@ class faiProfile extends plugin
    */
   function save_object()
   {
-    plugin::save_object();
+    if(!preg_match("/freeze/",$this->FAIstate)){
+      plugin::save_object();
+    }
   }
 
 
index e8d2b14db4646c79ca8373a37df08fb96441c597..2040cba682b7c23fc115b2dddbe2b2c0e5687749 100644 (file)
@@ -82,7 +82,9 @@
 <p class="seperator">&nbsp;</p>
 <br>
 <div style="align:right;" align="right">
+{if !$freeze}
        <input type="submit" value="{msgPool type=applyButton}"         name="SaveSubObject">&nbsp;
+{/if}
        <input type="submit" value="{msgPool type=cancelButton}"        name="CancelSubObject">
 </div>
 <!-- Place cursor -->