1 <?php
3 class divListSystemService extends MultiSelectWindow
4 {
5 /* CheckBoxes, to change default values modify $this->AddCheckBox */
6 var $parent ;
7 var $ui ;
9 function divListSystemService ($config,$parent)
10 {
11 MultiSelectWindow::MultiSelectWindow($config,"SystemService");
13 $this->parent = $parent;
14 $this->ui = get_userinfo();
16 /* Set list strings */
17 $this->SetTitle(_("Installed services"));
18 $this->SetSummary(_("Installed services"));
20 /* Result page will look like a headpage */
21 $this->SetHeadpageMode();
22 $this->SetInformation(_("This menu allows you to add, remove and configure the properties of a specific service."));
24 /* Disable buttonsm */
25 $this->EnableCloseButton(false);
26 $this->EnableSaveButton (false);
28 /* set Page header */
29 $this->AddHeader(array("string"=>" ","attach"=>"style='width:20px;'"));
30 $this->AddHeader(array("string"=>_("Service name")));
31 $this->AddHeader(array("string"=>_("Actions"),"attach"=>"style='width:100px;border-right:0px;'"));
32 $this->HideFilterPart();
33 $this->SetHeight(500);
34 }
36 function GenHeader()
37 {
38 /* Prepare departments,
39 which are shown in the listbox on top of the listbox
40 */
41 $options= "";
42 foreach ($this->config->idepartments as $key => $value){
43 if ($this->selectedBase == $key){
44 $options.= "<option selected='selected' value='$key'>$value</option>";
45 } else {
46 $options.= "<option value='$key'>$value</option>";
47 }
48 }
49 $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
50 " <input class='center' type='image' align='middle' src='images/select_new_server.png' class='center'
51 name='addNewService' alt='"._("Add service")."' title='"._("Add new service")."'> ".
52 " <input class='center' type='image' align='middle' src='images/status_start_all.png' class='center'
53 name='startServices' alt='"._("Start all")."' title='"._("Start all services")."'> ".
54 " <input class='center' type='image' align='middle' src='images/status_stop_all.png' class='center'
55 name='stopServices' alt='"._("Stop service")."' title='"._("Stop all services")."'> ".
56 " <input class='center' type='image' align='middle' src='images/status_restart_all.png' class='center'
57 name='resetServices' alt='"._("Reset service")."' title='"._("Reset all services")."'> ".
58 "</div>";
59 $this->SetListHeader($listhead);
60 }
62 function execute()
63 {
64 $this->ClearElementsList();
65 $this->GenHeader();
66 }
68 function setEntries($list)
69 {
70 foreach($list as $name => $entry){
72 switch($entry['Status']){
73 case '' : $str ="";break;
74 case SERVICE_STOPPED : $str ="<img src='images/status_stopped.png' title='"._("Stopped")."'>"; break;
75 case SERVICE_STARTED : $str ="<img src='images/status_running.png' title='"._("Started")."'>"; break;
76 case SERVICE_RESETTED : $str ="<img src='images/status_restarting.png' title='"._("Restarting")."' alt='R'>"; break;
77 default: $str= "<img src='images/select_user.png' alt='".$entry['Status']."' title='"._("User status")." : ".$entry['Status']."'>";
78 }
80 $field1 = array("string" => $str ,"attach" => "style='width:20px;'");
81 $field2 = array("string" => $entry['Message'] );
83 $actions ="";
84 if($entry['AllowStart']){
85 $actions .= " <input type='image' name='StartSingleService_".$name."' src='images/status_start.png'>";
86 }else{
87 $actions .= " <img src='images/empty' width='16' alt=''>";
88 }
89 if($entry['AllowStart']){
90 $actions .= " <input type='image' name='StopSingleService_".$name."' src='images/status_stop.png'>";
91 }else{
92 $actions .= " <img src='images/empty' width='16' alt=''>";
93 }
94 if($entry['AllowStart']){
95 $actions .= " <input type='image' name='ResetSingleService_".$name."' src='images/status_restart.png'>";
96 }else{
97 $actions .= " <img src='images/empty' width='16' alt=''>";
98 }
99 if($entry['AllowEdit']){
100 $actions .= " <input type='image' name='EditSingleService_".$name."' src='images/edit.png'>";
101 }else{
102 $actions .= " <img src='images/empty' width='16' alt=''>";
103 }
104 if($entry['AllowRemove']){
105 $actions .= " <input type='image' name='RemoveSingleService_".$name."' src='images/edittrash.png'>";
106 }else{
107 $actions .= " <img src='images/empty' width='16' alt=''>";
108 }
110 $field3 = array("string" => $actions ,"attach" => "style='width:100px;border-right:0px;'");
111 $this->AddElement(array($field1,$field2,$field3));
112 }
113 }
115 function Save()
116 {
117 MultiSelectWindow :: Save();
118 }
120 function save_object()
121 {
122 /* Save automatic created POSTs like regex, checkboxes */
123 MultiSelectWindow :: save_object();
124 }
125 }
126 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
127 ?>