From c67ddbb5f37d91bbe154892ed42ae319923be3fd Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 29 Jan 2010 13:58:53 +0000 Subject: [PATCH] Added abort action git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15448 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../goto/addons/goto/class_gotomasses.inc | 106 +++++++----------- gosa-plugins/goto/addons/goto/deploy-list.xml | 10 +- 2 files changed, 48 insertions(+), 68 deletions(-) diff --git a/gosa-plugins/goto/addons/goto/class_gotomasses.inc b/gosa-plugins/goto/addons/goto/class_gotomasses.inc index 98ce09942..bd3e4bbef 100644 --- a/gosa-plugins/goto/addons/goto/class_gotomasses.inc +++ b/gosa-plugins/goto/addons/goto/class_gotomasses.inc @@ -79,6 +79,7 @@ class gotomasses extends management $this->registerAction('prioPause', "prioPause"); $this->registerAction('processNow', "processNow"); $this->registerAction('viewLogs', "viewLogs"); + $this->registerAction('abort', "abortEvent"); $this->registerAction('saveEventDialog', "saveEventDialog"); } @@ -268,6 +269,44 @@ class gotomasses extends management $this->save(); } } + + + /*! \brief Force queue job to be aborted. + */ + function abortEvent($action="",$target=array(),$all=array()) + { + /* Entries are paused by setting the status to + * something different from 'waiting'. + * We simply use 'paused'. + */ + $data = array("status" => "paused"); + + /* Detect if the ids we got are valid and + * check if the status allows pausing. + */ + $update_ids = array(); + $headpage = $this->getHeadpage(); + foreach($target as $id){ + $tmp = $headpage->getEntry($id); + $update_ids[] = $tmp['MACADDRESS'][0]; + } + + if(class_available("DaemonEvent_faireboot")){ + $tmp = new DaemonEvent_faireboot($this->config); + $tmp->add_targets($update_ids); + $tmp->set_type(TRIGGERED_EVENT); + $this->recently_removed = $update_ids; + if(!$this->o_queue->append($tmp)){ + msg_dialog::display(_("Error"), sprintf(_("Cannot update queue entry: %s"),$id) , ERROR_DIALOG); + return(FALSE); + } + }else{ + msg_dialog::display(_("Error"), + sprintf(_("Required class '%s' cannot be found: job not aborted!"), + "DaemonEvent_faireboot") , ERROR_DIALOG); + } + } + function prioDown($action="",$target=array(),$all=array()) { @@ -421,13 +460,6 @@ class gotomasses extends management * EDIT ************/ - - /* Close dialog */ - if(isset($_POST['abort_event_dialog'])){ - $this->dialog = FALSE; - $this->current = -1; - } - /* Display dialogs if currently opened */ if(is_object($this->dialog)){ $this->dialog->save_object(); @@ -440,19 +472,6 @@ class gotomasses extends management } } - /************ - * Handle Divlist - ************/ - - $divlist = new MultiSelectWindow($this->config,"gotoMasses",array("gotomasses")); - $divlist->SetInformation(_("This menu allows you to remove and change the properties of GOsa tasks.")); - $divlist->SetSummary(_("List of queued jobs")); - $divlist->EnableCloseButton(FALSE); - $divlist->EnableSaveButton(FALSE); - $divlist->SetHeadpageMode(); - $s = ".|"._("Actions")."|\n"; - $s.= "..| "._("Create")."\n"; - if($this->acl_is_writeable("")){ foreach($this->events['SCHEDULED'] as $name => $event){ $s.= "...|".$event['MenuImage']." ".$event['s_Menu_Name']."|add_event_".$name."\n"; @@ -767,53 +786,6 @@ class gotomasses extends management } - /*! \brief Force queue job to be done as far as possible. - * @return Boolean TRUE in case of success, else FALSE. - */ - private function abort_queue_entries($ids) - { - if(!count($ids)){ - return; - } - - /* Entries are paused by setting the status to - * something different from 'waiting'. - * We simply use 'paused'. - */ - $data = array("status" => "paused"); - - /* Detect if the ids we got are valid and - * check if the status allows pausing. - */ - $update_ids = array(); - foreach($this->o_queue->get_entries_by_id($ids) as $entry){ - if(isset($entry['STATUS']) && preg_match("/processing/",$entry['STATUS'])){ - if(isset($entry['MACADDRESS'])){ - $update_ids[] = $entry['MACADDRESS']; - }else{ - trigger_error("No mac address found in event."); - } - } - } - - if(class_available("DaemonEvent_faireboot")){ - $tmp = new DaemonEvent_faireboot($this->config); - $tmp->add_targets($update_ids); - $tmp->set_type(TRIGGERED_EVENT); - $this->recently_removed = $update_ids; - - if(!$this->o_queue->append($tmp)){ - msg_dialog::display(_("Error"), sprintf(_("Cannot update queue entry: %s"),$id) , ERROR_DIALOG); - return(FALSE); - } - }else{ - msg_dialog::display(_("Error"), - sprintf(_("Required class '%s' cannot be found: job not aborted!"), - "DaemonEvent_faireboot") , ERROR_DIALOG); - } - } - - /*! \brief Pauses the specified queue entry from execution. * @return Boolean TRUE in case of success, else FALSE. */ diff --git a/gosa-plugins/goto/addons/goto/deploy-list.xml b/gosa-plugins/goto/addons/goto/deploy-list.xml index de3ba9370..13528cdeb 100644 --- a/gosa-plugins/goto/addons/goto/deploy-list.xml +++ b/gosa-plugins/goto/addons/goto/deploy-list.xml @@ -21,7 +21,7 @@ - |160|160|||||| + |||40|||| @@ -236,6 +236,14 @@ + + abort + entry + FAKE_OC__abort + images/small_error.png + + + -- 2.30.2