diff --git a/gosa-plugins/goto/addons/goto/class_gotomasses.inc b/gosa-plugins/goto/addons/goto/class_gotomasses.inc
index bd3e4bbef5c44ea33de103ff56cd4266bbd513c2..ff890d92ea938c2598e97f047d590462f2127f27 100644 (file)
}
// Build filter
- # if (session::global_is_set(get_class($this)."_filter")){
- # $filter= session::global_get(get_class($this)."_filter");
- # } else {
+ if (session::global_is_set(get_class($this)."_filter")){
+ $filter= session::global_get(get_class($this)."_filter");
+ } else {
$filter = new filter(get_template_path("deploy-filter.xml", true));
$filter->setObjectStorage($this->storagePoints);
-# }
+ }
$this->setFilter($filter);
// Build headpage
$this->registerAction('prioDown', "prioDown");
$this->registerAction('prioUp', "prioUp");
$this->registerAction('prioPause', "prioPause");
+ $this->registerAction('prioResume', "prioResume");
$this->registerAction('processNow', "processNow");
$this->registerAction('viewLogs', "viewLogs");
$this->registerAction('abort', "abortEvent");
$this->registerAction('saveEventDialog', "saveEventDialog");
+ $this->registerAction('halt', 'newEntry');
+ $this->registerAction('reboot', 'newEntry');
+ $this->registerAction('wakeup', 'newEntry');
+ $this->registerAction('update', 'newEntry');
+ $this->registerAction('lock', 'newEntry');
+ $this->registerAction('activate', 'newEntry');
+ $this->registerAction('reinstall', 'newEntry');
+ $this->registerAction('import', 'importEvents');
+ }
+
+ function newEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
+ {
+ if($this->acl_is_writeable("")){
+ $type = "DaemonEvent_".$action;
+ if(isset($this->events['BY_CLASS'][$type])){
+ $e_data = $this->events['BY_CLASS'][$type];
+ $this->dialogObject = new $e_data['CLASS_NAME']($this->config);
+ }
+ }
+ }
+
+ function importEvents()
+ {
+ $this->dialogObject = new goto_import_file($this->config,$this);
}
static function filterHostName($mac, $name ="")
/* Real percent */
} else {
if (preg_match('/install/', $headertag)){
- $status = "<img src='progress.php?x=80&y=13&p=".$progress."' alt=''
- id='progress_".preg_replace("/:/","_",$mac)."'>";
+ $status= progressbar($progress, 80, 13, true, false, "progress_".preg_replace("/:/","_",$mac));
} else {
$status = preg_replace('/ /', ' ', _("in progress"));
}
function prioPause($action="",$target=array(),$all=array())
{
$this->pause_queue_entries($target);
-# $this->resume_queue_entries($target);
+ }
+
+ function prioResume($action="",$target=array(),$all=array())
+ {
+ $this->resume_queue_entries($target);
}
function processNow($action="",$target=array(),$all=array())
{
$this->execute_queue_entries($target);
-# $this->abort_queue_entries($target);
}
function viewLogs($action="",$target=array(),$all=array())
{
- print_a($all);
+ if(count($target) == 1){
+ $id = $target[0];
+ $type = FALSE;
+ $headpage = $this->getHeadpage();
+ $tmp = $headpage->getEntry($id);
+ $entry = $tmp['EVENT'];
+ $this->dialogObject = new gotoLogView($this->config,"",$entry,$this);
+ }
}
function saveEventDialog()
if(isset($_POST['abort_event_dialog'])) $action['action'] = "cancel";
if(isset($_POST['delete_multiple_confirm'])) $action['action'] = "removeConfirmed";
if(isset($_POST['delete_cancel'])) $action['action'] = "cancel";
+ if(isset($_POST['import_abort'])) $action['action'] = "cancel";
return($action);
}
management::closeDialogs();
}
- function _execute()
- {
-
- /************
- * Import CSV file
- ************/
-
- if($s_action == "import_file" && $this->acl_is_writeable("")){
- $this->dialog = new goto_import_file($this->config,$this);
- }
-
- if(isset($_POST['import_abort'])){
- $this->dialog = FALSE;
- }
-
-
- /************
- * ADD
- ************/
-
- if(preg_match("/^add_event_/",$s_action) && $this->acl_is_writeable("")){
- $type = preg_replace("/^add_event_/","",$s_action);
- if(isset($this->events['BY_CLASS'][$type])){
- $e_data = $this->events['BY_CLASS'][$type];
- $this->dialog = new $e_data['CLASS_NAME']($this->config);
- }
- }
-
- /************
- * LOG VIEW
- ************/
-
- if($s_action == "logview" && $this->acl_is_readable("")){
- $id = $s_entry;
- $type = FALSE;
- if(isset($this->entries[$id])){
- $event = $this->entries[$s_entry];
- $this->dialog = new gotoLogView($this->config,"",$event,$this);
- }
- }
-
-
- /************
- /************
- * EDIT
- ************/
-
- /* Display dialogs if currently opened */
- if(is_object($this->dialog)){
- $this->dialog->save_object();
- $display = $this->dialog->execute();
-
- if($this->dialog instanceOf goto_import_file && $this->dialog->import_successful){
- $this->dialog = FALSE;
- }else{
- return($display);
- }
- }
-
- if($this->acl_is_writeable("")){
- foreach($this->events['SCHEDULED'] as $name => $event){
- $s.= "...|".$event['MenuImage']." ".$event['s_Menu_Name']."|add_event_".$name."\n";
- }
- }
- if($this->acl_is_removeable()){
- $s.= "..|---|\n";
- $s.= "..|<img src='images/lists/import.png' alt='' border='0' class='center'> "._("Import")."|import_file\n";
- $s.= "..|<img src='images/lists/trash.png' alt='' border='0' class='center'> "._("Remove")."|remove_multiple\n";
- }
- if(preg_match("/w/",$this->getacl(""))){
- $s.= "..|---|\n";
- $s.= "..|<img alt='"._("Resume")."' src='images/status_start.png' border='0' class='center'> "._("Resume")."|resume_all\n";
- $s.= "..|<img alt='"._("Pause")."' src='images/status_pause.png' border='0' class='center'> "._("Pause")."|pause_all\n";
- $s.= "..|<img alt='"._("Abort")."' src='images/small_error.png' border='0' class='center'> "._("Abort")."|abort_process_all\n";
- $s.= "..|<img alt='"._("Execute")."' src='images/rocket.png' border='0' class='center'> "._("Execute")."|execute_process_all\n";
- }
-
- $divlist->SetDropDownHeaderMenu($s);
-
- if($this->sort_dir == "up"){
- $sort_img = "<img src='images/lists/sort-up.png' alt='/\' border=0>";
- }else{
- $sort_img = "<img src='images/lists/sort-down.png' alt='\/' border=0>";
- }
-
- if($this->sort_by == "TargetName"){ $sort_img_1 = $sort_img; } else { $sort_img_1 = "" ;}
- if($this->sort_by == "TaskID"){ $sort_img_2 = $sort_img; } else { $sort_img_2 = "" ;}
- if($this->sort_by == "Schedule"){ $sort_img_3 = $sort_img; } else { $sort_img_3 = "" ;}
- if($this->sort_by == "Action"){ $sort_img_4 = $sort_img; } else { $sort_img_4 = "" ;}
-
- /* Create divlist */
- $divlist->SetListHeader("<input type='image' src='images/lists/reload.png' title='"._("Reload")."'>");
-
- $plug = $_GET['plug'];
- $chk = "<input type='checkbox' id='select_all' name='select_all'
- onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
-
- /* set Page header */
- $divlist->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'"));
- $divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=TargetName'>"._("Target").$sort_img_1."</a>"));
- $divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=TaskID'>"._("Task").$sort_img_2."</a>",
- "attach"=>"style='width:120px;'"));
- $divlist->AddHeader(array("string"=>_("Period"),
- "attach"=>"style='width:60px;'"));
- $divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=Schedule'>"._("Schedule").$sort_img_3."</a>",
- "attach"=>"style='width:140px;'"));
- $divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=Action'>"._("Status").$sort_img_4."</a>",
- "attach"=>"style='width:80px;'"));
- $divlist->AddHeader(array("string"=>_("Action"),
- "attach"=>"style='border-right:0px;width:140px;'"));
-
-
- /* Reload the list of entries */
- $this->reload();
-
- foreach($this->entries as $key => $task){
-
- $prio_actions="";
- $action = "";
-
-
- /* If WAITING add priority action
- */
- if(in_array($task['STATUS'],array("waiting")) && $this->acl_is_writeable("")){
- $prio_actions.= "<input class='center' type='image' src='plugins/goto/images/prio_increase.png'
- title='"._("Move up")."' name='prio_up_".$key."'> ";
- $prio_actions.= "<input class='center' type='image' src='plugins/goto/images/prio_decrease.png'
- title='"._("Move down")."' name='prio_down_".$key."'> ";
- }
-
- /* If WAITING add pause action
- */
- if(in_array($task['STATUS'],array("waiting")) && $this->acl_is_writeable("")){
- $prio_actions.= "<input class='center' type='image' src='images/status_pause.png'
- title='"._("Pause job")."' name='pause_".$key."'> ";
- }
-
- /* If PAUSED add resume action
- */
- if(in_array($task['STATUS'],array("paused")) && $this->acl_is_writeable("")){
- $prio_actions.= "<input class='center' type='image' src='images/status_start.png'
- title='"._("Resume job")."' name='resume_".$key."'> ";
- }
-
- /* If PAUSED or WAITING add execution action
- */
- if(in_array($task['STATUS'],array("paused","waiting")) && $this->acl_is_writeable("")){
- $prio_actions.= "<input class='center' type='image' src='images/rocket.png'
- title='"._("Execute now")."' name='execute_process_".$key."'> ";
- }
-
- /* Add logview button, currently ever.
- */
- if($this->acl_is_readable("")){
- $action .= "<input type='image' src='plugins/goto/images/view_logs.png' name='log_view_".$key."'
- class='center' title='"._("View logs")."' alt='"._("View logs")."'> ";
- }
-
- /* If PAUSED or WAITING add edit action
- */
- if(in_array($task['STATUS'],array("waiting")) && $this->acl_is_writeable("")){
- $action.= "<input type='image' src='images/lists/edit.png' name='edit_task_".$key."'
- class='center' title='"._("Edit")."' alt='"._("Edit")."'>";
- }
-
- /* If PROCESSING add abort action
- */
- if(in_array($task['STATUS'],array("processing")) && preg_match("/install/",$task['HEADERTAG']) && $this->acl_is_writeable("")){
- $action.= "<img src='images/empty.png' alt=''>";
- $action.= "<input class='center' type='image' src='images/small_error.png'
- title='"._("Abort job")."' name='abort_process_".$key."'>";
- }
-
- /* If WAITING or ERROR add remove action
- */
- if( $this->acl_is_removeable() && in_array($task['STATUS'],array("waiting","error","processed"))){
- $action.= "<input type='image' src='images/lists/trash.png' name='remove_task_".$key."'
- class='center' title='"._("Remove")."' alt='"._("Remove")."'>";
- }
- if($this->acl_is_writeable("") && in_array($task['STATUS'],array("processing")) && !preg_match("/install/",$task['HEADERTAG'])){
- $action.= "<input type='image' src='images/lists/trash.png' name='remove_task_".$key."'
- class='center' title='"._("Remove")."' alt='"._("Remove")."'>";
- }
-
- /* Create entry display name and tooltip */
- $color = "";
- $display = $task['MACADDRESS'];
- $tooltip = "";
- if(isset($task['PLAINNAME']) && !preg_match("/none/i",$task['PLAINNAME'])){
- $display = $task['PLAINNAME'];
- $tooltip = " title='".$task['MACADDRESS']."' ";
- }
-
-
- $display2= $task['HEADERTAG'];
-
- /* Check if this event exists as Daemon class
- * In this case, display a more accurate entry.
- */
- if(isset($this->events['QUEUED'][$task['HEADERTAG']])){
- $evt_name = $this->events['QUEUED'][$task['HEADERTAG']];
- $event_type = $this->events['BY_CLASS'][$evt_name];
- $display2 = $event_type['s_Menu_Name'];
-
- if(strlen($display2) > 20){
- $display2 = substr($display2,0,18)."...";
- }
-
- if(isset($event_type['ListImage']) && !empty($event_type['ListImage'])){
- $display2 = $event_type['ListImage']." ".$display2;
- }
- }
-
- $status = $task['STATUS'];
-
- if($status == "waiting"){
- $status = "<img class='center' src='plugins/goto/images/clock.png' alt=''> "._("Waiting");
- }
- if($status == "error"){
- $status = "<img class='center' src='images/false.png' alt=''> "._("Error");
- }
- if($status == "processed"){
- $status = "<img class='center' src='images/true.png' alt=''> "._("Processed");
- }
-
- /* Special handling for all entries that have
- STATUS == "processing" && PROGRESS == NUMERIC
- */
- if($status == "processing" && isset($task['PROGRESS'])){
- $percent = $task['PROGRESS'];
-
- /* Show activation? */
- if ($percent == "goto-activation"){
- $status = "<img class='center' src='images/lists/off.png' alt=''> "._("Locked");
-
- /* Show hardware detect? */
- } elseif ($percent == "goto-hardware-detection") {
- $status = "<img class='center' src='plugins/goto/images/hardware.png' alt=''> "._("Detection");
-
- /* Real percent */
- } else {
- if (preg_match('/install/', $task['HEADERTAG'])){
- $status = "<img src='progress.php?x=80&y=13&p=".$task['PROGRESS']."' alt=''
- id='progress_".preg_replace("/:/","_",$task['MACADDRESS'])."'>";
- } else {
- $status = preg_replace('/ /', ' ', _("in progress"));
- }
- }
- }
-
- // Check whether this is a periodical job or not.
- $period = "";
- if(isset($task['PERIODIC']) && !preg_match("/none/i",$task['PERIODIC'])){
- $tmp = explode("_", $task['PERIODIC']);
- if(count($tmp) == 2){
- $period= $tmp[0]." "._($tmp[1]);
- }
- }
-
- /* Create each field */
- $field0 = array("string" => "<input type='checkbox' id='item_selected_".$task['ID']."' name='item_selected_".$key."'>" ,
- "attach" => "style='width:20px;".$color."'");
- $field1 = array("string" => $display,
- "attach" => $tooltip."style='".$color."'");
- $field1a= array("string" => $display2,
- "attach" => "style='".$color.";width:120px;'");
- $field1b= array("string" => $period,
- "attach" => "style='".$color.";width:60px;'");
- if ($task['TIMESTAMP'] == "19700101000000"){
- $field2 = array("string" => _("immediately"),"attach" => "style='".$color.";width:140px;'");
- } else {
- $field2 = array("string" => date("d.m.Y H:i:s",strtotime($task['TIMESTAMP'])),"attach" => "style='".$color.";width:140px;'");
- }
- $field3 = array("string" => $status,"attach" => "style='".$color.";width:80px;'");
- $field4 = array("string" => $prio_actions.$action,"attach" => "style='".$color.";text-align:right;width:140px;border-right:0px;'");
- $divlist->AddElement(array($field0,$field1,$field1a,$field1b,$field2,$field3,$field4));
- }
-
- $smarty = get_smarty();
- $smarty->assign("events",$this->events);
- $smarty->assign("start",$this->start);
- $smarty->assign("start_real", ($this->start + 1));
- $smarty->assign("ranges", array("10" => "10",
- "20" => "20",
- "25" => "25",
- "50" => "50",
- "100"=> "100",
- "200"=> "200",
- "9999" => "*"));
-
- $count = $this->o_queue->number_of_queued_entries($this->event_tags);
- if(!$count) $count = $this->range;
- $divlist->SetListFooter(range_selector($count, $this->start, $this->range,"range"));
- $smarty->assign("range",$this->range);
- $smarty->assign("div",$divlist->Draw());
-
- return(management::execute());
- return($smarty->fetch (get_template_path('gotomasses.tpl', TRUE, dirname(__FILE__))));
- }
-
-
/*! \brief Resumes to status 'waiting'.
* @return Boolean TRUE in case of success, else FALSE.
*/
private function resume_queue_entries($ids)
{
- if(!count($ids)){
- return;
- }
-
/* Entries are resumed by setting the status to
* 'waiting'
*/
* allows resuming.
*/
$update_ids = array();
- foreach($this->o_queue->get_entries_by_id($ids) as $entry){
+ $headpage = $this->getHeadpage();
+ foreach($ids as $id){
+ $tmp = $headpage->getEntry($id);
+ $entry = $tmp['EVENT'];
if(isset($entry['STATUS']) && preg_match("/paused/",$entry['STATUS'])){
$update_ids[] = $entry['ID'];
}
*/
private function execute_queue_entries($ids)
{
- if(!count($ids)){
- return;
- }
-
/* Execution is forced by updating the status to
* waiting and setting the timestamp to current time.
*/
/* Only allow execution of paused or waiting entries
*/
$update_ids = array();
- foreach($this->o_queue->get_entries_by_id($ids) as $entry){
+ $headpage = $this->getHeadpage();
+ foreach($ids as $id){
+ $tmp = $headpage->getEntry($id);
+ $entry = $tmp['EVENT'];
if(in_array($entry['STATUS'],array("paused","waiting"))){
$update_ids[] = $entry['ID'];
}
*/
private function pause_queue_entries($ids)
{
- if(!count($ids)){
- return;
- }
-
/* Entries are paused by setting the status to
* something different from 'waiting'.
* We simply use 'paused'.
* check if the status allows pausing.
*/
$update_ids = array();
- foreach($this->o_queue->get_entries_by_id($ids) as $entry){
+ $headpage = $this->getHeadpage();
+ foreach($ids as $id){
+ $tmp = $headpage->getEntry($id);
+ $entry = $tmp['EVENT'];
if(isset($entry['STATUS']) && preg_match("/waiting/",$entry['STATUS'])){
$update_ids[] = $entry['ID'];
}
return(TRUE);
}
-
- /*! \brief Request list of queued jobs.
- * @return Returns an array of all queued jobs.
- */
- function reload()
- {
-
- /* Sort map html-post-name => daemon-col-name
- */
- $map = array(
- "QueuePosition" => "id",
- "Action" => "status",
- "TaskID" => "headertag",
- "TargetName" => "macaddress",
- "Schedule" => "timestamp");
-
- /* Create sort header
- */
- if(!isset($map[$this->sort_by])){
- $sort = "id DESC";
- }else{
- $sort = $map[$this->sort_by];
- if($this->sort_dir == "up"){
- $sort.= " ASC";
- }else{
- $sort.= " DESC";
- }
- }
-
- /* Get entries. */
- $start = $this->start;
- $stop = $this->range;
- $entries = $this->o_queue->get_queued_entries($this->event_tags,$start,$stop,$sort);
- if ($this->o_queue->is_error()){
- msg_dialog::display(_("Error"), sprintf(_("Cannot load queue entries: %s"), "<br><br>".$this->o_queue->get_error()), ERROR_DIALOG);
- }
-
- /* Assign entries by id.
- */
- $this->entries = array();
-
- foreach($entries as $entry){
-
- /* Skip entries which will be removed within the next seconds */
- if(isset($entry['MACADDRESS']) && in_array($entry['MACADDRESS'],$this->recently_removed)){
- continue;
- }
- $this->entries[$entry['ID']]= $entry;
- }
- $this->recently_removed = array();
- }
-
function save_object(){}
- /*! \brief Handle post jobs, like sorting.
- */
- function _save_object()
- {
- /* Check for sorting changes
- */
- $sort_vals = array("Action","QueuePosition","TargetName","Schedule","TaskID");
- if(isset($_GET['sort']) && in_array($_GET['sort'],$sort_vals)){
- $sort = $_GET['sort'];
- if($this->sort_by == $sort){
- if($this->sort_dir == "up"){
- $this->sort_dir = "down";
- }else{
- $this->sort_dir = "up";
- }
- }
- $this->sort_by = $sort;
- }
-
- /* Range selection used? */
- if(isset($_POST['range']) && is_numeric($_POST['range'])){
- $this->range = $_POST['range'];
- }
-
- /* Save filter settings */
- $gotomasses_filter = session::get("gotomasses_filter");
- foreach(array("range","sort_by","sort_dir") as $attr){
- $gotomasses_filter[$attr] = $this->$attr;
- }
- session::set("gotomasses_filter",$gotomasses_filter);
-
- /* Page changed. */
- if(isset($_GET['start'])){
- $start = $_GET['start'];
- if(is_numeric($start) || $start == 0){
- $this->start = $start;
- }
- }
-
- /* Check start stop and reset if necessary */
- $count = $this->o_queue->number_of_queued_entries($this->event_tags);
- if($this->start >= $count){
- $this->start = $count -1;
- }
- if($this->start < 0){
- $this->start = 0;
- }
- }
-
-
- function save()
- {
- // We do not save anything here.
- }
-
-
- /*! \brief Return a list of all selected items.
- @return Array Returns an array containing all selected item ids.
- */
- function list_get_selected_items()
- {
- $ids = array();
- foreach($_POST as $name => $value){
- if(preg_match("/^item_selected_[0-9]*$/",$name)){
- $id = preg_replace("/^item_selected_/","",$name);
- $ids[$id] = $id;
- }
- }
- return($ids);
- }
-
+ function save(){}
static function plInfo()
{