From: hickert Date: Wed, 6 Jan 2010 11:39:41 +0000 (+0000) Subject: Enabled multiple remove X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=df48c3bcedc43e38923abc6938b2386b171675e9;p=gosa.git Enabled multiple remove git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15082 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/fai/admin/fai/class_faiManagement.inc b/gosa-plugins/fai/admin/fai/class_faiManagement.inc index 03ba0cd83..08e50cf9b 100644 --- a/gosa-plugins/fai/admin/fai/class_faiManagement.inc +++ b/gosa-plugins/fai/admin/fai/class_faiManagement.inc @@ -76,45 +76,47 @@ class faiManagement extends management # if (session::global_is_set(get_class($this)."_filter")){ # $filter= session::global_get(get_class($this)."_filter"); # } else { - $filter = new filter(get_template_path("fai-filter.xml", true)); - $filter->setObjectStorage($this->storagePoints); + $filter = new filter(get_template_path("fai-filter.xml", true)); + $filter->setObjectStorage($this->storagePoints); # } - $this->setFilter($filter); + $this->setFilter($filter); - // Build headpage - $headpage = new listing(get_template_path("fai-list.xml", true)); - $headpage->setFilter($filter); - $headpage->setBase($this->fai_release); - $headpage->registerElementFilter("filterProperties", "faiManagement::filterProperties"); + // Build headpage + $headpage = new listing(get_template_path("fai-list.xml", true)); + $headpage->setFilter($filter); + $headpage->setBase($this->fai_release); + $headpage->registerElementFilter("filterProperties", "faiManagement::filterProperties"); - // Add copy&paste and snapshot handler. - if ($this->config->boolValueIsTrue("main", "copyPaste")){ - $this->cpHandler = new CopyPasteHandler($this->config); - } - if($this->config->get_cfg_value("enableSnapshots") == "true"){ - $this->snapHandler = new SnapshotHandler($this->config); - } + // Add copy&paste and snapshot handler. + if ($this->config->boolValueIsTrue("main", "copyPaste")){ + $this->cpHandler = new CopyPasteHandler($this->config); + } + if($this->config->get_cfg_value("enableSnapshots") == "true"){ + $this->snapHandler = new SnapshotHandler($this->config); + } - $this->registerAction("new_profile","newEntry"); - $this->registerAction("new_template","newEntry"); - $this->registerAction("new_script","newEntry"); - $this->registerAction("new_hook","newEntry"); - $this->registerAction("new_variable","newEntry"); - $this->registerAction("new_package","newEntry"); - $this->registerAction("new_partition","newEntry"); + $this->registerAction("remove_multiple","removeEntryRequested"); - $this->registerAction("newClassNameSelected","newClassNameSelected"); + $this->registerAction("new_profile","newEntry"); + $this->registerAction("new_template","newEntry"); + $this->registerAction("new_script","newEntry"); + $this->registerAction("new_hook","newEntry"); + $this->registerAction("new_variable","newEntry"); + $this->registerAction("new_package","newEntry"); + $this->registerAction("new_partition","newEntry"); - $this->registerAction("saveOpsiProperties","saveOpsiProperties"); + $this->registerAction("newClassNameSelected","newClassNameSelected"); - $this->registerAction("editByGroup","editByGroup"); - $this->registerAction("createBranch","createBranch"); - $this->registerAction("createFreeze","createFreeze"); - $this->registerAction("removeBranch","removeBranch"); - $this->registerAction("removeBranchConfirmed","removeBranchConfirmed"); - $this->registerAction("saveBranch","saveBranch"); - $this->registerAction("PerformBranch","PerformBranch"); - parent::__construct($config, $ui, "roles", $headpage); + $this->registerAction("saveOpsiProperties","saveOpsiProperties"); + + $this->registerAction("editByGroup","editByGroup"); + $this->registerAction("createBranch","createBranch"); + $this->registerAction("createFreeze","createFreeze"); + $this->registerAction("removeBranch","removeBranch"); + $this->registerAction("removeBranchConfirmed","removeBranchConfirmed"); + $this->registerAction("saveBranch","saveBranch"); + $this->registerAction("PerformBranch","PerformBranch"); + parent::__construct($config, $ui, "roles", $headpage); } @@ -257,11 +259,66 @@ class faiManagement extends management function removeEntryRequested($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="") { - $headpage = $this->getHeadpage(); - if(count($target) == 1){ - $entry = $headpage->getEntry($target[0]); - if($entry){ - $this->dialogObject = new faiGroupHandle($entry['GROUPS'],"remove"); + + $this->closeDialogs(); + if($action == "remove_multiple"){ + + /* Collect objects to delete and check if objects are freezed + */ + $errors = ""; + $headpage = $this->getHeadpage(); + $to_delete = array(); + foreach($target as $id){ + $object = $headpage->getEntry($id); + if(in_array("FAKE_OC_FAI", $object['objectClass'])){ + foreach($object['GROUPS'] as $entry){ + + // Only allow to remove FAI classes + array_push($to_delete, $entry); + } + } + } + + foreach($to_delete as $obj){ + if(isset($obj['FAIstate']) && preg_match('/^freeze/', $obj['FAIstate'])){ + $errors .= $obj['cn'].", "; + }else{ + $this->dns[] = $obj['dn']; + } + } + + if($errors != ""){ + msg_dialog::display(_("Branch locked"),sprintf(_("The following entries are locked, you can't remove them %s."), + "

