Code

Second FAI list rebuild
[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";
36   var $fai_release = ""; // The currently selected release while in release management mode!
38   function __construct($config,$ui)
39   {
40     $this->config = $config;
41     $this->ui = $ui;
43     $this->storagePoints = array(
44         get_ou('faiPartitionRDN'),
45         get_ou('faiPackageRDN'),
46         get_ou('faiScriptRDN'),
47         get_ou('faiVariableRDN'),
48         get_ou('faiHookRDN'),
49         get_ou('faiProfileRDN'),get_ou('faiTemplateRDN'));
50  
51     // Build filter
52 #    if (session::global_is_set(get_class($this)."_filter")){
53  #     $filter= session::global_get(get_class($this)."_filter");
54   #  } else {
55       $filter = new filter(get_template_path("fai-filter.xml", true));
56       $filter->setObjectStorage($this->storagePoints);
57    # }
58     $this->setFilter($filter);
60     // Build headpage
61     $headpage = new listing(get_template_path("fai-list.xml", true));
62     $headpage->setFilter($filter);
63     $headpage->registerElementFilter("filterProperties", "faiManagement::filterProperties");
65     // Add copy&paste and snapshot handler.
66     if ($this->config->boolValueIsTrue("main", "copyPaste")){
67       $this->cpHandler = new CopyPasteHandler($this->config);
68     }
69     if($this->config->get_cfg_value("enableSnapshots") == "true"){
70       $this->snapHandler = new SnapshotHandler($this->config);
71     }
72     parent::__construct($config, $ui, "roles", $headpage);
73   }
75   function renderList()
76   {
77     $filter = $this->getFilter();
78     $headpage = $this->getHeadpage();
79     $filter->setComboBoxOptions("RELEASE",$this->getReleaseList());
81     if(isset($_POST['RELEASE'])){
82       $this->fai_release = get_post('RELEASE');
83     }
84     $headpage->setBase($this->fai_release);
85     $headpage->update();
86     $display = $headpage->render();
87     return($this->getHeader().$display);
88   }
90   function getReleaseList($base = "", $prefix ="")
91   {
92     $list = array();
93     if(empty($base)){
94       $base = get_ou('faiBaseRDN').$this->config->current['BASE'];
95       $list[$base] = "/";
96     }
98     $ldap = $this->config->get_ldap_link();
99     $ldap->ls("(objectClass=FAIbranch)",$base,array("ou","FAIstate"));
100     $cfg_rel = $this->config->search("faiManagement","DEFAULTFAIRELEASE",array("menu"));
102     while($release = $ldap->fetch()){
103       $list[$release['dn']] = $prefix.$release['ou'][0];
105       // Preset to prefered releaes if necessary  
106       if(empty($this->fai_release) && $cfg_rel == $release['dn']){
107         $this->fai_release = $release['dn'];
108       }
110       $list = array_merge($list,$this->getReleaseList($release['dn'],$prefix."&nbsp; "));
111     }
112     return($list);
113   }
116   static function filterProperties($row, $classes)
117   {
118     $objects = array(
119         "FAIpartitionTable"  => array("IMG"=> "plugins/fai/images/fai_partitionTable.png",
120           "NAME"=>_("Partition table"),"KZL"=> "PT", "VAR"=>"ShowPartitions"),
121         "FAIpackageList"     => array("IMG"=> "plugins/fai/images/fai_packages.png",
122           "NAME"=>_("Package list") ,  "KZL"=> "PL", "VAR"=>"ShowPackages"),
123         "FAIscript"          => array("IMG"=> "plugins/fai/images/fai_script.png",
124           "NAME"=>_("Scripts") ,       "KZL"=> "S",  "VAR"=>"ShowScripts"),
125         "FAIvariable"        => array("IMG"=> "plugins/fai/images/fai_variable.png",
126           "NAME"=>_("Variables") ,     "KZL"=> "V",  "VAR"=>"ShowVariables"),
127         "FAIhook"            => array("IMG"=> "plugins/fai/images/fai_hook.png",
128           "NAME"=>_("Hooks"),          "KZL"=> "H",  "VAR"=>"ShowHooks"),
129         "FAIprofile"         => array("IMG"=> "plugins/fai/images/fai_profile.png",
130           "NAME"=>_("Profile") ,       "KZL"=> "P",  "VAR"=>"ShowProfiles"),
131         "FAItemplate"        => array("IMG"=> "plugins/fai/images/fai_template.png",
132           "NAME"=>_("Templates") ,     "KZL"=> "T",  "VAR"=>"ShowTemplates"),
133         "opsi_netboot"       => array("IMG"=> "plugins/opsi/images/netboot_package.png",
134           "NAME"=>_("OPSI netboot product") ,     "KZL"=> "ON",  "VAR"=>"ShowOpsiNetboot"),
135         "opsi_local"         => array("IMG"=> "plugins/opsi/images/local_package.png",
136           "NAME"=>_("OPSI localboot product")   ,     "KZL"=> "OL",  "VAR"=>"ShowOpsiLocal"));
138     $icon_list = "";
139     foreach($objects as $type => $type_data){
140       if(in_array($type, $classes)){
141         $icon_list .= "<input type='image' src='".$type_data['IMG']."' title='".$type_data['NAME']."'
142           alt='".$type_data['KZL']."' class='center' name='edit_".$row."_".$type."'>\n";
143       }else{
144         $icon_list .= "<img src='images/empty.png' alt=' ' class='center'>\n";
145       }
146     }
148     return $icon_list;
149   }
152
153 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
154 ?>