1 <?php
2 /*
3 * This code is part of GOsa (http://www.gosa-project.org)
4 * Copyright (C) 2003-2008 GONICUS GmbH
5 *
6 * ID: $$Id$$
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
23 class divListSystemService extends MultiSelectWindow
24 {
25 /* CheckBoxes, to change default values modify $this->AddCheckBox */
26 var $parent ;
27 var $ui ;
29 function divListSystemService ($config,$parent)
30 {
31 MultiSelectWindow::MultiSelectWindow($config,"SystemService", "server");
33 $this->parent = $parent;
34 $this->ui = get_userinfo();
35 $this->EnableJSLeaveMsg(TRUE);
37 /* Set list strings */
38 $this->SetTitle(_("Installed services"));
39 $this->SetSummary(_("Installed services"));
41 /* Result page will look like a headpage */
42 $this->SetInformation(_("Add, remove and configure the properties of system services here."));
44 /* Disable buttonsm */
45 $this->EnableCloseButton(false);
46 $this->EnableSaveButton (false);
48 /* set Page header */
49 $this->AddHeader(array("string"=>" ","attach"=>"style='width:20px;'"));
50 $this->AddHeader(array("string"=>_("Name")));
51 $this->AddHeader(array("string"=>_("Actions"),"attach"=>"style='width:100px;border-right:0px;'"));
52 $this->HideFilterPart();
53 }
55 function GenHeader()
56 {
57 /* Prepare departments,
58 which are shown in the listbox on top of the listbox
59 */
60 $listhead = "<div style='background:#F0F0F9;height:16px;padding:0px;'>".
61 " <input type='image' align='middle' src='plugins/systems/images/select_new_server.png' class='center'
62 name='addNewService' alt='"._("Add service")."' title='"._("Add new service")."'> ".
63 " <img class='center' src='images/lists/seperator.png' align='middle' alt='' height='16' width='1'> ".
64 " <input type='image' align='middle' src='images/status_start_all.png' class='center'
65 name='startServices' alt='"._("Start all")."' title='"._("Start all services")."'> ".
66 " <input type='image' align='middle' src='images/status_stop_all.png' class='center'
67 name='stopServices' alt='"._("Stop service")."' title='"._("Stop all services")."'> ".
68 " <input type='image' align='middle' src='images/status_restart_all.png' class='center'
69 name='restartServices' alt='"._("Restart service")."' title='"._("Restart all services")."'> ".
70 "</div>";
71 $this->SetListHeader($listhead);
72 }
74 function execute()
75 {
76 $this->ClearElementsList();
77 $this->GenHeader();
78 }
80 function setEntries($list)
81 {
82 $tmp = array();
83 foreach($list as $name => $entry){
84 $tmp[$name] = $entry['Message'];
85 }
87 natcasesort($tmp);
88 $tmp2 = array();
89 foreach($tmp as $name => $value){
90 $tmp2[$name] = $list[$name];
91 }
93 $ui = get_userinfo();
95 foreach($tmp2 as $name => $entry){
97 switch($entry['Status']){
98 case '' : $str =" ";break;
99 case SERVICE_STOPPED : $str ="<img src='images/lists/off.png' title='"._("Stopped")."'>"; break;
100 case SERVICE_STARTED : $str ="<img src='images/lists/on.png' title='"._("Started")."'>"; break;
101 case SERVICE_RESTARTED : $str ="<img src='images/status_restarting.png' title='"._("Restarting")."' alt='R'>"; break;
102 default: $str= "<img src='plugins/users/images/select_user.png' alt='".$entry['Status']."' title='"._("User status")." : ".$entry['Status']."'>";
103 }
105 $WasAccount = $this->parent->plugins[$name] -> initially_was_account;
107 $plug = $_GET['plug'];
109 if($entry['AllowEdit']){
110 $link = "<a href='?plug=".$plug."&act=open&id=".$name."'>".$entry['Message']."</a>";
111 }else{
112 $link = $entry['Message'];
113 }
115 $field1 = array("string" => $str ,"attach" => "style='width:20px;'");
116 $field2 = array("string" => $link);
118 $actions ="";
119 if($entry['AllowStart'] && $WasAccount){
120 $actions .= " <input type='image' name='StartSingleService_".$name."' src='images/status_start.png'
121 title='"._("Start service")."'>";
122 }else{
123 $actions .= " <img src='images/empty.png' width='16' alt=''>";
124 }
125 if($entry['AllowStop'] && $WasAccount){
126 $actions .= " <input type='image' name='StopSingleService_".$name."' src='images/status_stop.png'
127 title='"._("Stop service")."'>";
128 }else{
129 $actions .= " <img src='images/empty.png' width='16' alt=''>";
130 }
131 if($entry['AllowRestart'] && $WasAccount){
132 $actions .= " <input type='image' name='RestartSingleService_".$name."' src='images/lists/reload.png'
133 title='"._("Restart service")."'>";
134 }else{
135 $actions .= " <img src='images/empty.png' width='16' alt=''>";
136 }
138 /* Check if edit is enabled and allowed for current service */
139 if($entry['AllowEdit']){
140 $actions .= " <input type='image' name='EditSingleService_".$name."' src='images/lists/edit.png'
141 title='"._("Edit service")."'>";
142 }else{
143 $actions .= " <img src='images/empty.png' width='16' alt=''>";
144 }
146 /* Check if remove is enabled and allowed for current service */
147 if($entry['AllowRemove']){
148 $actions .= " <input type='image' name='RemoveSingleService_".$name."' src='images/lists/trash.png'
149 title='"._("Remove service")."'>";
150 }else{
151 $actions .= " <img src='images/empty.png' width='16' alt=''>";
152 }
154 $field3 = array("string" => $actions ,"attach" => "style='width:100px;border-right:0px;'");
155 $this->AddElement(array($field1,$field2,$field3));
156 }
157 }
159 function Save()
160 {
161 MultiSelectWindow :: Save();
162 }
164 function save_object()
165 {
166 /* Save automatic created POSTs like regex, checkboxes */
167 MultiSelectWindow :: save_object();
168 }
169 }
170 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
171 ?>