".trim($errors,", ")),INFO_DIALOG); + } + /* Check locking + */ + if(count($this->dns)){ + if ($user= get_multiple_locks($this->dns)){ + return(gen_locked_message($user,$this->dns)); + } + if(count($this->dns)){ + $smarty = get_smarty(); + $dns_names = array(); + foreach($this->dns as $dn){ + add_lock ($dn, $this->ui->dn); + $dns_names[] = LDAP::fix($dn); + } + $smarty->assign("info",msgPool::deleteInfo($dns_names,_("FAI object"))); + $smarty->assign("multiple", true); + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } + } + + }else{ + + // Try to remove a single object, only FAI objects can be removed! + $headpage = $this->getHeadpage(); + if(count($target) == 1){ + $entry = $headpage->getEntry($target[0]); + if($entry && !in_array("FAKE_OC_OPSI",$entry['objectClass'])){ + $this->dialogObject = new faiGroupHandle($entry['GROUPS'],"remove"); + } } } } @@ -276,7 +333,8 @@ class faiManagement extends management $altTabClass="",$altTabType="",$altAclCategory="") { $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); + $ldap->cd($this->config->current['BASE']); + foreach($this->dns as $key => $dn){ $ldap->cat($dn); if($ldap->count()){ @@ -404,6 +462,7 @@ class faiManagement extends management function detectPostActions() { $action = management::detectPostActions(); + if(isset($_POST['remove_multiple'])) $action['action'] = "remove"; if(isset($_POST['new_profile'])) $action['action'] = "new_profile"; if(isset($_POST['new_template'])) $action['action'] = "new_template"; if(isset($_POST['new_script'])) $action['action'] = "new_script"; diff --git a/gosa-plugins/fai/admin/fai/class_filterFAI.inc b/gosa-plugins/fai/admin/fai/class_filterFAI.inc index e270058dd..5524e0c1f 100644 --- a/gosa-plugins/fai/admin/fai/class_filterFAI.inc +++ b/gosa-plugins/fai/admin/fai/class_filterFAI.inc @@ -49,12 +49,13 @@ class filterFAI extends filterLDAP{ /* Clean up object informations */ $obj = array(); $obj['cn'] = $object['cn'][0]; - $obj['dn'] = $object['cn'][0]; + $obj['dn'] = $object['cn'][0].",".get_ou("faiBaseRDN").$config->current['BASE']; $obj['acl'] = $acl; $obj['class'] = $rest ['ACL']; $obj['FAIstate'] = $entry['FAIstate']; $obj['description'] = $object['description'][0]; $obj['objectClass'] = $object['objectClass']; + $obj['objectClass'][] = 'FAKE_OC_FAI'; if(!preg_match("/freeze/i", $entry['FAIstate'])){ $obj['objectClass'][] = "FAKE_OC_IsBranch"; @@ -139,8 +140,7 @@ class filterFAI extends filterLDAP{ } $item =array(); - // FAKE_OC_IsBranch allows us to delete this entry (indicates NOT freezed state) - $item['objectClass'] = array('count' => 2, $data['type'], "FAKE_OC_IsBranch"); + $item['objectClass'] = array('count' => 2, $data['type'],"FAKE_OC_OPSI"); $item[] = 'objectClass'; $item['cn'] = $data['cn']; $item[] = 'cn'; diff --git a/gosa-plugins/fai/admin/fai/fai-list.xml b/gosa-plugins/fai/admin/fai/fai-list.xml index d7b750320..703cae6d2 100644 --- a/gosa-plugins/fai/admin/fai/fai-list.xml +++ b/gosa-plugins/fai/admin/fai/fai-list.xml @@ -9,7 +9,7 @@ fai - 1 + 0 @@ -96,6 +96,17 @@ + + separator + + + + remove_multiple + entry + images/lists/trash.png + + + exporter @@ -114,10 +125,12 @@ - + cp + false + FAKE_OC_FAI copypaste @@ -128,11 +141,6 @@ - - snapshot - snapshot - - remove entry