Code

[COSMETIC] Fixed alignment in newer browsers
[gosa.git] / plugins / admin / fai / class_faiManagement.inc
1 <?php
2 /*
3    This code is part of GOsa (https://gosa.gonicus.de)
4    Copyright (C) 2003  Cajus Pollmeier
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20 require "tabsPartition.inc";
21 require "tabsVariable.inc";
22 require "tabsHook.inc";
23 require "tabsTemplate.inc";
24 require "tabsScript.inc";
25 require "tabsProfile.inc";
26 require "tabsPackage.inc";
29 class faiManagement extends plugin
30 {
31         /* Definitions */
32         var $plHeadline                 = "FAI";
33         var $plDescription              = "Fully Automatic Installation - management";
35         /* CLI vars */
36         var $cli_summary                = "Handling of FAI entries";
37         var $cli_description    = "This plugin represents a management tool\n
38                 which allows us to manage all needed attributes for fully automatic installations (FAI)";
39         var $cli_parameters             = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
41         /* Headpage attributes */
42         var $departments= array();
43         var $deptabs= NULL;
45         /* attribute list for save action */
46         var $attributes                 = array();      //      Attributes Managed by this plugin, none, 
47         //      because this is only an overview over all objects already defined in FAI.
48         var $objectclasses              = array();      //      ObjectClasses which the attributes are related to
49         var $dialog                             = array();      //      This object contains every dialog we have currently opened
51         var $objects                    = array();      //      This array contains all available objects shown in divlist
52         var $is_dialog                  = false;
54         /* construction/reconstruction 
55          * The Filter ($faifilter stored in $_SESSION['faifilter']) defines the last 
56          *  selected department and filter options
57          * If it is not defined already we create a new fresh faifilter.
58          */
59         function faiManagement ($config, $ui)
60         {
61                 $this->ui                       = $ui;  
63                 /* Set current dn to "", */
64                 $this->dn                       = "";
66                 /* Assign config */
67                 $this->config           = $config;
69                 /* Get global filter config */
70                 if (!is_global("faifilter")){
71                         $base   = get_base_from_people($ui->dn);
72                         $faifilter= array("base" => $base,
73                                         "regex" => "*");
74                         $faifilter['ShowProfiles']      = true;
75                         $faifilter['ShowTemplates'] = true;
76                         $faifilter['ShowScripts']       = true;
77                         $faifilter['ShowHooks']         = true;
78                         $faifilter['ShowVariables']     = true;
79                         $faifilter['ShowPackages']      = true;
80                         $faifilter['ShowPartitions']=true;
81                         register_global("faifilter", $faifilter);
82                 }
83         }
85         function execute()
86         {
88         /* Call parent execute */
89         plugin::execute();
91                 $display        = "";
92                 $smarty         = get_smarty();
93                 $s_action       = "";
94                 $s_entry        = "";
95                 /* filter management 
96                  * Filter will be changed if POST['regex'] or $_GET['search'] isset
97                  * New Filter will be stored in session and is used to generate list contents
98                  */     
99                 $faifilter = $_SESSION['faifilter'];
101                 /* Filter is posted by apply button 
102                  * Check every single chkbox 
103                  */
104                 if(isset($_POST['regex'])){
105                         $faifilter['regex'] = $_POST['regex']."*";
106                         foreach(array("ShowPartitions","ShowProfiles","ShowTemplates","ShowScripts","ShowHooks","ShowVariables","ShowPackages") as $attrs){
107                                 if(isset($_POST[$attrs])){
108                                         $faifilter[$attrs] = true;
109                                 }else{
110                                         $faifilter[$attrs] = false;
111                                 }
112                         }
113                 }
115                 /* Check ImageButton posts
116                  * Create new tab ich new_xx is posted
117                  */
118                 foreach($_POST as $key => $val){
119                         if(preg_match("/create_partition/i",$key)){
120                                 $s_action = "new_partition";
121                         }elseif(preg_match("/create_script/i",$key)){
122                                 $s_action = "new_script";
123                         }elseif(preg_match("/create_hook/i",$key)){
124                                 $s_action = "new_hook";
125                         }elseif(preg_match("/create_variable/i",$key)){
126                                 $s_action = "new_variable";
127                         }elseif(preg_match("/create_template/i",$key)){
128                                 $s_action = "new_template";
129                         }elseif(preg_match("/create_package/i",$key)){
130                                 $s_action = "new_package";
131                         }elseif(preg_match("/create_profile/i",$key)){
132                                 $s_action = "new_profile";
133                         }elseif(preg_match("/edit_continue/",$key)){
134                                 $s_action = "select_class_name_finished";
135                         }elseif(preg_match("/^entry_edit_.*/",$key)){
136                                 $s_entry = preg_replace("/^entry_edit_/","",$key);
137                                 $s_entry = preg_replace("/_.*$/","",$s_entry);
138                                 $s_action = "edit";
139                         }elseif(preg_match("/^entry_delete_.*/",$key)){
140                                 $s_entry = preg_replace("/^entry_delete_/","",$key);
141                                 $s_entry = preg_replace("/_.*$/","",$s_entry);
142                                 $s_action = "delete";
143                         }elseif(preg_match("/dep_back.*/i",$key)){
144                 $s_action="back";
145             }elseif(preg_match("/dep_home.*/i",$key)){
146                 $s_action="home";
147             }elseif(preg_match("/dep_root.*/i",$key)){
148                 $s_action="root";
149                         }
151                 }
153                 if($s_action=="root"){
154                         $faifilter['base']=($this->config->current['BASE']);
155                 }
157                 if($s_action=="home"){
158                         $faifilter['base']=(preg_replace("/^[^,]+,/","",$this->ui->dn));
159                         $faifilter['base']=(preg_replace("/^[^,]+,/","",$faifilter['base']));
160                 }
162                 if($s_action=="back"){
163                         $base_back          = preg_replace("/^[^,]+,/","",$faifilter['base']);
164                         $base_back          = convert_department_dn($base_back);
166                         if(isset($this->config->departments[trim($base_back)])){
167                                 $faifilter['base']= $this->config->departments[trim($base_back)];
168                         }else{
169                                 $faifilter['base']= $this->config->departments["/"];
170                         }
171                 }
173                 if(isset($_GET['act'])&&($_GET['act']=="dep_open")){
174             $s_action="open";
175             $s_entry = base64_decode($_GET['dep_id']);
176             $faifilter['base']= $this->config->departments[trim($s_entry)];
177         }
179                 if(isset($_GET['edit_entry'])){
180                         $s_entry = $_GET['edit_entry'];
181                         $s_action = "edit";
182                 }
184                 /* Confirm dialog 
185                  * Delte object 
186          */
187                 if ($s_action=="delete"){
189                         /* Get 'dn' from posted termlinst */
190                         $this->dn= $this->objects[$s_entry]['dn'];
192                         /* Load permissions for selected 'dn' and check if
193                            we're allowed to remove this 'dn' */
194                         $acl=           get_permissions ($this->dn, $this->ui->subtreeACL);
195                         $this->acl= get_module_permission($acl, "FAIclass", $this->dn);
196                         if (chkacl($this->acl, "delete") == ""){
198                                 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
199                                 if (($user= get_lock($this->dn)) != ""){
200                                         return(gen_locked_message ($user, $this->dn));
201                                 }
203                                 /* Lock the current entry, so nobody will edit it during deletion */
204                                 add_lock ($this->dn, $this->ui->dn);
205                                 $smarty->assign("warning", sprintf(_("You're about to delete all information about the FAI class at '%s'."), $this->dn));
206                                 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
207                         } else {
209                                 /* Obviously the user isn't allowed to delete. Show message and
210                                    clean session. */
211                                 print_red (_("You are not allowed to delete this component!"));
212                         }
213                 }
215                 /* Delete canceled? */
216                 if (isset($_POST['delete_cancel'])){
217                         del_lock ($this->dn);
218                 }
221                 /* Deltetion was confirmed, so delete this entry
222                  */
223                 if (isset($_POST['delete_terminal_confirm'])){
225                         /* Some nice guy may send this as POST, so we've to check
226                            for the permissions again. */
227                         if (chkacl($this->acl, "delete") == ""){
229                                 /* Find out more about the object type */
230                                 $ldap   = $this->config->get_ldap_link();
231                                 $ldap->cat($this->dn);
232                                 $attrs  = $ldap->fetch();
234                                 $type   = $this->get_type($attrs);                      
236                                 $this->dialog= new $type[0]($this->config,      $this->config->data['TABS'][$type[2]], $this->dn);
237                                 $this->dialog->set_acl(array($this->acl));
239                                 $this->dialog->by_object[$type[1]]->remove_from_parent ();
240                                 unset ($this->dialog);
241                                 gosa_log ("FAI class '".$this->dn."' has been removed");
242                                 $this->dialog= NULL;
244                                 /* Terminal list has changed, reload it. */
245                                 $this->reload ();
246                         } else {
248                                 /* Normally this shouldn't be reached, send some extra
249                                    logs to notify the administrator */
250                                 print_red (_("You are not allowed to delete this component!"));
251                                 gosa_log ("Warning: '".$this->ui->uid."' tried to trick system ".
252                                                 "deletion.");
253                         }
255                         /* Remove lock file after successfull deletion */
256                         del_lock ($this->dn);
257                 }
259                 /* Edit Entry */
260                 if($s_action == "edit"){
261                         $entry  = $this->objects[$s_entry];
263                         $a_setup = ($this->get_type($entry));
264                 
265                         $this->dn = $entry['dn'];
267                         $this->dialog= new $a_setup[0]($this->config,
268                                         $this->config->data['TABS'][$a_setup[2]],$this->dn);
269                         $this->is_dialog = true;
270                         $_SESSION['objectinfo'] = $this->dn;
271                 }
274                 /* Dialog handling */
275                 if($s_action == "new_partition"){
276                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpartitionTable");
277                 }
279                 /* Dialog handling */
280                 if($s_action == "new_script"){
281                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIscript");
282                 }
284                 /* Dialog handling */
285                 if($s_action == "new_hook"){
286                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIhook");
287                 }
289                 /* Dialog handling */
290                 if($s_action == "new_variable"){
291                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIvariable");
292                 }
294                 /* Dialog handling */
295                 if($s_action == "new_template"){
296                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAItemplate");
297                 }
299                 /* Dialog handling */
300                 if($s_action == "new_package"){
301                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpackageList");
302                 }
304                 /* New Profile */
305                 if($s_action == "new_profile"){
306                         $this->dn = "new" ;
307                         $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
309                         $this->dialog = new $a_setup[0]($this->config,
310                                         $this->config->data['TABS'][$a_setup[2]],$this->dn);
311                         $this->is_dialog = true;
313                 }
315                 if($s_action == "select_class_name_finished"){
316                         $this->dialog->save_object();
317                         if(count($this->dialog->check())!=0){
318                                 foreach($this->dialog->check() as $msg){
319                                         print_red($msg);
320                                 }               
321                         }else{
322                                 $this->dn = "new" ;
323                                 $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
324                                 $name = $this->dialog->save();
326                                 $this->dialog = new $a_setup[0]($this->config,
327                                                 $this->config->data['TABS'][$a_setup[2]],$this->dn,$name);
328                                 $this->dialog->by_object[$a_setup[1]]->cn = $name;
329                                 $this->is_dialog = true;
330                         }               
331                 }       
334                 /* Search is set */
335                 if(isset($_GET['search'])){
336                         $faifilter['regex']=$_GET['search']."*";
337                 }
339                 /* Department select */
340                 if(isset($_POST['base'])){
341                         $faifilter['base']=$_POST['base'];
342                 }
344                 /* remove double asterisks and save new filter */
345                 $faifilter['regex'] = preg_replace("/\*\*/","*",$faifilter['regex']);
346                 $_SESSION['faifilter']= $faifilter;
348                 /* Edit dialog was canceled 
349                  * Remove dialog an show management dialog
350                  */
351                 if(isset($_POST['edit_cancel'])){
352                         unset($this->dialog);
353                         $this->dialog=NULL;
354                         $this->is_dialog = false;
355                         unset($_SESSION['objectinfo']);
356                 }
358                 /* This check if the given tab could be saved 
359                  * If it was possible to save it, remove dialog object. 
360                  * If it wasn't possible, show errors and keep dialog.
361                  */
362                 if(isset($_POST['edit_finish'])){
363                         $this->dialog->save_object();
364                         if(count($this->dialog->check())!=0){
365                                 foreach($this->dialog->check() as $msg){
366                                         print_red($msg);
367                                 }
368                         }else{
369                                 $this->dialog->save();
370                                 unset($this->dialog);
371                                 $this->dialog=NULL;
372                                 $this->is_dialog=false;
373                                 unset($_SESSION['objectinfo']);
374                         }
375                 }
377                 /* If dialog is set, but $this->is_dialog==false, then 
378                  *  only the "abort" button is shown, this are dialogs that must not be saved.  
379                  * If is_dialog == true, we are currently editing tab objects.
380                  *  Here we need both, save and cancel
381                  */ 
383                 if($this->dialog != NULL){
384                         $display .= $this->dialog->execute();
385                         /* Don't show buttons if tab dialog requests this */
386                         if (((isset($this->dialog->current))&&($this->dialog->by_object[$this->dialog->current]->is_dialog))){
387                                 
388                         }elseif(((isset($this->dialog->current))&&(!$this->dialog->by_object[$this->dialog->current]->is_dialog))){
389                                 $display.= "<p style=\"text-align:right\">\n";
390                                 $display.= "<input type=submit name=\"edit_finish\" value=\""._("Finish")."\">\n";
391                                 $display.= "&nbsp;\n";
392                                 $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
393                                 $display.= "</p>";
394                         }elseif(!isset($this->dialog->current)){
395                                 $display.= "<p style=\"text-align:right\">\n";
396                                 $display.= "<input type=submit name=\"edit_continue\" value=\""._("Continue")."\">&nbsp;";
397                                 $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
398                                 $display.= "</p>";
399                         }
400                         return($display);
401                 }
403                 /* Show Management template
404                  * The following code will only be reached if no dialog (tabs or dialogs)
405                  *  are currently opened.
406                  * Assign all reguired vars to template engine
407                  */
409                 /* Prepare departments */
410                 $options= "";
411                 foreach ($this->config->idepartments as $key => $value){
412                         if ($faifilter['base'] == $key){
413                                 $options.= "<option selected value='$key'>$value</option>";
414                         } else {
415                                 $options.= "<option value='$key'>$value</option>";
416                         }
417                 }
419                 /* Create listhead, it will be shown on top of the divlist. 
420                  * It provides general navigation and object creation
421                  */
422                 $faihead = 
423                         "<div style='background:#F0F0F9;padding:5px;'>&nbsp;".
425                         "<input class='center' type='image' src='images/list_up.png' align='middle' 
426                         title='"._("Go up one department")."' name='dep_back' alt='"._("Up"). "'>&nbsp;".
428                         "<input class='center' type='image' src='images/list_root.png' align='middle' 
429                         title='"._("Go to root department")."' name='dep_root' alt='".      _("Root")."'>&nbsp;".
431                         "<input class='center' type='image' src='images/list_home.png' align='middle' 
432                         title='"._("Go to users home department")."' name='dep_home' alt='"._("Home")."'>&nbsp;".
434                         "<img class='center' src=\"images/list_seperator.png\" alt=\"\" align=\"middle\" height=\"16\" width=\"1\">&nbsp;".
435                         
436                         " <input class='center' type='image' src='images/fai_new_profile.png' align='middle' 
437                         title='"._("New profile")."' name='Create_profile' alt='"._("P")."'>&nbsp;".
438                         
439                         "<img class='center' src=\"images/list_seperator.png\" alt=\"\" align=\"middle\" height=\"16\" width=\"1\">&nbsp;".
440                                 
441                         " <input class='center' type='image' src='images/fai_new_partitionTable.png' align='middle' 
442                         title='"._("New partition table")."' name='Create_partition' alt='"._("PT")."'>&nbsp;".
444                         " <input class='center' type='image' src='images/fai_new_script.png' align='middle' 
445                         title='"._("New scripts")."' name='Create_script' alt='"._("S")."'>&nbsp;".
447                         " <input class='center' type='image' src='images/fai_new_hook.png' align='middle' 
448                         title='"._("New hooks")."' name='Create_hook' alt='"._("H")."'>&nbsp;".
450                         " <input class='center' type='image' src='images/fai_new_variable.png' align='middle' 
451                         title='"._("New variables")."' name='Create_variable' alt='"._("V")."'>&nbsp;".
452                         
453                         " <input class='center' type='image' src='images/fai_new_template.png' align='middle' 
454                         title='"._("New templates")."' name='Create_template' alt='"._("T")."'>&nbsp;".
456                         " <input class='center' type='image' src='images/fai_new_packages.png' align='middle' 
457                         title='"._("New package list")."' name='Create_package' alt='"._("PK")."'>&nbsp;".
459                         " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
461                         _("Current base")."&nbsp;<select name='base' onChange='mainform.submit()'>$options</select>".
462                         " <input class='center' type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
463                         
464                         "</div>";
466                 $this->reload();
468                 /* Create list with objects */
469                 $divlist = new divlist("faiManagement"); 
470                 $divlist->SetEntriesPerPage(0);
471                 $divlist->SetSummary(_("This table displays all systems, in the selected tree."));
473                 $divlist->SetHeader(array(
474                                         array("string" => "&nbsp;", "attach" => "style='text-align:center;width:20px;'"),
475                                         array("string" => _("Name of FAI class"), "attach" => "style=''"),
476                                         array("string" => _("Class type"), "attach" => "style='width:200px;'"),
477                                         array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'")));
480                 $action  = "<input type='image' src='images/edit.png'   alt='"._("edit")."'   name='entry_edit_%KEY%' title='"._("Edit class")."'>";
481                 $action .= "<input type='image' src='images/edittrash.png' alt='"._("delete")."' name='entry_delete_%KEY%' title='"._("Delete class")."'>";
483                 $editlink ="<a href='?plug=".$_GET['plug']."&edit_entry=%KEY%'>%NAME%</a>";             
484                 $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
486                 foreach($this->departments as $key => $val) {
487                         if(!isset($this->config->departments[trim($key)])){
488                                 $this->config->departments[trim($key)]="";
489                         }
491                         $non_empty="";
492                         $keys= str_replace("/","\/",$key);
493                         foreach($this->config->departments as $keyd=>$vald ){
494                                 if(preg_match("/".$keys."\/.*/",$keyd)){
495                                         $non_empty="full";
496                                 }
497                         }
500                         $title = $this->config->departments[$key];
501                         $field0 = array("string" => "<img src='images/".$non_empty."folder.png' title='"._("department")."' alt='department'>", "attach" => "style='text-align:center;width:20px;'");
502                         $field1 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style='' title='".$title."'");
503                         $field2 = array("string" => "&nbsp;", "attach" => "style='width:200px;'");
504                         $field3 = array("string" => "&nbsp;", "attach" => "style='width:60px;border-right:0px;text-align:right;'");
506                         $divlist->AddEntry( array($field0,$field1,$field2,$field3));
508                 }
511                 /* Attach objects */
512                 foreach($this->objects as $key => $value){
513                                 $info= "";
514                                 $img = "";
515                                 $type = $value['type'];
516                                 $abort=false;
518                                 switch($type) {
519                                         case "FAIpartitionTable"        : 
520                                                 if(!$faifilter['ShowPartitions']){ 
521                                                         $abort = true;
522                                                 }
523                                         $img="<img src='images/fai_partitionTable.png' title='"._("Partition table")."' alt='PT'>";
524                                         $info = _("Partition table");
525                                         break;
526                                         case "FAIpackageList"           : 
527                                                 if(!$faifilter['ShowPackages']){ 
528                                                         $abort = true;
529                                                 }
530                                         $img="<img src='images/fai_packages.png' title='"._("Package list")."' alt='PL'>";
531                                         $info = _("Package list");
532                                         break;
533                                         case "FAIscript"                        : 
534                                                 if(!$faifilter['ShowScripts']){ 
535                                                         $abort = true;
536                                                 }
537                                         $img="<img src='images/fai_script.png' title='"._("Scripts")."' alt='S'>";
538                                         $info = _("Scripts");
539                                         break;
540                                         case "FAIvariable"                      : 
541                                                 if(!$faifilter['ShowVariables']){ 
542                                                         $abort = true;
543                                                 }
544                                         $img="<img src='images/fai_variable.png' title='"._("Variables")."' alt='V'>";
545                                         $info = _("Variables");
546                                         break;
547                                         case "FAIhook"                          :
548                                                 if(!$faifilter['ShowHooks']){ 
549                                                         $abort = true;
550                                                 }
551                                         $img="<img src='images/fai_hook.png' title='"._("Hooks")."' alt='H'>";
552                                         $info = _("Hooks");
553                                         break;
554                                         case "FAIprofile"                       : 
555                                                 if(!$faifilter['ShowProfiles']){ 
556                                                         $abort = true;
557                                                 }
558                                         $img="<img src='images/fai_profile.png' title='"._("Profile")."' alt='P'>";
559                                         $info = _("Profile");
560                                         break;
561                                         case "FAItemplate"                      : 
562                                                 if(!$faifilter['ShowTemplates']){ 
563                                                         $abort = true;
564                                                 }
565                                         $img="<img src='images/fai_template.png' title='"._("Templates")."' alt='T'>";
566                                         $info = _("Templates");
567                                         break;
568                                         default                                         : 
569                                         $img="<img src='images/empty.png' alt=''>";$info = "";break;
571                                 }
572                                 
573                                 if(!$abort)     {
574                                         if((isset($value['description']))&&(!empty($value['description']))){
575                                                 $desc= " [".$value['description']."]";
576                                         }else{
577                                                 $desc= "";
578                                         }
580                                         $field1 = array("string" => $img , "attach" => "style='text-align:center;width:20px;'");
581                                         $field2 = array("string" => preg_replace(array("/%KEY%/","/%NAME%/"),array($key,$value['cn'].$desc),$editlink) , "attach" => "style=''");
582                                         $field3 = array("string" => $info, "attach" => "style='width:200px;'");
583                                         $field4 = array("string" => preg_replace("/%KEY%/",$key,$action) , "attach" => "style='width:60px;border-right:0px;text-align:right;'");
584                                         $divlist->AddEntry(array($field1,$field2,$field3,$field4));
586                         }
587                 }
589                 foreach($faifilter as $attrs => $value){
590                         if($value){
591                                 $smarty->assign($attrs."CHK", " checked ");
592                         }else{
593                                 $smarty->assign($attrs."CHK", " ");
594                         }
595                 }
597                 /* Assign all reguired vars to template engine */
598                 $smarty->assign("faihead"               , $faihead);    
599                 $smarty->assign("failist"               , $divlist->DrawList());
600                 $smarty->assign("regex"                 , $faifilter['regex']); 
601                 $smarty->assign("infoimage"             , get_template_path('images/info.png'));
602                 $smarty->assign("launchimage"   , get_template_path('images/launch.png'));
603                 $smarty->assign("alphabet"              , generate_alphabet());
604                 $smarty->assign("apply"                 , apply_filter());
605                 $smarty->assign("search_image"  , get_template_path('images/search.png'));
607                 $display        = $smarty->fetch(get_template_path('headpage.tpl', TRUE, dirname(__FILE__)));
608                 return ($display);
609         }
612         function reload()
613         {
614                 /* Create a new list of FAI object 
615                  * Object list depends on faifilter['regex']
616                  * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ... 
617                  */
618                 $faifilter= get_global('faifilter');
619                 // Added for dirlist function...
621                 /* Set base for all searches */
622                 $base= "ou=fai,ou=configs,ou=systems,".$faifilter['base'];
623                 $regex = $faifilter['regex'];   
625                 /* Array to save objects */
626                 $objects = array();
627         
628                 $this->objects=array();
630                 /* NEW LIST MANAGMENT
631                  * We also need to search for the departments
632                  * So we are able to navigate like in konquerer
633                  */
634                 $base2 = $faifilter['base'];
636                 $res3 =  get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))",
637                                 TRUE, $base2, array("ou", "description"), TRUE);
639                 $this->departments= array();
640                 $tmp = array();
641                 foreach ($res3 as $value){
642                         $tmp[strtolower($value['dn']).$value['dn']]=$value;
643                 }
644                 ksort($tmp);
645                 foreach($tmp as $value){
646                         if($value["description"][0]!=".."){
647                                 $this->departments[$value['dn']]=convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
648                         }else{
649                                 $this->departments[$value['dn']]=$value["description"][0];
650                         }
651                 }
653                 /* END NEW LIST MANAGMENT
654                  */
656         
657                 $res= get_list($this->ui->subtreeACL, "(objectClass=organizationalUnit)", 
658                                 FALSE, $base, array("cn","description","objectClass"),TRUE);
660                 foreach($res as $objecttypes){
661                         $res2 = get_list($this->ui->subtreeACL, "(&(objectClass=*)(cn=".$regex."))",
662                                         FALSE, $objecttypes['dn'], array("cn","description","objectClass","FAIclass"),TRUE);
663                         foreach($res2 as $object){
664                                 $type= "";      
665                                 unset($object['objectClass']['count']);
666                                 if(!isset($object['description'][0])){
667                                         $object['description'][0]="";
668                                 }
669                                 
670                                 /* Clean up object informations */
671                                 $obj['cn']                      = $object['cn'][0];
672                                 $obj['dn']                      = $object['dn'];
673                                 $obj['description'] = $object['description'][0];
674                                 $obj['objectClass'] = $object['objectClass'];
676                                 if(in_array("FAIpartitionTable",$obj['objectClass'])){
677                                         $type = "FAIpartitionTable";
678                                 }elseif(in_array("FAIpackageList",$obj['objectClass'])){
679                                         $type = "FAIpackageList";
680                                 }elseif(in_array("FAIscript",$obj['objectClass'])){
681                                         $type = "FAIscript";
682                                 }elseif(in_array("FAIvariable",$obj['objectClass'])){
683                                         $type = "FAIvariable";
684                                 }elseif(in_array("FAIhook",$obj['objectClass'])){
685                                         $type = "FAIhook";
686                                 }elseif(in_array("FAIprofile",$obj['objectClass'])){
687                                         $obj['FAIclass']        = $object['FAIclass'][0];
688                                         $type = "FAIprofile";
689                                 }elseif(in_array("FAItemplate",$obj['objectClass'])){
690                                         $type = "FAItemplate";
691                                 }
692                                 $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj;
693                                 $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type;
694  
695                         }
696                 }
697                 ksort($this->objects);
698                 reset ($this->objects);
699         
700                 /* use numeric index, thats a bit more secure */        
701                 $tmp0 = array();
702                 foreach($this->objects as $obj){
703                         $tmp0[]= $obj;
704                 }
705                 $this->objects = array();
706                 $this->objects = $tmp0;
708         }
710         function remove_lock()
711         {
712                 if (isset($this->dn)){
713                         del_lock ($this->dn);
714                 }
715         }
717         function get_type($array){
718                 if(in_array("FAIpartitionTable",$array['objectClass'])){
719                         return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS"));
720                 }
721                 if(in_array("FAIscript",$array['objectClass'])){
722                         return(array("tabsScript","faiScript","FAISCRIPTTABS"));
723                 }
724                 if(in_array("FAItemplate",$array['objectClass'])){
725                         return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS"));
726                 }
727                 if(in_array("FAIhook",$array['objectClass'])){
728                         return(array("tabsHook","faiHook","FAIHOOKTABS"));
729                 }
730                 if(in_array("FAIvariable",$array['objectClass'])){
731                         return(array("tabsVariable","faiVariable","FAIVARIABLETABS"));
732                 }
733                 if(in_array("FAIprofile",$array['objectClass'])){
734                         return(array("tabsProfile","faiProfile","FAIPROFILETABS"));
735                 }
736                 
737                 if(in_array("FAIpackageList",$array['objectClass'])){
738                         return(array("tabsPackage","faiPackage","FAIPACKAGETABS"));
739                 }
740         }
744 ?>