From b07cff3e121e8fcccfa7064d5e3b728838f55490 Mon Sep 17 00:00:00 2001 From: cajus Date: Mon, 19 Sep 2005 13:50:36 +0000 Subject: [PATCH] Generic layout changes git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1394 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/fai/class_faiManagement.inc | 4 +- plugins/admin/fai/class_faiPartitionTable.inc | 19 +- .../fai/class_faiPartitionTableEntry.inc | 214 ++++++------------ plugins/admin/fai/faiHook.tpl | 2 +- plugins/admin/fai/faiHookEntry.tpl | 10 +- plugins/admin/fai/faiPackage.tpl | 2 +- plugins/admin/fai/faiPartitionTable.tpl | 12 +- plugins/admin/fai/faiPartitionTableEntry.tpl | 27 +-- plugins/admin/fai/faiScriptEntry.tpl | 6 +- plugins/admin/fai/faiTemplateEntry.tpl | 10 +- plugins/admin/fai/faiVariableEntry.tpl | 8 +- 11 files changed, 108 insertions(+), 206 deletions(-) diff --git a/plugins/admin/fai/class_faiManagement.inc b/plugins/admin/fai/class_faiManagement.inc index 87046b498..22d4e28a0 100644 --- a/plugins/admin/fai/class_faiManagement.inc +++ b/plugins/admin/fai/class_faiManagement.inc @@ -398,8 +398,8 @@ class faiManagement extends plugin array("string" => _("Actions"), "attach"=>"style='border:none;width:40px;'"))); - $action = ""; - $action .= ""; + $action = ""; + $action .= ""; /* Attach objects */ foreach($this->objects as $key => $value){ diff --git a/plugins/admin/fai/class_faiPartitionTable.inc b/plugins/admin/fai/class_faiPartitionTable.inc index db65fed85..888c1e104 100644 --- a/plugins/admin/fai/class_faiPartitionTable.inc +++ b/plugins/admin/fai/class_faiPartitionTable.inc @@ -11,7 +11,6 @@ class faiPartitionTable extends plugin var $ignore_account = TRUE; var $attributes = array("cn","description"); var $objectclasses = array("top","FAIclass","FAIpartitionTable"); - var $base64_encode = array("FAImountPoint","FAImountOptions","FAIfsOptions","description"); /* Specific attributes */ var $cn = ""; // The class name for this object @@ -65,13 +64,10 @@ class faiPartitionTable extends plugin $partition[$key] = $val[0]; } } + /* Append fetched partitions */ $partition['status']="edited"; - - foreach($this->base64_encode as $attrs){ - $partition[$attrs] = base64_decode($partition[$attrs]); - } $this->disks[$name]['partitions'][$partition['FAIpartitionNr']] = $partition; } } @@ -215,9 +211,9 @@ class faiPartitionTable extends plugin } } if(!empty($disk['description'])){ - $a_return[$key]= $disk['cn']." [".$disk['description']."] - "._("Number of Partitions")." :".$cnt; + $a_return[$key]= $disk['cn']." [".$disk['description']."], ".sprintf(_("%s partition(s)"), $cnt); }else{ - $a_return[$key]= $disk['cn']." - "._("Number of Partitions")." :".$cnt; + $a_return[$key]= $disk['cn'].", ".sprintf(_("%s partition(s)"), $cnt); } } } @@ -339,10 +335,6 @@ class faiPartitionTable extends plugin foreach($disk['partitions'] as $key => $partition){ $partition_attrs = array(); - foreach($this->base64_encode as $attrs){ - $partition[$attrs] = base64_encode($partition[$attrs]); - } - foreach($partition as $key => $value){ if(!empty($value)){ $partition_attrs[$key]=$value; @@ -351,8 +343,9 @@ class faiPartitionTable extends plugin } } - $partition_dn = "cn=".$partition_attrs['cn'].",".$disk_dn; - $partition_attrs['objectClass'] = array("top","FAIclass","FAIpartitionEntry"); + $partition_dn= "FAIpartitionNr=".$partition_attrs['FAIpartitionNr'].",".$disk_dn; + $partition_attrs['objectClass']= array("top","FAIclass","FAIpartitionEntry"); + $partition_attrs['cn']= $partition_attrs['FAIpartitionNr']; unset($partition_attrs['status']); unset($partition_attrs['old_cn']); diff --git a/plugins/admin/fai/class_faiPartitionTableEntry.inc b/plugins/admin/fai/class_faiPartitionTableEntry.inc index 878ffafe9..64c716be4 100644 --- a/plugins/admin/fai/class_faiPartitionTableEntry.inc +++ b/plugins/admin/fai/class_faiPartitionTableEntry.inc @@ -17,7 +17,6 @@ class faiPartitionTableEntry extends plugin var $partitions = array(); var $UsedAttrs = array(); - var $AvailableDiskNames = array(); var $is_edit = false; var $old_cn = ""; var $status = "new"; @@ -29,16 +28,6 @@ class faiPartitionTableEntry extends plugin $this->UsedAttrs = array("cn","description","FAIpartitionType","FAIpartitionNr","FAIfsType","FAImountPoint","FAIpartitionSize", "FAImountOptions","FAIfsOptions","FAIpartitionFlags"); - /* Generate available disknames, to avoid duplicates in cn */ - $this->AvailableDiskNames = array(); - foreach(array("a","b","c","d","e","f","g","h") as $ts){ - if(!in_array("hd".$ts,$usedDiskNames)){ - $this->AvailableDiskNames["hd".$ts]= "hd".$ts; - } - } - - $this->AvailableDiskNames['disk1']= "disk1"; - $this->AvailableDiskNames['disk2']= "disk2"; /* Default status is new */ $this->status = "new"; @@ -153,10 +142,6 @@ class faiPartitionTableEntry extends plugin $this->partitions[count($this->partitions)+1]=$tmp; } - /* Tell smarty which Disknames are available. - */ - $smarty->assign("cns", $this->AvailableDiskNames); - /* $setup contains a table with the partitions. */ $smarty->assign("setup", $this->generateParts()); @@ -186,21 +171,20 @@ class faiPartitionTableEntry extends plugin $FAIfsTypes = array("ext2","ext3","xfs","swap","reiserfs","dos fat 16","win fat 32"); /* Display Header */ - $str = ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - + $str = "
"._("Nr").""._("Name").""._("Description").""._("Type").""._("FS type").""._("Mount point").""._("Size in MB").""._("Mount options").""._("FS option").""._("Preserve")."
"; + if (count($this->partitions)){ + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + } + /* Walk through all defined partitions. * Create a new row for each partition and append it to * the header defined above. @@ -234,13 +218,10 @@ class faiPartitionTableEntry extends plugin $FAIfsType.=""; $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; $str .= ""; $str .= ""; $str .= ""; - $str .= ""; + $str .= ""; $str .= ""; $str .= ""; if($part['FAIpartitionFlags']!=false){ @@ -257,6 +238,36 @@ class faiPartitionTableEntry extends plugin } + function save() + { + $tmp = array(); + $tmp['cn'] = $this->DISK_cn; + + /* Attach partitions */ + foreach($this->partitions as $key=>$val) { + $this->partitions[$key]['FAIpartitionNr']=$key; + } + + /* Attach deleted */ + foreach($this->deletePartitions as $key=>$val) { + $this->partitions[$key."-delete"]=$val; + $this->partitions[$key."-delete"]['status']="delete"; + } + + $tmp['description'] = $this->DISK_description; + $tmp['partitions'] = $this->partitions; + $tmp['status'] = $this->status; + + /* If hdd name has changed, tell partitionTable to rename it */ + if(($this->is_edit)&&($this->old_cn != $this->DISK_cn)){ + $tmp['rename']['from'] = $this->old_cn; + $tmp['rename']['to'] = $this->DISK_cn; + } + + return($tmp); + } + + /* Save data to object */ function save_object() { @@ -294,11 +305,6 @@ class faiPartitionTableEntry extends plugin $message[] = _("Please enter a description for your disk."); } - $str = utf8_encode("üöä"); - if(preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->DISK_description)){ - $message[]=_("Please enter a valid description."); - } - /* check every partition. * if there is an invalid value defined, append an errorstr to message */ @@ -311,22 +317,10 @@ class faiPartitionTableEntry extends plugin foreach($this->partitions as $key => $part){ - if((empty($part['cn']))||(preg_match("/[^0-9a-z]/",$part['cn']))){ - $message[]=sprintf(_("Please enter a valid name for partition %s."),($key)); - } - - if(in_array($part['cn'],$alreadyUsed['cn'])){ - $message[]=sprintf(_("please enter a unique name for partition %s"),($key)); - } - if(in_array($part['FAImountPoint'],$alreadyUsed['FAImountPoint'])){ $message[]=sprintf(_("please enter a unique mount point for partition %s"),($key)); } - if(empty($part['description'])){ - $message[]=sprintf(_("Please enter a valid description for partition %s." ),($key)); - } - if((empty($part['FAImountPoint']))||(!((preg_match("/^\/.*/",$part['FAImountPoint']))||(preg_match("/^swap$/",$part['FAImountPoint']))))){ $message[]=sprintf(_("Please enter a valid mount point for partition %s." ),($key)); } @@ -338,112 +332,36 @@ class faiPartitionTableEntry extends plugin } $tmp = split("-",$part['FAIpartitionSize']); - if(count($tmp)!=2){ - $message[]=sprintf(_("Please enter a range for partition size, 'from-to', for partition %s."),($key)); - }elseif((!is_numeric($tmp[0]))||(!is_numeric($tmp[1]))){ - $message[]=sprintf(_("Please enter a valid range for partition %s."),($key)); - }elseif($tmp[0]>=$tmp[1]){ - $message[]=sprintf(_("Please enter a valid range for partition %s."),($key)); - }elseif($this->checkSize($part['FAIpartitionSize'],$alreadyUsed['FAIpartitionSize'],$key)){ - $message[]=$this->checkSize($part['FAIpartitionSize'],$alreadyUsed['FAIpartitionSize'],$key); + switch (count($tmp)){ + case 0: + $message[]= sprintf(_("Please enter a valid partition size for partition %s."),($key)); + break; + case 1: + if (!is_id(is_id($tmp[0]))){ + $message[]= sprintf(_("Please enter a valid partition size for partition %s."),($key)); + } + break; + + case 2: + if((!is_id($tmp[0]))||(!is_id($tmp[1]))){ + $message[]=sprintf(_("Please enter a valid range for partition %s."),($key)); + }elseif($tmp[0]>=$tmp[1]){ + $message[]=sprintf(_("Please enter a valid range for partition %s."),($key)); + } + break; + + default: + $message[]=sprintf(_("Please enter a range for partition size for partition %s."),($key)); } + foreach($this->UsedAttrs as $attrs){ $alreadyUsed[$attrs][$key] = $part[$attrs]; } } - - /* Only show 5 errors */ - $cnt = 0; - if(count($message)>5){ - foreach($message as $msg){ - if($cnt < 5){ - $tmp2[]=$msg; - } - $cnt ++; - } - $tmp2[] = "..."; - $message = $tmp2; - } - return ($message); } - - /* This function checks the selected partition sizes - * If a size setting overlap with another, it returns an error msg - */ - function checkSize($current,$others,$ckey){ - $tmp = split("-",$current); - $from = $tmp[0]; - $to = $tmp[1]; - foreach($others as $key=> $other){ - $tmp = split("-",$other); - $oth_from = $tmp[0]; - $oth_to = $tmp[1]; - /* surrounds another entry */ - if( (($from <= $oth_from)&&($to >= $oth_to))|| // inside - (($from >= $oth_from)&&($to <= $oth_to))|| // outside - (($to >= $oth_from)&&($to <= $oth_to)) || // overlap at right - (($from >= $oth_from)&&($from <= $oth_to)) ){ // overlap left - $message =sprintf( _("Size settings for partition %s, overlap with size settings for partition %s."),$ckey,$key); - return($message); - } - } - return(false); - } - - function save() - { - /* This function returns the new or edited disk with its partitions. - * If the disk was edited and not a new one, we reset the name of the disk - * to keep the correct index. - */ - - /* Check partition rename - */ - foreach($this->partitions as $key => $part){ - if($part['cn'] != $part['old_cn']){ - if($part['status'] == "edited"){ - - $tmp = $part; - $tmp['status']= "delete"; - $tmp['cn'] = $part['old_cn']; - - $this->deletePartitions[] = $tmp; - } - $this->partitions[$key]['old_cn']=$part['cn']; - $this->partitions[$key]['status']="new"; - } - } - - $tmp = array(); - $tmp['cn'] = $this->DISK_cn; - - /* Attach partitions */ - foreach($this->partitions as $key=>$val) { - $this->partitions[$key]['FAIpartitionNr']=$key; - } - - /* Attach deleted */ - foreach($this->deletePartitions as $key=>$val) { - $this->partitions[$key."-delete"]=$val; - $this->partitions[$key."-delete"]['status']="delete"; - } - - $tmp['description'] = $this->DISK_description; - $tmp['partitions'] = $this->partitions; - $tmp['status'] = $this->status; - - /* If hdd name has changed, tell partitionTable to rename it */ - if(($this->is_edit)&&($this->old_cn != $this->DISK_cn)){ - $tmp['rename']['from'] = $this->old_cn; - $tmp['rename']['to'] = $this->DISK_cn; - } - - return($tmp); - } - } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: diff --git a/plugins/admin/fai/faiHook.tpl b/plugins/admin/fai/faiHook.tpl index ab2fcc35b..245852d6f 100644 --- a/plugins/admin/fai/faiHook.tpl +++ b/plugins/admin/fai/faiHook.tpl @@ -1,7 +1,7 @@
"._("Type").""._("FS type").""._("Mount point").""._("Size in MB").""._("Mount options").""._("FS option").""._("Preserve")." 
".($key)."".$PartitionType."".$FAIfsType."
-

 {t}Generic{/t}

+

 {t}Generic{/t}

diff --git a/plugins/admin/fai/faiHookEntry.tpl b/plugins/admin/fai/faiHookEntry.tpl index 2dd86e4fc..c74f41988 100644 --- a/plugins/admin/fai/faiHookEntry.tpl +++ b/plugins/admin/fai/faiHookEntry.tpl @@ -6,7 +6,7 @@
- {t}Name{/t} {$must} + {t}Name{/t}{$must}  @@ -14,7 +14,7 @@
- {t}Description{/t} {$must} + {t}Description{/t}{$must}  @@ -31,7 +31,7 @@
@@ -41,7 +41,7 @@
@@ -56,6 +56,6 @@
  - +
diff --git a/plugins/admin/fai/faiPackage.tpl b/plugins/admin/fai/faiPackage.tpl index d72310d6d..ea72c87b8 100644 --- a/plugins/admin/fai/faiPackage.tpl +++ b/plugins/admin/fai/faiPackage.tpl @@ -1,7 +1,7 @@
-

 {t}Generic{/t}


+

 {t}Generic{/t}

diff --git a/plugins/admin/fai/faiPartitionTable.tpl b/plugins/admin/fai/faiPartitionTable.tpl index 6d3f6229a..b8150b892 100644 --- a/plugins/admin/fai/faiPartitionTable.tpl +++ b/plugins/admin/fai/faiPartitionTable.tpl @@ -1,7 +1,7 @@
-

 {t}Generic{/t}


+

 {t}Generic{/t}

@@ -20,7 +20,7 @@ - +
@@ -29,15 +29,15 @@  
-

  +

  -


+
- {html_options values=$diskKeys output=$disks}
diff --git a/plugins/admin/fai/faiPartitionTableEntry.tpl b/plugins/admin/fai/faiPartitionTableEntry.tpl index 776905dae..a03dddca2 100644 --- a/plugins/admin/fai/faiPartitionTableEntry.tpl +++ b/plugins/admin/fai/faiPartitionTableEntry.tpl @@ -1,25 +1,16 @@ -
-

 {t}Generic{/t}

- +

 {t}Device{/t}

+
- - - - -
 {$must} - - + {$must}  +
 {$must} - - +  {t}Description{/t} + {$must}  +
@@ -36,5 +27,5 @@
- +
diff --git a/plugins/admin/fai/faiScriptEntry.tpl b/plugins/admin/fai/faiScriptEntry.tpl index e5d7a7018..c07a8dc09 100644 --- a/plugins/admin/fai/faiScriptEntry.tpl +++ b/plugins/admin/fai/faiScriptEntry.tpl @@ -6,7 +6,7 @@
- {t}Name{/t} {$must} + {t}Name{/t}{$must}  @@ -14,7 +14,7 @@
- {t}Description{/t} {$must} + {t}Description{/t}{$must}  @@ -67,6 +67,6 @@
  - +
diff --git a/plugins/admin/fai/faiTemplateEntry.tpl b/plugins/admin/fai/faiTemplateEntry.tpl index 44c3bf8cd..70dd862f6 100644 --- a/plugins/admin/fai/faiTemplateEntry.tpl +++ b/plugins/admin/fai/faiTemplateEntry.tpl @@ -6,7 +6,7 @@
- {t}Name{/t} {$must} + {t}Name{/t}{$must}  @@ -14,7 +14,7 @@
- {t}Description{/t} {$must} + {t}Description{/t}{$must}  @@ -31,7 +31,7 @@
@@ -41,7 +41,7 @@
@@ -56,6 +56,6 @@
  - +
diff --git a/plugins/admin/fai/faiVariableEntry.tpl b/plugins/admin/fai/faiVariableEntry.tpl index 131e7d1a3..d2a80113a 100644 --- a/plugins/admin/fai/faiVariableEntry.tpl +++ b/plugins/admin/fai/faiVariableEntry.tpl @@ -6,7 +6,7 @@
- {t}Name{/t} {$must} + {t}Name{/t}{$must}  @@ -14,7 +14,7 @@
- {t}Description{/t} {$must} + {t}Description{/t}{$must}  @@ -31,7 +31,7 @@
@@ -46,6 +46,6 @@
  - +
-- 2.30.2