1 <?php
3 class divListMasses extends MultiSelectWindow
4 {
6 /* Current base */
7 var $selectedBase = "";
8 var $departments = array();
10 var $parent ;
11 var $ui ;
13 var $wake = TRUE;
15 function divListMasses (&$config,$parent)
16 {
17 MultiSelectWindow::MultiSelectWindow($config, "gotoMasses", array("gotomasses"));
19 $this->parent = $parent;
20 $this->ui = get_userinfo();
21 $this->SetSummary(_("List of queued deamon jobs."));
22 $this->SetHeadpageMode();
23 $this->EnableCloseButton(FALSE);
24 $this->EnableSaveButton(FALSE);
25 $this->SetInformation(_("This menu allows you to remove and change the properties of GOsa deamon tasks."));
27 foreach($this->parent->get_actions() as $name => $desc){
28 $this->$name = TRUE;
29 $this->AddCheckBox($name,sprintf(_("Display entries with action %s."),$desc),
30 sprintf(_("Display entries with action %s."),$desc),TRUE);
31 }
32 $plug = $_GET['plug'];
34 /* Toggle all selected / deselected */
35 $chk = "<input type='checkbox' id='select_all' name='select_all'
36 onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
38 /* set Page header */
39 $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'"));
40 $this->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=QueuePosition'>"._("#")."</a>",
41 "attach"=>"style='width:20px;'"));
42 $this->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=TargetName'>"._("Target")."</a> / ".
43 "<a href='?plug=".$plug."&sort=TaskID'>"._("Task")."</a>"));
44 $this->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=Schedule'>"._("Schedule")."</a>",
45 "attach"=>"style='width:100px;'"));
46 $this->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=Action'>"._("Status")."</a>",
47 "attach"=>"style='width:80px;'"));
48 $this->AddHeader(array("string"=>_("Action"),
49 "attach"=>"style='border-right:0px;width:120px;'"));
50 }
52 function GenHeader()
53 {
55 /* Display add button if allowed */
56 $header = "<div style='padding:5px'>";
57 # if($this->parent->acl_is_createable()){
58 # $header .= "<input type='image' src='images/gotomasses_new_task.png' name='new_task' class='center'> ";
59 # }
61 /* Display remove button if allowed */
62 if($this->parent->acl_is_removeable()){
63 $header .= "<input type='image' src='images/edittrash.png' name='remove_multiple_task' class='center'> ";
64 }
66 /* Add priority options */
67 if(preg_match("/w/",$this->parent->getacl(""))){
68 $header .= "<input type='image' src='images/status_stop_all.png' name='stop_all' class='center'> ";
69 $header .= "<input type='image' src='images/status_start_all.png' name='start_all' class='center'> ";
70 }
71 $header .= "</div>";
73 /* Create divlist */
74 $this->SetListHeader($header);
75 }
78 function execute()
79 {
80 $this->ClearElementsList();
81 $this->GenHeader();
82 }
85 function setEntries($tasks)
86 {
87 /* Create edit link */
88 $plug = $_GET['plug'];
89 # $edit_link = "<div style='width:100%;overflow:hidden;'><nobr><a href='?plug=".$_GET['plug']."&act=edit&id=%id%'>%str%</nobr></div>";
90 $edit_link = "%str%";
92 /* Create action filter array, to sort out those actions we do not want to see */
93 $allowed_action = array();
94 foreach($this->parent->get_actions() as $name => $desc){
95 if($this->$name){
96 $allowed_action[] = $name;
97 }
98 }
100 $colors[0] = "#DDDDDD";
101 $colors[1] = "#EEEEEE";
102 $c_keys = array();
103 $last_c = 0;
104 if($this->parent->sort_dir=="down"){
105 $last_c = !$last_c;
106 }
108 foreach($tasks as $key => $task){
110 $color = "";
111 /* Skip unchecked actions */
112 # if(!in_array($task['Action'],$allowed_action)){
113 # continue;
114 # }
116 /* Create actions */
117 $id = $task['ID'];
118 $queue_pos = $id;
119 $prio_actions = "<input class='center' type='image' src='images/status_stop_all.png' name='stop_".$id."'> ";
120 $prio_actions.= "<input class='center' type='image' src='images/status_start_all.png' name='start_".$id."'> ";
121 $action = "<input type='image' src='images/edit.png' name='edit_task_".$id."' class='center' alt='"._("Edit")."'>";
122 if($this->parent->acl_is_removeable()){
123 $action.= "<input type='image' src='images/edittrash.png' name='remove_task_".$id."' class='center' alt='"._("Reomve")."'>";
124 }
126 $display = preg_replace(array("/%id%/","/%str%/"),array($id,$task['MACADDRESS']),$edit_link);
127 $display2= $task['HEADERTAG'];
129 /* Create each field */
130 $field0 = array("string" => "<input type='checkbox' id='item_selected_".$id."' name='item_selected_".$id."'>" ,
131 "attach" => "style='width:20px;".$color."'");
132 $field0a= array("string" => $queue_pos ,"attach" => "style='width:20px;".$color."'");
133 $field1 = array("string" => $display,
134 "attach" => "style='".$color."'");
135 $field1a= array("string" => $display2,
136 "attach" => "style='".$color.";width:80px;'");
137 $field2 = array("string" => $this->stamp_to_date($task['TIMESTAMP']),"attach" => "style='".$color.";width:100px;'");
138 $field3 = array("string" => $task['STATUS'],"attach" => "style='".$color.";width:80px;'");
139 $field4 = array("string" => $prio_actions.$action,"attach" => "style='".$color.";text-align:right;width:120px;border-right:0px;'");
140 $this->AddElement(array($field0,$field0a,$field1,$field1a,$field2,$field3,$field4));
141 }
142 }
145 function stamp_to_date($stamp)
146 {
147 return(date("d.m.Y H:i:s",strtotime($stamp)));
148 }
151 function Save()
152 {
153 MultiSelectWindow :: Save();
154 }
157 function save_object()
158 {
159 /* Save automatic created POSTs like regex, checkboxes */
160 MultiSelectWindow :: save_object();
161 }
162 }
163 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
164 ?>