Code

[COSMETIC] some more centering
[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         {
87         /* Call parent execute */
88         plugin::execute();
90                 $display        = "";
91                 $smarty         = get_smarty();
92                 $s_action       = "";
93                 $s_entry        = "";
94                 /* filter management 
95                  * Filter will be changed if POST['regex'] or $_GET['search'] isset
96                  * New Filter will be stored in session and is used to generate list contents
97                  */     
98                 $faifilter = $_SESSION['faifilter'];
100                 /* Filter is posted by apply button 
101                  * Check every single chkbox 
102                  */
103                 if(isset($_POST['regex'])){
104                         $faifilter['regex'] = $_POST['regex']."*";
105                         foreach(array("ShowPartitions","ShowProfiles","ShowTemplates","ShowScripts","ShowHooks","ShowVariables","ShowPackages") as $attrs){
106                                 if(isset($_POST[$attrs])){
107                                         $faifilter[$attrs] = true;
108                                 }else{
109                                         $faifilter[$attrs] = false;
110                                 }
111                         }
112                 }
114                 /* Check ImageButton posts
115                  * Create new tab ich new_xx is posted
116                  */
117                 foreach($_POST as $key => $val){
118                         if(preg_match("/create_partition/i",$key)){
119                                 $s_action = "new_partition";
120                         }elseif(preg_match("/create_script/i",$key)){
121                                 $s_action = "new_script";
122                         }elseif(preg_match("/create_hook/i",$key)){
123                                 $s_action = "new_hook";
124                         }elseif(preg_match("/create_variable/i",$key)){
125                                 $s_action = "new_variable";
126                         }elseif(preg_match("/create_template/i",$key)){
127                                 $s_action = "new_template";
128                         }elseif(preg_match("/create_package/i",$key)){
129                                 $s_action = "new_package";
130                         }elseif(preg_match("/create_profile/i",$key)){
131                                 $s_action = "new_profile";
132                         }elseif(preg_match("/edit_continue/",$key)){
133                                 $s_action = "select_class_name_finished";
134                         }elseif(preg_match("/^entry_edit_.*/",$key)){
135                                 $s_entry = preg_replace("/^entry_edit_/","",$key);
136                                 $s_entry = preg_replace("/_.*$/","",$s_entry);
137                                 $s_action = "edit";
138                         }elseif(preg_match("/^entry_delete_.*/",$key)){
139                                 $s_entry = preg_replace("/^entry_delete_/","",$key);
140                                 $s_entry = preg_replace("/_.*$/","",$s_entry);
141                                 $s_action = "delete";
142                         }elseif(preg_match("/dep_back.*/i",$key)){
143                 $s_action="back";
144             }elseif(preg_match("/dep_home.*/i",$key)){
145                 $s_action="home";
146             }elseif(preg_match("/dep_root.*/i",$key)){
147                 $s_action="root";
148                         }
150                 }
152                 if($s_action=="root"){
153                         $faifilter['base']=($this->config->current['BASE']);
154                 }
156                 if($s_action=="home"){
157                         $faifilter['base']=(preg_replace("/^[^,]+,/","",$this->ui->dn));
158                         $faifilter['base']=(preg_replace("/^[^,]+,/","",$faifilter['base']));
159                 }
161                 if($s_action=="back"){
162                         $base_back          = preg_replace("/^[^,]+,/","",$faifilter['base']);
163                         $base_back          = convert_department_dn($base_back);
165                         if(isset($this->config->departments[trim($base_back)])){
166                                 $faifilter['base']= $this->config->departments[trim($base_back)];
167                         }else{
168                                 $faifilter['base']= $this->config->departments["/"];
169                         }
170                 }
172                 if(isset($_GET['act'])&&($_GET['act']=="dep_open")){
173             $s_action="open";
174             $s_entry = base64_decode($_GET['dep_id']);
175             $faifilter['base']= $this->config->departments[trim($s_entry)];
176         }
178                 if(isset($_GET['edit_entry'])){
179                         $s_entry = $_GET['edit_entry'];
180                         $s_action = "edit";
181                 }
183                 /* Confirm dialog 
184                  * Delte object 
185          */
186                 if ($s_action=="delete"){
188                         /* Get 'dn' from posted termlinst */
189                         $this->dn= $this->objects[$s_entry]['dn'];
191                         /* Load permissions for selected 'dn' and check if
192                            we're allowed to remove this 'dn' */
193                         $acl=           get_permissions ($this->dn, $this->ui->subtreeACL);
194                         $this->acl= get_module_permission($acl, "FAIclass", $this->dn);
195                         if (chkacl($this->acl, "delete") == ""){
197                                 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
198                                 if (($user= get_lock($this->dn)) != ""){
199                                         return(gen_locked_message ($user, $this->dn));
200                                 }
202                                 /* Lock the current entry, so nobody will edit it during deletion */
203                                 add_lock ($this->dn, $this->ui->dn);
204                                 $smarty->assign("warning", sprintf(_("You're about to delete all information about the FAI class at '%s'."), $this->dn));
205                                 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
206                         } else {
208                                 /* Obviously the user isn't allowed to delete. Show message and
209                                    clean session. */
210                                 print_red (_("You are not allowed to delete this component!"));
211                         }
212                 }
214                 /* Delete canceled? */
215                 if (isset($_POST['delete_cancel'])){
216                         del_lock ($this->dn);
217                 }
220                 /* Deltetion was confirmed, so delete this entry
221                  */
222                 if (isset($_POST['delete_terminal_confirm'])){
224                         /* Some nice guy may send this as POST, so we've to check
225                            for the permissions again. */
226                         if (chkacl($this->acl, "delete") == ""){
228                                 /* Find out more about the object type */
229                                 $ldap   = $this->config->get_ldap_link();
230                                 $ldap->cat($this->dn);
231                                 $attrs  = $ldap->fetch();
233                                 $type   = $this->get_type($attrs);                      
235                                 $this->dialog= new $type[0]($this->config,      $this->config->data['TABS'][$type[2]], $this->dn);
236                                 $this->dialog->set_acl(array($this->acl));
238                                 $this->dialog->by_object[$type[1]]->remove_from_parent ();
239                                 unset ($this->dialog);
240                                 gosa_log ("FAI class '".$this->dn."' has been removed");
241                                 $this->dialog= NULL;
243                                 /* Terminal list has changed, reload it. */
244                                 $this->reload ();
245                         } else {
247                                 /* Normally this shouldn't be reached, send some extra
248                                    logs to notify the administrator */
249                                 print_red (_("You are not allowed to delete this component!"));
250                                 gosa_log ("Warning: '".$this->ui->uid."' tried to trick system ".
251                                                 "deletion.");
252                         }
254                         /* Remove lock file after successfull deletion */
255                         del_lock ($this->dn);
256                 }
258                 /* Edit Entry */
259                 if($s_action == "edit"){
260                         $entry  = $this->objects[$s_entry];
262                         $a_setup = ($this->get_type($entry));
263                 
264                         $this->dn = $entry['dn'];
265                         add_lock ($this->dn, $this->ui->dn);
267                         $this->dialog= new $a_setup[0]($this->config,
268                                         $this->config->data['TABS'][$a_setup[2]],$this->dn);
269                         $this->is_dialog = true;
270                         $_SESSION['objectinfo'] = $this->dn;
271                 }
274                 /* Dialog handling */
275                 if($s_action == "new_partition"){
276                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpartitionTable");
277                 }
279                 /* Dialog handling */
280                 if($s_action == "new_script"){
281                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIscript");
282                 }
284                 /* Dialog handling */
285                 if($s_action == "new_hook"){
286                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIhook");
287                 }
289                 /* Dialog handling */
290                 if($s_action == "new_variable"){
291                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIvariable");
292                 }
294                 /* Dialog handling */
295                 if($s_action == "new_template"){
296                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAItemplate");
297                 }
299                 /* Dialog handling */
300                 if($s_action == "new_package"){
301                         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpackageList");
302                 }
304                 /* New Profile */
305                 if($s_action == "new_profile"){
306                         $this->dn = "new" ;
307                         $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
309                         $this->dialog = new $a_setup[0]($this->config,
310                                         $this->config->data['TABS'][$a_setup[2]],$this->dn);
311                         $this->is_dialog = true;
313                 }
315                 if($s_action == "select_class_name_finished"){
316                         $this->dialog->save_object();
317                         if(count($this->dialog->check())!=0){
318                                 foreach($this->dialog->check() as $msg){
319                                         print_red($msg);
320                                 }               
321                         }else{
322                                 $this->dn = "new" ;
323                                 $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
324                                 $name = $this->dialog->save();
326                                 $this->dialog = new $a_setup[0]($this->config,
327                                                 $this->config->data['TABS'][$a_setup[2]],$this->dn,$name);
328                                 $this->dialog->by_object[$a_setup[1]]->cn = $name;
329                                 $this->is_dialog = true;
330                         }               
331                 }       
334                 /* Search is set */
335                 if(isset($_GET['search'])){
336                         $faifilter['regex']=$_GET['search']."*";
337                 }
339                 /* Department select */
340                 if((isset($_POST['base']))&&($s_action=="")){
341                         $faifilter['base']=$_POST['base'];
342                 }
344                 /* remove double asterisks and save new filter */
345                 $faifilter['regex'] = preg_replace("/\*\*/","*",$faifilter['regex']);
346                 $_SESSION['faifilter']= $faifilter;
348                 /* Edit dialog was canceled 
349                  * Remove dialog an show management dialog
350                  */
351                 if(isset($_POST['edit_cancel'])){
352                         unset($this->dialog);
353                         $this->dialog=NULL;
354                         $this->is_dialog = false;
355                         unset($_SESSION['objectinfo']);
356                         del_lock ($this->dn);
357                 }
359                 /* This check if the given tab could be saved 
360                  * If it was possible to save it, remove dialog object. 
361                  * If it wasn't possible, show errors and keep dialog.
362                  */
363                 if(isset($_POST['edit_finish'])){
364                         $this->dialog->save_object();
365                         if(count($this->dialog->check())!=0){
366                                 foreach($this->dialog->check() as $msg){
367                                         print_red($msg);
368                                 }
369                         }else{
370                                 del_lock ($this->dn);
371                                 $this->dialog->save();
372                                 unset($this->dialog);
373                                 $this->dialog=NULL;
374                                 $this->is_dialog=false;
375                                 unset($_SESSION['objectinfo']);
376                         }
377                 }
379                 /* If dialog is set, but $this->is_dialog==false, then 
380                  *  only the "abort" button is shown, this are dialogs that must not be saved.  
381                  * If is_dialog == true, we are currently editing tab objects.
382                  *  Here we need both, save and cancel
383                  */ 
385                 if($this->dialog != NULL){
386                         $display .= $this->dialog->execute();
387                         /* Don't show buttons if tab dialog requests this */
388                         if (((isset($this->dialog->current))&&($this->dialog->by_object[$this->dialog->current]->is_dialog))){
389                                 
390                         }elseif(((isset($this->dialog->current))&&(!$this->dialog->by_object[$this->dialog->current]->is_dialog))){
391                                 $display.= "<p style=\"text-align:right\">\n";
392                                 $display.= "<input type=\"submit\" name=\"edit_finish\" value=\""._("Finish")."\">\n";
393                                 $display.= "&nbsp;\n";
394                                 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
395                                 $display.= "</p>";
396                         }elseif(!isset($this->dialog->current)){
397                                 $display.= "<p style=\"text-align:right\">\n";
398                                 $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\">&nbsp;";
399                                 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
400                                 $display.= "</p>";
401                         }
402                         return($display);
403                 }
405                 /* Show Management template
406                  * The following code will only be reached if no dialog (tabs or dialogs)
407                  *  are currently opened.
408                  * Assign all reguired vars to template engine
409                  */
411                 /* Prepare departments */
412                 $options= "";
413                 foreach ($this->config->idepartments as $key => $value){
414                         if ($faifilter['base'] == $key){
415                                 $options.= "<option selected='selected' value='$key'>$value</option>";
416                         } else {
417                                 $options.= "<option value='$key'>$value</option>";
418                         }
419                 }
421                 /* Create listhead, it will be shown on top of the divlist. 
422                  * It provides general navigation and object creation
423                  */
424                 $faihead = 
425                         "<div style='background:#F0F0F9;padding:5px;'>&nbsp;".
427                         "<input class='center' type='image' src='images/list_up.png' align='middle' 
428                         title='"._("Go up one department")."' name='dep_back' alt='"._("Up"). "'>&nbsp;".
430                         "<input class='center' type='image' src='images/list_root.png' align='middle' 
431                         title='"._("Go to root department")."' name='dep_root' alt='".      _("Root")."'>&nbsp;".
433                         "<input class='center' type='image' src='images/list_home.png' align='middle' 
434                         title='"._("Go to users home department")."' name='dep_home' alt='"._("Home")."'>&nbsp;".
436                         "<img class='center' src=\"images/list_seperator.png\" alt=\"\" align=\"middle\" height=\"16\" width=\"1\">&nbsp;".
437                         
438                         " <input class='center' type='image' src='images/fai_new_profile.png' align='middle' 
439                         title='"._("New profile")."' name='Create_profile' alt='"._("P")."'>&nbsp;".
440                         
441                         "<img class='center' src=\"images/list_seperator.png\" alt=\"\" align=\"middle\" height=\"16\" width=\"1\">&nbsp;".
442                                 
443                         " <input class='center' type='image' src='images/fai_new_partitionTable.png' align='middle' 
444                         title='"._("New partition table")."' name='Create_partition' alt='"._("PT")."'>&nbsp;".
446                         " <input class='center' type='image' src='images/fai_new_script.png' align='middle' 
447                         title='"._("New scripts")."' name='Create_script' alt='"._("S")."'>&nbsp;".
449                         " <input class='center' type='image' src='images/fai_new_hook.png' align='middle' 
450                         title='"._("New hooks")."' name='Create_hook' alt='"._("H")."'>&nbsp;".
452                         " <input class='center' type='image' src='images/fai_new_variable.png' align='middle' 
453                         title='"._("New variables")."' name='Create_variable' alt='"._("V")."'>&nbsp;".
454                         
455                         " <input class='center' type='image' src='images/fai_new_template.png' align='middle' 
456                         title='"._("New templates")."' name='Create_template' alt='"._("T")."'>&nbsp;".
458                         " <input class='center' type='image' src='images/fai_new_packages.png' align='middle' 
459                         title='"._("New package list")."' name='Create_package' alt='"._("PK")."'>&nbsp;".
461                         " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
463                         _("Current base")."&nbsp;<select name='base' onChange='mainform.submit()'>$options</select>".
464                         " <input class='center' type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
465                         
466                         "</div>";
468                 $this->reload();
470                 /* Create list with objects */
471                 $divlist = new divlist("faiManagement"); 
472                 $divlist->SetEntriesPerPage(0);
473                 $divlist->SetSummary(_("This table displays all systems, in the selected tree."));
475                 $divlist->SetHeader(array(
476                                         array("string" => "&nbsp;", "attach" => "style='text-align:center;width:20px;'"),
477                                         array("string" => _("Name of FAI class"), "attach" => "style=''"),
478                                         array("string" => _("Class type"), "attach" => "style='width:200px;'"),
479                                         array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'")));
482                 $action  = "<input class='center' type='image' src='images/edit.png'    alt='"._("edit")."'   name='entry_edit_%KEY%' title='"._("Edit class")."'>";
483                 $action .= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."' name='entry_delete_%KEY%' title='"._("Delete class")."'>";
485                 $editlink ="<a href='?plug=".$_GET['plug']."&edit_entry=%KEY%'>%NAME%</a>";             
486                 $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
488                 foreach($this->departments as $key => $val) {
489                         if(!isset($this->config->departments[trim($key)])){
490                                 $this->config->departments[trim($key)]="";
491                         }
493                         $non_empty="";
494                         $keys= str_replace("/","\/",$key);
495                         foreach($this->config->departments as $keyd=>$vald ){
496                                 if(preg_match("/".$keys."\/.*/",$keyd)){
497                                         $non_empty="full";
498                                 }
499                         }
502                         $title = $this->config->departments[$key];
503                         $field0 = array("string" => "<img src='images/".$non_empty."folder.png' title='"._("department")."' alt='department'>", "attach" => "style='text-align:center;width:20px;'");
504                         $field1 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style='' title='".$title."'");
505                         $field2 = array("string" => "&nbsp;", "attach" => "style='width:200px;'");
506                         $field3 = array("string" => "&nbsp;", "attach" => "style='width:60px;border-right:0px;text-align:right;'");
508                         $divlist->AddEntry( array($field0,$field1,$field2,$field3));
510                 }
513                 /* Attach objects */
514                 foreach($this->objects as $key => $value){
515                                 $info= "";
516                                 $img = "";
517                                 $type = $value['type'];
518                                 $abort=false;
520                                 switch($type) {
521                                         case "FAIpartitionTable"        : 
522                                                 if(!$faifilter['ShowPartitions']){ 
523                                                         $abort = true;
524                                                 }
525                                         $img="<img class='center' src='images/fai_partitionTable.png' title='"._("Partition table")."' alt='PT'>";
526                                         $info = _("Partition table");
527                                         break;
528                                         case "FAIpackageList"           : 
529                                                 if(!$faifilter['ShowPackages']){ 
530                                                         $abort = true;
531                                                 }
532                                         $img="<img class='center' src='images/fai_packages.png' title='"._("Package list")."' alt='PL'>";
533                                         $info = _("Package list");
534                                         break;
535                                         case "FAIscript"                        : 
536                                                 if(!$faifilter['ShowScripts']){ 
537                                                         $abort = true;
538                                                 }
539                                         $img="<img class='center' src='images/fai_script.png' title='"._("Scripts")."' alt='S'>";
540                                         $info = _("Scripts");
541                                         break;
542                                         case "FAIvariable"                      : 
543                                                 if(!$faifilter['ShowVariables']){ 
544                                                         $abort = true;
545                                                 }
546                                         $img="<img class='center' src='images/fai_variable.png' title='"._("Variables")."' alt='V'>";
547                                         $info = _("Variables");
548                                         break;
549                                         case "FAIhook"                          :
550                                                 if(!$faifilter['ShowHooks']){ 
551                                                         $abort = true;
552                                                 }
553                                         $img="<img class='center' src='images/fai_hook.png' title='"._("Hooks")."' alt='H'>";
554                                         $info = _("Hooks");
555                                         break;
556                                         case "FAIprofile"                       : 
557                                                 if(!$faifilter['ShowProfiles']){ 
558                                                         $abort = true;
559                                                 }
560                                         $img="<img class='center' src='images/fai_profile.png' title='"._("Profile")."' alt='P'>";
561                                         $info = _("Profile");
562                                         break;
563                                         case "FAItemplate"                      : 
564                                                 if(!$faifilter['ShowTemplates']){ 
565                                                         $abort = true;
566                                                 }
567                                         $img="<img class='center' src='images/fai_template.png' title='"._("Templates")."' alt='T'>";
568                                         $info = _("Templates");
569                                         break;
570                                         default                                         : 
571                                         $img="<img class='center' src='images/empty.png' alt=''>";$info = "";break;
573                                 }
574                                 
575                                 if(!$abort)     {
576                                         if((isset($value['description']))&&(!empty($value['description']))){
577                                                 $desc= " [".$value['description']."]";
578                                         }else{
579                                                 $desc= "";
580                                         }
582                                         $field1 = array("string" => $img , "attach" => "style='text-align:center;width:20px;'");
583                                         $field2 = array("string" => preg_replace(array("/%KEY%/","/%NAME%/"),array($key,$value['cn'].$desc),$editlink) , "attach" => "style=''");
584                                         $field3 = array("string" => $info, "attach" => "style='width:200px;'");
585                                         $field4 = array("string" => preg_replace("/%KEY%/",$key,$action) , "attach" => "style='width:60px;border-right:0px;text-align:right;'");
586                                         $divlist->AddEntry(array($field1,$field2,$field3,$field4));
588                         }
589                 }
591                 foreach($faifilter as $attrs => $value){
592                         if($value){
593                                 $smarty->assign($attrs."CHK", " checked ");
594                         }else{
595                                 $smarty->assign($attrs."CHK", " ");
596                         }
597                 }
599                 /* Assign all reguired vars to template engine */
600                 $smarty->assign("faihead"               , $faihead);    
601                 $smarty->assign("failist"               , $divlist->DrawList());
602                 $smarty->assign("regex"                 , $faifilter['regex']); 
603                 $smarty->assign("infoimage"             , get_template_path('images/info.png'));
604                 $smarty->assign("launchimage"   , get_template_path('images/launch.png'));
605                 $smarty->assign("alphabet"              , generate_alphabet());
606                 $smarty->assign("apply"                 , apply_filter());
607                 $smarty->assign("search_image"  , get_template_path('images/search.png'));
608                 $smarty->assign("hint", print_sizelimit_warning());
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(isset($value["description"][0])){
650                                 $this->departments[$value['dn']]=convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
651                         }else{
652                                 $this->departments[$value['dn']]=convert_department_dn2($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 ?>