Code

Updated FAI partition tables.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 17 Jul 2008 10:05:50 +0000 (10:05 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 17 Jul 2008 10:05:50 +0000 (10:05 +0000)
-Fixed ACLs && freeze checks

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

gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc
gosa-plugins/fai/admin/fai/class_faiPartitionTableEntry.inc
gosa-plugins/fai/admin/fai/faiPartitionTable.tpl
gosa-plugins/fai/admin/fai/faiPartitionTableEntry.tpl

index b1d6dffdeab28fe1aa82c9555b20f0cd015760b7..20f40827968a50e937c8feaec3fcea3045844559 100644 (file)
@@ -34,12 +34,6 @@ class faiPartitionTable extends plugin
     if($dn != "new"){
       $this->dn =$dn;
 
-      /* Get FAIstate
-       */
-      if(isset($this->attrs['FAIstate'][0])){
-        $this->FAIstate = $this->attrs['FAIstate'][0];
-      }
-
       /* Read all disks from ldap taht are defined fot this partition table 
        */
       $ldap = $this->config->get_ldap_link();
@@ -135,7 +129,7 @@ class faiPartitionTable extends plugin
      * This code adds a new HDD to the disks 
      * A new Dialog will be opened 
      */
-    if(isset($_POST['AddDisk'])){
+    if(isset($_POST['AddDisk']) && !preg_match("/freeze/i",$this->FAIstate)){
       $usedDiskNames =array();
       foreach($this->disks as $key=>$disk){
         $usedDiskNames[]= $key;
@@ -197,7 +191,7 @@ class faiPartitionTable extends plugin
      */
     if(isset($_POST['SaveDisk'])){
 
-      if (!preg_match("/freeze/", $this->FAIstate)){
+      if (!preg_match("/freeze/i", $this->FAIstate)){
         $this->dialog->save_object();
         if(count($this->dialog->check())){
           foreach($this->dialog->check() as $msg){
@@ -238,7 +232,7 @@ class faiPartitionTable extends plugin
      * Assign delete status for all its partitions      
      */
     if((isset($_POST['DelDisk']))&&(!empty($_POST['disks']))){
-      if (!preg_match("/freeze/", $this->FAIstate)){
+      if (!preg_match("/freeze/i", $this->FAIstate)){
         foreach($_POST['disks'] as $disk) {
 
           if(isset($this->disks[$disk])){
@@ -284,10 +278,13 @@ class faiPartitionTable extends plugin
     $smarty->assign("sub_object_is_addable",
         preg_match("/c/",$this->ui->get_permissions($dn,"fai/faiPartitionTableEntry")) &&
         !preg_match("/freeze/",$this->FAIstate));
+    $smarty->assign("sub_object_is_removeable",
+        preg_match("/d/",$this->ui->get_permissions($dn,"fai/faiPartitionTableEntry")) &&
+        !preg_match("/freeze/",$this->FAIstate));
 
     $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/i",$this->FAIstate)));
     }
     $disks = $this->getDisks();
     $smarty->assign("disks"   ,$disks);
index ee62ddd0963f38cfbaf16957afad1c82caf4859b..82be755250140e9f9cacbc7fe84a19940303e923 100644 (file)
@@ -109,7 +109,7 @@ class faiPartitionTableEntry extends plugin
      * The number specifies the index we want to delete
      */
     foreach($_POST as $name => $value){
-      if((preg_match("/Delete_.*/",$name)) && $this->acl_is_removeable()){
+      if((preg_match("/Delete_.*/",$name)) && $this->acl_is_removeable() && !preg_match("/freeze/i",$this->FAIstate)){
         $tmp = split("_",$name);
         $s_action = "remove";
         $s_entry  = $tmp[1]; 
@@ -120,7 +120,7 @@ class faiPartitionTableEntry extends plugin
      * We must sort the index again, else we possibly got problems 
      * with partitions order.
      */
-    if($s_action == "remove" && $this->acl_is_removeable()){
+    if($s_action == "remove" && $this->acl_is_removeable() && !preg_match("/freeze/i",$this->FAIstate)){
       if($this->partitions[$s_entry]['status'] == "edited"){
         $this->deletePartitions[$s_entry]= $this->partitions[$s_entry];
         $this->deletePartitions[$s_entry]['FAIpartitionNr']=$s_entry;
@@ -138,7 +138,7 @@ class faiPartitionTableEntry extends plugin
     /* To add a partitions we only append an empty 
      *  array to the already defined partitions.
      */
-    if(isset($_POST['AddPartition']) && $this->acl_is_createable()){
+    if(isset($_POST['AddPartition']) && $this->acl_is_createable() && !preg_match("/freeze/i",$this->FAIstate)){
       foreach($this->UsedAttrs as $attr){
         $tmp[$attr]                = "";     
       }
@@ -157,17 +157,12 @@ class faiPartitionTableEntry extends plugin
     $tmp = $this->plInfo();
     $sacl = "";
     foreach($tmp['plProvidedAcls'] as $name => $translated){
-
-      $acl = $this->getacl($name);
-      $sacl .= $acl;
-      if($this->FAIstate == "freezed"){
-        $acl = preg_replace("/w/","",$acl);
-      }
+      $acl = $this->getacl($name, preg_match("/freeze/i",$this->FAIstate));
       $smarty->assign($name."ACL",$acl);
     }
-    $smarty->assign("allowSave",$sacl);
    
     $smarty->assign("sub_object_is_createable",$this->acl_is_createable());
+    $smarty->assign("freeze",preg_match("/freeze/i",$this->FAIstate));
  
     /* Fetch template and show the result
      */
index 537d06a4b5f29d39dc7b8250e723c319494f7af6..b5f1e2eae1ad43673d92e832b3c144439bd84bf8 100644 (file)
 {if $sub_object_is_addable}
                                                <input type="submit" name="AddDisk"     value="{msgPool type=addButton}"     title="{msgPool type=addButton}">
 {else}
-                                               <input type="submit" name="AddDisk"     value="{msgPool type=addButton}"     title="{msgPool type=addButton}" disabled >
+                                               <input type="button" name="dummy_c" value="{msgPool type=addButton}"     title="{msgPool type=addButton}" disabled >
 {/if}
 
                                                <input type="submit" name="EditDisk"    value="{t}Edit{/t}"    title="{t}Edit{/t}">
+
+{if $sub_object_is_removeable}
                                                <input type="submit" name="DelDisk"     value="{msgPool type=delButton}"  title="{msgPool type=delButton}">
+{else}
+                                               <input type="button" name="dummy_r" disabled value="{msgPool type=delButton}"  title="{msgPool type=delButton}">
+{/if}
                                        </td>
                                </tr>
                                </table>
index 4b920ed0ac508ba18284795cb0ff64c5e2664239..d535b3e17c503c85c462020979a07a87c9ad5778 100644 (file)
 <h2><img class="center" alt="" src="images/lists/paste.png" align="middle" title="{t}Partition entries{/t}">&nbsp;{t}Partition entries{/t}</h2>
 {$setup}
 <br>
-{if $sub_object_is_createable}
-       <input type="submit" name="AddPartition" value="{t}Add partition{/t}">
-{else}
-       <input type="submit" name="restricted" value="{t}Add partition{/t}" disabled>
+{if !$freeze}
+       {if $sub_object_is_createable}
+               <input type="submit" name="AddPartition" value="{t}Add partition{/t}">
+       {else}
+               <input type="submit" name="restricted" value="{t}Add partition{/t}" disabled>
+       {/if}
 {/if}
 <br>   
 <br>
 <p class="seperator">&nbsp;</p>
 <br>
 <div style="align:right;" align="right">
-{render acl=$allowSave}
-<input type="submit" name="SaveDisk" value="{msgPool type=saveButton}">
-{/render}
+{if !$freeze}
+       <input type="submit" name="SaveDisk" value="{msgPool type=saveButton}">
+{/if}
 <input type="submit" name="CancelDisk" value="{msgPool type=cancelButton}" >
 </div>
 <!-- Place cursor -->