c98116dd11c42da09fd851b668e3b9c734e3c183
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 // Test Every Entry and generate divlist Array
138 foreach($terminals as $key => $val){
140 $acl= get_permissions ($val['dn'], $this->ui->subtreeACL);
141 $acl= get_module_permission($acl, "terminal", $val['dn']);
143 $action= "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."' name='user_edit_%KEY%' title='"._("Edit system")."'>";
144 if(chkacl($acl,"delete") ==""){
145 $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."' name='user_del_%KEY%' title='"._("Delete system")."'>";
146 }
149 /* Generate picture list, which is currently disabled */
150 if(in_array("goCupsServer" ,$val['objectClass'])) $cups = $img1; else $cups =$empty;
151 if(in_array("goLogDBServer" ,$val['objectClass'])) $logdb = $img2; else $logdb =$empty;
152 if(in_array("goSyslogServer" ,$val['objectClass'])) $syslog = $img3; else $syslog=$empty;
153 if(in_array("goImapServer" ,$val['objectClass'])) $imap = $img4; else $imap =$empty;
154 if(in_array("sambaSamAccount" ,$val['objectClass'])) $samba = $img5; else $samba =$empty;
155 if(in_array("goShareServer" ,$val['objectClass'])) $nfs = $img6; else $nfs =$empty;
156 if(in_array("goKrbServer" ,$val['objectClass'])) $krb = $img7; else $krb =$empty;
157 if(in_array("goFonServer" ,$val['objectClass'])) $fon = $img8; else $fon =$empty;
158 if(in_array("goFaxServer" ,$val['objectClass'])) $fax = $img9; else $fax =$empty;
159 if(in_array("goLdapServer" ,$val['objectClass'])) $ldap = $img10; else $ldap =$empty;
161 $pics = $cups.$logdb.$syslog.$imap.$samba.$nfs.$krb.$fon.$fax.$ldap;
162 $pics = ""; // Pictures currently hidden
164 $val['cn'][0]= preg_replace('/\$$/', '', $val['cn'][0]);
166 // Generate Array to Add
167 $dsc= "";
168 if (isset($val['description'][0])){
169 $dsc= " [".$val['description'][0]."]";
170 }
171 if((isset($val['is_new']))&&(!empty($val['is_new']))){
172 $display= $val["cn"][0]." ".$val['is_new'].$dsc;
173 }else{
174 $display= $val["cn"][0].$dsc;
175 }
177 if(((in_array("gotoTerminal",$val['objectClass']))||(in_array("gotoWorkstation",$val['objectClass']))) && chkacl($acl,"password") == ""){
178 $action2 = "<input class='center' type='image' src='images/certs.png' alt='"._("Password")."' name='user_setpwd_%KEY%' title='"._("Set root password")."'>";
179 }else{
180 $action2 = "";
181 }
183 if($this->do_iso && in_array("gotoWorkstation",$val['objectClass'])){
184 $action2= "<input class='center' type='image' src='images/cdrom.png' alt='"._("Create CD")."' name='gen_cd_%KEY%' title='"._("Create FAI CD")."'>".$action2;
185 }
187 /* Add Message generated by mangement->reload*/
188 if(isset($val['message'])){
189 $display.= " (".$val['message'].")";
190 }
192 $img = $this->parent->convert_list($val);
193 $field1 = array("string" => sprintf($img['img'],$val['dn']), "attach" => "style='text-align:center;width:20px;'");
194 $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'");
195 $field3 = array("string" => preg_replace("/%KEY%/", "$key", $action2.$action), "attach" => "style='width:70px;border-right:0px;text-align:right;'");
196 $this->AddElement( array($field1,$field2,$field3));
197 }
199 }
201 function Save()
202 {
203 MultiSelectWindow :: Save();
204 }
206 function save_object()
207 {
208 /* Save automatic created POSTs like regex, checkboxes */
209 MultiSelectWindow :: save_object();
210 }
211 }
212 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
213 ?>