From: hickert Date: Mon, 23 Oct 2006 09:43:50 +0000 (+0000) Subject: Added Acls to partition table X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=fad4bc687f5361f6ce89beaa2746e8f782b72ea6;p=gosa.git Added Acls to partition table git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4917 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/fai/class_faiPartitionTable.inc b/plugins/admin/fai/class_faiPartitionTable.inc index 5ace0cba5..550e71999 100644 --- a/plugins/admin/fai/class_faiPartitionTable.inc +++ b/plugins/admin/fai/class_faiPartitionTable.inc @@ -136,7 +136,7 @@ class faiPartitionTable extends plugin $usedDiskNames[]= $key; } $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames); - $this->dialog->set_acl_base($this->acl_base_for_current_object($obj['dn'])); + $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; @@ -160,18 +160,21 @@ class faiPartitionTable extends plugin $usedDiskNames[]= $key; } } - $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames,$this->disks[$Udisk]); - $this->dialog->set_acl_base($this->acl_base_for_current_object($obj['dn'])); - $this->dialog->set_acl_category("fai"); - $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; } @@ -270,14 +273,13 @@ class faiPartitionTable extends plugin $dn = $this->acl_base_for_current_object($this->dn); $smarty->assign("sub_object_is_addable", - preg_match("/c/",$this->ui->get_permissions($dn,"fai/faiScriptEntry")) && + 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)); @@ -290,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); + } } } } diff --git a/plugins/admin/fai/class_faiPartitionTableEntry.inc b/plugins/admin/fai/class_faiPartitionTableEntry.inc index 9a3804a7e..bef8d646b 100644 --- a/plugins/admin/fai/class_faiPartitionTableEntry.inc +++ b/plugins/admin/fai/class_faiPartitionTableEntry.inc @@ -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)){ + if((preg_match("/Delete_.*/",$name)) && $this->acl_is_removeable()){ $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"){ + if($s_action == "remove" && $this->acl_is_removeable()){ if($this->partitions[$s_entry]['status'] == "edited"){ $this->deletePartitions[]= $this->partitions[$s_entry]; unset($this->partitions[$s_entry]); @@ -137,7 +137,7 @@ class faiPartitionTableEntry extends plugin /* To add a partitions we only append an empty * array to the already defined partitions. */ - if(isset($_POST['AddPartition'])){ + if(isset($_POST['AddPartition']) && $this->acl_is_createable()){ foreach($this->UsedAttrs as $attr){ $tmp[$attr] = ""; } @@ -153,26 +153,21 @@ class faiPartitionTableEntry extends plugin $smarty->assign($attr,$this->$attr); } - foreach($this->UsedAttrs as $attr){ - if(($this->FAIstate == "freeze") || (chkacl($this->acl,$attr)!= "")){ - $smarty->assign($attr."ACL"," disabled "); - }else{ - $smarty->assign($attr."ACL"," "); + $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); } + $smarty->assign($name."ACL",$acl); } - - - /* The user can't change a diskname - * if we are currently in edit mode for the specified disk - */ -// if($this->is_edit){ -// $smarty->assign("DISK_cnACL"," disabled "); -// }else{ - $smarty->assign("DISK_cnACL",""); -// } - - - + $smarty->assign("allowSave",$sacl); + + $smarty->assign("sub_object_is_createable",$this->acl_is_createable()); + /* Fetch template and show the result */ $display.= $smarty->fetch(get_template_path('faiPartitionTableEntry.tpl', TRUE)); @@ -189,13 +184,13 @@ class faiPartitionTableEntry extends plugin $str = ""; if (count($this->partitions)){ $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; $str .= ""; $str .= ""; } @@ -218,38 +213,61 @@ class faiPartitionTableEntry extends plugin } if($part['status']!="delete"){ + /* Generate Partition select box */ - $PartitionType = ""; + $PartitionType = ""; + if($this->acl_is_writeable("FAIpartitionType")){ + $PartitionType = ""; + }elseif($this->acl_is_readable("FAIpartitionType")){ + $PartitionType = $part['FAIpartitionType']; + } /* Generate fsType select box */ - $FAIfsType= ""; + foreach($FAIfsTypes as $type){ + if($part['FAIfsType'] == $type){ + $FAIfsType .=""; + }else{ + $FAIfsType .=""; + } + } + $FAIfsType.=""; + }elseif($this->acl_is_readable("FAIfsType")){ + $FAIfsType = $part['FAIfsType']; + } + + foreach(array("FAImountPoint","FAIpartitionSize","FAImountOptions","FAIfsOptions") as $attr){ + $$attr = ""; + if($this->acl_is_writeable($attr)){ + $$attr = ""; + + }elseif($this->acl_is_readable($attr)){ + $$attr = $part[$attr]; } - } - $FAIfsType.=""; + } + $str .= "\n"; $str .= "\n"; $str .= "\n"; - $str .= "\n"; - $str .= "\n"; - $str .= "\n"; - $str .= "\n"; + $str .= "\n"; + $str .= "\n"; + $str .= "\n"; + $str .= "\n"; $changeState = "onClick=\"changeState('FAImountPoint_".$key."') ; ". "changeState('FAIpartitionSize_".$key."') ; ". @@ -257,13 +275,24 @@ class faiPartitionTableEntry extends plugin "changeState('FAIfsType_".$key."') ; ". "changeState('FAIfsOptions_".$key."') ; \""; - - if($part['FAIpartitionFlags']!=false){ - $str .= "\n"; + if($this->acl_is_writeable("FAIpartitionFlags")){ + if($part['FAIpartitionFlags']!=false){ + $str .= "\n"; + }else{ + $str .= "\n"; + } + }else{ + if($part['FAIpartitionFlags']!=false){ + $str .= ""; + }else{ + $str .= ""; + } + } + if($this->acl_is_removeable()){ + $str .= "\n"; }else{ - $str .= "\n"; + $str .= "\n"; } - $str .= "\n"; $str .= "\n"; } } @@ -307,19 +336,16 @@ class faiPartitionTableEntry extends plugin if((isset($_POST['TableEntryFrameSubmitted'])) && ($this->FAIstate != "freeze") ){ plugin::save_object(); - /* Check base attributes */ - foreach($this->attributes as $attrs){ - if(isset($_POST[$attrs])){ - $this->$attrs = $_POST[$attrs]; - } - } - foreach($this->partitions as $key => $part){ foreach($this->UsedAttrs as $attrs){ - if(isset($_POST[$attrs."_".$key])){ - $this->partitions[$key][$attrs] = $_POST[$attrs."_".$key]; - }else{ - $this->partitions[$key][$attrs] = false; + + if($this->acl_is_writeable($attrs)){ + + if(isset($_POST[$attrs."_".$key])){ + $this->partitions[$key][$attrs] = $_POST[$attrs."_".$key]; + }else{ + $this->partitions[$key][$attrs] = false; + } } } } diff --git a/plugins/admin/fai/faiPartitionTable.tpl b/plugins/admin/fai/faiPartitionTable.tpl index a62397906..2b7ee4f07 100644 --- a/plugins/admin/fai/faiPartitionTable.tpl +++ b/plugins/admin/fai/faiPartitionTable.tpl @@ -10,7 +10,9 @@ @@ -20,7 +22,9 @@
"._("Type").""._("FS type").""._("Mount point").""._("Size in MB").""._("Mount options").""._("FS option").""._("Preserve").""._("Type").""._("FS type").""._("Mount point").""._("Size in MB").""._("Mount options").""._("FS option").""._("Preserve")." 
".$PartitionType."".$FAIfsType."".$FAImountPoint."".$FAIpartitionSize."".$FAImountOptions."".$FAIfsOptions.""._("False").""._("True")."
- +{render acl=$cnACL} + +{/render}
- +{render acl=$descriptionACL} + +{/render}
@@ -40,9 +44,14 @@
- - - +{if $sub_object_is_addable} + +{else} + +{/if} + + + diff --git a/plugins/admin/fai/faiPartitionTableEntry.tpl b/plugins/admin/fai/faiPartitionTableEntry.tpl index 9ceab9439..1e17e156f 100644 --- a/plugins/admin/fai/faiPartitionTableEntry.tpl +++ b/plugins/admin/fai/faiPartitionTableEntry.tpl @@ -5,12 +5,16 @@ {$must}  - +{render acl=$cnACL} + +{/render}   - +{render acl=$descriptionACL} + +{/render} @@ -20,13 +24,19 @@

 {t}Partition entries{/t}

{$setup}
- +{if $sub_object_is_createable} + +{else} + +{/if}

 


- +{render acl=$allowSave} + +{/render}