diff --git a/plugins/admin/fai/class_faiPartitionTable.inc b/plugins/admin/fai/class_faiPartitionTable.inc
index db65fed8545ccba3f6e724d4a42bf8a208918ee3..f6adfeb34f8aae34c3072253f33598490213b228 100644 (file)
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
$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;
}
}
}
+ ksort($this->disks);
}
function execute()
{
+ /* Call parent execute */
+ plugin::execute();
+
/* Fill templating stuff */
$smarty= get_smarty();
$display= "";
/* Edit disk.
* Open dialog which allows us to edit the selected entry
*/
+
+ if($this->dn != "new"){
+ $_SESSION['objectinfo']= $this->dn;
+ }
+
if((isset($_POST['EditDisk']))&&(isset($_POST['disks']))){
$usedDiskNames =array();
+
+ $Udisk = $_POST['disks'][0];
+
foreach($this->disks as $key=>$disk){
- if($key != $_POST['disks']){
+ if($key != $Udisk){
$usedDiskNames[]= $key;
}
}
- $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames,$this->disks[$_POST['disks']]);
+ $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames,$this->disks[$Udisk]);
+ $_SESSION['objectinfo'] = $this->disks[$Udisk]['dn'];
$this->is_dialog = true;
}
unset($this->dialog);
$this->dialog = NULL;
$this->is_dialog=false;
+ ksort($this->disks);
}
}
* Assign delete status for all its partitions
*/
if((isset($_POST['DelDisk']))&&(!empty($_POST['disks']))){
- $disk = $_POST['disks'];
- if($this->disks[$disk]['status']=="edited"){
- $this->disks[$disk."-delete"]=$this->disks[$disk];
- unset($this->disks[$disk]);
- $disk = $disk."-delete";
- $this->disks[$disk]['status']="delete";
- foreach($this->disks[$disk]['partitions'] as $name => $value ){
- if($value['status']=="edited"){
- $this->disks[$disk]['partitions'][$name]['status']="delete";
- }else{
- unset($this->disks[$disk]['partitions'][$name]);
+
+ foreach($_POST['disks'] as $disk) {
+ if($this->disks[$disk]['status']=="edited"){
+ $this->disks[$disk."-delete"]=$this->disks[$disk];
+ unset($this->disks[$disk]);
+ $disk = $disk."-delete";
+ $this->disks[$disk]['status']="delete";
+ foreach($this->disks[$disk]['partitions'] as $name => $value ){
+ if($value['status']=="edited"){
+ $this->disks[$disk]['partitions'][$name]['status']="delete";
+ }else{
+ unset($this->disks[$disk]['partitions'][$name]);
+ }
}
+ }else{
+ unset($this->disks[$disk]);
}
- }else{
- unset($this->disks[$disk]);
}
}
}
}
if(!empty($disk['description'])){
- $a_return[$key]= $disk['cn']." [".$disk['description']."] - "._("Number of Partitions")." :".$cnt;
+ 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']." - "._("Number of Partitions")." :".$cnt;
+ if($cnt == 1){
+ $a_return[$key]= $disk['cn'].", ".sprintf(_("%s partition"), $cnt);
+ }else{
+ $a_return[$key]= $disk['cn'].", ".sprintf(_("%s partition(s)"), $cnt);
+ }
}
}
}
{
$message= array();
-
- $str = utf8_encode("üöä");
- if((empty($this->description))||(preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->description))){
- $message[]=_("Please enter a valid description.");
- }
-
- if((empty($this->cn))||(preg_match("/[^a-z0-9]/i",$this->cn))){
- $message[]=_("Please enter a valid name.");
- }
-
return ($message);
}
$ldap = $this->config->get_ldap_link();
if($this->new){
- $ldap->cd($this->dn);
- $ldap->create_missing_trees($this->dn);
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
$ldap->cd($this->dn);
$ldap->add($this->attrs);
show_ldap_error($ldap->get_error());
$disk_attrs['cn'] = $disk['cn'];
$disk_attrs['description'] = $disk['description'];
$disk_attrs['objectClass'] = array("top","FAIclass","FAIpartitionDisk");
-
+
+ if($disk['status']=="new"){
+ $ldap->cat($disk_dn);
+ if($ldap->count()){
+ $disk['status']="edited";
+ }
+ }
+
if($disk['status'] == "delete"){
$ldap->cd($disk_dn);
$ldap->rmdir_recursive($disk_dn);
}elseif($disk['status']== "edited"){
+ if(empty($disk_attrs['description'])){
+ $disk_attrs['description']=array();
+ }
$ldap->cd($disk_dn);
$ldap->modify($disk_attrs);
}elseif($disk['status']== "new"){
- $ldap->cd($disk_dn);
- $ldap->create_missing_trees($disk_dn);
+ if(empty($disk_attrs['description'])){
+ unset($disk_attrs['description']);
+ }
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $disk_dn));
$ldap->cd($disk_dn);
$ldap->add($disk_attrs);
}else{
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;
}
}
- $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']);
-
+
+ if($partition['status']=="new"){
+ $ldap->cat($partition_dn);
+ if($ldap->count()){
+ $partition['status']="edited";
+ }
+ }
+
+ if((!isset($partition['FAImountPoint']))||(empty($partition['FAImountPoint']))){
+ $partition_attrs['FAImountPoint']="swap";
+ }
+
if(($partition['status'] == "delete")&&($disk['status']!="new")){
$ldap->cd($partition_dn);
$ldap->rmdir_recursive($partition_dn);
}elseif($partition['status'] == "new"){
- $ldap->cd($partition_dn);
- $ldap->create_missing_trees($partition_dn);
+ if(empty($partition_attrs['description'])){
+ unset($partition_attrs['description']);
+ }
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $partition_dn));
$ldap->cd($partition_dn);
$ldap->add($partition_attrs);
}elseif($partition['status'] == "edited"){
+ if(empty($partition_attrs['description'])){
+ $partition_attrs['description']=array();
+ }
$ldap->cd($partition_dn);
$ldap->modify($partition_attrs);
}