1 <?php
3 class divListMasses extends MultiSelectWindow
4 {
6 /* Current base */
7 var $selectedBase = "";
8 var $departments = array();
10 var $parent ;
11 var $ui ;
12 var $Regex = "*";
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 $plug = $_GET['plug'];
29 /* Toggle all selected / deselected */
30 $chk = "<input type='checkbox' id='select_all' name='select_all'
31 onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
33 /* set Page header */
34 $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'"));
35 $this->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=QueuePosition'>"._("#")."</a>",
36 "attach"=>"style='width:20px;'"));
37 $this->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=TargetName'>"._("Target")."</a> / ".
38 "<a href='?plug=".$plug."&sort=TaskID'>"._("Task")."</a>"));
39 $this->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=Schedule'>"._("Schedule")."</a>",
40 "attach"=>"style='width:100px;'"));
41 $this->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=Action'>"._("Status")."</a>",
42 "attach"=>"style='width:80px;'"));
43 $this->AddHeader(array("string"=>_("Action"),
44 "attach"=>"style='border-right:0px;width:120px;'"));
45 }
47 function GenHeader()
48 {
50 /* Display add button if allowed */
51 $header = "<div style='padding:5px'>";
52 # if($this->parent->acl_is_createable()){
53 # $header .= "<input type='image' src='images/gotomasses_new_task.png' name='new_task' class='center'> ";
54 # }
56 /* Display remove button if allowed */
57 if($this->parent->acl_is_removeable()){
58 $header .= "<input type='image' src='images/edittrash.png' name='remove_multiple_task' class='center'> ";
59 }
61 /* Add priority options */
62 if(preg_match("/w/",$this->parent->getacl(""))){
63 $header .= "<input type='image' src='images/status_stop_all.png' name='stop_all' class='center'> ";
64 $header .= "<input type='image' src='images/status_start_all.png' name='start_all' class='center'> ";
65 }
66 $header .= "</div>";
68 /* Create divlist */
69 $this->SetListHeader($header);
70 }
73 function execute()
74 {
75 $this->ClearElementsList();
76 $this->GenHeader();
77 }
80 function setEntries($tasks)
81 {
82 /* Create edit link */
83 $plug = $_GET['plug'];
84 # $edit_link = "<div style='width:100%;overflow:hidden;'><nobr><a href='?plug=".$_GET['plug']."&act=edit&id=%id%'>%str%</nobr></div>";
85 $edit_link = "%str%";
87 $colors[0] = "#DDDDDD";
88 $colors[1] = "#EEEEEE";
89 $c_keys = array();
90 $last_c = 0;
91 if($this->parent->sort_dir=="down"){
92 $last_c = !$last_c;
93 }
95 foreach($tasks as $key => $task){
97 $color = "";
98 /* Skip unchecked actions */
99 # if(!in_array($task['Action'],$allowed_action)){
100 # continue;
101 # }
103 /* Create actions */
104 $id = $task['ID'];
105 $queue_pos = $id;
106 $prio_actions = "<input class='center' type='image' src='images/status_stop_all.png' name='stop_".$id."'> ";
107 $prio_actions.= "<input class='center' type='image' src='images/status_start_all.png' name='start_".$id."'> ";
108 $action = "<input type='image' src='images/edit.png' name='edit_task_".$id."' class='center' alt='"._("Edit")."'>";
109 if($this->parent->acl_is_removeable()){
110 $action.= "<input type='image' src='images/edittrash.png' name='remove_task_".$id."' class='center' alt='"._("Reomve")."'>";
111 }
113 $display = preg_replace(array("/%id%/","/%str%/"),array($id,$task['MACADDRESS']),$edit_link);
114 $display2= $task['HEADERTAG'];
116 /* Create each field */
117 $field0 = array("string" => "<input type='checkbox' id='item_selected_".$id."' name='item_selected_".$id."'>" ,
118 "attach" => "style='width:20px;".$color."'");
119 $field0a= array("string" => $queue_pos ,"attach" => "style='width:20px;".$color."'");
120 $field1 = array("string" => $display,
121 "attach" => "style='".$color."'");
122 $field1a= array("string" => $display2,
123 "attach" => "style='".$color.";width:80px;'");
124 $field2 = array("string" => $this->stamp_to_date($task['TIMESTAMP']),"attach" => "style='".$color.";width:100px;'");
125 $field3 = array("string" => $task['STATUS'],"attach" => "style='".$color.";width:80px;'");
126 $field4 = array("string" => $prio_actions.$action,"attach" => "style='".$color.";text-align:right;width:120px;border-right:0px;'");
127 $this->AddElement(array($field0,$field0a,$field1,$field1a,$field2,$field3,$field4));
128 }
129 }
132 function stamp_to_date($stamp)
133 {
134 return(date("d.m.Y H:i:s",strtotime($stamp)));
135 }
138 function Save()
139 {
140 MultiSelectWindow :: Save();
141 }
144 function save_object()
145 {
146 /* Save automatic created POSTs like regex, checkboxes */
147 MultiSelectWindow :: save_object();
148 }
149 }
150 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
151 ?>