1 <?php
3 class divListSystem extends MultiSelectWindow
4 {
6 /* Current base */
7 var $selectedBase = "";
8 var $departments = array();
9 var $do_iso = FALSE;
11 /* Regex */
12 var $Regex = "*";
13 var $UserRegex = "*";
15 /* CheckBoxes, to change default values modify $this->AddCheckBox */
16 var $ShowServers;
17 var $ShowTerminals;
18 var $ShowWorkstations;
19 var $ShowWinWorkstations;
20 var $ShowPrinters;
21 var $ShowDevices;
22 var $ShowPhones;
24 /* Subsearch checkbox */
25 var $SubSearch;
27 var $parent ;
28 var $ui ;
30 function divListSystem ($config,$parent)
31 {
32 MultiSelectWindow::MultiSelectWindow($config,"System");
34 $this->parent = $parent;
35 $this->ui = get_userinfo();
37 if (search_config($config->data['TABS'], "workgeneric", "ISOCMD")){
38 $this->do_iso= TRUE;
39 }
41 /* Set list strings */
42 $this->SetTitle(_("List of systems"));
43 $this->SetSummary(_("List of systems"));
45 /* Result page will look like a headpage */
46 $this->SetHeadpageMode();
47 $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."));
49 $this->EnableAplhabet (true);
51 /* Disable buttonsm */
52 $this->EnableCloseButton(false);
53 $this->EnableSaveButton (false);
55 /* set Page header */
56 $this->AddHeader(array("string"=>" ","attach"=>"style='width:20px;'"));
57 $this->AddHeader(array("string"=>_("System / Department")));
58 $this->AddHeader(array("string"=>_("Actions"),"attach"=>"style='width:70px;border-right:0px;'"));
60 /* Text ,Value ,Name ,Is selected */
61 $this->AddCheckBox("ShowServers", _("Select to see servers"), _("Show servers"), true);
62 $this->AddCheckBox("ShowTerminals", _("Select to see Linux terminals"), _("Show terminals") , true);
63 $this->AddCheckBox("ShowWorkstations", _("Select to see Linux workstations"), _("Show workstations"), true);
64 $this->AddCheckBox("ShowWinWorkstations", _("Select to see MicroSoft Windows based workstations"), _("Show windows based workstations"),true);
65 $this->AddCheckBox("ShowPrinters", _("Select to see network printers"), _("Show network printers") ,true);
66 $this->AddCheckBox("ShowPhones", _("Select to see VOIP phones"), _("Show phones") , true);
67 $this->AddCheckBox("ShowDevices", _("Select to see network devices"), _("Show network devices"), true);
69 /* Add SubSearch checkbox */
70 $this->AddCheckBox(SEPERATOR);
71 $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false);
73 /* Name ,Text ,Default , Connect with alphabet */
74 $this->AddRegex ("Regex", _("Display systems matching"),"*" , true);
75 /*$this->AddRegex ("UserRegex", _("Display systems of user"), "*" , false, "images/search_user.png");*/
76 }
78 function GenHeader()
79 {
80 /* Prepare departments,
81 which are shown in the listbox on top of the listbox
82 */
83 $options= "";
84 foreach ($this->config->idepartments as $key => $value){
85 if ($this->selectedBase == $key){
86 $options.= "<option selected='selected' value='$key'>$value</option>";
87 } else {
88 $options.= "<option value='$key'>$value</option>";
89 }
90 }
92 /* Add default header */
93 $listhead = MultiSelectWindow::get_default_header();
94 $listhead.=" <input class='center' type='image' align='middle' src='images/select_new_terminal.png'
95 name='newsystem_terminal' alt='"._("New Terminal template")."' title='"._("New Terminal")."'>".
96 " <input class='center' type='image' align='middle' src='images/select_new_workstation.png'
97 name='newsystem_workstation' alt='"._("New Workstation template")."' title='"._("New Workstation")."'>".
98 " <input class='center' type='image' align='middle' src='images/select_new_server.png' name='newsystem_server' alt='"._("New Server")."'
99 title='"._("New Server")."'>".
100 " <input class='center' type='image' align='middle' src='images/select_new_printer.png' name='newsystem_printer' alt='"._("New Printer")."'
101 title='"._("New Printer")."'>".
102 " <input class='center' type='image' align='middle' src='images/select_new_phone.png' name='newsystem_phone' alt='"._("New Phone")."'
103 title='"._("New Phone")."'>".
104 " <input class='center' type='image' align='middle' src='images/select_new_component.png' name='newsystem_component' alt='"._("New Component")."'
105 title='"._("New Component")."'>".
106 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> "._("Base")." ".
107 " <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
108 " <input class='center' type='image' src='images/list_submit.png' align='middle'
109 title='"._("Submit department")."' name='submit_department' alt='". _("Submit")."'> ".
110 "</div>";
111 $this->SetListHeader($listhead);
112 }
114 function execute()
115 {
116 $this->ClearElementsList();
117 $this->GenHeader();
118 }
120 function setEntries($terminals)
121 {
122 $img1 = "<img class='center' src='images/printer.png' alt='C' title='"._("Cups Server") ."'>";
123 $img2 = "<img class='center' src='images/scanner.png' alt='L' title='"._("Log Db") ."'>";
124 $img3 = "<img class='center' src='images/select_terminal.png' alt='L' title='"._("Syslog Server") ."'>";
125 $img4 = "<img class='center' src='images/mailto.png' alt='M' title='"._("Mail Server") ."'>";
126 $img5 = "<img class='center' src='images/select_phone.png' alt='I' title='"._("Imap Server") ."'>";
127 $img6 = "<img class='center' src='images/fax_small.png' alt='F' title='"._("Nfs Server") ."'>";
128 $img7 = "<img class='center' src='images/select_winstation.png' alt='K' title='"._("Kerberos Server") ."'>";
129 $img8 = "<img class='center' src='images/select_phone.png' alt='A' title='"._("Asterisk Server") ."'>";
130 $img9 = "<img class='center' src='images/fax_small.png' alt='F' title='"._("Fax Server") ."'>";
131 $img10 = "<img class='center' src='images/save.png' alt='L' title='"._("Ldap Server") ."'>";
133 $empty =" ";
134 // User and Template Images
135 $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
137 $cnts = array("component" => 0 , "terminal" => 0 , "workstation" => 0 ,
138 "printer" => 0 , "phone" => 0 , "server" => 0,
139 "NewDevice" => 0, "winstation"=> 0);
141 // Test Every Entry and generate divlist Array
142 foreach($terminals as $key => $val){
144 $acl= get_permissions ($val['dn'], $this->ui->subtreeACL);
145 $acl= get_module_permission($acl, "terminal", $val['dn']);
147 $action= "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."' name='user_edit_%KEY%' title='"._("Edit system")."'>";
148 if(chkacl($acl,"delete") ==""){
149 $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."' name='user_del_%KEY%' title='"._("Delete system")."'>";
150 }
152 $type = $this->parent->get_system_type($val['objectClass']);
153 $cnts[$type] ++;
155 /* Generate picture list, which is currently disabled */
156 if(in_array("goCupsServer" ,$val['objectClass'])) $cups = $img1; else $cups =$empty;
157 if(in_array("goLogDBServer" ,$val['objectClass'])) $logdb = $img2; else $logdb =$empty;
158 if(in_array("goSyslogServer" ,$val['objectClass'])) $syslog = $img3; else $syslog=$empty;
159 if(in_array("goImapServer" ,$val['objectClass'])) $imap = $img4; else $imap =$empty;
160 if(in_array("sambaSamAccount" ,$val['objectClass'])) $samba = $img5; else $samba =$empty;
161 if(in_array("goShareServer" ,$val['objectClass'])) $nfs = $img6; else $nfs =$empty;
162 if(in_array("goKrbServer" ,$val['objectClass'])) $krb = $img7; else $krb =$empty;
163 if(in_array("goFonServer" ,$val['objectClass'])) $fon = $img8; else $fon =$empty;
164 if(in_array("goFaxServer" ,$val['objectClass'])) $fax = $img9; else $fax =$empty;
165 if(in_array("goLdapServer" ,$val['objectClass'])) $ldap = $img10; else $ldap =$empty;
167 $pics = $cups.$logdb.$syslog.$imap.$samba.$nfs.$krb.$fon.$fax.$ldap;
168 $pics = ""; // Pictures currently hidden
170 $val['cn'][0]= preg_replace('/\$$/', '', $val['cn'][0]);
172 // Generate Array to Add
173 $dsc= "";
174 if (isset($val['description'][0])){
175 $dsc= " [".$val['description'][0]."]";
176 }
177 if((isset($val['is_new']))&&(!empty($val['is_new']))){
178 $display= $val["cn"][0]." ".$val['is_new'].$dsc;
179 }else{
180 $display= $val["cn"][0].$dsc;
181 }
183 if(((in_array("gotoTerminal",$val['objectClass']))||(in_array("gotoWorkstation",$val['objectClass']))) && chkacl($acl,"password") == ""){
184 $action2 = "<input class='center' type='image' src='images/certs.png' alt='"._("Password")."' name='user_setpwd_%KEY%' title='"._("Set root password")."'>";
185 }else{
186 $action2 = "";
187 }
189 if($this->do_iso && in_array("gotoWorkstation",$val['objectClass'])){
190 $action2= "<input class='center' type='image' src='images/cdrom.png' alt='"._("Create CD")."' name='gen_cd_%KEY%' title='"._("Create FAI CD")."'>".$action2;
191 }
193 /* Add Message generated by mangement->reload*/
194 if(isset($val['message'])){
195 $display.= " (".$val['message'].")";
196 }
198 /* Cutted objects should be displayed in light grey */
199 if(isset($this->parent->CopyPasteHandler) && $this->parent->CopyPasteHandler->cutCurrent && $val['dn'] == $this->parent->CopyPasteHandler->objectdn){
200 $display = "<font color='#999999'>".$display."</font>";
201 }
203 $img = $this->parent->convert_list($val);
205 $field1 = array("string" => sprintf($img['img'],$val['dn']), "attach" => "style='text-align:center;width:20px;'");
206 $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'");
207 $field3 = array("string" => preg_replace("/%KEY%/", "$key", $action2.$action), "attach" => "style='width:70px;border-right:0px;text-align:right;'");
208 $this->AddElement( array($field1,$field2,$field3));
209 }
212 /* Create summary string for list footer */
213 $num_deps=0;
214 if(!$this->SubSearch){
215 $num_deps = count($this->Added_Departments);
216 }
218 $str ="";
220 /* Servers */
221 $str.= $cnts['server']." ";
222 $cnts['server'] != 1 ? $str.=_("Servers").", " : $str .= _("Server").", ";
224 /* Workstations */
225 $str.= $cnts['workstation']." ";
226 $cnts['workstation'] != 1 ? $str.=_("Workstations").", ": $str .= _("Workstation").", ";
228 /* Terminals */
229 $str.= $cnts['terminal']." ";
230 $cnts['terminal'] != 1 ? $str.=_("Terminals").", " : $str .= _("Terminal").", ";
232 /* Phones */
233 $str.= $cnts['phone']." ";
234 $cnts['phone'] != 1 ? $str.=_("Phones").", " : $str .= _("Phone").", ";
236 /* Printer */
237 $str.= $cnts['printer']." ";
238 $cnts['printer'] != 1 ? $str.=_("Printers").", " : $str .= _("Printer").", ";
240 /* Components */
241 $str.= $cnts['component']." ";
242 $cnts['component'] != 1 ? $str.=_("Components").", " : $str .= _("Component").", ";
244 /* New devices */
245 $str.= $cnts['NewDevice']." ";
246 $cnts['NewDevice'] != 1 ? $str.=_("New devices").", " : $str .= _("New device").", ";
248 /* Windows workstations */
249 $str.= $cnts['winstation']." ";
250 $cnts['winstation'] != 1 ? $str.=_("Windows workstations").", " : $str .= _("Windows workstation").", ";
252 $str.= $num_deps." ";
253 $num_deps != 1 ? $str.=_("Departments") : $str .= _("Department");
254 $this->set_List_Bottom_Info($str);
256 }
258 function Save()
259 {
260 MultiSelectWindow :: Save();
261 }
263 function save_object()
264 {
265 /* Save automatic created POSTs like regex, checkboxes */
266 MultiSelectWindow :: save_object();
267 }
268 }
269 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
270 ?>