Code

bd5c1fb3b7ec890f60b1e3943a0426ed6dfbbf4c
[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         {
87                 $display        = "";
88                 $smarty         = get_smarty();
89                 $s_action       = "";
90                 $s_entry        = "";
91                 /* filter management 
92                  * Filter will be changed if POST['regex'] or $_GET['search'] isset
93                  * New Filter will be stored in session and is used to generate list contents
94                  */     
95                 $faifilter = $_SESSION['faifilter'];
97                 /* Filter is posted by apply button 
98                  * Check every single chkbox 
99                  */
100                 if(isset($_POST['regex'])){
101                         $faifilter['regex'] = $_POST['regex']."*";
102                         foreach(array("ShowPartitions","ShowProfiles","ShowTemplates","ShowScripts","ShowHooks","ShowVariables","ShowPackages") as $attrs){
103                                 if(isset($_POST[$attrs])){
104                                         $faifilter[$attrs] = true;
105                                 }else{
106                                         $faifilter[$attrs] = false;
107                                 }
108                         }
109                 }
111                 /* Check ImageButton posts
112                  * Create new tab ich new_xx is posted
113                  */
114                 foreach($_POST as $key => $val){
115                         if(preg_match("/create_partition/i",$key)){
116                                 $s_action = "new_partition";
117                         }elseif(preg_match("/create_script/i",$key)){
118                                 $s_action = "new_script";
119                         }elseif(preg_match("/create_hook/i",$key)){
120                                 $s_action = "new_hook";
121                         }elseif(preg_match("/create_variable/i",$key)){
122                                 $s_action = "new_variable";
123                         }elseif(preg_match("/create_template/i",$key)){
124                                 $s_action = "new_template";
125                         }elseif(preg_match("/create_package/i",$key)){
126                                 $s_action = "new_package";
127                         }elseif(preg_match("/create_profile/i",$key)){
128                                 $s_action = "new_profile";
129                         }elseif(preg_match("/edit_continue/",$key)){
130                                 $s_action = "select_class_name_finished";
131                         }elseif(preg_match("/^entry_edit_.*/",$key)){
132                                 $s_entry = preg_replace("/^entry_edit_/","",$key);
133                                 $s_entry = preg_replace("/_.*$/","",$s_entry);
134                                 $s_action = "edit";
135                         }elseif(preg_match("/^entry_delete_.*/",$key)){
136                                 $s_entry = preg_replace("/^entry_delete_/","",$key);
137                                 $s_entry = preg_replace("/_.*$/","",$s_entry);
138                                 $s_action = "delete";
139                         }elseif(preg_match("/dep_back.*/i",$key)){
140                 $s_action="back";
141             }elseif(preg_match("/dep_home.*/i",$key)){
142                 $s_action="home";
143             }elseif(preg_match("/dep_root.*/i",$key)){
144                 $s_action="root";
145                         }
147                 }
149                 if($s_action=="root"){
150                         $faifilter['base']=($this->config->current['BASE']);
151                 }
153                 if($s_action=="home"){
154                         $faifilter['base']=(preg_replace("/^[^,]+,/","",$this->ui->dn));
155                         $faifilter['base']=(preg_replace("/^[^,]+,/","",$faifilter['base']));
156                 }
158                 if($s_action=="back"){
159                         $base_back          = preg_replace("/^[^,]+,/","",$faifilter['base']);
160                         $base_back          = convert_department_dn($base_back);
162                         if(isset($this->config->departments[trim($base_back)])){
163                                 $faifilter['base']= $this->config->departments[trim($base_back)];
164                         }else{
165                                 $faifilter['base']= $this->config->departments["/"];
166                         }
167                 }
169                 if(isset($_GET['act'])&&($_GET['act']=="dep_open")){
170             $s_action="open";
171             $s_entry = base64_decode($_GET['dep_id']);
172             $faifilter['base']= $this->config->departments[trim($s_entry)];
173         }
175                 if(isset($_GET['edit_entry'])){
176                         $s_entry = $_GET['edit_entry'];
177                         $s_action = "edit";
178                 }
180                 /* Confirm dialog 
181                  * Delte object 
182          */
183                 if ($s_action=="delete"){
185                         /* Get 'dn' from posted termlinst */
186                         $this->dn= $this->objects[$s_entry]['dn'];
188                         /* Load permissions for selected 'dn' and check if
189                            we're allowed to remove this 'dn' */
190                         $acl=           get_permissions ($this->dn, $this->ui->subtreeACL);
191                         $this->acl= get_module_permission($acl, "FAIclass", $this->dn);
192                         if (chkacl($this->acl, "delete") == ""){
194                                 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
195                                 if (($user= get_lock($this->dn)) != ""){
196                                         return(gen_locked_message ($user, $this->dn));
197                                 }
199                                 /* Lock the current entry, so nobody will edit it during deletion */
200                                 add_lock ($this->dn, $this->ui->dn);
201                                 $smarty->assign("warning", sprintf(_("You're about to delete all information about the FAI class at '%s'."), $this->dn));
202                                 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
203                         } else {
205                                 /* Obviously the user isn't allowed to delete. Show message and
206                                    clean session. */
207                                 print_red (_("You are not allowed to delete this component!"));
208                         }
209                 }
211                 /* Delete canceled? */
212                 if (isset($_POST['delete_cancel'])){
213                         del_lock ($this->dn);
214                 }
217                 /* Deltetion was confirmed, so delete this entry
218                  */
219                 if (isset($_POST['delete_terminal_confirm'])){
221                         /* Some nice guy may send this as POST, so we've to check
222                            for the permissions again. */
223                         if (chkacl($this->acl, "delete") == ""){
225                                 /* Find out more about the object type */
226                                 $ldap   = $this->config->get_ldap_link();
227                                 $ldap->cat($this->dn);
228                                 $attrs  = $ldap->fetch();
230                                 $type   = $this->get_type($attrs);                      
232                                 $this->dialog= new $type[0]($this->config,      $this->config->data['TABS'][$type[2]], $this->dn);
233                                 $this->dialog->set_acl(array($this->acl));
235                                 $this->dialog->by_object[$type[1]]->remove_from_parent ();
236                                 unset ($this->dialog);
237                                 gosa_log ("FAI class '".$this->dn."' has been removed");
238                                 $this->dialog= NULL;
240                                 /* Terminal list has changed, reload it. */
241                                 $this->reload ();
242                         } else {
244                                 /* Normally this shouldn't be reached, send some extra
245                                    logs to notify the administrator */
246                                 print_red (_("You are not allowed to delete this component!"));
247                                 gosa_log ("Warning: '".$this->ui->uid."' tried to trick system ".
248                                                 "deletion.");
249                         }
251                         /* Remove lock file after successfull deletion */
252                         del_lock ($this->dn);
253                 }
255                 /* Edit Entry */
256                 if($s_action == "edit"){
257                         $entry  = $this->objects[$s_entry];
259                         $a_setup = ($this->get_type($entry));
260                 
261                         $this->dn = $entry['dn'];
263                         $this->dialog= new $a_setup[0]($this->config,
264                                         $this->config->data['TABS'][$a_setup[2]],$this->dn);
265                         $this->is_dialog = true;
266                 }
269                 /* Dialog handling */
270                 if($s_action == "new_partition"){
271                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpartitionTable");
272                 }
274                 /* Dialog handling */
275                 if($s_action == "new_script"){
276                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIscript");
277                 }
279                 /* Dialog handling */
280                 if($s_action == "new_hook"){
281                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIhook");
282                 }
284                 /* Dialog handling */
285                 if($s_action == "new_variable"){
286                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIvariable");
287                 }
289                 /* Dialog handling */
290                 if($s_action == "new_template"){
291                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAItemplate");
292                 }
294                 /* Dialog handling */
295                 if($s_action == "new_package"){
296                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpackageList");
297                 }
299                 /* New Profile */
300                 if($s_action == "new_profile"){
301                         $this->dn = "new" ;
302                         $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
304                         $this->dialog = new $a_setup[0]($this->config,
305                                         $this->config->data['TABS'][$a_setup[2]],$this->dn);
306                         $this->is_dialog = true;
308                 }
310                 if($s_action == "select_class_name_finished"){
311                         $this->dialog->save_object();
312                         if(count($this->dialog->check())!=0){
313                                 foreach($this->dialog->check() as $msg){
314                                         print_red($msg);
315                                 }               
316                         }else{
317                                 $this->dn = "new" ;
318                                 $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
319                                 $name = $this->dialog->save();
321                                 $this->dialog = new $a_setup[0]($this->config,
322                                                 $this->config->data['TABS'][$a_setup[2]],$this->dn,$name);
323                                 $this->dialog->by_object[$a_setup[1]]->cn = $name;
324                                 $this->is_dialog = true;
325                         }               
326                 }       
329                 /* Search is set */
330                 if(isset($_GET['search'])){
331                         $faifilter['regex']=$_GET['search']."*";
332                 }
334                 /* remove double asterisks and save new filter */
335                 $faifilter['regex'] = preg_replace("/\*\*/","*",$faifilter['regex']);
336                 $_SESSION['faifilter']= $faifilter;
338                 /* Edit dialog was canceled 
339                  * Remove dialog an show management dialog
340                  */
341                 if(isset($_POST['edit_cancel'])){
342                         unset($this->dialog);
343                         $this->dialog=NULL;
344                         $this->is_dialog = false;
345                 }
348                 /* This check if the given tab could be saved 
349                  * If it was possible to save it, remove dialog object. 
350                  * If it wasn't possible, show errors and keep dialog.
351                  */
352                 if(isset($_POST['edit_finish'])){
353                         $this->dialog->save_object();
354                         if(count($this->dialog->check())!=0){
355                                 foreach($this->dialog->check() as $msg){
356                                         print_red($msg);
357                                 }
358                         }else{
359                                 $this->dialog->save();
360                                 unset($this->dialog);
361                                 $this->dialog=NULL;
362                                 $this->is_dialog=false;
363                         }
364                 }
367                 /* If dialog is set, but $this->is_dialog==false, then 
368                  *  only the "abort" button is shown, this are dialogs that must not be saved.  
369                  * If is_dialog == true, we are currently editing tab objects.
370                  *  Here we need both, save and cancel
371                  */ 
373                 if($this->dialog != NULL){
374                         $display .= $this->dialog->execute();
375                         /* Don't show buttons if tab dialog requests this */
376                         if (((isset($this->dialog->current))&&($this->dialog->by_object[$this->dialog->current]->is_dialog))){
377                                 
378                         }elseif(((isset($this->dialog->current))&&(!$this->dialog->by_object[$this->dialog->current]->is_dialog))){
379                                 $display.= "<p style=\"text-align:right\">\n";
380                                 $display.= "<input type=submit name=\"edit_finish\" value=\""._("Finish")."\">\n";
381                                 $display.= "&nbsp;\n";
382                                 $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
383                                 $display.= "</p>";
384                         }elseif(!isset($this->dialog->current)){
385                                 $display.= "<p style=\"text-align:right\">\n";
386                                 $display.= "<input type=submit name=\"edit_continue\" value=\""._("Continue")."\">&nbsp;";
387                                 $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
388                                 $display.= "</p>";
389                         }
390                         return($display);
391                 }
393                 /* Show Management template
394                  * The following code will only be reached if no dialog (tabs or dialogs)
395                  *  are currently opened.
396                  * Assign all reguired vars to template engine
397                  */
399                 /* Prepare departments */
400                 $options= "";
401                 foreach ($this->config->idepartments as $key => $value){
402                         if ($faifilter['base'] == $key){
403                                 $options.= "<option selected value='$key'>$value</option>";
404                         } else {
405                                 $options.= "<option value='$key'>$value</option>";
406                         }
407                 }
409                 /* Create listhead, it will be shown on top of the divlist. 
410                  * It provides general navigation and object creation
411                  */
412                 $faihead = 
413                         "<div style='background:#F0F0F9;padding:5px;'>&nbsp;".
415                         "<input type='image' src='images/list_up.png' align='middle' 
416                         title='"._("Go up one department")."' name='dep_back' alt='"._("Up"). "'>&nbsp;".
418                         "<input type='image' src='images/list_root.png' align='middle' 
419                         title='"._("Go to root department")."' name='dep_root' alt='".      _("Root")."'>&nbsp;".
421                         "<input type='image' src='images/list_home.png' align='middle' 
422                         title='"._("Go to users home department")."' name='dep_home' alt='"._("Home")."'>&nbsp;".
424                         "<img src=\"images/list_seperator.png\" alt=\"\" align=\"middle\" height=\"16\" width=\"1\">&nbsp;".
425                         
426                         " <input type='image' src='images/fai_new_profile.png' align='middle' 
427                         title='"._("New profile")."' name='Create_profile' alt='"._("P")."'>&nbsp;".
428                         
429                         "<img src=\"images/list_seperator.png\" alt=\"\" align=\"middle\" height=\"16\" width=\"1\">&nbsp;".
430                                 
431                         " <input type='image' src='images/fai_new_partitionTable.png' align='middle' 
432                         title='"._("New partition table")."' name='Create_partition' alt='"._("PT")."'>&nbsp;".
434                         " <input type='image' src='images/fai_new_script.png' align='middle' 
435                         title='"._("New scripts")."' name='Create_script' alt='"._("S")."'>&nbsp;".
437                         " <input type='image' src='images/fai_new_hook.png' align='middle' 
438                         title='"._("New hooks")."' name='Create_hook' alt='"._("H")."'>&nbsp;".
440                         " <input type='image' src='images/fai_new_variable.png' align='middle' 
441                         title='"._("New variables")."' name='Create_variable' alt='"._("V")."'>&nbsp;".
442                         
443                         " <input type='image' src='images/fai_new_template.png' align='middle' 
444                         title='"._("New templates")."' name='Create_template' alt='"._("T")."'>&nbsp;".
446                         " <input type='image' src='images/fai_new_packages.png' align='middle' 
447                         title='"._("New package list")."' name='Create_package' alt='"._("PK")."'>&nbsp;".
449                         " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
451                         _("Current base")."&nbsp;<select name='base' onChange='mainform.submit()'>$options</select>".
452                         " <input type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
453                         
454                         "</div>";
456                 $this->reload();
458                 /* Create list with objects */
459                 $divlist = new divlist("faiManagement"); 
460                 $divlist->SetEntriesPerPage(20);
461                 $divlist->SetSummary(_("This table displays all systems, in the selected tree."));
463                 $divlist->SetHeader(array(
464                                         array("string" => "&nbsp;"),
465                                         array("string" => _("Name of FAI class")),
466                                         array("string" => _("Class type")),
467                                         array("string" => _("Actions"), "attach"=>"style='border-right:none;width:40px;'")));
470                 $action  = "<input type='image' src='images/edit.png'   alt='"._("edit")."'   name='entry_edit_%KEY%' title='"._("Edit class")."'>";
471                 $action .= "<input type='image' src='images/edittrash.png' alt='"._("delete")."' name='entry_delete_%KEY%' title='"._("Delete class")."'>";
473                 $editlink ="<a href='?plug=".$_GET['plug']."&edit_entry=%KEY%'>%NAME%</a>";             
474                 $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
476                 foreach($this->departments as $key => $val) {
477                         if(!isset($this->config->departments[trim($key)])){
478                                 $this->config->departments[trim($key)]="";
479                         }
481                         $non_empty="";
482                         $keys= str_replace("/","\/",$key);
483                         foreach($this->config->departments as $keyd=>$vald ){
484                                 if(preg_match("/".$keys."\/.*/",$keyd)){
485                                         $non_empty="full";
486                                 }
487                         }
490                         $title = $this->config->departments[$key];
491                         $field0 = array("string" => "<img src='images/".$non_empty."folder.png' title='"._("department")."' alt='department'>",                     "attach"=>"style='width:20px;'");
492                         $field1 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "title='".$title."'");
493                         $field2 = array("string" => "");
494                         $field3 = array("string" => "","attach"=>"style='text-align:right;border-right:none;'");
496                         $divlist->AddEntry( array($field0,$field1,$field2,$field3));
498                 }
501                 /* Attach objects */
502                 foreach($this->objects as $key => $value){
503                                 $info= "";
504                                 $img = "";
505                                 $type = $value['type'];
506                                 $abort=false;
508                                 switch($type) {
509                                         case "FAIpartitionTable"        : 
510                                                 if(!$faifilter['ShowPartitions']){ 
511                                                         $abort = true;
512                                                 }
513                                         $img="<img src='images/fai_partitionTable.png' title='"._("Partition table")."' alt='PT'>";
514                                         $info = _("Partition table");
515                                         break;
516                                         case "FAIpackageList"           : 
517                                                 if(!$faifilter['ShowPackages']){ 
518                                                         $abort = true;
519                                                 }
520                                         $img="<img src='images/fai_packages.png' title='"._("Package list")."' alt='PL'>";
521                                         $info = _("Package list");
522                                         break;
523                                         case "FAIscript"                        : 
524                                                 if(!$faifilter['ShowScripts']){ 
525                                                         $abort = true;
526                                                 }
527                                         $img="<img src='images/fai_script.png' title='"._("Scripts")."' alt='S'>";
528                                         $info = _("Scripts");
529                                         break;
530                                         case "FAIvariable"                      : 
531                                                 if(!$faifilter['ShowVariables']){ 
532                                                         $abort = true;
533                                                 }
534                                         $img="<img src='images/fai_variable.png' title='"._("Variables")."' alt='V'>";
535                                         $info = _("Variables");
536                                         break;
537                                         case "FAIhook"                          :
538                                                 if(!$faifilter['ShowHooks']){ 
539                                                         $abort = true;
540                                                 }
541                                         $img="<img src='images/fai_hook.png' title='"._("Hooks")."' alt='H'>";
542                                         $info = _("Hooks");
543                                         break;
544                                         case "FAIprofile"                       : 
545                                                 if(!$faifilter['ShowProfiles']){ 
546                                                         $abort = true;
547                                                 }
548                                         $img="<img src='images/fai_profile.png' title='"._("Profile")."' alt='P'>";
549                                         $info = _("Profile");
550                                         break;
551                                         case "FAItemplate"                      : 
552                                                 if(!$faifilter['ShowTemplates']){ 
553                                                         $abort = true;
554                                                 }
555                                         $img="<img src='images/fai_template.png' title='"._("Templates")."' alt='T'>";
556                                         $info = _("Templates");
557                                         break;
558                                         default                                         : 
559                                         $img="<img src='images/empty.png' alt=''>";$info = "";break;
561                                 }
562                                 
563                                 if(!$abort)     {
564                                         if((isset($value['description']))&&(!empty($value['description']))){
565                                                 $desc= " [".$value['description']."]";
566                                         }else{
567                                                 $desc= "";
568                                         }
570                                         $field1 = array("string" => $img , "attach" => "style='height:26px;width=20px;'");
571                                         $field2 = array("string" => preg_replace(array("/%KEY%/","/%NAME%/"),array($key,$value['cn'].$desc),$editlink) , "attach" => "");
572                                         $field3 = array("string" => $info, "attach" => "");
573                                         $field4 = array("string" => preg_replace("/%KEY%/",$key,$action) , "attach"=>"style='text-align:right;border:none'");
574                                         $divlist->AddEntry(array($field1,$field2,$field3,$field4));
576                         }
577                 }
579                 foreach($faifilter as $attrs => $value){
580                         if($value){
581                                 $smarty->assign($attrs."CHK", " checked ");
582                         }else{
583                                 $smarty->assign($attrs."CHK", " ");
584                         }
585                 }
587                 /* Assign all reguired vars to template engine */
588                 $smarty->assign("faihead"               , $faihead);    
589                 $smarty->assign("failist"               , $divlist->DrawList());
590                 $smarty->assign("regex"                 , $faifilter['regex']); 
591                 $smarty->assign("infoimage"             , get_template_path('images/info.png'));
592                 $smarty->assign("launchimage"   , get_template_path('images/launch.png'));
593                 $smarty->assign("alphabet"              , generate_alphabet());
594                 $smarty->assign("apply"                 , apply_filter());
595                 $smarty->assign("search_image"  , get_template_path('images/search.png'));
597                 $display        = $smarty->fetch(get_template_path('headpage.tpl', TRUE, dirname(__FILE__)));
598                 return ($display);
599         }
602         function reload()
603         {
604                 /* Create a new list of FAI object 
605                  * Object list depends on faifilter['regex']
606                  * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ... 
607                  */
608                 $faifilter= get_global('faifilter');
609                 // Added for dirlist function...
611                 /* Set base for all searches */
612                 $base= "ou=fai,ou=configs,ou=systems,".$faifilter['base'];
613                 $regex = $faifilter['regex'];   
615                 /* Array to save objects */
616                 $objects = array();
617         
618                 $this->objects=array();
620                 /* NEW LIST MANAGMENT
621                  * We also need to search for the departments
622                  * So we are able to navigate like in konquerer
623                  */
624                 $base2 = $faifilter['base'];
626                 $res3 =  get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))",
627                                 TRUE, $base2, array("ou", "description"), TRUE);
629                 $this->departments= array();
630                 $tmp = array();
631                 foreach ($res3 as $value){
632                         $tmp[strtolower($value['dn']).$value['dn']]=$value;
633                 }
634                 ksort($tmp);
635                 foreach($tmp as $value){
636                         if($value["description"][0]!=".."){
637                                 $this->departments[$value['dn']]=convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
638                         }else{
639                                 $this->departments[$value['dn']]=$value["description"][0];
640                         }
641                 }
643                 /* END NEW LIST MANAGMENT
644                  */
646         
647                 $res= get_list($this->ui->subtreeACL, "(objectClass=organizationalUnit)", 
648                                 FALSE, $base, array("cn","description","objectClass"),TRUE);
650                 foreach($res as $objecttypes){
651                         $res2 = get_list($this->ui->subtreeACL, "(&(objectClass=*)(cn=".$regex."))",
652                                         FALSE, $objecttypes['dn'], array("cn","description","objectClass","FAIclass"),TRUE);
653                         foreach($res2 as $object){
654                                 $type= "";      
655                                 unset($object['objectClass']['count']);
656                                 if(!isset($object['description'][0])){
657                                         $object['description'][0]="";
658                                 }
659                                 
660                                 /* Clean up object informations */
661                                 $obj['cn']                      = $object['cn'][0];
662                                 $obj['dn']                      = $object['dn'];
663                                 $obj['description'] = $object['description'][0];
664                                 $obj['objectClass'] = $object['objectClass'];
666                                 if(in_array("FAIpartitionTable",$obj['objectClass'])){
667                                         $type = "FAIpartitionTable";
668                                 }elseif(in_array("FAIpackageList",$obj['objectClass'])){
669                                         $type = "FAIpackageList";
670                                 }elseif(in_array("FAIscript",$obj['objectClass'])){
671                                         $type = "FAIscript";
672                                 }elseif(in_array("FAIvariable",$obj['objectClass'])){
673                                         $type = "FAIvariable";
674                                 }elseif(in_array("FAIhook",$obj['objectClass'])){
675                                         $type = "FAIhook";
676                                 }elseif(in_array("FAIprofile",$obj['objectClass'])){
677                                         $obj['FAIclass']        = $object['FAIclass'][0];
678                                         $type = "FAIprofile";
679                                 }elseif(in_array("FAItemplate",$obj['objectClass'])){
680                                         $type = "FAItemplate";
681                                 }
682                                 $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj;
683                                 $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type;
684  
685                         }
686                 }
687                 ksort($this->objects);
688                 reset ($this->objects);
689         
690                 /* use numeric index, thats a bit more secure */        
691                 $tmp0 = array();
692                 foreach($this->objects as $obj){
693                         $tmp0[]= $obj;
694                 }
695                 $this->objects = array();
696                 $this->objects = $tmp0;
698         }
700         function remove_lock()
701         {
702                 if (isset($this->dn)){
703                         del_lock ($this->dn);
704                 }
705         }
707         function get_type($array){
708                 if(in_array("FAIpartitionTable",$array['objectClass'])){
709                         return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS"));
710                 }
711                 if(in_array("FAIscript",$array['objectClass'])){
712                         return(array("tabsScript","faiScript","FAISCRIPTTABS"));
713                 }
714                 if(in_array("FAItemplate",$array['objectClass'])){
715                         return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS"));
716                 }
717                 if(in_array("FAIhook",$array['objectClass'])){
718                         return(array("tabsHook","faiHook","FAIHOOKTABS"));
719                 }
720                 if(in_array("FAIvariable",$array['objectClass'])){
721                         return(array("tabsVariable","faiVariable","FAIVARIABLETABS"));
722                 }
723                 if(in_array("FAIprofile",$array['objectClass'])){
724                         return(array("tabsProfile","faiProfile","FAIPROFILETABS"));
725                 }
726                 
727                 if(in_array("FAIpackageList",$array['objectClass'])){
728                         return(array("tabsPackage","faiPackage","FAIPACKAGETABS"));
729                 }
730         }
734 ?>