Code

Updated check for new Devices.
[gosa.git] / plugins / admin / systems / class_divListSystem.inc
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");
33     
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);
50   
51     /* Disable buttonsm */
52     $this->EnableCloseButton(false);
53     $this->EnableSaveButton (false);
55     /* set Page header */
56     $this->AddHeader(array("string"=>"&nbsp;","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'>&nbsp;"._("Base")."&nbsp;".
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")."'>&nbsp;".
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    ="&nbsp;";
134     // User and Template  Images
135     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;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,"ArpNewDevice"=>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);
153       $cnts[$type] ++;
154  
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;
166       
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('/ /', '&nbsp;', @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     $num_ser_str = _("Number of listed servers");
219     $num_ws_str  = _("Number of listed workstations");
220     $num_ter_str = _("Number of listed terminals");
221     $num_pho_str = _("Number of listed phones");
222     $num_prt_str = _("Number of listed printers");
223     $num_com_str = _("Number of listed network components");
224     $num_new_str = _("Number of listed new devices");
225     $num_wws_str = _("Number of listed windows workstations");
226     $num_dep_str = _("Number of listed departments");
228     $str = "<img class='center' src='images/select_server.png'
229               title='".$num_ser_str."' alt='".$num_ser_str."'>&nbsp;".$cnts['server']."&nbsp;&nbsp;&nbsp;&nbsp;";
230     $str.= "<img class='center' src='images/select_workstation.png'
231               title='".$num_ws_str."' alt='".$num_ws_str."'>&nbsp;".$cnts['workstation']."&nbsp;&nbsp;&nbsp;&nbsp;";
232     $str.= "<img class='center' src='images/select_terminal.png'
233               title='".$num_ter_str."' alt='".$num_ter_str."'>&nbsp;".$cnts['terminal']."&nbsp;&nbsp;&nbsp;&nbsp;";
234     $str.= "<img class='center' src='images/select_phone.png'
235               title='".$num_pho_str."' alt='".$num_pho_str."'>&nbsp;".$cnts['phone']."&nbsp;&nbsp;&nbsp;&nbsp;";
236     $str.= "<img class='center' src='images/select_printer.png'
237               title='".$num_prt_str."' alt='".$num_prt_str."'>&nbsp;".$cnts['printer']."&nbsp;&nbsp;&nbsp;&nbsp;";
238     $str.= "<img class='center' src='images/select_component.png'
239               title='".$num_com_str."' alt='".$num_com_str."'>&nbsp;".$cnts['component']."&nbsp;&nbsp;&nbsp;&nbsp;";
240     $str.= "<img class='center' src='images/select_newsystem.png'
241               title='".$num_new_str."' alt='".$num_new_str."'>&nbsp;".($cnts['NewDevice']+$cnts['ArpNewDevice'])."&nbsp;&nbsp;&nbsp;&nbsp;";
242     $str.= "<img class='center' src='images/select_winstation.png'
243               title='".$num_wws_str."' alt='".$num_wws_str."'>&nbsp;".$cnts['winstation']."&nbsp;&nbsp;&nbsp;&nbsp;";
244     $str.= "<img class='center' src='images/folder.png'
245               title='".$num_dep_str."' alt='".$num_dep_str."'>&nbsp;".$num_deps."&nbsp;&nbsp;&nbsp;&nbsp;";
247     $this->set_List_Bottom_Info($str);
248   }
250   function Save()
251   {
252     MultiSelectWindow :: Save();  
253   }
255   function save_object()
256   {
257     /* Save automatic created POSTs like regex, checkboxes */
258     MultiSelectWindow :: save_object();   
259   }
261 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
262 ?>