Code

Replaced hard coded base prefixes with get_ou('name').
[gosa.git] / gosa-core / plugins / addons / gotomasses / class_divListMasses.inc
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;  
14   
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 system deployment tasks"));
22     $this->SetHeadpageMode();
23     $this->EnableCloseButton(FALSE);
24     $this->EnableSaveButton(FALSE);
25     $this->SetInformation(_("This menu allows you to add, remove and change the properties of system deployment 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."&amp;sort=QueuePosition'>"._("#")."</a>",
41                            "attach"=>"style='width:20px;'"));
42     $this->AddHeader(array("string"=>"<a href='?plug=".$plug."&amp;sort=TargetName'>"._("Target")."</a>&nbsp;/&nbsp;".
43                                      "<a href='?plug=".$plug."&amp;sort=TaskID'>"._("Task")."</a>"));
44     $this->AddHeader(array("string"=>"<a href='?plug=".$plug."&amp;sort=Schedule'>"._("Schedule")."</a>",
45                                       "attach"=>"style='width:100px;'"));
46     $this->AddHeader(array("string"=>"<a href='?plug=".$plug."&amp;sort=Action'>"._("Type")."</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   {
54     
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'>&nbsp;";
59     }
61     /* Display add 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'>&nbsp;";
64     }
66     /* Add priority options */
67     if(preg_match("/w/",$this->parent->getacl(""))){
68       $header .= "<input type='image' src='images/prio_top.png'       name='multiple_prio_top'      class='center'>&nbsp;";
69       $header .= "<input type='image' src='images/prio_increase.png'  name='multiple_prio_increase' class='center'>&nbsp;";
70       $header .= "<input type='image' src='images/prio_decrease.png'  name='multiple_prio_decrease' class='center'>&nbsp;";
71       $header .= "<input type='image' src='images/prio_bottom.png'    name='multiple_prio_bottom'   class='center'>&nbsp;";
72     }
73     $header .= "</div>";
74     
75     /* Create divlist */
76     $this->SetListHeader($header);
78   }
80   function execute()
81   {
82     $this->ClearElementsList();
83     $this->GenHeader();
84   }
87   function setEntries($tasks)
88   {
89     /* Create edit link */
90     $plug = $_GET['plug'];
91     $edit_link = "<div style='width:100%;overflow:hidden;'><nobr><a href='?plug=".$_GET['plug']."&act=edit&id=%id%'>%str%</nobr></div>";
93     /* Create action filter array, to sort out those actions we do not want to see */
94     $allowed_action = array();
95     foreach($this->parent->get_actions() as $name => $desc){
96       if($this->$name){
97         $allowed_action[] = $name;
98       }
99     }
101     $colors[0] = "#DDDDDD";
102     $colors[1] = "#EEEEEE";
103     $c_keys = array();
104     $last_c = 0;
105     if($this->parent->sort_dir=="down"){
106       $last_c = !$last_c; 
107     }
108   
109     foreach($tasks as $key => $task){
111       /* Skip unchecked actions */ 
112       if(!in_array($task['Action'],$allowed_action)){
113         continue;
114       }
116       /* Handle coloring */
117       $color="";
118       if($this->parent->sort_by == "TaskID"){
119         if(!in_array($task['TASK_ID'],$c_keys)){
120           $c_keys[] = $task['TASK_ID'];
121           $last_c = !$last_c;
122         }
123         $color = "background-color: ".$colors[$last_c];
124       }
126       /* Create actions */
127       $id         = $task['ID'];
128       $queue_pos  = $task['Queue_Position'];
129       $prio_actions = "<input class='center' type='image' src='images/prio_top.png'      name='prio_top_".$id."'>&nbsp;";
130       $prio_actions.= "<input class='center' type='image' src='images/prio_increase.png' name='prio_increase_".$id."'>&nbsp;";
131       $prio_actions.= "<input class='center' type='image' src='images/prio_decrease.png' name='prio_decrease_".$id."'>&nbsp;";
132       $prio_actions.= "<input class='center' type='image' src='images/prio_bottom.png'   name='prio_bottom_".$id."'>&nbsp;";
133       $action = "<input type='image' src='images/edit.png' name='edit_task_".$id."' class='center' alt='"._("Edit")."'>";
134       if($this->parent->acl_is_removeable()){
135         $action.= "<input type='image' src='images/edittrash.png' name='remove_task_".$id."' class='center' alt='"._("Reomve")."'>";
136       }
138       $display = preg_replace(array("/%id%/","/%str%/"),array($id,$this->parent->target_to_string($task)),$edit_link);
139       $display2= $this->parent->get_additional_entry_informations($task);
141       /* Create each field */
142       $field0 = array("string" => "<input type='checkbox' id='item_selected_".$id."' name='item_selected_".$id."'>" ,
143                       "attach" => "style='width:20px;".$color."'");
144       $field0a= array("string" => $queue_pos ,"attach" => "style='width:20px;".$color."'");
145       $field1 = array("string" => $display,
146                       "attach" => "style='".$color."'");
147       $field1a= array("string" => $display2,
148                       "attach" => "style='".$color.";width:80px;'");
149       $field2 = array("string" => $this->parent->time_to_string($task),"attach" => "style='".$color.";width:100px;'");
150       $field3 = array("string" => $this->parent->action_to_string($task),"attach" => "style='".$color.";width:80px;'");
151       $field4 = array("string" => $prio_actions.$action,"attach" => "style='".$color.";text-align:right;width:120px;border-right:0px;'");
152       $this->AddElement(array($field0,$field0a,$field1,$field1a,$field2,$field3,$field4));
153     }
154   }
157   function Save()
158   {
159     MultiSelectWindow :: Save();  
160   }
163   function save_object()
164   {
165     /* Save automatic created POSTs like regex, checkboxes */
166     MultiSelectWindow :: save_object();  
167   }
169 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
170 ?>