Code

Added gray out to navigation icons in divlist
[gosa.git] / plugins / admin / fai / class_faiPartitionTable.inc
index 0e5e30921bcd7b8656b0d8b978f3a4e38dbdad6f..550e719991cc036a9955d983edb24279c90b7179 100644 (file)
@@ -20,6 +20,7 @@ class faiPartitionTable extends plugin
   var $dialog           = NULL;     // a dialog, e.g. new disk dialog
 
   var $FAIstate         = "";
+  var $ui;
 
   function faiPartitionTable ($config, $dn= NULL)
   {
@@ -28,6 +29,8 @@ class faiPartitionTable extends plugin
 
     $this->acl ="#all#";
 
+    $this->ui = get_userinfo();    
+
     /* If "dn==new" we try to create a new entry
      * Else we must read all objects from ldap which belong to this entry.
      * First read disks from ldap ... and then the partition definitions for the disks.
@@ -35,13 +38,6 @@ class faiPartitionTable extends plugin
     if($dn != "new"){
       $this->dn =$dn;
 
-      /* Set acls
-       */
-      $ui   = get_userinfo();
-      $acl  = get_permissions ($this->dn, $ui->subtreeACL);
-      $acli = get_module_permission($acl, "FAIclass", $this->dn);
-      $this->acl=$acli;
-
       /* Get FAIstate
        */
       if(isset($this->attrs['FAIstate'][0])){
@@ -107,6 +103,20 @@ class faiPartitionTable extends plugin
     ksort($this->disks);
   }
 
+
+  function acl_base_for_current_object($dn)
+  {
+    if($dn == "new"){
+      if($this->dn == "new"){
+        $dn= $_SESSION['CurrentMainBase'];
+      }else{
+        $dn = $this->dn;
+      }
+    }
+    return($dn);
+  }
+
+
   function execute()
   {
        /* Call parent execute */
@@ -126,7 +136,8 @@ class faiPartitionTable extends plugin
         $usedDiskNames[]= $key;
       }
       $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames); 
-      $this->dialog->acl = $this->acl;
+      $this->dialog->set_acl_base($this->acl_base_for_current_object($this->dn));
+      $this->dialog->set_acl_category("fai");
       $this->dialog->FAIstate = $this->FAIstate;
       $this->is_dialog = true;
     }
@@ -149,17 +160,21 @@ class faiPartitionTable extends plugin
           $usedDiskNames[]= $key;
         }
       }
-      $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames,$this->disks[$Udisk]); 
-      $this->dialog->acl = $this->acl;
-      $this->dialog->FAIstate = $this->FAIstate;
-     
+    
       /* Set object info string, which will be displayed in plugin info line */ 
       if(isset($this->disks[$Udisk]['dn'])){
         $_SESSION['objectinfo'] = $this->disks[$Udisk]['dn'];
+        $dn = $this->disks[$Udisk]['dn'];
       }else{
         $_SESSION['objectinfo'] = "";
+        $dn = "new";
       }
-    
+
+      $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames,$this->disks[$Udisk]); 
+      $this->dialog->set_acl_base($this->acl_base_for_current_object($dn));
+      $this->dialog->set_acl_category("fai");
+      $this->dialog->FAIstate = $this->FAIstate;
+     
       $this->is_dialog = true;
     }
 
@@ -256,10 +271,15 @@ class faiPartitionTable extends plugin
       }
     }
    
-    foreach($this->attributes as $attr){
-      $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
+    $dn = $this->acl_base_for_current_object($this->dn);
+    $smarty->assign("sub_object_is_addable",
+        preg_match("/c/",$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));
     }
-
     $disks = $this->getDisks();
     $smarty->assign("disks"   ,$disks);
     $display.= $smarty->fetch(get_template_path('faiPartitionTable.tpl', TRUE));
@@ -272,24 +292,34 @@ class faiPartitionTable extends plugin
      */
     $a_return = array();
     foreach($this->disks as $key => $disk){
-      if($disk['status'] != "delete"){
-        $cnt=0;
-        foreach($disk['partitions'] as $val){
-          if($val['status']!="delete"){
-            $cnt ++;
-          }
-        }
-        if(!empty($disk['description'])){
-          if($cnt == 1){
-            $a_return[$key]=  $disk['cn']." [".$disk['description']."], ".sprintf(_("%s partition"), $cnt);
-          }else{
-            $a_return[$key]=  $disk['cn']." [".$disk['description']."], ".sprintf(_("%s partition(s)"), $cnt);
+
+      $dn = "new";
+      if(isset($obj['dn'])){
+        $dn = $obj['dn'];
+      }
+      $dn = $this->acl_base_for_current_object($dn);
+      $acl = $this->ui->get_permissions($dn,"fai/faiPartitionTableEntry");
+      if(preg_match("/(r|w)/",$acl)) {
+
+        if($disk['status'] != "delete"){
+          $cnt=0;
+          foreach($disk['partitions'] as $val){
+            if($val['status']!="delete"){
+              $cnt ++;
+            }
           }
-        }else{
-          if($cnt == 1){
-            $a_return[$key]=  $disk['cn'].", ".sprintf(_("%s partition"), $cnt);
+          if(!empty($disk['description'])){
+            if($cnt == 1){
+              $a_return[$key]=  $disk['cn']." [".$disk['description']."], ".sprintf(_("%s partition"), $cnt);
+            }else{
+              $a_return[$key]=  $disk['cn']." [".$disk['description']."], ".sprintf(_("%s partition(s)"), $cnt);
+            }
           }else{
-            $a_return[$key]=  $disk['cn'].", ".sprintf(_("%s partition(s)"), $cnt);
+            if($cnt == 1){
+              $a_return[$key]=  $disk['cn'].", ".sprintf(_("%s partition"), $cnt);
+            }else{
+              $a_return[$key]=  $disk['cn'].", ".sprintf(_("%s partition(s)"), $cnt);
+            }
           }
         }
       }
@@ -491,19 +521,12 @@ class faiPartitionTable extends plugin
           "plDescription" => _("FAI partition table"),
           "plSelfModify"  => FALSE,
           "plDepends"     => array(),
-          "plPriority"    => 0,
+          "plPriority"    => 26,
           "plSection"     => array("administration"),
           "plCategory"    => array("fai"),
           "plProvidedAcls" => array(
-            "cn"                => _("Name"),
-            "FAIpartitionType"  => _("Partition type"),
-            "FAIpartitionNr"    => _("Partition no."),
-            "FAIfsType"         => _("File system type"),
-            "FAImountPoint"     => _("Mount point"),
-            "FAIpartitionSize"  => _("Partition size"),
-            "FAImountOptions"   => _("Mount options"),
-            "FAIfsOptions"      => _("File system options"),
-            "FAIpartitionFlags" => _("Partition flags"))
+            "cn"                => _("Name")." ("._("Read only").")",
+            "description"       => _("Description"))
           ));
   }
 }