Code

7e9dab75d31f875f6353bd3f48238b0a67261f88
[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";
28 class faiManagement extends plugin
29 {
30         /* Definitions */
31         var $plHeadline                 = "FAI";
32         var $plDescription              = "Fully Automatic Installation - management";
34         /* CLI vars */
35         var $cli_summary                = "Handling of FAI entries";
36         var $cli_description    = "This plugin represents a management tool\n
37                 which allows us to manage all needed attributes for fully automatic installations (FAI)";
38         var $cli_parameters             = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
40         /* Headpage attributes */
41         var $departments= array();
42         var $deptabs= NULL;
44         /* attribute list for save action */
45         var $attributes                 = array();      //      Attributes Managed by this plugin, none, 
46         //      because this is only an overview over all objects already defined in FAI.
47         var $objectclasses              = array();      //      ObjectClasses which the attributes are related to
48         var $dialog                             = array();      //      This object contains every dialog we have currently opened
50         var $objects                    = array();      //      This array contains all available objects shown in divlist
51         var $is_dialog                  = false;
53         /* construction/reconstruction 
54          * The Filter ($faifilter stored in $_SESSION['faifilter']) defines the last 
55          *  selected department and filter options
56          * If it is not defined already we create a new fresh faifilter.
57          */
58         function faiManagement ($config, $ui)
59         {
60                 $this->ui                       = $ui;  
62                 /* Set current dn to "", */
63                 $this->dn                       = "";
65                 /* Assign config */
66                 $this->config           = $config;
68                 /* Get global filter config */
69                 if (!is_global("faifilter")){
70                         $base   = get_base_from_people($ui->dn);
71                         $faifilter= array("base" => $base,
72                                         "regex" => "*");
73                         $faifilter['ShowProfiles']      = true;
74                         $faifilter['ShowTemplates'] = true;
75                         $faifilter['ShowScripts']       = true;
76                         $faifilter['ShowHooks']         = true;
77                         $faifilter['ShowVariables']     = true;
78                         $faifilter['ShowPackages']      = true;
79                         $faifilter['ShowPartitions']=true;
80                         register_global("faifilter", $faifilter);
81                 }
82         }
84         function execute()
85         {
86                 $display        = "";
87                 $smarty         = get_smarty();
88                 $s_action       = "";
89                 $s_entry        = "";
90                 /* filter management 
91                  * Filter will be changed if POST['regex'] or $_GET['search'] isset
92                  * New Filter will be stored in session and is used to generate list contents
93                  */     
94                 $faifilter = $_SESSION['faifilter'];
96                 /* Filter is posted by apply button 
97                  * Check every single chkbox 
98                  */
99                 if(isset($_POST['regex'])){
100                         $faifilter['regex'] = $_POST['regex']."*";
101                         foreach(array("ShowPartitions","ShowProfiles","ShowTemplates","ShowScripts","ShowHooks","ShowVariables","ShowPackages") as $attrs){
102                                 if(isset($_POST[$attrs])){
103                                         $faifilter[$attrs] = true;
104                                 }else{
105                                         $faifilter[$attrs] = false;
106                                 }
107                         }
108                 }
110                 /* Check ImageButton posts
111                  * Create new tab ich new_xx is posted
112                  */
113                 foreach($_POST as $key => $val){
114                         if(preg_match("/create_partition/i",$key)){
115                                 $s_action = "new_partition";
116                         }elseif(preg_match("/create_script/i",$key)){
117                                 $s_action = "new_script";
118                         }elseif(preg_match("/create_hook/i",$key)){
119                                 $s_action = "new_hook";
120                         }elseif(preg_match("/create_variable/i",$key)){
121                                 $s_action = "new_variable";
122                         }elseif(preg_match("/create_template/i",$key)){
123                                 $s_action = "new_template";
124                         }elseif(preg_match("/create_package/i",$key)){
125                                 $s_action = "new_package";
126                         }elseif(preg_match("/create_profile/i",$key)){
127                                 $s_action = "new_profile";
128                         }elseif(preg_match("/edit_continue/",$key)){
129                                 $s_action = "select_class_name_finished";
130                         }elseif(preg_match("/^entry_edit_.*/",$key)){
131                                 $s_entry = preg_replace("/^entry_edit_/","",$key);
132                                 $s_entry = preg_replace("/_.*$/","",$s_entry);
133                                 $s_action = "edit";
134                         }elseif(preg_match("/^entry_delete_.*/",$key)){
135                                 $s_entry = preg_replace("/^entry_delete_/","",$key);
136                                 $s_entry = preg_replace("/_.*$/","",$s_entry);
137                                 $s_action = "delete";
138                         }elseif(preg_match("/dep_back.*/i",$key)){
139                 $s_action="back";
140             }elseif(preg_match("/dep_home.*/i",$key)){
141                 $s_action="home";
142             }elseif(preg_match("/dep_root.*/i",$key)){
143                 $s_action="root";
144                         }
146                 }
148                 if($s_action=="root"){
149                         $faifilter['base']=($this->config->current['BASE']);
150                 }
152                 if($s_action=="home"){
153                         $faifilter['base']=(preg_replace("/^[^,]+,/","",$this->ui->dn));
154                         $faifilter['base']=(preg_replace("/^[^,]+,/","",$faifilter['base']));
155                 }
157                 if($s_action=="back"){
158                         $base_back          = preg_replace("/^[^,]+,/","",$faifilter['base']);
159                         $base_back          = convert_department_dn($base_back);
161                         if(isset($this->config->departments[trim($base_back)])){
162                                 $faifilter['base']= $this->config->departments[trim($base_back)];
163                         }else{
164                                 $faifilter['base']= $this->config->departments["/"];
165                         }
166                 }
168                 if(isset($_GET['act'])&&($_GET['act']=="dep_open")){
169             $s_action="open";
170             $s_entry = base64_decode($_GET['dep_id']);
171             $faifilter['base']= $this->config->departments[trim($s_entry)];
172         }
174                 if(isset($_GET['edit_entry'])){
175                         $s_entry = $_GET['edit_entry'];
176                         $s_action = "edit";
177                 }
179                 /* Confirm dialog 
180                  * Delte object 
181          */
182                 if ($s_action=="delete"){
184                         /* Get 'dn' from posted termlinst */
185                         $this->dn= $this->objects[$s_entry]['dn'];
187                         /* Load permissions for selected 'dn' and check if
188                            we're allowed to remove this 'dn' */
189                         $acl=           get_permissions ($this->dn, $this->ui->subtreeACL);
190                         $this->acl= get_module_permission($acl, "FAIclass", $this->dn);
191                         if (chkacl($this->acl, "delete") == ""){
193                                 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
194                                 if (($user= get_lock($this->dn)) != ""){
195                                         return(gen_locked_message ($user, $this->dn));
196                                 }
198                                 /* Lock the current entry, so nobody will edit it during deletion */
199                                 add_lock ($this->dn, $this->ui->dn);
200                                 $smarty->assign("warning", sprintf(_("You're about to delete all information about the FAI class at '%s'."), $this->dn));
201                                 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
202                         } else {
204                                 /* Obviously the user isn't allowed to delete. Show message and
205                                    clean session. */
206                                 print_red (_("You are not allowed to delete this component!"));
207                         }
208                 }
210                 /* Delete canceled? */
211                 if (isset($_POST['delete_cancel'])){
212                         del_lock ($this->dn);
213                 }
216                 /* Deltetion was confirmed, so delete this entry
217                  */
218                 if (isset($_POST['delete_terminal_confirm'])){
220                         /* Some nice guy may send this as POST, so we've to check
221                            for the permissions again. */
222                         if (chkacl($this->acl, "delete") == ""){
224                                 /* Find out more about the object type */
225                                 $ldap   = $this->config->get_ldap_link();
226                                 $ldap->cat($this->dn);
227                                 $attrs  = $ldap->fetch();
229                                 $type   = $this->get_type($attrs);                      
231                                 $this->dialog= new $type[0]($this->config,      $this->config->data['TABS'][$type[2]], $this->dn);
232                                 $this->dialog->set_acl(array($this->acl));
234                                 $this->dialog->by_object[$type[1]]->remove_from_parent ();
235                                 unset ($this->dialog);
236                                 gosa_log ("FAI class '".$this->dn."' has been removed");
237                                 $this->dialog= NULL;
239                                 /* Terminal list has changed, reload it. */
240                                 $this->reload ();
241                         } else {
243                                 /* Normally this shouldn't be reached, send some extra
244                                    logs to notify the administrator */
245                                 print_red (_("You are not allowed to delete this component!"));
246                                 gosa_log ("Warning: '".$this->ui->uid."' tried to trick system ".
247                                                 "deletion.");
248                         }
250                         /* Remove lock file after successfull deletion */
251                         del_lock ($this->dn);
252                 }
254                 /* Edit Entry */
255                 if($s_action == "edit"){
256                         $entry  = $this->objects[$s_entry];
258                         $a_setup = ($this->get_type($entry));
259                 
260                         $this->dn = $entry['dn'];
262                         $this->dialog= new $a_setup[0]($this->config,
263                                         $this->config->data['TABS'][$a_setup[2]],$this->dn);
264                         $this->is_dialog = true;
265                 }
268                 /* Dialog handling */
269                 if($s_action == "new_partition"){
270                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpartitionTable");
271                 }
273                 /* Dialog handling */
274                 if($s_action == "new_script"){
275                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIscript");
276                 }
278                 /* Dialog handling */
279                 if($s_action == "new_hook"){
280                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIhook");
281                 }
283                 /* Dialog handling */
284                 if($s_action == "new_variable"){
285                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIvariable");
286                 }
288                 /* Dialog handling */
289                 if($s_action == "new_template"){
290                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAItemplate");
291                 }
293                 /* Dialog handling */
294                 if($s_action == "new_package"){
295                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpackageList");
296                 }
298                 /* New Profile */
299                 if($s_action == "new_profile"){
300                         $this->dn = "new" ;
301                         $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
303                         $this->dialog = new $a_setup[0]($this->config,
304                                         $this->config->data['TABS'][$a_setup[2]],$this->dn);
305                         $this->is_dialog = true;
307                 }
309                 if($s_action == "select_class_name_finished"){
310                         $this->dialog->save_object();
311                         if(count($this->dialog->check())!=0){
312                                 foreach($this->dialog->check() as $msg){
313                                         print_red($msg);
314                                 }               
315                         }else{
316                                 $this->dn = "new" ;
317                                 $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
318                                 $name = $this->dialog->save();
320                                 $this->dialog = new $a_setup[0]($this->config,
321                                                 $this->config->data['TABS'][$a_setup[2]],$this->dn);
322                                 $this->dialog->by_object[$a_setup[1]]->cn = $name;
323                                 $this->is_dialog = true;
324                         }               
325                 }       
328                 /* Search is set */
329                 if(isset($_GET['search'])){
330                         $faifilter['regex']=$_GET['search']."*";
331                 }
333                 /* remove double asterisks and save new filter */
334                 $faifilter['regex'] = preg_replace("/\*\*/","*",$faifilter['regex']);
335                 $_SESSION['faifilter']= $faifilter;
337                 /* Edit dialog was canceled 
338                  * Remove dialog an show management dialog
339                  */
340                 if(isset($_POST['edit_cancel'])){
341                         unset($this->dialog);
342                         $this->dialog=NULL;
343                         $this->is_dialog = false;
344                 }
347                 /* This check if the given tab could be saved 
348                  * If it was possible to save it, remove dialog object. 
349                  * If it wasn't possible, show errors and keep dialog.
350                  */
351                 if(isset($_POST['edit_finish'])){
352                         $this->dialog->save_object();
353                         if(count($this->dialog->check())!=0){
354                                 foreach($this->dialog->check() as $msg){
355                                         print_red($msg);
356                                 }
357                         }else{
358                                 $this->dialog->save();
359                                 unset($this->dialog);
360                                 $this->dialog=NULL;
361                                 $this->is_dialog=false;
362                         }
363                 }
366                 /* If dialog is set, but $this->is_dialog==false, then 
367                  *  only the "abort" button is shown, this are dialogs that must not be saved.  
368                  * If is_dialog == true, we are currently editing tab objects.
369                  *  Here we need both, save and cancel
370                  */ 
372                 if($this->dialog != NULL){
373                         $display .= $this->dialog->execute();
374                         /* Don't show buttons if tab dialog requests this */
375                         if (((isset($this->dialog->current))&&($this->dialog->by_object[$this->dialog->current]->is_dialog))){
376                                 
377                         }elseif(((isset($this->dialog->current))&&(!$this->dialog->by_object[$this->dialog->current]->is_dialog))){
378                                 $display.= "<p style=\"text-align:right\">\n";
379                                 $display.= "<input type=submit name=\"edit_finish\" value=\""._("Finish")."\">\n";
380                                 $display.= "&nbsp;\n";
381                                 $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
382                                 $display.= "</p>";
383                         }elseif(!isset($this->dialog->current)){
384                                 $display.= "<p style=\"text-align:right\">\n";
385                                 $display.= "<input type=submit name=\"edit_continue\" value=\""._("Continue")."\">&nbsp;";
386                                 $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
387                                 $display.= "</p>";
388                         }
389                         return($display);
390                 }
392                 /* Show Management template
393                  * The following code will only be reached if no dialog (tabs or dialogs)
394                  *  are currently opened.
395                  * Assign all reguired vars to template engine
396                  */
398                 /* Create listhead, it will be shown on top of the divlist. 
399                  * It provides general navigation and object creation
400                  */
401                 $faihead = 
402                         "<div style='background:#F0F0F9;padding:5px;'>&nbsp;".
404                         "<input type='image' src='images/list_up.png' align='middle' 
405                         title='"._("Go up one department")."' name='dep_back' alt='"._("Up"). "'>&nbsp;".
407                         "<input type='image' src='images/list_root.png' align='middle' 
408                         title='"._("Go to root department")."' name='dep_root' alt='".      _("Root")."'>&nbsp;".
410                         "<input type='image' src='images/list_home.png' align='middle' 
411                         title='"._("Go to users home department")."' name='dep_home' alt='"._("Home")."'>&nbsp;".
413                         "<img src=\"images/list_seperator.png\" alt=\"\" align=\"middle\" height=\"16\" width=\"1\">&nbsp;".
414                         
415                         " <input type='image' src='images/fai_new_profile.png' align='middle' 
416                         title='"._("New profile")."' name='Create_profile' alt='"._("P")."'>&nbsp;".
417                         
418                         "<img src=\"images/list_seperator.png\" alt=\"\" align=\"middle\" height=\"16\" width=\"1\">&nbsp;".
419                                 
420                         " <input type='image' src='images/fai_new_partitionTable.png' align='middle' 
421                         title='"._("New partition table")."' name='Create_partition' alt='"._("PT")."'>&nbsp;".
423                         " <input type='image' src='images/fai_new_script.png' align='middle' 
424                         title='"._("New scripts")."' name='Create_script' alt='"._("S")."'>&nbsp;".
426                         " <input type='image' src='images/fai_new_hook.png' align='middle' 
427                         title='"._("New hooks")."' name='Create_hook' alt='"._("H")."'>&nbsp;".
429                         " <input type='image' src='images/fai_new_variable.png' align='middle' 
430                         title='"._("New variables")."' name='Create_variable' alt='"._("V")."'>&nbsp;".
431                         
432                         " <input type='image' src='images/fai_new_template.png' align='middle' 
433                         title='"._("New templates")."' name='Create_template' alt='"._("T")."'>&nbsp;".
435                         " <input type='image' src='images/fai_new_packages.png' align='middle' 
436                         title='"._("New package list")."' name='Create_package' alt='"._("PK")."'>&nbsp;".
437                         
438                         "</div>";
440                 $this->reload();
442                 /* Create list with objects */
443                 $divlist = new divlist("faiManagement"); 
444                 $divlist->SetEntriesPerPage(20);
445                 $divlist->SetSummary(_("This table displays all systems, in the selected tree."));
447                 $divlist->SetHeader(array(
448                                         array("string" => "&nbsp;"),
449                                         array("string" => _("Name of FAI class")),
450                                         array("string" => _("Class type")),
451                                         array("string" => _("Actions"), "attach"=>"style='border:none;width:40px;'")));
454                 $action  = "<input type='image' src='images/edit.png'   alt='"._("edit")."'   name='entry_edit_%KEY%' title='"._("Edit class")."'>";
455                 $action .= "<input type='image' src='images/edittrash.png' alt='"._("delete")."' name='entry_delete_%KEY%' title='"._("Delete class")."'>";
457                 $editlink ="<a href='?plug=".$_GET['plug']."&edit_entry=%KEY%'>%NAME%</a>";             
458                 $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
460                 foreach($this->departments as $key => $val) {
461                         if(!isset($this->config->departments[trim($key)])){
462                                 $this->config->departments[trim($key)]="";
463                         }
465                         $non_empty="";
466                         $keys= str_replace("/","\/",$key);
467                         foreach($this->config->departments as $keyd=>$vald ){
468                                 if(preg_match("/".$keys."\/.*/",$keyd)){
469                                         $non_empty="full";
470                                 }
471                         }
474                         $title = $this->config->departments[$key];
475                         $field0 = array("string" => "<img src='images/".$non_empty."folder.png' title='"._("department")."' alt='department'>",                     "attach"=>"style='width:20px;'");
476                         $field1 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "title='".$title."'");
477                         $field2 = array("string" => "");
478                         $field3 = array("string" => "","attach"=>"style='text-align:right'");
480                         $divlist->AddEntry( array($field0,$field1,$field2,$field3));
482                 }
485                 /* Attach objects */
486                 foreach($this->objects as $key => $value){
487                                 $info= "";
488                                 $img = "";
489                                 $type = $value['type'];
490                                 $abort=false;
492                                 switch($type) {
493                                         case "FAIpartitionTable"        : 
494                                                 if(!$faifilter['ShowPartitions']){ 
495                                                         $abort = true;
496                                                 }
497                                         $img="<img src='images/fai_partitionTable.png' title='"._("Partition table")."' alt='PT'>";
498                                         $info = _("Partition table");
499                                         break;
500                                         case "FAIpackageList"           : 
501                                                 if(!$faifilter['ShowPackages']){ 
502                                                         $abort = true;
503                                                 }
504                                         $img="<img src='images/fai_packages.png' title='"._("Package list")."' alt='PL'>";
505                                         $info = _("Package list");
506                                         break;
507                                         case "FAIscript"                        : 
508                                                 if(!$faifilter['ShowScripts']){ 
509                                                         $abort = true;
510                                                 }
511                                         $img="<img src='images/fai_script' title='"._("Scripts")."' alt='S'>";
512                                         $info = _("Scripts");
513                                         break;
514                                         case "FAIvariable"                      : 
515                                                 if(!$faifilter['ShowVariables']){ 
516                                                         $abort = true;
517                                                 }
518                                         $img="<img src='images/fai_variable.png' title='"._("Variables")."' alt='V'>";
519                                         $info = _("Variables");
520                                         break;
521                                         case "FAIhook"                          :
522                                                 if(!$faifilter['ShowHooks']){ 
523                                                         $abort = true;
524                                                 }
525                                         $img="<img src='images/fai_hook.png' title='"._("Hooks")."' alt='H'>";
526                                         $info = _("Hooks");
527                                         break;
528                                         case "FAIprofile"                       : 
529                                                 if(!$faifilter['ShowProfiles']){ 
530                                                         $abort = true;
531                                                 }
532                                         $img="<img src='images/fai_profile.png' title='"._("Profile")."' alt='P'>";
533                                         $info = _("Profile");
534                                         break;
535                                         case "FAItemplate"                      : 
536                                                 if(!$faifilter['ShowTemplates']){ 
537                                                         $abort = true;
538                                                 }
539                                         $img="<img src='images/fai_template.png' title='"._("Templates")."' alt='T'>";
540                                         $info = _("Templates");
541                                         break;
542                                         default                                         : 
543                                         $img="<img src='images/empty.png' >";$info = "";break;
545                                 }
546                                 
547                                 if(!$abort)     {
548                                         if((isset($value['description']))&&(!empty($value['description']))){
549                                                 $desc= " [".$value['description']."]";
550                                         }else{
551                                                 $desc= "";
552                                         }
554                                         $field1 = array("string" => $img , "attach" => "style='height:26px;width=20px;'");
555                                         $field2 = array("string" => preg_replace(array("/%KEY%/","/%NAME%/"),array($key,$value['cn'].$desc),$editlink) , "attach" => "");
556                                         $field3 = array("string" => $info, "attach" => "");
557                                         $field4 = array("string" => preg_replace("/%KEY%/",$key,$action) , "attach"=>"style='text-align:right;border:none'");
558                                         $divlist->AddEntry(array($field1,$field2,$field3,$field4));
560                         }
561                 }
563                 foreach($faifilter as $attrs => $value){
564                         if($value){
565                                 $smarty->assign($attrs."CHK", " checked ");
566                         }else{
567                                 $smarty->assign($attrs."CHK", " ");
568                         }
569                 }
571                 /* Assign all reguired vars to template engine */
572                 $smarty->assign("faihead"               , $faihead);    
573                 $smarty->assign("failist"               , $divlist->DrawList());
574                 $smarty->assign("regex"                 , $faifilter['regex']); 
575                 $smarty->assign("infoimage"             , get_template_path('images/info.png'));
576                 $smarty->assign("launchimage"   , get_template_path('images/launch.png'));
577                 $smarty->assign("alphabet"              , generate_alphabet());
578                 $smarty->assign("apply"                 , apply_filter());
579                 $smarty->assign("search_image"  , get_template_path('images/search.png'));
581                 $display        = $smarty->fetch(get_template_path('headpage.tpl', TRUE, dirname(__FILE__)));
582                 return ($display);
583         }
586         function reload()
587         {
588                 /* Create a new list of FAI object 
589                  * Object list depends on faifilter['regex']
590                  * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ... 
591                  */
592                 $faifilter= get_global('faifilter');
593                 // Added for dirlist function...
595                 /* Set base for all searches */
596                 $base= "ou=fai,ou=configs,ou=systems,".$faifilter['base'];
597                 $regex = $faifilter['regex'];   
599                 /* Array to save objects */
600                 $objects = array();
601         
602                 $this->objects=array();
604                 /* NEW LIST MANAGMENT
605                  * We also need to search for the departments
606                  * So we are able to navigate like in konquerer
607                  */
608                 $base2 = $faifilter['base'];
610                 $res3 =  get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))",
611                                 TRUE, $base2, array("ou", "description"), TRUE);
613                 $this->departments= array();
614                 $tmp = array();
615                 foreach ($res3 as $value){
616                         $tmp[strtolower($value['dn']).$value['dn']]=$value;
617                 }
618                 ksort($tmp);
619                 foreach($tmp as $value){
620                         if($value["description"][0]!=".."){
621                                 $this->departments[$value['dn']]=convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
622                         }else{
623                                 $this->departments[$value['dn']]=$value["description"][0];
624                         }
625                 }
627                 /* END NEW LIST MANAGMENT
628                  */
630         
631                 $res= get_list($this->ui->subtreeACL, "(objectClass=organizationalUnit)", 
632                                 FALSE, $base, array("cn","description","objectClass"),TRUE);
634                 foreach($res as $objecttypes){
635                         $res2 = get_list($this->ui->subtreeACL, "(&(objectClass=*)(cn=".$regex."))",
636                                         FALSE, $objecttypes['dn'], array("cn","description","objectClass","FAIclass"),TRUE);
637                         foreach($res2 as $object){
638                                 $type= "";      
639                                 unset($object['objectClass']['count']);
640                                 if(!isset($object['description'][0])){
641                                         $object['description'][0]="";
642                                 }
643                                 
644                                 /* Clean up object informations */
645                                 $obj['cn']                      = $object['cn'][0];
646                                 $obj['dn']                      = $object['dn'];
647                                 $obj['description'] = $object['description'][0];
648                                 $obj['objectClass'] = $object['objectClass'];
650                                 if(in_array("FAIpartitionTable",$obj['objectClass'])){
651                                         $type = "FAIpartitionTable";
652                                 }elseif(in_array("FAIpackageList",$obj['objectClass'])){
653                                         $type = "FAIpackageList";
654                                 }elseif(in_array("FAIscript",$obj['objectClass'])){
655                                         $type = "FAIscript";
656                                 }elseif(in_array("FAIvariable",$obj['objectClass'])){
657                                         $type = "FAIvariable";
658                                 }elseif(in_array("FAIhook",$obj['objectClass'])){
659                                         $type = "FAIhook";
660                                 }elseif(in_array("FAIprofile",$obj['objectClass'])){
661                                         $obj['FAIclass']        = $object['FAIclass'][0];
662                                         $type = "FAIprofile";
663                                 }elseif(in_array("FAItemplate",$obj['objectClass'])){
664                                         $type = "FAItemplate";
665                                 }
666                                 $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj;
667                                 $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type;
668  
669                         }
670                 }
671                 ksort($this->objects);
672                 reset ($this->objects);
673         }
675         function remove_lock()
676         {
677                 if (isset($this->dn)){
678                         del_lock ($this->dn);
679                 }
680         }
682         function get_type($array){
683                 if(in_array("FAIpartitionTable",$array['objectClass'])){
684                         return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS"));
685                 }
686                 if(in_array("FAIscript",$array['objectClass'])){
687                         return(array("tabsScript","faiScript","FAISCRIPTTABS"));
688                 }
689                 if(in_array("FAItemplate",$array['objectClass'])){
690                         return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS"));
691                 }
692                 if(in_array("FAIhook",$array['objectClass'])){
693                         return(array("tabsHook","faiHook","FAIHOOKTABS"));
694                 }
695                 if(in_array("FAIvariable",$array['objectClass'])){
696                         return(array("tabsVariable","faiVariable","FAIVARIABLETABS"));
697                 }
698                 if(in_array("FAIprofile",$array['objectClass'])){
699                         return(array("tabsProfile","faiProfile","FAIPROFILETABS"));
700                 }
701                 
702                 if(in_array("FAIpackageList",$array['objectClass'])){
703                         return(array("tabsPackage","faiPackage","FAIPACKAGETABS"));
704                 }
705         }
709 ?>