Code

Added lock message for edited FAI dialogs
[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'];
266                         add_lock ($this->dn, $this->ui->dn);
268                         $this->dialog= new $a_setup[0]($this->config,
269                                         $this->config->data['TABS'][$a_setup[2]],$this->dn);
270                         $this->is_dialog = true;
271                         $_SESSION['objectinfo'] = $this->dn;
272                 }
275                 /* Dialog handling */
276                 if($s_action == "new_partition"){
277                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpartitionTable");
278                 }
280                 /* Dialog handling */
281                 if($s_action == "new_script"){
282                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIscript");
283                 }
285                 /* Dialog handling */
286                 if($s_action == "new_hook"){
287                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIhook");
288                 }
290                 /* Dialog handling */
291                 if($s_action == "new_variable"){
292                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIvariable");
293                 }
295                 /* Dialog handling */
296                 if($s_action == "new_template"){
297                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAItemplate");
298                 }
300                 /* Dialog handling */
301                 if($s_action == "new_package"){
302                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpackageList");
303                 }
305                 /* New Profile */
306                 if($s_action == "new_profile"){
307                         $this->dn = "new" ;
308                         $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
310                         $this->dialog = new $a_setup[0]($this->config,
311                                         $this->config->data['TABS'][$a_setup[2]],$this->dn);
312                         $this->is_dialog = true;
314                 }
316                 if($s_action == "select_class_name_finished"){
317                         $this->dialog->save_object();
318                         if(count($this->dialog->check())!=0){
319                                 foreach($this->dialog->check() as $msg){
320                                         print_red($msg);
321                                 }               
322                         }else{
323                                 $this->dn = "new" ;
324                                 $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
325                                 $name = $this->dialog->save();
327                                 $this->dialog = new $a_setup[0]($this->config,
328                                                 $this->config->data['TABS'][$a_setup[2]],$this->dn,$name);
329                                 $this->dialog->by_object[$a_setup[1]]->cn = $name;
330                                 $this->is_dialog = true;
331                         }               
332                 }       
335                 /* Search is set */
336                 if(isset($_GET['search'])){
337                         $faifilter['regex']=$_GET['search']."*";
338                 }
340                 /* Department select */
341                 if(isset($_POST['base'])){
342                         $faifilter['base']=$_POST['base'];
343                 }
345                 /* remove double asterisks and save new filter */
346                 $faifilter['regex'] = preg_replace("/\*\*/","*",$faifilter['regex']);
347                 $_SESSION['faifilter']= $faifilter;
349                 /* Edit dialog was canceled 
350                  * Remove dialog an show management dialog
351                  */
352                 if(isset($_POST['edit_cancel'])){
353                         unset($this->dialog);
354                         $this->dialog=NULL;
355                         $this->is_dialog = false;
356                         unset($_SESSION['objectinfo']);
357                         del_lock ($this->dn);
358                 }
360                 /* This check if the given tab could be saved 
361                  * If it was possible to save it, remove dialog object. 
362                  * If it wasn't possible, show errors and keep dialog.
363                  */
364                 if(isset($_POST['edit_finish'])){
365                         $this->dialog->save_object();
366                         if(count($this->dialog->check())!=0){
367                                 foreach($this->dialog->check() as $msg){
368                                         print_red($msg);
369                                 }
370                         }else{
371                                 del_lock ($this->dn);
372                                 $this->dialog->save();
373                                 unset($this->dialog);
374                                 $this->dialog=NULL;
375                                 $this->is_dialog=false;
376                                 unset($_SESSION['objectinfo']);
377                         }
378                 }
380                 /* If dialog is set, but $this->is_dialog==false, then 
381                  *  only the "abort" button is shown, this are dialogs that must not be saved.  
382                  * If is_dialog == true, we are currently editing tab objects.
383                  *  Here we need both, save and cancel
384                  */ 
386                 if($this->dialog != NULL){
387                         $display .= $this->dialog->execute();
388                         /* Don't show buttons if tab dialog requests this */
389                         if (((isset($this->dialog->current))&&($this->dialog->by_object[$this->dialog->current]->is_dialog))){
390                                 
391                         }elseif(((isset($this->dialog->current))&&(!$this->dialog->by_object[$this->dialog->current]->is_dialog))){
392                                 $display.= "<p style=\"text-align:right\">\n";
393                                 $display.= "<input type=submit name=\"edit_finish\" value=\""._("Finish")."\">\n";
394                                 $display.= "&nbsp;\n";
395                                 $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
396                                 $display.= "</p>";
397                         }elseif(!isset($this->dialog->current)){
398                                 $display.= "<p style=\"text-align:right\">\n";
399                                 $display.= "<input type=submit name=\"edit_continue\" value=\""._("Continue")."\">&nbsp;";
400                                 $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
401                                 $display.= "</p>";
402                         }
403                         return($display);
404                 }
406                 /* Show Management template
407                  * The following code will only be reached if no dialog (tabs or dialogs)
408                  *  are currently opened.
409                  * Assign all reguired vars to template engine
410                  */
412                 /* Prepare departments */
413                 $options= "";
414                 foreach ($this->config->idepartments as $key => $value){
415                         if ($faifilter['base'] == $key){
416                                 $options.= "<option selected value='$key'>$value</option>";
417                         } else {
418                                 $options.= "<option value='$key'>$value</option>";
419                         }
420                 }
422                 /* Create listhead, it will be shown on top of the divlist. 
423                  * It provides general navigation and object creation
424                  */
425                 $faihead = 
426                         "<div style='background:#F0F0F9;padding:5px;'>&nbsp;".
428                         "<input class='center' type='image' src='images/list_up.png' align='middle' 
429                         title='"._("Go up one department")."' name='dep_back' alt='"._("Up"). "'>&nbsp;".
431                         "<input class='center' type='image' src='images/list_root.png' align='middle' 
432                         title='"._("Go to root department")."' name='dep_root' alt='".      _("Root")."'>&nbsp;".
434                         "<input class='center' type='image' src='images/list_home.png' align='middle' 
435                         title='"._("Go to users home department")."' name='dep_home' alt='"._("Home")."'>&nbsp;".
437                         "<img class='center' src=\"images/list_seperator.png\" alt=\"\" align=\"middle\" height=\"16\" width=\"1\">&nbsp;".
438                         
439                         " <input class='center' type='image' src='images/fai_new_profile.png' align='middle' 
440                         title='"._("New profile")."' name='Create_profile' alt='"._("P")."'>&nbsp;".
441                         
442                         "<img class='center' src=\"images/list_seperator.png\" alt=\"\" align=\"middle\" height=\"16\" width=\"1\">&nbsp;".
443                                 
444                         " <input class='center' type='image' src='images/fai_new_partitionTable.png' align='middle' 
445                         title='"._("New partition table")."' name='Create_partition' alt='"._("PT")."'>&nbsp;".
447                         " <input class='center' type='image' src='images/fai_new_script.png' align='middle' 
448                         title='"._("New scripts")."' name='Create_script' alt='"._("S")."'>&nbsp;".
450                         " <input class='center' type='image' src='images/fai_new_hook.png' align='middle' 
451                         title='"._("New hooks")."' name='Create_hook' alt='"._("H")."'>&nbsp;".
453                         " <input class='center' type='image' src='images/fai_new_variable.png' align='middle' 
454                         title='"._("New variables")."' name='Create_variable' alt='"._("V")."'>&nbsp;".
455                         
456                         " <input class='center' type='image' src='images/fai_new_template.png' align='middle' 
457                         title='"._("New templates")."' name='Create_template' alt='"._("T")."'>&nbsp;".
459                         " <input class='center' type='image' src='images/fai_new_packages.png' align='middle' 
460                         title='"._("New package list")."' name='Create_package' alt='"._("PK")."'>&nbsp;".
462                         " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
464                         _("Current base")."&nbsp;<select name='base' onChange='mainform.submit()'>$options</select>".
465                         " <input class='center' type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
466                         
467                         "</div>";
469                 $this->reload();
471                 /* Create list with objects */
472                 $divlist = new divlist("faiManagement"); 
473                 $divlist->SetEntriesPerPage(0);
474                 $divlist->SetSummary(_("This table displays all systems, in the selected tree."));
476                 $divlist->SetHeader(array(
477                                         array("string" => "&nbsp;", "attach" => "style='text-align:center;width:20px;'"),
478                                         array("string" => _("Name of FAI class"), "attach" => "style=''"),
479                                         array("string" => _("Class type"), "attach" => "style='width:200px;'"),
480                                         array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'")));
483                 $action  = "<input type='image' src='images/edit.png'   alt='"._("edit")."'   name='entry_edit_%KEY%' title='"._("Edit class")."'>";
484                 $action .= "<input type='image' src='images/edittrash.png' alt='"._("delete")."' name='entry_delete_%KEY%' title='"._("Delete class")."'>";
486                 $editlink ="<a href='?plug=".$_GET['plug']."&edit_entry=%KEY%'>%NAME%</a>";             
487                 $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
489                 foreach($this->departments as $key => $val) {
490                         if(!isset($this->config->departments[trim($key)])){
491                                 $this->config->departments[trim($key)]="";
492                         }
494                         $non_empty="";
495                         $keys= str_replace("/","\/",$key);
496                         foreach($this->config->departments as $keyd=>$vald ){
497                                 if(preg_match("/".$keys."\/.*/",$keyd)){
498                                         $non_empty="full";
499                                 }
500                         }
503                         $title = $this->config->departments[$key];
504                         $field0 = array("string" => "<img src='images/".$non_empty."folder.png' title='"._("department")."' alt='department'>", "attach" => "style='text-align:center;width:20px;'");
505                         $field1 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style='' title='".$title."'");
506                         $field2 = array("string" => "&nbsp;", "attach" => "style='width:200px;'");
507                         $field3 = array("string" => "&nbsp;", "attach" => "style='width:60px;border-right:0px;text-align:right;'");
509                         $divlist->AddEntry( array($field0,$field1,$field2,$field3));
511                 }
514                 /* Attach objects */
515                 foreach($this->objects as $key => $value){
516                                 $info= "";
517                                 $img = "";
518                                 $type = $value['type'];
519                                 $abort=false;
521                                 switch($type) {
522                                         case "FAIpartitionTable"        : 
523                                                 if(!$faifilter['ShowPartitions']){ 
524                                                         $abort = true;
525                                                 }
526                                         $img="<img src='images/fai_partitionTable.png' title='"._("Partition table")."' alt='PT'>";
527                                         $info = _("Partition table");
528                                         break;
529                                         case "FAIpackageList"           : 
530                                                 if(!$faifilter['ShowPackages']){ 
531                                                         $abort = true;
532                                                 }
533                                         $img="<img src='images/fai_packages.png' title='"._("Package list")."' alt='PL'>";
534                                         $info = _("Package list");
535                                         break;
536                                         case "FAIscript"                        : 
537                                                 if(!$faifilter['ShowScripts']){ 
538                                                         $abort = true;
539                                                 }
540                                         $img="<img src='images/fai_script.png' title='"._("Scripts")."' alt='S'>";
541                                         $info = _("Scripts");
542                                         break;
543                                         case "FAIvariable"                      : 
544                                                 if(!$faifilter['ShowVariables']){ 
545                                                         $abort = true;
546                                                 }
547                                         $img="<img src='images/fai_variable.png' title='"._("Variables")."' alt='V'>";
548                                         $info = _("Variables");
549                                         break;
550                                         case "FAIhook"                          :
551                                                 if(!$faifilter['ShowHooks']){ 
552                                                         $abort = true;
553                                                 }
554                                         $img="<img src='images/fai_hook.png' title='"._("Hooks")."' alt='H'>";
555                                         $info = _("Hooks");
556                                         break;
557                                         case "FAIprofile"                       : 
558                                                 if(!$faifilter['ShowProfiles']){ 
559                                                         $abort = true;
560                                                 }
561                                         $img="<img src='images/fai_profile.png' title='"._("Profile")."' alt='P'>";
562                                         $info = _("Profile");
563                                         break;
564                                         case "FAItemplate"                      : 
565                                                 if(!$faifilter['ShowTemplates']){ 
566                                                         $abort = true;
567                                                 }
568                                         $img="<img src='images/fai_template.png' title='"._("Templates")."' alt='T'>";
569                                         $info = _("Templates");
570                                         break;
571                                         default                                         : 
572                                         $img="<img src='images/empty.png' alt=''>";$info = "";break;
574                                 }
575                                 
576                                 if(!$abort)     {
577                                         if((isset($value['description']))&&(!empty($value['description']))){
578                                                 $desc= " [".$value['description']."]";
579                                         }else{
580                                                 $desc= "";
581                                         }
583                                         $field1 = array("string" => $img , "attach" => "style='text-align:center;width:20px;'");
584                                         $field2 = array("string" => preg_replace(array("/%KEY%/","/%NAME%/"),array($key,$value['cn'].$desc),$editlink) , "attach" => "style=''");
585                                         $field3 = array("string" => $info, "attach" => "style='width:200px;'");
586                                         $field4 = array("string" => preg_replace("/%KEY%/",$key,$action) , "attach" => "style='width:60px;border-right:0px;text-align:right;'");
587                                         $divlist->AddEntry(array($field1,$field2,$field3,$field4));
589                         }
590                 }
592                 foreach($faifilter as $attrs => $value){
593                         if($value){
594                                 $smarty->assign($attrs."CHK", " checked ");
595                         }else{
596                                 $smarty->assign($attrs."CHK", " ");
597                         }
598                 }
600                 /* Assign all reguired vars to template engine */
601                 $smarty->assign("faihead"               , $faihead);    
602                 $smarty->assign("failist"               , $divlist->DrawList());
603                 $smarty->assign("regex"                 , $faifilter['regex']); 
604                 $smarty->assign("infoimage"             , get_template_path('images/info.png'));
605                 $smarty->assign("launchimage"   , get_template_path('images/launch.png'));
606                 $smarty->assign("alphabet"              , generate_alphabet());
607                 $smarty->assign("apply"                 , apply_filter());
608                 $smarty->assign("search_image"  , get_template_path('images/search.png'));
610                 $display        = $smarty->fetch(get_template_path('headpage.tpl', TRUE, dirname(__FILE__)));
611                 return ($display);
612         }
615         function reload()
616         {
617                 /* Create a new list of FAI object 
618                  * Object list depends on faifilter['regex']
619                  * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ... 
620                  */
621                 $faifilter= get_global('faifilter');
622                 // Added for dirlist function...
624                 /* Set base for all searches */
625                 $base= "ou=fai,ou=configs,ou=systems,".$faifilter['base'];
626                 $regex = $faifilter['regex'];   
628                 /* Array to save objects */
629                 $objects = array();
630         
631                 $this->objects=array();
633                 /* NEW LIST MANAGMENT
634                  * We also need to search for the departments
635                  * So we are able to navigate like in konquerer
636                  */
637                 $base2 = $faifilter['base'];
639                 $res3 =  get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))",
640                                 TRUE, $base2, array("ou", "description"), TRUE);
642                 $this->departments= array();
643                 $tmp = array();
644                 foreach ($res3 as $value){
645                         $tmp[strtolower($value['dn']).$value['dn']]=$value;
646                 }
647                 ksort($tmp);
648                 foreach($tmp as $value){
649                         if($value["description"][0]!=".."){
650                                 $this->departments[$value['dn']]=convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
651                         }else{
652                                 $this->departments[$value['dn']]=$value["description"][0];
653                         }
654                 }
656                 /* END NEW LIST MANAGMENT
657                  */
659         
660                 $res= get_list($this->ui->subtreeACL, "(objectClass=organizationalUnit)", 
661                                 FALSE, $base, array("cn","description","objectClass"),TRUE);
663                 foreach($res as $objecttypes){
664                         $res2 = get_list($this->ui->subtreeACL, "(&(objectClass=*)(cn=".$regex."))",
665                                         FALSE, $objecttypes['dn'], array("cn","description","objectClass","FAIclass"),TRUE);
666                         foreach($res2 as $object){
667                                 $type= "";      
668                                 unset($object['objectClass']['count']);
669                                 if(!isset($object['description'][0])){
670                                         $object['description'][0]="";
671                                 }
672                                 
673                                 /* Clean up object informations */
674                                 $obj['cn']                      = $object['cn'][0];
675                                 $obj['dn']                      = $object['dn'];
676                                 $obj['description'] = $object['description'][0];
677                                 $obj['objectClass'] = $object['objectClass'];
679                                 if(in_array("FAIpartitionTable",$obj['objectClass'])){
680                                         $type = "FAIpartitionTable";
681                                 }elseif(in_array("FAIpackageList",$obj['objectClass'])){
682                                         $type = "FAIpackageList";
683                                 }elseif(in_array("FAIscript",$obj['objectClass'])){
684                                         $type = "FAIscript";
685                                 }elseif(in_array("FAIvariable",$obj['objectClass'])){
686                                         $type = "FAIvariable";
687                                 }elseif(in_array("FAIhook",$obj['objectClass'])){
688                                         $type = "FAIhook";
689                                 }elseif(in_array("FAIprofile",$obj['objectClass'])){
690                                         $obj['FAIclass']        = $object['FAIclass'][0];
691                                         $type = "FAIprofile";
692                                 }elseif(in_array("FAItemplate",$obj['objectClass'])){
693                                         $type = "FAItemplate";
694                                 }
695                                 $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj;
696                                 $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type;
697  
698                         }
699                 }
700                 ksort($this->objects);
701                 reset ($this->objects);
702         
703                 /* use numeric index, thats a bit more secure */        
704                 $tmp0 = array();
705                 foreach($this->objects as $obj){
706                         $tmp0[]= $obj;
707                 }
708                 $this->objects = array();
709                 $this->objects = $tmp0;
711         }
713         function remove_lock()
714         {
715                 if (isset($this->dn)){
716                         del_lock ($this->dn);
717                 }
718         }
720         function get_type($array){
721                 if(in_array("FAIpartitionTable",$array['objectClass'])){
722                         return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS"));
723                 }
724                 if(in_array("FAIscript",$array['objectClass'])){
725                         return(array("tabsScript","faiScript","FAISCRIPTTABS"));
726                 }
727                 if(in_array("FAItemplate",$array['objectClass'])){
728                         return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS"));
729                 }
730                 if(in_array("FAIhook",$array['objectClass'])){
731                         return(array("tabsHook","faiHook","FAIHOOKTABS"));
732                 }
733                 if(in_array("FAIvariable",$array['objectClass'])){
734                         return(array("tabsVariable","faiVariable","FAIVARIABLETABS"));
735                 }
736                 if(in_array("FAIprofile",$array['objectClass'])){
737                         return(array("tabsProfile","faiProfile","FAIPROFILETABS"));
738                 }
739                 
740                 if(in_array("FAIpackageList",$array['objectClass'])){
741                         return(array("tabsPackage","faiPackage","FAIPACKAGETABS"));
742                 }
743         }
747 ?>