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