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 $tmp = array();
72 foreach($list as $name => $entry){
73 $tmp[$name] = $entry['Message'];
74 }
76 natcasesort($tmp);
77 $tmp2 = array();
78 foreach($tmp as $name => $value){
79 $tmp2[$name] = $list[$name];
80 }
82 foreach($tmp2 as $name => $entry){
84 switch($entry['Status']){
85 case '' : $str =" ";break;
86 case SERVICE_STOPPED : $str ="<img src='images/status_stopped.png' title='"._("Stopped")."'>"; break;
87 case SERVICE_STARTED : $str ="<img src='images/status_running.png' title='"._("Started")."'>"; break;
88 case SERVICE_RESTARTED : $str ="<img src='images/status_restarting.png' title='"._("Restarting")."' alt='R'>"; break;
89 default: $str= "<img src='images/select_user.png' alt='".$entry['Status']."' title='"._("User status")." : ".$entry['Status']."'>";
90 }
92 $WasAccount = $this->parent->plugins[$name] -> initially_was_account;
94 $field1 = array("string" => $str ,"attach" => "style='width:20px;'");
95 $field2 = array("string" => $entry['Message'] );
97 $actions ="";
98 if($entry['AllowStart'] && $WasAccount){
99 $actions .= " <input type='image' name='StartSingleService_".$name."' src='images/status_start.png'
100 title='"._("Start service")."'>";
101 }else{
102 $actions .= " <img src='images/empty' width='16' alt=''>";
103 }
104 if($entry['AllowStart'] && $WasAccount){
105 $actions .= " <input type='image' name='StopSingleService_".$name."' src='images/status_stop.png'
106 title='"._("Stop service")."'>";
107 }else{
108 $actions .= " <img src='images/empty' width='16' alt=''>";
109 }
110 if($entry['AllowStart'] && $WasAccount){
111 $actions .= " <input type='image' name='RestartSingleService_".$name."' src='images/status_restart.png'
112 title='"._("Restart service")."'>";
113 }else{
114 $actions .= " <img src='images/empty' width='16' alt=''>";
115 }
116 if($entry['AllowEdit']){
117 $actions .= " <input type='image' name='EditSingleService_".$name."' src='images/edit.png'
118 title='"._("Edit service")."'>";
119 }else{
120 $actions .= " <img src='images/empty' width='16' alt=''>";
121 }
122 if($entry['AllowRemove']){
123 $actions .= " <input type='image' name='RemoveSingleService_".$name."' src='images/edittrash.png'
124 title='"._("Remove service")."'>";
125 }else{
126 $actions .= " <img src='images/empty' width='16' alt=''>";
127 }
129 $field3 = array("string" => $actions ,"attach" => "style='width:100px;border-right:0px;'");
130 $this->AddElement(array($field1,$field2,$field3));
131 }
132 }
134 function Save()
135 {
136 MultiSelectWindow :: Save();
137 }
139 function save_object()
140 {
141 /* Save automatic created POSTs like regex, checkboxes */
142 MultiSelectWindow :: save_object();
143 }
144 }
145 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
146 ?>