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