diff --git a/plugins/admin/fai/class_faiPartitionTable.inc b/plugins/admin/fai/class_faiPartitionTable.inc
index 888c1e1044f042f515e875aaed7e0112ac8b4a2f..fc35fd188204f1ff3cc2218af40e4c03074100bd 100644 (file)
}
}
}
}
}
}
+ ksort($this->disks);
}
function execute()
{
}
function execute()
{
+ /* Call parent execute */
+ plugin::execute();
+
/* Fill templating stuff */
$smarty= get_smarty();
$display= "";
/* Fill templating stuff */
$smarty= get_smarty();
$display= "";
/* Edit disk.
* Open dialog which allows us to edit the selected entry
*/
/* 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();
foreach($this->disks as $key=>$disk){
if((isset($_POST['EditDisk']))&&(isset($_POST['disks']))){
$usedDiskNames =array();
foreach($this->disks as $key=>$disk){
}
}
$this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames,$this->disks[$_POST['disks']]);
}
}
$this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames,$this->disks[$_POST['disks']]);
+ $_SESSION['objectinfo'] = $this->disks[$_POST['disks']]['dn'];
$this->is_dialog = true;
}
$this->is_dialog = true;
}
unset($this->dialog);
$this->dialog = NULL;
$this->is_dialog=false;
unset($this->dialog);
$this->dialog = NULL;
$this->is_dialog=false;
+ ksort($this->disks);
}
}
}
}
}
}
if(!empty($disk['description'])){
}
}
if(!empty($disk['description'])){
- $a_return[$key]= $disk['cn']." [".$disk['description']."], ".sprintf(_("%s partition(s)"), $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{
}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);
+ }
}
}
}
}
}
}
{
$message= array();
{
$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);
}
return ($message);
}
$ldap = $this->config->get_ldap_link();
if($this->new){
$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());
$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");
$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($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->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{
$ldap->cd($disk_dn);
$ldap->add($disk_attrs);
}else{
unset($partition_attrs['status']);
unset($partition_attrs['old_cn']);
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"){
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"){
$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);
}
$ldap->cd($partition_dn);
$ldap->modify($partition_attrs);
}