Code

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