1 <?php
3 class divListSystem extends MultiSelectWindow
4 {
6 /* Current base */
7 var $selectedBase = "";
8 var $departments = array();
10 /* Regex */
11 var $Regex = "*";
12 var $UserRegex = "*";
14 /* CheckBoxes */
15 var $ShowServers = true;
16 var $ShowTerminals = true;
17 var $ShowWorkstations = true;
18 var $ShowWinWorkstations= true;
19 var $ShowPrinters = true;
20 var $ShowDevices = true;
21 var $ShowPhones = true;
23 /* Subsearch checkbox */
24 var $SubSearch = false;
26 var $parent ;
27 var $ui ;
29 function divListSystem ($config,$parent)
30 {
31 MultiSelectWindow::MultiSelectWindow($config,"System");
33 $this->parent = $parent;
34 $this->ui = get_userinfo();
36 /* Set default base */
37 if(!isset($_SESSION['CurrentMainBase'])){
38 $_SESSION['CurrentMainBase'] = $this->config->current['BASE'];
39 }
40 $this->selectedBase = $_SESSION['CurrentMainBase'];
42 /* Set list strings */
43 $this->SetTitle(_("List of systems"));
44 $this->SetSummary(_("List of systems"));
46 /* Result page will look like a headpage */
47 $this->SetHeadpageMode();
48 $this->SetInformation(_("This menu allows you to add, remove and change the properties of specific systems. You can only add systems which have already been started once."));
50 $this->EnableAplhabet (true);
52 /* Disable buttonsm */
53 $this->EnableCloseButton(false);
54 $this->EnableSaveButton (false);
56 /* set Page header */
57 $this->AddHeader(array("string"=>" ","attach"=>"style='width:20px;'"));
58 $this->AddHeader(array("string"=>_("System / Department")));
59 $this->AddHeader(array("string"=>_("Actions"),"attach"=>"style='width:60px;border-right:0px;'"));
61 /* Text ,Value ,Name ,Is selected */
62 $this->AddCheckBox("ShowServers", _("Select to see servers"), _("Show servers"), true);
63 $this->AddCheckBox("ShowTerminals", _("Select to see Linux terminals"), _("Show terminals") , true);
64 $this->AddCheckBox("ShowWorkstations", _("Select to see Linux workstations"), _("Show workstations"), true);
65 $this->AddCheckBox("ShowWinWorkstations", _("Select to see MicroSoft Windows based workstations"), _("Show windows based workstations"),true);
66 $this->AddCheckBox("ShowPrinters", _("Select to see network printers"), _("Show network printers") ,true);
67 $this->AddCheckBox("ShowPhones", _("Select to see VOIP phones"), _("Show phones") , true);
68 $this->AddCheckBox("ShowDevices", _("Select to see network devices"), _("Show network devices"), true);
70 /* Add SubSearch checkbox */
71 $this->AddCheckBox(SEPERATOR);
72 $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Ignore subtrees"), false);
74 /* Name ,Text ,Default , Connect with alphabet */
75 $this->AddRegex ("Regex", _("Display systems matching"),"*" , true);
76 $this->AddRegex ("UserRegex", _("Display systems of user"), "*" , false, "images/search_user.png");
77 }
79 function GenHeader()
80 {
81 /* Prepare departments,
82 which are shown in the listbox on top of the listbox
83 */
84 $options= "";
85 foreach ($this->config->idepartments as $key => $value){
86 if ($this->selectedBase == $key){
87 $options.= "<option selected='selected' value='$key'>$value</option>";
88 } else {
89 $options.= "<option value='$key'>$value</option>";
90 }
91 }
92 $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
93 " <input class='center' type='image' src='images/list_root.png' align='middle'
94 title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'> ".
95 " <input class='center' type='image' align='middle' src='images/list_back.png'
96 title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'> ".
97 " <input class='center' type='image' align='middle' src='images/list_home.png'
98 title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'> ".
99 " <input class='center' type='image' src='images/list_reload.png' align='middle' title='"._("Reload list")."' name='submit_department' alt='". _("Submit")."'> ".
100 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ".
101 " <input class='center' type='image' align='middle' src='images/select_new_terminal.png'
102 name='newsystem_terminal' alt='"._("New Terminal template")."' title='"._("New Terminal")."'>".
103 " <input class='center' type='image' align='middle' src='images/select_new_workstation.png'
104 name='newsystem_workstation' alt='"._("New Workstation template")."' title='"._("New Workstation")."'>".
105 " <input class='center' type='image' align='middle' src='images/select_new_server.png' name='newsystem_server' alt='"._("New Server")."'
106 title='"._("New Server")."'>".
107 " <input class='center' type='image' align='middle' src='images/select_new_printer.png' name='newsystem_printer' alt='"._("New Printer")."'
108 title='"._("New Printer")."'>".
109 " <input class='center' type='image' align='middle' src='images/select_new_phone.png' name='newsystem_phone' alt='"._("New Phone")."'
110 title='"._("New Phone")."'>".
111 " <input class='center' type='image' align='middle' src='images/select_new_component.png' name='newsystem_component' alt='"._("New Component")."'
112 title='"._("New Component")."'>".
113 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> "._("Base")." ".
114 " <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
115 " <input class='center' type='image' src='images/list_submit.png' align='middle'
116 title='"._("Submit department")."' name='submit_department' alt='". _("Submit")."'> ".
117 "</div>";
118 $this->SetListHeader($listhead);
119 }
121 function execute()
122 {
123 $this->ClearElementsList();
124 $this->GenHeader();
125 }
127 function setEntries($terminals)
128 {
129 $img1 = "<img class='center' src='images/printer.png' alt='C' title='"._("Cups Server") ."'>";
130 $img2 = "<img class='center' src='images/scanner.png' alt='L' title='"._("Log Db") ."'>";
131 $img3 = "<img class='center' src='images/select_terminal.png' alt='L' title='"._("Syslog Server") ."'>";
132 $img4 = "<img class='center' src='images/mailto.png' alt='M' title='"._("Mail Server") ."'>";
133 $img5 = "<img class='center' src='images/select_phone.png' alt='I' title='"._("Imap Server") ."'>";
134 $img6 = "<img class='center' src='images/fax_small.png' alt='F' title='"._("Nfs Server") ."'>";
135 $img7 = "<img class='center' src='images/select_winstation.png' alt='K' title='"._("Kerberos Server") ."'>";
136 $img8 = "<img class='center' src='images/select_phone.png' alt='A' title='"._("Asterisk Server") ."'>";
137 $img9 = "<img class='center' src='images/fax_small.png' alt='F' title='"._("Fax Server") ."'>";
138 $img10 = "<img class='center' src='images/save.png' alt='L' title='"._("Ldap Server") ."'>";
140 $empty =" ";
141 $action= "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."' name='user_edit_%KEY%' title='"._("Edit system")."'>";
142 $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."' name='user_del_%KEY%' title='"._("Delete system")."'>";
144 // User and Template Images
145 $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
147 // Test Every Entry and generate divlist Array
148 foreach($terminals as $key => $val){
150 /* Generate picture list, which is currently disabled */
151 if(in_array("goCupsServer" ,$val['objectClass'])) $cups = $img1; else $cups =$empty;
152 if(in_array("goLogDBServer" ,$val['objectClass'])) $logdb = $img2; else $logdb =$empty;
153 if(in_array("goSyslogServer" ,$val['objectClass'])) $syslog = $img3; else $syslog=$empty;
154 if(in_array("goImapServer" ,$val['objectClass'])) $imap = $img4; else $imap =$empty;
155 if(in_array("sambaSamAccount" ,$val['objectClass'])) $samba = $img5; else $samba =$empty;
156 if(in_array("goShareServer" ,$val['objectClass'])) $nfs = $img6; else $nfs =$empty;
157 if(in_array("goKrbServer" ,$val['objectClass'])) $krb = $img7; else $krb =$empty;
158 if(in_array("goFonServer" ,$val['objectClass'])) $fon = $img8; else $fon =$empty;
159 if(in_array("goFaxServer" ,$val['objectClass'])) $fax = $img9; else $fax =$empty;
160 if(in_array("goLdapServer" ,$val['objectClass'])) $ldap = $img10; else $ldap =$empty;
162 $pics = $cups.$logdb.$syslog.$imap.$samba.$nfs.$krb.$fon.$fax.$ldap;
163 $pics = ""; // Pictures currently hidden
165 $val['cn'][0]= preg_replace('/\$$/', '', $val['cn'][0]);
167 // Generate Array to Add
168 if((isset($val['is_new']))&&(!empty($val['is_new']))){
169 $display= "".$val["cn"][0]." ".$val['is_new'];
170 }else{
171 $display= "".$val["cn"][0]."";
172 }
174 if((in_array("gotoTerminal",$val['objectClass']))||(in_array("gotoWorkstation",$val['objectClass']))){
175 $action2 = "<input class='center' type='image' src='images/certs.png' alt='"._("Password")."' name='user_setpwd_%KEY%' title='"._("Set root password")."'>";
176 }else{
177 $action2 = "";
178 }
180 if(isset($val['message'])){
181 $display.= " (".$val['message']." '".$this->config->idepartments[$_SESSION['CurrentMainBase']]."' )";
182 }
184 $img = $this->parent->convert_list($val);
185 $field1 = array("string" => sprintf($img['img'],$val['dn']), "attach" => "style='text-align:center;width:20px;'");
186 $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".@LDAP::fix($val['dn'])."'");
187 $field3 = array("string" => preg_replace("/%KEY%/", "$key", $action2.$action), "attach" => "style='width:60px;border-right:0px;text-align:right;'");
188 $this->AddElement( array($field1,$field2,$field3));
189 }
191 }
193 function Save()
194 {
195 MultiSelectWindow :: Save();
196 }
198 function save_object()
199 {
200 /* Save automatic created POSTs like regex, checkboxes */
201 MultiSelectWindow::save_object();
203 $s_action ="";
204 foreach($_POST as $key => $value){
205 if(preg_match("/^dep_back.*/i",$key)){
206 $s_action="back";
207 }elseif(preg_match("/^dep_root.*/",$key)){
208 $s_action="root";
209 }elseif(preg_match("/^dep_home.*/i",$key)){
210 $s_action="home";
211 }
212 }
214 /* Save base selection from headpage selectbox*/
215 if(isset($_POST['CurrentMainBase'])){
216 $this->selectedBase = $_POST['CurrentMainBase'];
217 }
219 /* Homebutton is posted */
220 if($s_action=="home"){
221 $ui= get_userinfo();
222 $this->selectedBase=(preg_replace("/^[^,]+,/","",$ui->dn));
223 $this->selectedBase=(preg_replace("/^[^,]+,/","",$this->selectedBase));
224 }
226 /* Open selected department
227 this is posted by the parent class MultiSelectWindow */
228 if(isset($_GET['act'])&& ($_GET['act'] == "dep_open")){
229 $s_entry = base64_decode($_GET['dep_id']);
230 $this->selectedBase = $this->config->departments[trim($s_entry)];
231 }
233 /* back to the roots ^^ */
234 if($s_action=="root"){
235 $this->selectedBase=($this->config->current['BASE']);
236 }
238 /* If Backbutton is Posted */
239 if($s_action=="back"){
240 $base_back = preg_replace("/^[^,]+,/","",$this->selectedBase);
241 $base_back = convert_department_dn($base_back);
242 if(isset($this->config->departments[trim($base_back)])){
243 $this->selectedBase= $this->config->departments[trim($base_back)];
244 }else{
245 $this->selectedBase= $this->config->departments["/"];
246 }
247 }
249 $_SESSION['CurrentMainBase'] = $this->selectedBase;
250 }
251 }
252 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
253 ?>