Code

Upps
[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  */
21 require "tabsPartition.inc";
22 require "tabsVariable.inc";
23 require "tabsHook.inc";
24 require "tabsTemplate.inc";
25 require "tabsScript.inc";
26 require "tabsProfile.inc";
27 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 $lock_type    = "";    // should be branch/freeze
43   var $lock_name    = "";
44   var $lock_dn      = "";  
46         /* attribute list for save action */
47         var $attributes         = array("lock_type","lock_name","lock_dn");     //      Attributes Managed by this plugin 
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   var $dispNewBranch= false;
55   var $dispNewFreeze= false;
57   var $DivListFai;
59         /* construction/reconstruction 
60          */
61         function faiManagement ($config, $ui)
62         {
63                 /* Set defaults */
64                 $this->dn                       = "";
65                 $this->config   = $config;
66                 $this->ui                       = $ui;  
67     
68     /* Creat dialog object */
69     $this->DivListFai = new divListFai($this->config,$this);
70         }
72         function execute()
73         {
74     /* Call parent execute */
75     plugin::execute();
77     /* Initialise vars and smarty */
78                 $smarty         = get_smarty();
79                 $smarty->assign("BranchName","");
80     
81                 $display        = "";
82     $s_action   = "";
83                 $s_entry        = "";
84     
85     /* If an entry was locked, these vars will be stored in a session to allow direct edit */
86     $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit_entry$/","/^id$/","/^entry_edit_/","/^entry_delete_/");
89     /****************
90       Handle posts 
91      ****************/
93                 /* Check ImageButton posts
94                  * Create new tab ich new_xx is posted
95                  */
96     $posts = array( "/remove_branch/"=>"remove_branch",    "/branch_branch/"=>"branch_branch",
97                     "/freeze_branch/"=>"freeze_branch",    "/create_partition/i"=>"new_partition",
98                     "/create_script/i"=>"new_script",      "/create_hook/i"=>"new_hook",
99                     "/create_variable/i"=>"new_variable",  "/create_template/i"=>"new_template",
100                     "/create_package/i"=>"new_package",    "/create_profile/i"=>"new_profile",
101                     "/edit_continue/"=>"select_class_name_finished");
103                 foreach($_POST as $name => $value){
104       foreach($posts as $reg => $act ){
105         if(preg_match($reg,$name)){
106           $s_action = $act;
107         }
108       }
109                         if(preg_match("/^entry_edit_.*/",$name)){
110                                 $s_entry = preg_replace("/^entry_edit_/","",$name);
111                                 $s_entry = preg_replace("/_.*$/","",$s_entry);
112                                 $s_action = "edit";
113                         }elseif(preg_match("/^entry_delete_.*/",$name)){
114                                 $s_entry = preg_replace("/^entry_delete_/","",$name);
115                                 $s_entry = preg_replace("/_.*$/","",$s_entry);
116         $s_action = "delete";
117       }
118     }
120                 if(isset($_GET['edit_entry'])){
121                         $s_entry = $_GET['edit_entry'];
122                         $s_action = "edit";
123                 }
124     
125     if((isset($_POST['CancelBranchName'])) || (isset($_POST['CloseIFrame']))){
126       $this->dispNewBranch = false;
127       $this->dispNewFreeze = false;
128     }
131     /****************
132       Delete confirme dialog 
133      ****************/
135                 if ($s_action=="delete"){
137                         /* Get 'dn' from posted termlinst */
138                         $this->dn= $this->objects[$s_entry]['dn'];
140                         /* Load permissions for selected 'dn' and check if
141                            we're allowed to remove this 'dn' */
142                         $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
143                         $this->acl= get_module_permission($acl, "FAIclass", $this->dn);
144                         if (chkacl($this->acl, "delete") == ""){
146                                 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
147                                 if (($user= get_lock($this->dn)) != ""){
148                                         return(gen_locked_message ($user, $this->dn));
149                                 }
151                                 /* Lock the current entry, so nobody will edit it during deletion */
152                                 add_lock ($this->dn, $this->ui->dn);
153                                 $smarty->assign("warning", sprintf(_("You're about to delete all information about the FAI class at '%s'."), LDAP::fix($this->dn)));
154                                 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
155                         } else {
157                                 /* Obviously the user isn't allowed to delete. Show message and
158                                    clean session. */
159                                 print_red (_("You are not allowed to delete this component!"));
160                         }
161                 }
164     /****************
165       Delete aborted  
166      ****************/
168                 /* Delete canceled? */
169                 if (isset($_POST['delete_cancel'])){
170                         del_lock ($this->dn);
171                 }
174     /****************
175       Delete confirmed 
176      ****************/
178                 /* Deltetion was confirmed, so delete this entry
179                  */
180                 if (isset($_POST['delete_terminal_confirm'])){
182                         /* Some nice guy may send this as POST, so we've to check
183                            for the permissions again. */
184                         if (chkacl($this->acl, "delete") == ""){
186                                 /* Find out more about the object type */
187                                 $ldap     = $this->config->get_ldap_link();
188                                 $ldap->cat($this->dn, array('objectClass'));
189                                 $attrs  = $ldap->fetch();
190                                 $type     = $this->get_type($attrs);                    
191                                 $this->dialog = new $type[0]($this->config,     $this->config->data['TABS'][$type[2]], $this->dn);
192                                 $this->dialog->set_acl(array($this->acl));
194                                 $this->dialog->by_object[$type[1]]->remove_from_parent ();
195                                 unset ($this->dialog);
196                                 gosa_log ("FAI class '".$this->dn."' has been removed");
197                                 $this->dialog= NULL;
198                         } else {
200                                 /* Normally this shouldn't be reached, send some extra
201                                    logs to notify the administrator */
202                                 print_red (_("You are not allowed to delete this component!"));
203                                 gosa_log ("Warning: '".$this->ui->uid."' tried to trick system ".
204                                                 "deletion.");
205                         }
207                         /* Remove lock file after successfull deletion */
208                         del_lock ($this->dn);
209                 }
212     /****************
213       Edit entry 
214      ****************/
216                 if(($s_action == "edit") && (!isset($this->dialog->config))){
217                         $entry    = $this->objects[$s_entry];
218                         $a_setup  = $this->get_type($entry);
219                         $this->dn = $entry['dn'];
221                         /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
222                         if (($user= get_lock($this->dn)) != ""){
223                                 return(gen_locked_message ($user, $this->dn));
224                         }
225                         add_lock ($this->dn, $this->ui->dn);
227                         $this->dialog     = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn);
228                         $this->is_dialog  = true;
230       if($entry['FAIstate'] == "freeze"){
231         $this->dialog->set_acl(array("*none*"))  ;
232       }
233                         $_SESSION['objectinfo'] = $this->dn;
234                 }
237     /*  Branch handling 
238         09.01.2006
239     */
241     /****************
242       Remove branch
243      ****************/
245     /* Remove branch 
246      */
247     if($s_action == "remove_branch"){
248       $base= $this->DivListFai->selectedBranch;
250       /* Load permissions for selected 'dn' and check if
251          we're allowed to remove this 'dn' */
252       $acl= get_permissions ($this->DivListFai->selectedBase, $this->ui->subtreeACL);
253       $this->acl= get_module_permission($acl, "FAIclass", $base);
254       if (chkacl($this->acl, "delete") == ""){
255         $smarty->assign("info", sprintf(_("You're about to delete a fai branch / freeze  '%s'."), $this->DivListFai->selectedBranch));
256         return($smarty->fetch(get_template_path('remove_branch.tpl',TRUE)));
257       } else {
258         print_red (_("You are not allowed to delete this release!"));
259       }
260     }
262     
263     /****************
264       Remove branch confirmed
265      ****************/
267     if(isset($_POST['delete_branch_confirm'])){
268       $bb =  $this->DivListFai->selectedBranch;
269       if(!isset($ldap)){
270         $ldap = $this->config->get_ldap_link();
271       }
273       $br = $this->getBranches();
275       if(isset($br[$bb])){
276         $name = $br[$bb];
277         $ldap->cd($bb);
278         $ldap->recursive_remove();
279         $ldap->cd(preg_replace('/,ou=fai,ou=configs,ou=systems,/', ',ou=apps,', $bb));
280         $ldap->recursive_remove();
281         $this->DivListFai->selectedBranch = "main";
283         /* Post remove */
284         $this->lock_name   = $name;
285         $this->lock_dn     = $bb;
286         $this->postremove();
287       }
288     }
291     /****************
292       Create a new branch "insert Name"
293      ****************/
295     if((isset($_POST['UseBranchName']))&&(($this->dispNewBranch)||($this->dispNewFreeze))){
296       $_SESSION['LASTPOST'] = $_POST;
298       if($this->dispNewBranch){
299         $type = "branch";
300       }else{
301         $type = "freeze";
302       }
304       /* Check branch name */
305       $name = $_POST['BranchName'];
306       $is_ok = true;
307       $smarty->assign("BranchName",$name);
308       $base= "ou=fai,ou=configs,ou=systems,".$this->DivListFai->selectedBase;
310       /* Check used characters */
311       if(preg_match("/[^0-9a-z \ö\ä\ü\.-_:,]/i",$name)){
312         if($type == "branch"){
313           print_red(_("Specified branch name is invalid."));
314         }else{
315           print_red(_("Specified freeze name is invalid."));
316         }
317         $is_ok = false;
318       }
320       /* Check if this name is already in use */
321       if(!$this->CheckNewBranchName($_POST['BranchName'],$this->DivListFai->selectedBranch)){
322         print_red(_("This name is already in use."));
323         $is_ok = false;
324       }
326       if($is_ok){
327         $_SESSION['LASTPOST']['base'] = $base;
328         $_SESSION['LASTPOST']['type'] = $type;
329         $smarty->assign("iframe", true);
330         $smarty->assign("plugID", $_GET['plug']);
331         $display        = $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
332         return($display);
333       }
334     }
337     /****************
338       Create a new branch 
339      ****************/
341     if(isset($_GET['PerformBranch'])){
342       /* Create it know */
343       $this->dispNewBranch = false;
344       $this->dispNewFreeze = false;
345       $base = $_SESSION['LASTPOST']['base'];
346       $_POST = $_SESSION['LASTPOST'];      
347       $name = $_POST['BranchName'];
349       $type = $_SESSION['LASTPOST']['type'];
350       $ldap = $this->config->get_ldap_link();
352       $baseToUse = $base;
353       if($this->DivListFai->selectedBranch != "main" ){
354         $baseToUse = $this->DivListFai->selectedBranch;
355       }
356   
357       /* Create new Release name to be able to set faidebianRelease for FAIpackageList */
358       
359       $CurrentReleases  = $this->getBranches();
360       $NewReleaseName   = $name;
361       if(isset($CurrentReleases[$this->DivListFai->selectedBranch])) {
362         if($this->DivListFai->selectedBranch != "main"){
363           $NewReleaseName = $CurrentReleases[$this->DivListFai->selectedBranch]."/".$name;
364           $NewReleaseName = preg_replace("#\/#","/",$NewReleaseName); 
365         }else{
366           $NewReleaseName   = $name;
367         }
368       }
370       $appsrc = preg_replace("/ou=fai,ou=configs,ou=systems,/","ou=apps,",$baseToUse); 
371       $appdst = preg_replace("/ou=fai,ou=configs,ou=systems,/","ou=apps,","ou=".$name.",".$baseToUse) ; 
373       /* Print header to have styles included */
374       echo "<!-- headers.tpl-->".$smarty->fetch(get_template_path('headers.tpl'));
375       echo "<body style='background-image:none;margin:3px;color:black'>";
377       /* Duplicate applications 
378        */
379       $ldap->cd ($appdst);
380       $ldap->recursive_remove();
381       $ldap->cd ($this->config->current['BASE']);
382       $ldap->copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true);
384       /* Duplicate fai objects 
385        */
386       $ldap->cd ("ou=".$name.",".$baseToUse);
387       $ldap->recursive_remove();
388       $ldap->cd ($this->config->current['BASE']);
389       $ldap->copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,$NewReleaseName,$type,true);
391       echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
392               <br><input type='submit' name='CloseIFrame' value='"._("Continue")."'>
393             </form></div>";
395       /* Print footer to have valid html */
396       echo "</body></html>";
398       $this->dispNewFreeze = false; 
400       /* Postcreate */ 
402       /* Assign possible attributes */
403       $this->lock_type  = $type; 
404       $this->lock_name  = $name; 
405       $this->lock_dn    = $baseToUse;
406       $this->postcreate();
407       exit();
408     }
411     /****************
412       Display dialog to enter new Branch name
413      ****************/
415     if(($s_action == "branch_branch")||($this->dispNewBranch)){
416       $this->dispNewBranch=true;
417       $smarty->assign("iframe",false);
418                   $display      .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
419       return($display);
420     }
421    
422  
423     /****************
424       Display dialog to enter new Freeze name
425      ****************/
427     if(($s_action == "freeze_branch")||($this->dispNewFreeze)){
428       $this->dispNewFreeze = true;
429       $smarty->assign("iframe",false);
430                   $display      .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
431       return($display);
432     }
435     /****************
436       Create a new object 
437      ****************/
439     $types = array( "new_partition"     =>  "FAIpartitionTable",
440                     "new_script"        =>  "FAIscript",
441                     "new_hook"          =>  "FAIhook",
442                     "new_variable"      =>  "FAIvariable",
443                     "new_template"      =>  "FAItemplate",
444                     "new_package"       =>  "FAIpackageList");
446     if(isset($types[$s_action])){
447       $this->dialog = new askClassName($this->config,$this->dn,$this->ui,$types[$s_action]);
448     }
450     /* New Profile */
451     if($s_action == "new_profile"){
452       $this->dn = "new" ;
453       $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
455       $this->dialog = new $a_setup[0]($this->config,
456           $this->config->data['TABS'][$a_setup[2]],$this->dn);
457       $this->is_dialog = true;
458     }
461     /****************
462       Get from ask class name dialog 
463      ****************/
465     if($s_action == "select_class_name_finished"){
466       $this->dialog->save_object();
467       if(count($this->dialog->check())!=0){
468         foreach($this->dialog->check() as $msg){
469           print_red($msg);
470         }               
471       }else{
472         $this->dn = "new" ;
473         $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
474         $name = $this->dialog->save();
476         $this->dialog = new $a_setup[0]($this->config,
477             $this->config->data['TABS'][$a_setup[2]],$this->dn,$name);
478         $this->dialog->by_object[$a_setup[1]]->cn = $name;
479         $this->is_dialog = true;
480       }         
481     }   
484     /****************
485      Cancel dialogs 
486      ****************/
488                 if(isset($_POST['edit_cancel'])){
489                         unset($this->dialog);
490                         $this->dialog=NULL;
491                         $this->is_dialog = false;
492                         unset($_SESSION['objectinfo']);
493                         del_lock ($this->dn);
494                 }
497     /****************
498       Save sub dialogs 
499      ****************/
501                 /* This check if the given tab could be saved 
502                  * If it was possible to save it, remove dialog object. 
503                  * If it wasn't possible, show errors and keep dialog.
504                  */
505                 if((isset($_POST['edit_finish'])) && (isset($this->dialog->config))){
506                         $this->dialog->save_object();
507                         if(count($this->dialog->check())!=0){
508                                 foreach($this->dialog->check() as $msg){
509                                         print_red($msg);
510                                 }
511                         }else{
512                                 del_lock ($this->dn);
513                                 $this->dialog->save();
514                                 unset($this->dialog);
515                                 $this->dialog=NULL;
516                                 $this->is_dialog=false;
517                                 unset($_SESSION['objectinfo']);
518                         }
519                 }
522     /****************
523       Display currently open dialog 
524      ****************/
526                 /* If dialog is set, but $this->is_dialog==false, then 
527                  *  only the "abort" button is shown, this are dialogs that must not be saved.  
528                  * If is_dialog == true, we are currently editing tab objects.
529                  *  Here we need both, save and cancel
530                  */ 
532                 if(($this->dialog != NULL) && (isset($this->dialog->config))){
533                         $display .= $this->dialog->execute();
534                         /* Don't show buttons if tab dialog requests this */
535                         if (((isset($this->dialog->current))&&($this->dialog->by_object[$this->dialog->current]->is_dialog))){
536                                 
537                         }elseif(((isset($this->dialog->current))&&(!$this->dialog->by_object[$this->dialog->current]->is_dialog))){
538                                 $display.= "<p style=\"text-align:right\">\n";
539                                 $display.= "<input type=\"submit\" name=\"edit_finish\" value=\""._("Save")."\">\n";
540                                 $display.= "&nbsp;\n";
541                                 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
542                                 $display.= "</p>";
543                         }elseif(!isset($this->dialog->current)){
544                                 $display.= "<p style=\"text-align:right\">\n";
545                                 $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\">&nbsp;";
546                                 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
547                                 $display.= "</p>";
548                         }
549                         return($display);
550                 }
551                 
553     /****************
554       Dialog display
555      ****************/
557     /* Display dialog with system list */
558     $this->DivListFai->parent = $this;
559     $this->DivListFai->execute();
560     $this->DivListFai->AddDepartments($this->DivListFai->selectedBase,4);
561     $this->reload();
562     $this->DivListFai->setEntries($this->objects);
563     return($this->DivListFai->Draw());
564         }
567   /* Get available branches for current base */
568   function getBranches($base = false,$prefix = "")
569   {
570     $ret = array("main"=>"/");
571     $ldap = $this->config->get_ldap_link();
572     if(!$base){
573       $base= "ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase'];
574     }
575     $ldap->ls("(objectClass=FAIbranch)",$base);
576     while($attrs = $ldap->fetch()){
577       if((isset($attrs['ou']))&&($attrs['dn']!=$base)){
578         $ret[$attrs['dn']]= $prefix.$attrs['ou'][0];
579         $ret = array_merge($ret,$this->getBranches($attrs['dn'],"".$prefix.$attrs['ou'][0]."/"));
580       }
581     }
583     return ($ret);
584   }
586   
587   /* reload list of objects */
588         function reload()
589         {
590     /* Create a new list of FAI object 
591      * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ... 
592      */
593     $ObjectTypes = array(
594         "FAIpartitionTable"  => array("OU"=>"ou=disks,"       , "CHKBOX"=>"ShowPartitions"),
595         "FAIpackageList"     => array("OU"=>"ou=packages,"    , "CHKBOX"=>"ShowPackages"),
596         "FAIscript"          => array("OU"=>"ou=scripts,"     , "CHKBOX"=>"ShowScripts"),
597         "FAIvariable"        => array("OU"=>"ou=variables,"   , "CHKBOX"=>"ShowVariables"),
598         "FAIhook"            => array("OU"=>"ou=hooks,"       , "CHKBOX"=>"ShowHooks"),
599         "FAIprofile"         => array("OU"=>"ou=profiles,"    , "CHKBOX"=>"ShowProfiles"),
600         "FAItemplate"        => array("OU"=>"ou=templates,"   , "CHKBOX"=>"ShowTemplates"));
602     /* Set base for all searches */
603     $base           = "ou=fai,ou=configs,ou=systems,".$this->DivListFai->selectedBase;
604     if($this->DivListFai->selectedBranch != "main"){
605       $br = $this->getBranches();
606       if(isset($br[$this->DivListFai->selectedBranch])){
607         $base = $this->DivListFai->selectedBranch;
608       }else{
609         $base = "ou=fai,ou=configs,ou=systems,".$this->DivListFai->selectedBase;
610       }
611     }
613     $Regex          = $this->DivListFai->Regex;
614     $str            = "";
615     $objects        = array();
616     $this->objects  = array();
618     /* Walk through possible sub departments and fetch all FAI objects */
619                 foreach($ObjectTypes as $type => $obj){
621       /* Skip all unchecked types */
622       if(! $this->DivListFai->$obj['CHKBOX']){
623         continue;
624       }
626       /* Fetch objects from fai sub department */
627       $res= get_list("(&(objectClass=".$type.")(cn=$Regex))", $this->ui->subtreeACL, $obj['OU'].$base,
628             array("cn","description","objectClass","FAIclass","FAIstate"), GL_SIZELIMIT);
630       /* Walk through objects */
631                         foreach($res as $object){
633         /* Prepare object */
634                                 unset($object['objectClass']['count']);
635                                 if(!isset($object['description'][0])){
636                                         $object['description'][0]="";
637                                 }
638                                 
639                                 /* Clean up object informations */
640                                 $obj['cn']                            = $object['cn'][0];
641                                 $obj['dn']                            = $object['dn'];
642                                 $obj['description']   = $object['description'][0];
643                                 $obj['objectClass']   = $object['objectClass'];
645         /* Append type to this string, to be able to check if the selected 
646          * entry is of type 'freeze' or 'branch'
647          */
648         if(isset($object['FAIstate'])){
649           $obj['FAIstate'] = $object['FAIstate'][0];
650           $str.="|".$obj['FAIstate'];
651         }else{
652           $obj['FAIstate'] ="";
653         }
654                                 $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj;
655                                 $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type;
656                         }
657                 }
659     /* Tell class what we have currently opened 
660         'main' has type '' */
661     if(preg_match("/freeze/",$str)){
662       $this->lock_type = "freeze";
663     }elseif(preg_match("/branch/",$str)){
664       $this->lock_type = "branch";
665     }else{
666       $this->lock_type = "";
667     }
669                 ksort($this->objects);
670                 reset ($this->objects);
671         
672                 /* use numeric index, thats a bit more secure */        
673                 $tmp0 = array();
674                 foreach($this->objects as $obj){
675                         $tmp0[]= $obj;
676                 }
677                 $this->objects = array();
678                 $this->objects = $tmp0;
679         }
681         function remove_lock()
682         {
683                 if (isset($this->dn)){
684                         del_lock ($this->dn);
685                 }
686         }
688         function get_type($array){
689                 if(in_array("FAIpartitionTable",$array['objectClass'])){
690                         return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS"));
691                 }
692                 if(in_array("FAIscript",$array['objectClass'])){
693                         return(array("tabsScript","faiScript","FAISCRIPTTABS"));
694                 }
695                 if(in_array("FAItemplate",$array['objectClass'])){
696                         return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS"));
697                 }
698                 if(in_array("FAIhook",$array['objectClass'])){
699                         return(array("tabsHook","faiHook","FAIHOOKTABS"));
700                 }
701                 if(in_array("FAIvariable",$array['objectClass'])){
702                         return(array("tabsVariable","faiVariable","FAIVARIABLETABS"));
703                 }
704                 if(in_array("FAIprofile",$array['objectClass'])){
705                         return(array("tabsProfile","faiProfile","FAIPROFILETABS"));
706                 }
707                 
708                 if(in_array("FAIpackageList",$array['objectClass'])){
709                         return(array("tabsPackage","faiPackage","FAIPACKAGETABS"));
710                 }
711         }
713   function CheckNewBranchName($name,$base)
714   {
715     $f = $this->DivListFai->selectedBranch;
716     if(empty($name)){
717       return(false);
718     }elseif(in_array($name,$this->getBranches($f))) {
719       return(false);
720     }elseif(empty($name)){
721       return(false);
722     }elseif(is_department_name_reserved($name,$base)){
723       return(false);
724     }
725     return(true);
726   }
728   function save_object()
729   {
730     $this->DivListFai->save_object();
731   }
734 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
735 ?>