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, to change default values modify $this->AddCheckBox */
15 var $ShowServers;
16 var $ShowTerminals;
17 var $ShowWorkstations;
18 var $ShowWinWorkstations;
19 var $ShowPrinters;
20 var $ShowDevices;
21 var $ShowPhones;
23 /* Subsearch checkbox */
24 var $SubSearch;
26 var $parent ;
27 var $ui ;
29 function divListSystem ($config,$parent)
30 {
31 MultiSelectWindow::MultiSelectWindow($config, "System", array("server",
32 "workstation",
33 "terminal",
34 "phone",
35 "printer"));
37 $this->parent = $parent;
38 $this->ui = get_userinfo();
40 /* Set list strings */
41 $this->SetTitle(_("List of systems"));
42 $this->SetSummary(_("List of systems"));
44 /* Result page will look like a headpage */
45 $this->SetHeadpageMode();
46 $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."));
48 $this->EnableAplhabet (true);
50 /* Disable buttonsm */
51 $this->EnableCloseButton(false);
52 $this->EnableSaveButton (false);
54 /* Dynamic action col, depending on snapshot icons */
55 $action_col_size = 50;
56 if($this->parent->snapshotEnabled()){
57 $action_col_size += 38;
58 }
60 /* set Page header */
61 $this->AddHeader(array("string"=>" ","attach"=>"style='width:20px;'"));
62 $this->AddHeader(array("string"=>_("System / Department")));
63 $this->AddHeader(array("string"=>_("Actions"),"attach"=>"style='width:".$action_col_size."px;border-right:0px;'"));
65 /* Text ,Value ,Name ,Is selected */
66 $this->AddCheckBox("ShowServers", _("Select to see servers"), _("Show servers"), true);
67 $this->AddCheckBox("ShowTerminals", _("Select to see Linux terminals"), _("Show terminals") , true);
68 $this->AddCheckBox("ShowWorkstations", _("Select to see Linux workstations"), _("Show workstations"), true);
69 $this->AddCheckBox("ShowWinWorkstations", _("Select to see MicroSoft Windows based workstations"), _("Show windows based workstations"),true);
70 $this->AddCheckBox("ShowPrinters", _("Select to see network printers"), _("Show network printers") ,true);
71 $this->AddCheckBox("ShowPhones", _("Select to see VOIP phones"), _("Show phones") , true);
72 $this->AddCheckBox("ShowDevices", _("Select to see network devices"), _("Show network devices"), true);
74 /* Add SubSearch checkbox */
75 $this->AddCheckBox(SEPERATOR);
76 $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Ignore subtrees"), false);
78 /* Name ,Text ,Default , Connect with alphabet */
79 $this->AddRegex ("Regex", _("Display systems matching"),"*" , true);
80 $this->AddRegex ("UserRegex", _("Display systems of user"), "*" , false, "images/search_user.png");
81 }
83 function GenHeader()
84 {
85 /* Prepare departments,
86 which are shown in the listbox on top of the listbox
87 */
88 $options= "";
89 foreach ($this->config->idepartments as $key => $value){
90 if ($this->selectedBase == $key){
91 $options.= "<option selected='selected' value='$key'>$value</option>";
92 } else {
93 $options.= "<option value='$key'>$value</option>";
94 }
95 }
96 $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
97 " <input class='center' type='image' src='images/list_root.png' align='middle'
98 title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'> ".
99 " <input class='center' type='image' align='middle' src='images/list_back.png'
100 title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'> ".
101 " <input class='center' type='image' align='middle' src='images/list_home.png'
102 title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'> ".
103 " <input class='center' type='image' src='images/list_reload.png' align='middle' title='"._("Reload list")."' name='submit_department' alt='". _("Submit")."'> ".
104 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ";
105 $listhead .= $this->get_snapshot_header($this->selectedBase);
106 $listhead .= " <input class='center' type='image' align='middle' src='images/select_new_terminal.png'
107 name='newsystem_terminal' alt='"._("New Terminal template")."' title='"._("New Terminal")."'>".
108 " <input class='center' type='image' align='middle' src='images/select_new_workstation.png'
109 name='newsystem_workstation' alt='"._("New Workstation template")."' title='"._("New Workstation")."'>".
110 " <input class='center' type='image' align='middle' src='images/select_new_server.png' name='newsystem_server' alt='"._("New Server")."'
111 title='"._("New Server")."'>".
112 " <input class='center' type='image' align='middle' src='images/select_new_printer.png' name='newsystem_printer' alt='"._("New Printer")."'
113 title='"._("New Printer")."'>".
114 " <input class='center' type='image' align='middle' src='images/select_new_phone.png' name='newsystem_phone' alt='"._("New Phone")."'
115 title='"._("New Phone")."'>".
116 " <input class='center' type='image' align='middle' src='images/select_new_component.png' name='newsystem_component' alt='"._("New Component")."'
117 title='"._("New Component")."'>".
118 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> "._("Base")." ".
119 " <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
120 " <input class='center' type='image' src='images/list_submit.png' align='middle'
121 title='"._("Submit department")."' name='submit_department' alt='". _("Submit")."'> ".
122 "</div>";
123 $this->SetListHeader($listhead);
124 }
126 function execute()
127 {
128 $this->ClearElementsList();
129 $this->GenHeader();
130 }
133 function setEntries($terminals)
134 {
135 $img1 = "<img class='center' src='images/printer.png' alt='C' title='"._("Cups Server") ."'>";
136 $img2 = "<img class='center' src='images/scanner.png' alt='L' title='"._("Log Db") ."'>";
137 $img3 = "<img class='center' src='images/select_terminal.png' alt='L' title='"._("Syslog Server") ."'>";
138 $img4 = "<img class='center' src='images/mailto.png' alt='M' title='"._("Mail Server") ."'>";
139 $img5 = "<img class='center' src='images/select_phone.png' alt='I' title='"._("Imap Server") ."'>";
140 $img6 = "<img class='center' src='images/fax_small.png' alt='F' title='"._("Nfs Server") ."'>";
141 $img7 = "<img class='center' src='images/select_winstation.png' alt='K' title='"._("Kerberos Server") ."'>";
142 $img8 = "<img class='center' src='images/select_phone.png' alt='A' title='"._("Asterisk Server") ."'>";
143 $img9 = "<img class='center' src='images/fax_small.png' alt='F' title='"._("Fax Server") ."'>";
144 $img10 = "<img class='center' src='images/save.png' alt='L' title='"._("Ldap Server") ."'>";
146 $empty =" ";
148 /* Dynamic action col, depending on snapshot icons */
149 $action_col_size = 50;
150 if($this->parent->snapshotEnabled()){
151 $action_col_size += 38;
152 }
154 // User and Template Images
155 $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
157 // Test Every Entry and generate divlist Array
158 foreach($terminals as $key => $val){
160 $action= "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."' name='user_edit_%KEY%' title='"._("Edit system")."'>";
161 $action.= $this->GetSnapShotActions($val['dn']);
162 $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."' name='user_del_%KEY%' title='"._("Delete system")."'>";
164 /* Generate picture list, which is currently disabled */
165 if(in_array("goCupsServer" ,$val['objectClass'])) $cups = $img1; else $cups =$empty;
166 if(in_array("goLogDBServer" ,$val['objectClass'])) $logdb = $img2; else $logdb =$empty;
167 if(in_array("goSyslogServer" ,$val['objectClass'])) $syslog = $img3; else $syslog=$empty;
168 if(in_array("goImapServer" ,$val['objectClass'])) $imap = $img4; else $imap =$empty;
169 if(in_array("sambaSamAccount" ,$val['objectClass'])) $samba = $img5; else $samba =$empty;
170 if(in_array("goShareServer" ,$val['objectClass'])) $nfs = $img6; else $nfs =$empty;
171 if(in_array("goKrbServer" ,$val['objectClass'])) $krb = $img7; else $krb =$empty;
172 if(in_array("goFonServer" ,$val['objectClass'])) $fon = $img8; else $fon =$empty;
173 if(in_array("goFaxServer" ,$val['objectClass'])) $fax = $img9; else $fax =$empty;
174 if(in_array("goLdapServer" ,$val['objectClass'])) $ldap = $img10; else $ldap =$empty;
176 $pics = $cups.$logdb.$syslog.$imap.$samba.$nfs.$krb.$fon.$fax.$ldap;
177 $pics = ""; // Pictures currently hidden
179 $val['cn'][0]= preg_replace('/\$$/', '', $val['cn'][0]);
181 // Generate Array to Add
182 $dsc= "";
183 if (isset($val['description'][0])){
184 $dsc= " [".$val['description'][0]."]";
185 }
186 if((isset($val['is_new']))&&(!empty($val['is_new']))){
187 $display= $val["cn"][0]." ".$val['is_new'].$dsc;
188 }else{
189 $display= $val["cn"][0].$dsc;
190 }
192 if((in_array("gotoTerminal",$val['objectClass']))||(in_array("gotoWorkstation",$val['objectClass']))){
193 $action2 = "<input class='center' type='image' src='images/certs.png' alt='"._("Password")."' name='user_setpwd_%KEY%' title='"._("Set root password")."'>";
194 }else{
195 $action2 = "";
196 }
198 if(isset($val['message'])){
199 $display.= " (".$val['message']." '".$this->config->idepartments[$_SESSION['CurrentMainBase']]."' )";
200 }
202 $img = $this->parent->convert_list($val);
203 $field1 = array("string" => sprintf($img['img'],$val['dn']), "attach" => "style='text-align:center;width:20px;'");
204 $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'");
205 $field3 = array("string" => preg_replace("/%KEY%/", "$key", $action2.$action), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
206 $this->AddElement( array($field1,$field2,$field3));
207 }
209 }
212 function Save()
213 {
214 MultiSelectWindow :: Save();
215 }
218 function save_object()
219 {
220 /* Save automatic created POSTs like regex, checkboxes */
221 MultiSelectWindow :: save_object();
224 }
225 }
226 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
227 ?>