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='restartServices' alt='"._("Restart service")."' title='"._("Restart 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_RESTARTED : $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 title='"._("Start service")."'>";
88 }else{
89 $actions .= " <img src='images/empty' width='16' alt=''>";
90 }
91 if($entry['AllowStart']){
92 $actions .= " <input type='image' name='StopSingleService_".$name."' src='images/status_stop.png'
93 title='"._("Stop service")."'>";
94 }else{
95 $actions .= " <img src='images/empty' width='16' alt=''>";
96 }
97 if($entry['AllowStart']){
98 $actions .= " <input type='image' name='RestartSingleService_".$name."' src='images/status_restart.png'
99 title='"._("Restart service")."'>";
100 }else{
101 $actions .= " <img src='images/empty' width='16' alt=''>";
102 }
103 if($entry['AllowEdit']){
104 $actions .= " <input type='image' name='EditSingleService_".$name."' src='images/edit.png'
105 title='"._("Edit service")."'>";
106 }else{
107 $actions .= " <img src='images/empty' width='16' alt=''>";
108 }
109 if($entry['AllowRemove']){
110 $actions .= " <input type='image' name='RemoveSingleService_".$name."' src='images/edittrash.png'
111 title='"._("Remove service")."'>";
112 }else{
113 $actions .= " <img src='images/empty' width='16' alt=''>";
114 }
116 $field3 = array("string" => $actions ,"attach" => "style='width:100px;border-right:0px;'");
117 $this->AddElement(array($field1,$field2,$field3));
118 }
119 }
121 function Save()
122 {
123 MultiSelectWindow :: Save();
124 }
126 function save_object()
127 {
128 /* Save automatic created POSTs like regex, checkboxes */
129 MultiSelectWindow :: save_object();
130 }
131 }
132 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
133 ?>