Code

Moved ldapmanager
[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 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."&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'>"._("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   {
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 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'>&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);
77   }
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>";
92     $edit_link = "%str%";
94     /* Create action filter array, to sort out those actions we do not want to see */
95     $allowed_action = array();
96     foreach($this->parent->get_actions() as $name => $desc){
97       if($this->$name){
98         $allowed_action[] = $name;
99       }
100     }
102     $colors[0] = "#DDDDDD";
103     $colors[1] = "#EEEEEE";
104     $c_keys = array();
105     $last_c = 0;
106     if($this->parent->sort_dir=="down"){
107       $last_c = !$last_c; 
108     }
109   
110     foreach($tasks as $key => $task){
112       $color = "";
113       /* Skip unchecked actions */ 
114 #      if(!in_array($task['Action'],$allowed_action)){
115 #        continue;
116 #      }
118       /* Create actions */
119       $id         = $task['ID'];
120       $queue_pos  = $id;
121       $prio_actions = "<input class='center' type='image' src='images/prio_top.png'      name='prio_top_".$id."'>&nbsp;";
122       $prio_actions.= "<input class='center' type='image' src='images/prio_increase.png' name='prio_increase_".$id."'>&nbsp;";
123       $prio_actions.= "<input class='center' type='image' src='images/prio_decrease.png' name='prio_decrease_".$id."'>&nbsp;";
124       $prio_actions.= "<input class='center' type='image' src='images/prio_bottom.png'   name='prio_bottom_".$id."'>&nbsp;";
125       $action = "<input type='image' src='images/edit.png' name='edit_task_".$id."' class='center' alt='"._("Edit")."'>";
126       if($this->parent->acl_is_removeable()){
127         $action.= "<input type='image' src='images/edittrash.png' name='remove_task_".$id."' class='center' alt='"._("Reomve")."'>";
128       }
130       $display = preg_replace(array("/%id%/","/%str%/"),array($id,$task['MACADDRESS']),$edit_link);
131       $display2= $task['HEADERTAG'];
133       /* Create each field */
134       $field0 = array("string" => "<input type='checkbox' id='item_selected_".$id."' name='item_selected_".$id."'>" ,
135                       "attach" => "style='width:20px;".$color."'");
136       $field0a= array("string" => $queue_pos ,"attach" => "style='width:20px;".$color."'");
137       $field1 = array("string" => $display,
138                       "attach" => "style='".$color."'");
139       $field1a= array("string" => $display2,
140                       "attach" => "style='".$color.";width:80px;'");
141       $field2 = array("string" => $this->stamp_to_date($task['TIMESTAMP']),"attach" => "style='".$color.";width:100px;'");
142       $field3 = array("string" => $task['STATUS'],"attach" => "style='".$color.";width:80px;'");
143       $field4 = array("string" => $prio_actions.$action,"attach" => "style='".$color.";text-align:right;width:120px;border-right:0px;'");
144       $this->AddElement(array($field0,$field0a,$field1,$field1a,$field2,$field3,$field4));
145     }
146   }
149   function stamp_to_date($stamp)
150   {
151     return(date("d.m.Y H:i:s",strtotime($stamp)));
152   }
155   function Save()
156   {
157     MultiSelectWindow :: Save();  
158   }
161   function save_object()
162   {
163     /* Save automatic created POSTs like regex, checkboxes */
164     MultiSelectWindow :: save_object();  
165   }
167 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
168 ?>