diff --git a/plugins/admin/fai/class_faiPartitionTable.inc b/plugins/admin/fai/class_faiPartitionTable.inc
index ca107408b685b35d7e5cc6bc82ca78f1f0588c81..efc90856b669f60b3235cec13dc789bc13935d77 100644 (file)
var $is_dialog = false; // specifies which buttons will be shown to save or abort
var $dialog = NULL; // a dialog, e.g. new disk dialog
+ var $FAIstate = "";
+
function faiPartitionTable ($config, $dn= NULL)
{
/* Load Attributes */
plugin::plugin ($config, $dn);
+ $this->acl ="#all#";
+
/* 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])){
+ $this->FAIstate = $this->attrs['FAIstate'][0];
+ }
+
/* Read all disks from ldap taht are defined fot this partition table
*/
$ldap = $this->config->get_ldap_link();
$usedDiskNames[]= $key;
}
$this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames);
+ $this->dialog->acl = $this->acl;
+ $this->dialog->FAIstate = $this->FAIstate;
$this->is_dialog = true;
}
/* Edit disk.
* Open dialog which allows us to edit the selected entry
*/
- $_SESSION['objectinfo'] = $this->dn;
+
+ 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']]);
- $_SESSION['objectinfo'] = $this->disks[$_POST['disks']]['dn'];
+ $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'];
+ }else{
+ $_SESSION['objectinfo'] = "";
+ }
+
$this->is_dialog = true;
}
$this->dialog = NULL;
$this->is_dialog=false;
}
-
+
/* Dialog saved
* Save given data from Dialog, if no error is occured
*/
if(isset($_POST['SaveDisk'])){
- $this->dialog->save_object();
- if(count($this->dialog->check())){
- foreach($this->dialog->check() as $msg){
- print_red($msg);
- }
- }else{
- $disk = $this->dialog->save();
- if(isset($disk['rename'])){
- if($this->disks[$disk['rename']['from']]['status']=="edited"){
- $this->disks[$disk['rename']['from']]['status']="delete";
- }else{
- unset($this->disks[$disk['rename']['from']]);
+
+ if($this->FAIstate != "freeze"){
+ $this->dialog->save_object();
+ if(count($this->dialog->check())){
+ foreach($this->dialog->check() as $msg){
+ print_red($msg);
}
-
- foreach($disk['partitions'] as $key => $val){
- if($disk['partitions'][$key]['status']!="delete"){
- $disk['partitions'][$key]['status']= "new";
+ }else{
+ $disk = $this->dialog->save();
+ if(isset($disk['rename'])){
+ if($this->disks[$disk['rename']['from']]['status']=="edited"){
+ $this->disks[$disk['rename']['from']]['status']="delete";
+ }else{
+ unset($this->disks[$disk['rename']['from']]);
+ }
+
+ foreach($disk['partitions'] as $key => $val){
+ if($disk['partitions'][$key]['status']!="delete"){
+ $disk['partitions'][$key]['status']= "new";
+ }
}
+
+ $disk['status']="new";
+ $disk['cn']= $disk['rename']['to'];
}
- $disk['status']="new";
- $disk['cn']= $disk['rename']['to'];
+ $this->disks[$disk['cn']]=$disk;
+ unset($this->dialog);
+ $this->dialog = NULL;
+ $this->is_dialog=false;
+ ksort($this->disks);
}
-
- $this->disks[$disk['cn']]=$disk;
- unset($this->dialog);
+ }else{
$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";
+ if($this->FAIstate != "freeze"){
+ 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]['partitions'][$name]);
+ unset($this->disks[$disk]);
}
}
- }else{
- unset($this->disks[$disk]);
}
}
$smarty->assign($attrs."CHK"," disabled ");
}
}
-
+
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
+ }
+
$disks = $this->getDisks();
$smarty->assign("disks" ,$disks);
- $smarty->assign("diskKeys",array_flip($disks));
$display.= $smarty->fetch(get_template_path('faiPartitionTable.tpl', TRUE));
return($display);
}
*/
function save_object()
{
+ if($this->FAIstate == "freeze") return;
plugin::save_object();
foreach($this->attributes as $attrs){
if(isset($_POST[$attrs])){
/* Check supplied data */
function check()
{
+ /* Call common method to give check the hook */
+ $message= plugin::check();
- $message= array();
return ($message);
}
$ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
$ldap->cd($this->dn);
$ldap->add($this->attrs);
- show_ldap_error($ldap->get_error());
}else{
/* Add partition table to ldap
*/
$ldap->cd($this->dn);
- $ldap->modify($this->attrs);
- show_ldap_error($ldap->get_error());
+ $this->cleanup();
+ $ldap->modify ($this->attrs);
}
+ show_ldap_error($ldap->get_error(), _("Saving FAI partition table base failed"));
+ /* Do object tagging */
+ $this->handle_object_tagging();
/* Sort entries, because we must delete entries with status="delete" first */
$order = array();
$disk_attrs['objectClass'] = array("top","FAIclass","FAIpartitionDisk");
if($disk['status']=="new"){
- $ldap->cat($disk_dn);
+ $ldap->cat($disk_dn,array("objectClass"));
if($ldap->count()){
$disk['status']="edited";
}
}
+
+ /* Fix problem with missing objectClass "gosaAdministrativeUnitTag" for disks */
+ $ldap->cat($disk_dn,array("objectClass"));
+ $attrs = $ldap->fetch();
+ if(isset($attrs['objectClass']) && in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){
+ $disk_attrs['objectClass'][] = "gosaAdministrativeUnitTag";
+ }
if($disk['status'] == "delete"){
$ldap->cd($disk_dn);
$ldap->rmdir_recursive($disk_dn);
+ show_ldap_error($ldap->get_error(), _("Removing FAI partition table failed"));
}elseif($disk['status']== "edited"){
if(empty($disk_attrs['description'])){
$disk_attrs['description']=array();
}
$ldap->cd($disk_dn);
- $ldap->modify($disk_attrs);
+ $this->cleanup();
+ $ldap->modify ($disk_attrs);
+ show_ldap_error($ldap->get_error(), _("Saving FAI partition table failed"));
}elseif($disk['status']== "new"){
if(empty($disk_attrs['description'])){
unset($disk_attrs['description']);
$ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $disk_dn));
$ldap->cd($disk_dn);
$ldap->add($disk_attrs);
+ show_ldap_error($ldap->get_error(), _("Saving FAI partition table failed"));
}else{
print_red("unknown status while saving disks");
}
- show_ldap_error($ldap->get_error());
+ $this->handle_object_tagging($disk_dn, $this->gosaUnitTag);
+
if($disk['status']!="delete")
/* Add all partitions */
foreach($disk['partitions'] as $key => $partition){
unset($partition_attrs['old_cn']);
if($partition['status']=="new"){
- $ldap->cat($partition_dn);
+ $ldap->cat($partition_dn,array("objectClass"));
if($ldap->count()){
$partition['status']="edited";
}
$partition_attrs['FAImountPoint']="swap";
}
+ /* Fix problem with missing objectClass "gosaAdministrativeUnitTag" for partitions */
+ $ldap->cat($partition_dn,array("objectClass"));
+ $attrs = $ldap->fetch();
+ if(isset($attrs['objectClass']) && in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){
+ $partition_attrs['objectClass'][] = "gosaAdministrativeUnitTag";
+ }
+
if(($partition['status'] == "delete")&&($disk['status']!="new")){
$ldap->cd($partition_dn);
$ldap->rmdir_recursive($partition_dn);
+ show_ldap_error($ldap->get_error(), _("Removing FAI partition table entry failed"));
}elseif($partition['status'] == "new"){
if(empty($partition_attrs['description'])){
unset($partition_attrs['description']);
$ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $partition_dn));
$ldap->cd($partition_dn);
$ldap->add($partition_attrs);
+ show_ldap_error($ldap->get_error(), _("Saving FAI partition table entry failed"));
}elseif($partition['status'] == "edited"){
if(empty($partition_attrs['description'])){
$partition_attrs['description']=array();
}
$ldap->cd($partition_dn);
- $ldap->modify($partition_attrs);
+ $this->cleanup();
+ $ldap->modify ($partition_attrs);
+ show_ldap_error($ldap->get_error(), _("Saving FAI partition table entry failed"));
}
- show_ldap_error($ldap->get_error());
+
+ $this->handle_object_tagging($partition_dn, $this->gosaUnitTag);
}
}
$this->handle_post_events("add");