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 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ".
53 " <input class='center' type='image' align='middle' src='images/status_start_all.png' class='center'
54 name='startServices' alt='"._("Start all")."' title='"._("Start all services")."'> ".
55 " <input class='center' type='image' align='middle' src='images/status_stop_all.png' class='center'
56 name='stopServices' alt='"._("Stop service")."' title='"._("Stop all services")."'> ".
57 " <input class='center' type='image' align='middle' src='images/status_restart_all.png' class='center'
58 name='resetServices' alt='"._("Reset service")."' title='"._("Reset all services")."'> ".
59 "</div>";
60 $this->SetListHeader($listhead);
61 }
63 function execute()
64 {
65 $this->ClearElementsList();
66 $this->GenHeader();
67 }
69 function setEntries($list)
70 {
71 foreach($list as $name => $entry){
73 switch($entry['Status']){
74 case '' : $str ="";break;
75 case SERVICE_STOPPED : $str ="<img src='images/status_stopped.png' title='"._("Stopped")."'>"; break;
76 case SERVICE_STARTED : $str ="<img src='images/status_running.png' title='"._("Started")."'>"; break;
77 case SERVICE_RESETTED : $str ="<img src='images/status_restarting.png' title='"._("Restarting")."' alt='R'>"; break;
78 default: $str= "<img src='images/select_user.png' alt='".$entry['Status']."' title='"._("User status")." : ".$entry['Status']."'>";
79 }
81 $field1 = array("string" => $str ,"attach" => "style='width:20px;'");
82 $field2 = array("string" => $entry['Message'] );
84 $actions ="";
85 if($entry['AllowStart']){
86 $actions .= " <input type='image' name='StartSingleService_".$name."' src='images/status_start.png'>";
87 }else{
88 $actions .= " <img src='images/empty' width='16' alt=''>";
89 }
90 if($entry['AllowStart']){
91 $actions .= " <input type='image' name='StopSingleService_".$name."' src='images/status_stop.png'>";
92 }else{
93 $actions .= " <img src='images/empty' width='16' alt=''>";
94 }
95 if($entry['AllowStart']){
96 $actions .= " <input type='image' name='ResetSingleService_".$name."' src='images/status_restart.png'>";
97 }else{
98 $actions .= " <img src='images/empty' width='16' alt=''>";
99 }
100 if($entry['AllowEdit']){
101 $actions .= " <input type='image' name='EditSingleService_".$name."' src='images/edit.png'>";
102 }else{
103 $actions .= " <img src='images/empty' width='16' alt=''>";
104 }
105 if($entry['AllowRemove']){
106 $actions .= " <input type='image' name='RemoveSingleService_".$name."' src='images/edittrash.png'>";
107 }else{
108 $actions .= " <img src='images/empty' width='16' alt=''>";
109 }
111 $field3 = array("string" => $actions ,"attach" => "style='width:100px;border-right:0px;'");
112 $this->AddElement(array($field1,$field2,$field3));
113 }
114 }
116 function Save()
117 {
118 MultiSelectWindow :: Save();
119 }
121 function save_object()
122 {
123 /* Save automatic created POSTs like regex, checkboxes */
124 MultiSelectWindow :: save_object();
125 }
126 }
127 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
128 ?>