diff --git a/plugins/admin/fai/class_faiPartitionTable.inc b/plugins/admin/fai/class_faiPartitionTable.inc
index 59a1cc5d390304dffc56cebd1ee777b891aaefd1..550e719991cc036a9955d983edb24279c90b7179 100644 (file)
var $dialog = NULL; // a dialog, e.g. new disk dialog
var $FAIstate = "";
+ var $ui;
function faiPartitionTable ($config, $dn= NULL)
{
$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.
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])){
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 */
$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;
}
$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;
}
}
}
- 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));
*/
$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);
+ }
}
}
}
$ldap = $this->config->get_ldap_link();
$ldap->cd ($this->dn);
- $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $this->dn);
+# $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $this->dn);
+ $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $this->dn);
if($_SESSION['faifilter']['branch'] == "main"){
$use_dn = $this->dn;
}
foreach($this->disks as $disk){
$disk_dn = "cn=".$disk['cn'].",".$this->dn;
- $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $disk_dn);
+# $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $disk_dn);
+ $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $disk_dn);
if($_SESSION['faifilter']['branch'] == "main"){
$use_dn = $disk_dn;
}
foreach($disk['partitions'] as $key => $partition){
$partition_dn= "FAIpartitionNr=".$partition['FAIpartitionNr'].",".$disk_dn;
- $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $partition_dn);
+# $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $partition_dn);
+ $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $partition_dn);
if($_SESSION['faifilter']['branch'] == "main"){
$use_dn = $disk_dn;
}
"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"))
));
}
}