Code

c918b423594bfdb3743b2a01ab36dd5647b36127
[gosa.git] / gosa-plugins / fai / admin / fai / class_faiManagement.inc
1 <?php
2 /*
3  * This code is part of GOsa (http://www.gosa-project.org)
4  * Copyright (C) 2003-2008 GONICUS GmbH
5  *
6  * ID: $$Id: class_roleManagement.inc 14742 2009-11-04 13:18:33Z hickert $$
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
23 class faiManagement extends management
24 {
25   var $plHeadline     = "Software deployment";
26   var $plDescription  = "Manage software packages and deployment reciepes";
27   var $plIcon  = "plugins/fai/images/plugin.png";
29   // Tab definition 
30   protected $tabClass = "roletabs";
31   protected $tabType = "ROLETABS";
32   protected $aclCategory = "roles";
33   protected $aclPlugin   = "role";
34   protected $objectName   = "role";
37   var $dispNewBranch=false;
38   var $dispNewFreeze=false;
40   var $fai_release = ""; // The currently selected release while in release management mode!
41   var $fai_base = ""; 
42   var $acl_base = ""; 
44   function __construct($config,$ui)
45   {
46     $this->config = $config;
47     $this->fai_base = get_ou("faiBaseRDN").$this->config->current['BASE'];
48     $this->fai_release = $this->fai_base;
49     $this->acl_base = $this->config->current['BASE'];
50     $this->ui = $ui;
51     $this->storagePoints = array(
52         get_ou('faiPartitionRDN'),
53         get_ou('faiPackageRDN'),
54         get_ou('faiScriptRDN'),
55         get_ou('faiVariableRDN'),
56         get_ou('faiHookRDN'),
57         get_ou('faiProfileRDN'),get_ou('faiTemplateRDN'));
59 #    // Build filter
60 #    if (session::global_is_set(get_class($this)."_filter")){
61 #      $filter= session::global_get(get_class($this)."_filter");
62 #    } else {
63       $filter = new filter(get_template_path("fai-filter.xml", true));
64       $filter->setObjectStorage($this->storagePoints);
65 #    }
66     $this->setFilter($filter);
68     // Build headpage
69     $headpage = new listing(get_template_path("fai-list.xml", true));
70     $headpage->setFilter($filter);
71     $headpage->setBase($this->fai_release);
72     $headpage->registerElementFilter("filterProperties", "faiManagement::filterProperties");
74     // Add copy&paste and snapshot handler.
75     if ($this->config->boolValueIsTrue("main", "copyPaste")){
76       $this->cpHandler = new CopyPasteHandler($this->config);
77     }
78     if($this->config->get_cfg_value("enableSnapshots") == "true"){
79       $this->snapHandler = new SnapshotHandler($this->config);
80     }
81     $this->registerAction("editByGroup","editByGroup");
82     $this->registerAction("createBranch","createBranch");
83     $this->registerAction("createFreeze","createFreeze");
84     $this->registerAction("removeBranch","removeBranch");
85     $this->registerAction("saveBranch","saveBranch");
86     $this->registerAction("PerformBranch","PerformBranch");
87     parent::__construct($config, $ui, "roles", $headpage);
88   }
91   function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
92   {
93     $headpage = $this->getHeadpage();
94     if(count($target) == 1){
95       $entry = $headpage->getEntry($target[0]);
96       if($entry){
97         if(count($entry['GROUPS']) == 1){
98           $data = array_pop($entry['GROUPS']);
99           $type = $this->get_type($data);
100           management::editEntry('editEntry',array($data['dn']),array(),$type[0],$type[2],$type[1]);
101         }else{
102           $this->dialogObject = new faiGroupHandle($entry['GROUPS'],"edit");
103         }
104       }
105     }
106   }
109   function removeEntryRequested($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
110   {
111     $headpage = $this->getHeadpage();
112     if(count($target) == 1){
113       $entry = $headpage->getEntry($target[0]);
114       if($entry){
115         $this->dialogObject = new faiGroupHandle($entry['GROUPS'],"remove");
116       }
117     }
118   }
120   /*! \brief  Object removal was confirmed, now remove the requested entries.
121    *
122    *  @param  String  'action'  The name of the action which was the used as trigger.
123    *  @param  Array   'target'  A list of object dns, which should be affected by this method.
124    *  @param  Array   'all'     A combination of both 'action' and 'target'.
125    */
126   function removeEntryConfirmed($action="",$target=array(),$all=array(),
127       $altTabClass="",$altTabType="",$altAclCategory="")
128   {
129     $ldap = $this->config->get_ldap_link();
130     $ldap->cd($this->config->current['BASE']);  
131     foreach($this->dns as $key => $dn){
132       $ldap->cat($dn);
133       if($ldap->count()){
134         $attrs = $ldap->fetch();
135         $type= $this->get_type($attrs);
136         management::removeEntryConfirmed($action,array($dn),$all,$type[0],$type[2],$type[1]);
138         // Now save changes
139         FAI::save_release_changes_now();
140         $to_del = FAI::clean_up_releases($dn);
141         foreach($to_del as $dn){
142           $ldap->rmdir_recursive($dn);
143         }
144       }
145     }
146   }
149   function editByGroup()
150   {
151     if($this->dialogObject instanceOf faiGroupHandle && $this->dialogObject->get_mode() == "edit"){
152       $this->dialogObject->save_object();
153       $entry = $this->dialogObject->get_selected();
154       $this->closeDialogs();
155       $data = array_pop($entry);
156       $type = $this->get_type($data);
157       management::editEntry('editEntry',array($data['dn']),array(),$type[0],$type[2],$type[1]);
158     }elseif($this->dialogObject instanceOf faiGroupHandle && $this->dialogObject->get_mode() == "remove"){
159       $this->dialogObject->save_object();
160       $to_delete = $entry = $this->dialogObject->get_selected();
161       $dns = array();
164       // Check FAIstate to ensure that we do not remove frozen objects
165       //  additionally check ACLs
166       $locked = array();
167       $disallowed = array();
168       foreach($to_delete as $obj){
169         if(isset($obj['FAIstate']) && preg_match('/^freeze/', $obj['FAIstate'])){
170           $locked[] = $obj['dn'];
171         }else{
172           $type = $this->get_type($obj);
173           $acl = $this->ui->get_permissions($obj['dn'], 'acl/'.$type[1]);
174           if(!preg_match("/d/",$acl)){
175             $disallowed[] = $obj['dn']; 
176           }else{
177             $dns[] = $obj['dn'];
178           }
179         }
180       }
182       // Display info dialog about locked and not removeable entries
183       if(count($locked)){
184         msg_dialog::display(_("Branch locked"),sprintf(_("The following entries are locked, you can't remove them %s."),
185             msgPool::buildList($locked)));
186       }
188       // Display info dialog about not removeable entries due to permissions
189       if(count($disallowed)){
190         msg_dialog::display(_("Permission"),msgPool::permDelete($disallowed),INFO_DIALOG);
191       }
193       // There are entries left to be removed
194       if(count($dns)){  
195         $this->closeDialogs();
196         $this->dns = $dns;
198         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$target,"Entry removel requested!");
200         // check locks
201         if ($user= get_multiple_locks($this->dns)){
202           return(gen_locked_message($user,$this->dns));
203         }
205         // Add locks
206         $dns_names = array();
207         foreach($this->dns as $dn){
208           $dns_names[] =LDAP::fix($dn);
209         }
210         add_lock ($this->dns, $this->ui->dn);
212         // Display confirmation dialog.
213         $smarty = get_smarty();
214         $smarty->assign("info", msgPool::deleteInfo($dns_names,_($this->objectName)));
215         $smarty->assign("multiple", true);
216         return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
217       }else{
218         $this->closeDialogs();
219       }
220     }
221   }
223   
224   protected function saveChanges()
225   {
226     management::saveChanges();
228     // Now save changes
229     FAI::save_release_changes_now();
230     $to_del = FAI::clean_up_releases($this->last_dn);
231     foreach($to_del as $dn){
232       $ldap->rmdir_recursive($dn);
233     }
234   }
236   protected function applyChanges()
237   {
238     management::applyChanges();
240     // Now save changes
241     FAI::save_release_changes_now();
242     $to_del = FAI::clean_up_releases($this->last_dn);
243     foreach($to_del as $dn){
244       $ldap->rmdir_recursive($dn);
245     }
246   }
248   function detectPostActions()
249   {
250     $action = management::detectPostActions();
251     if(isset($_POST['faiGroupHandle_cancel'])) $action['action'] = "cancel";
252     if(isset($_POST['CancelBranchName'])) $action['action'] = "cancel";
253     if(isset($_GET['PerformBranch'])) $action['action'] = "PerformBranch";
254     if(isset($_POST['UseBranchName'])) $action['action'] = "saveBranch";
255     if(isset($_POST['faiGroupHandle_apply']))  $action['action'] = "editByGroup";
256     if(isset($_GET['act']) && $_GET['act'] == "branch_branch")  $action['action'] = "createBranch";
257     if(isset($_GET['act']) && $_GET['act'] == "freeze_branch")  $action['action'] = "createFreeze";
258     if(isset($_GET['act']) && $_GET['act'] == "remove_branch")  $action['action'] = "removeBranch";
260     foreach($_POST as $name => $value){
261       if(preg_match("/^edit_([0-9]*)_([a-z]*)_(x|y)/i", $name)){
262         $id = preg_replace("/^edit_([0-9]*)_([a-z]*)_(x|y)/i","\\1", $name);
263         $tab = preg_replace("/^edit_([0-9]*)_([a-z]*)_(x|y)/i","\\2", $name);
264         $headpage = $this->getHeadpage();
265         if(isset($headpage->entries[$id]['GROUPS'][$tab])){
266           $data =$headpage->entries[$id]['GROUPS'][$tab];
267           $type = $this->get_type($data);
268           management::editEntry('editEntry',array($data['dn']),array(),$type[0],$type[2],$type[1]); 
269         } 
270         break;
271       }
272     }
273     return($action);
274   }
277   function renderList()
278   {
279     $filter = $this->getFilter();
280     $headpage = $this->getHeadpage();
281     $filter->setComboBoxOptions("RELEASE",$this->getReleaseList());
283     if(isset($_POST['RELEASE'])){
284       $this->fai_release = get_post('RELEASE');
285     }
286     $headpage->setBase($this->fai_release);
287     $headpage->update();
288     $smarty = get_smarty();
289     $smarty->assign("fai_release", $this->fai_release);
290     $smarty->assign("fai_base", $this->fai_base);
291     $r = $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'));
292     $c = $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'));
293     $smarty->assign("allow_create", $c);
294     $smarty->assign("allow_remove", $r);
295     $display = $headpage->render();
296     return($this->getHeader().$display);
297   }
299   function getReleaseList($base = "", $prefix ="")
300   {
301     $list = array();
302     if(empty($base)){
303       $base = $this->fai_base;
304       $list[$base] = "/";
305     }
307     $ldap = $this->config->get_ldap_link();
308     $ldap->ls("(objectClass=FAIbranch)",$base,array("ou","FAIstate"));
309     $cfg_rel = $this->config->search("faiManagement","DEFAULTFAIRELEASE",array("menu"));
311     while($release = $ldap->fetch()){
312       $list[$release['dn']] = $prefix.$release['ou'][0];
314       // Preset to prefered releaes if necessary  
315       if(empty($this->fai_release) && $cfg_rel == $release['dn']){
316         $this->fai_release = $release['dn'];
317       }
319       $list = array_merge($list,$this->getReleaseList($release['dn'],$prefix."&nbsp; "));
320     }
321     return($list);
322   }
325   static function filterProperties($row, $classes)
326   {
327     $objects = array(
328         "FAIpartitionTable"  => array("IMG"=> "plugins/fai/images/fai_partitionTable.png",
329           "NAME"=>_("Partition table"),"KZL"=> "PT", "VAR"=>"ShowPartitions"),
330         "FAIpackageList"     => array("IMG"=> "plugins/fai/images/fai_packages.png",
331           "NAME"=>_("Package list") ,  "KZL"=> "PL", "VAR"=>"ShowPackages"),
332         "FAIscript"          => array("IMG"=> "plugins/fai/images/fai_script.png",
333           "NAME"=>_("Scripts") ,       "KZL"=> "S",  "VAR"=>"ShowScripts"),
334         "FAIvariable"        => array("IMG"=> "plugins/fai/images/fai_variable.png",
335           "NAME"=>_("Variables") ,     "KZL"=> "V",  "VAR"=>"ShowVariables"),
336         "FAIhook"            => array("IMG"=> "plugins/fai/images/fai_hook.png",
337           "NAME"=>_("Hooks"),          "KZL"=> "H",  "VAR"=>"ShowHooks"),
338         "FAIprofile"         => array("IMG"=> "plugins/fai/images/fai_profile.png",
339           "NAME"=>_("Profile") ,       "KZL"=> "P",  "VAR"=>"ShowProfiles"),
340         "FAItemplate"        => array("IMG"=> "plugins/fai/images/fai_template.png",
341           "NAME"=>_("Templates") ,     "KZL"=> "T",  "VAR"=>"ShowTemplates"),
342         "opsi_netboot"       => array("IMG"=> "plugins/opsi/images/netboot_package.png",
343           "NAME"=>_("OPSI netboot product") ,     "KZL"=> "ON",  "VAR"=>"ShowOpsiNetboot"),
344         "opsi_local"         => array("IMG"=> "plugins/opsi/images/local_package.png",
345           "NAME"=>_("OPSI localboot product")   ,     "KZL"=> "OL",  "VAR"=>"ShowOpsiLocal"));
347     $icon_list = "";
348     foreach($objects as $type => $type_data){
349       if(in_array($type, $classes)){
350         $icon_list .= "<input type='image' src='".$type_data['IMG']."' title='".$type_data['NAME']."'
351           alt='".$type_data['KZL']."' class='center' name='edit_".$row."_".$type."'>\n";
352       }else{
353         $icon_list .= "<img src='images/empty.png' alt=' ' class='center'>\n";
354       }
355     }
357     return $icon_list;
358   }
363   function removeBranch()
364   {
366     }
369   function createBranch()
370   { 
371     $smarty = get_smarty();
372     $this->dispNewBranch=true;
373     $smarty->assign("iframe",false);
374     if(isset($_POST['BranchName'])){
375       $smarty->assign("BranchName", $_POST['BranchName']);
376     }else{
377       $smarty->assign("BranchName","");
378     }
379     return($smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__))));
380   }
382   function createFreeze()
383   { 
384     $smarty = get_smarty();
385     $this->dispNewFreeze=true;
386     $smarty->assign("iframe",false);
387     if(isset($_POST['BranchName'])){
388       $smarty->assign("BranchName", $_POST['BranchName']);
389     }else{
390       $smarty->assign("BranchName","");
391     }
392     return($smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__))));
393   }
405   /****************
406     Create a new branch
407    ****************/
409   function PerformBranch()
410   {
411     if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
412       msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
413     }else{
415       /* In order to see error messages we have to reset the error handler.
416          Due to the exit();
417        */
418       restore_error_handler();
420       /* Create it know */
421       $this->dispNewBranch = false;
422       $this->dispNewFreeze = false;
424       $LASTPOST = session::get('LASTPOST');
425       $base = $LASTPOST['base'];
426       $_POST  = session::get('LASTPOST');
427       $name = $_POST['BranchName'];
429       $type = $LASTPOST['type'];
430       $ldap = $this->config->get_ldap_link();
432       $baseToUse = $base;
433       if($this->fai_release !=  $this->fai_base){
434         $baseToUse = $this->fai_release;
435       }
437       /* Create new Release name to be able to set faidebianRelease for FAIpackageList */
439       $CurrentReleases  = $this->getBranches();
440       $NewReleaseName   = $name;
441       if(isset($CurrentReleases[$this->fai_release])) {
442         if($this->fai_release != $this->fai_base){
443           $NewReleaseName = $CurrentReleases[$this->fai_release]."/".$name;
444           $NewReleaseName = preg_replace("#\/#","/",$NewReleaseName);
445         }else{
446           $NewReleaseName   = $name;
447         }
448       }
449       $appsrc = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/i",get_ou('applicationRDN'),$baseToUse);
450       $appdst = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/i",get_ou('applicationRDN'),"ou=".$name.",".$baseToUse) ;
452       $mimesrc = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/i",get_ou('mimetypeRDN'),$baseToUse);
453       $mimedst = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/i",get_ou('mimetypeRDN'),"ou=".$name.",".$baseToUse) ;
455       /* Check if source depeartments exist */
456       foreach(array($baseToUse,$appsrc,$mimesrc) as $dep){
457         $ldap->cd($this->config->current['BASE']);
458         $ldap->cat($dep);
459         if(!$ldap->count()){
460           $ldap->create_missing_trees($dep);
461         }
462       }
464       /* Print header to have styles included */
465       echo '  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
466         <html>
467         <head>
468         <title></title>
469         <style type="text/css">@import url("themes/default/style.css");</style>
470         <script language="javascript" src="include/focus.js" type="text/javascript"></script>
471         </head>
472         <body style="background: none;margin:3px;color:black">
473         ';
475       new log("create","fai/".get_class($this),$NewReleaseName,array(),"New $type created");
477       /* Duplicate group application releases
478        */
479       FAI::copy_FAI_group_releases($CurrentReleases[$this->fai_release],$name,$type);
481       /* Duplicate applications
482        */
483       $ldap->cat($appsrc,array("dn")) ;
484       if($ldap->count()){
485         $ldap->cd ($appdst);
486         $ldap->recursive_remove();
487         FAI::copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true);
488       }
490       /* Duplicate mime types
491        */
492       $ldap->cat($mimesrc,array("dn")) ;
493       if($ldap->count()){
494         $ldap->cd ($mimedst);
495         $ldap->recursive_remove();
496         FAI::copy_FAI_resource_recursive($mimesrc,$mimedst,$NewReleaseName,$type,true);
497       }
499       $attr = array();
500       $attr['objectClass'] = array("organizationalUnit","FAIbranch");
501       $attr['ou']       = $name;
502       $attr['FAIstate'] = $type;
503       $ldap->cd($this->config->current['BASE']);
504       $ldap->cd("ou=".$name.",".$baseToUse);
505       $ldap->cat("ou=".$name.",".$baseToUse);
506       if($ldap->count()){
507         $ldap->modify($attr);
508       }else{
509         $ldap->add($attr);
510       }
512       /* Duplicate fai objects
513        */
514       //      $ldap->cd ("ou=".$name.",".$baseToUse);
515       //      $ldap->recursive_remove();
516       //      FAI::copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,$NewReleaseName,$type,true);
518       echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
519         <br><input type='submit' name='CloseIFrame' value='"._("Continue")."'>
520         <input type='hidden' name='php_c_check' value='1'>
521         </form></div>";
523       echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
525       /* Print footer to have valid html */
526       echo "</body></html>";
528       $this->dispNewFreeze = false;
530       /* Postcreate */
532       /* Assign possible attributes */
533       $this->lock_type  = $type;
534       $this->lock_name  = $name;
535       $this->lock_dn    = $baseToUse;
536       $this->postcreate();
538       /* Send daemon event to reload the fai release database
539        */
540       if(class_available("DaemonEvent") && class_available("gosaSupportDaemon")){
541         $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
542         if(isset($events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'])){
543           $evt = $events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'];
544           $tmp = new $evt['CLASS_NAME']($this->config);
545           $tmp->set_type(TRIGGERED_EVENT);
546           $tmp->add_targets(array("GOSA"));
547           $o_queue = new gosaSupportDaemon();
548           if(!$o_queue->append($tmp)){
549             msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
550           }
551         }
552       }else{
553         trigger_error("Unknown class DaemonEvent / gosaSupportDaemon");
554         msg_dialog::display(_("Fatal error"),
555             "Daemon events called but classes where not accessible, DaemonEvent gosaSupportDaemon",
556             FATAL_ERROR_DIALOG);
557       }
558       exit();
559     }
560   }
565   function saveBranch()
566   {
567     if($this->dispNewBranch){
568       $type = "branch";
569     }else{
570       $type = "freeze";
571     }
573     /* Check branch name */
574     $name = $_POST['BranchName'];
575     $is_ok = true;
576     $smarty = get_smarty();
577     $smarty->assign("BranchName",$name);
578     $base= $this->fai_base;
580     /* Check used characters */
581     if(!preg_match("/^[0-9a-z\.]*$/",$name)){
582       msg_dialog::display(_("Error"), msgPool::invalid(_("Name"),$name,"/[0-9a-z\.]/"), ERROR_DIALOG);
583       $is_ok = false;
584     }
586     // Check if this name is already in use 
587     if(!$this->CheckNewBranchName($_POST['BranchName'],$this->fai_release)){
588       msg_dialog::display(_("Error"), msgPool::duplicated(_("Name")), ERROR_DIALOG);
589       $is_ok = false;
590     }
592     // Handle errors
593     if(!$is_ok && $this->dispNewFreeze){
594       return($this->createFreeze());
595     }elseif(!$is_ok && $this->dispNewBranch){
596       return($this->createBranch());
597     }
599     // Now create new release
601     if(session::is_set('LASTPOST')){
602       $LASTPOST = session::get('LASTPOST');
603     }else{
604       $LASTPOST = array();
605     }
606     $LASTPOST['base'] = $base;
607     $LASTPOST['type'] = $type;
608     $LASTPOST['BranchName'] = $name;
609     session::set('LASTPOST',$LASTPOST);
610     $smarty->assign("iframe", true);
611     $smarty->assign("plugID", $_GET['plug']);
612     $display  = $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
613     return($display);
614  
615   }
618   function CheckNewBranchName($name,$base)
619   {
620     $f = $this->fai_release;
621     if($name == ""){
622       return(false);
623     }elseif(in_array($name,$this->getBranches($f))) {
624       return(false);
625     }elseif(tests::is_department_name_reserved($name,$base)){
626       return(false);
627     }
628     return(true);
629   }
632   /* Get available branches for current base */
633   function getBranches($base = false,$prefix = "")
634   {
635     $ret = array("/"=>$this->fai_base);
636     $ldap = $this->config->get_ldap_link();
637     if(!$base){
638       $base = $this->fai_base;
639     }
640     $tmp = FAI::get_all_releases_from_base($base,true);
641     foreach($tmp as $dn => $name){
642       $ret[$name]=$dn;
643     }
644     ksort($ret);
645     $ret = array_flip($ret);
647     return ($ret);
648   }
651   function get_type($array){
652     if(!isset($array['objectClass'])) return(array());
653     if(in_array("FAIpartitionTable",$array['objectClass'])){
654       return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS"));
655     }
656     if(in_array("FAIscript",$array['objectClass'])){
657       return(array("tabsScript","faiScript","FAISCRIPTTABS"));
658     }
659     if(in_array("FAItemplate",$array['objectClass'])){
660       return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS"));
661     }
662     if(in_array("FAIhook",$array['objectClass'])){
663       return(array("tabsHook","faiHook","FAIHOOKTABS"));
664     }
665     if(in_array("FAIvariable",$array['objectClass'])){
666       return(array("tabsVariable","faiVariable","FAIVARIABLETABS"));
667     }
668     if(in_array("FAIprofile",$array['objectClass'])){
669       return(array("tabsProfile","faiProfile","FAIPROFILETABS"));
670     }
671     if(in_array("FAIpackageList",$array['objectClass'])){
672       return(array("tabsPackage","faiPackage","FAIPACKAGETABS"));
673     }
674     return(array());
675   }
676
677 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
678 ?>