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'));
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 $this->registerAction("editByGroup","editByGroup");
73 parent::__construct($config, $ui, "roles", $headpage);
74 }
78 function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
79 {
80 $headpage = $this->getHeadpage();
81 if(count($target) == 1){
82 $entry = $headpage->getEntry($target[0]);
83 if($entry){
84 echo $target[0];
85 print_a($entry);
86 if(count($entry['GROUPS']) == 1){
87 $data = array_pop($entry['GROUPS']);
88 $type = $this->get_type($data);
89 management::editEntry('editEntry',array($data['dn']),array(),$type[0],$type[2],$type[1]);
90 }else{
91 $this->dialogObject = new faiGroupHandle($entry['GROUPS'],"edit");
92 }
93 }
94 }
95 }
97 function editByGroup()
98 {
99 if($this->dialogObject instanceOf faiGroupHandle && $this->dialogObject->get_mode() == "edit"){
100 $entry = $this->dialogObject->get_selected();
101 $this->editEntryByType(key($entry), array_pop($entry));
102 }
103 }
105 function editEntryByType($type, $data)
106 {
107 $this->closeDialogs();
108 $type = $this->get_type($data);
109 management::editEntry('editEntry',array($data['dn']),array(),$type[0],$type[2],$type[1]);
110 }
112 function detectPostActions()
113 {
114 $action = management::detectPostActions();
115 if(isset($_POST['faiGroupHandle_cancel'])) $action['action'] = "cancel";
116 if(isset($_POST['faiGroupHandle_apply'])) $action['action'] = "editByGroup";
117 return($action);
118 }
121 function renderList()
122 {
123 $filter = $this->getFilter();
124 $headpage = $this->getHeadpage();
125 $filter->setComboBoxOptions("RELEASE",$this->getReleaseList());
127 if(isset($_POST['RELEASE'])){
128 $this->fai_release = get_post('RELEASE');
129 }
130 $headpage->setBase($this->fai_release);
131 $headpage->update();
132 $display = $headpage->render();
133 return($this->getHeader().$display);
134 }
136 function getReleaseList($base = "", $prefix ="")
137 {
138 $list = array();
139 if(empty($base)){
140 $base = get_ou('faiBaseRDN').$this->config->current['BASE'];
141 $list[$base] = "/";
142 }
144 $ldap = $this->config->get_ldap_link();
145 $ldap->ls("(objectClass=FAIbranch)",$base,array("ou","FAIstate"));
146 $cfg_rel = $this->config->search("faiManagement","DEFAULTFAIRELEASE",array("menu"));
148 while($release = $ldap->fetch()){
149 $list[$release['dn']] = $prefix.$release['ou'][0];
151 // Preset to prefered releaes if necessary
152 if(empty($this->fai_release) && $cfg_rel == $release['dn']){
153 $this->fai_release = $release['dn'];
154 }
156 $list = array_merge($list,$this->getReleaseList($release['dn'],$prefix." "));
157 }
158 print_a($_POST);
159 return($list);
160 }
163 static function filterProperties($row, $classes)
164 {
165 $objects = array(
166 "FAIpartitionTable" => array("IMG"=> "plugins/fai/images/fai_partitionTable.png",
167 "NAME"=>_("Partition table"),"KZL"=> "PT", "VAR"=>"ShowPartitions"),
168 "FAIpackageList" => array("IMG"=> "plugins/fai/images/fai_packages.png",
169 "NAME"=>_("Package list") , "KZL"=> "PL", "VAR"=>"ShowPackages"),
170 "FAIscript" => array("IMG"=> "plugins/fai/images/fai_script.png",
171 "NAME"=>_("Scripts") , "KZL"=> "S", "VAR"=>"ShowScripts"),
172 "FAIvariable" => array("IMG"=> "plugins/fai/images/fai_variable.png",
173 "NAME"=>_("Variables") , "KZL"=> "V", "VAR"=>"ShowVariables"),
174 "FAIhook" => array("IMG"=> "plugins/fai/images/fai_hook.png",
175 "NAME"=>_("Hooks"), "KZL"=> "H", "VAR"=>"ShowHooks"),
176 "FAIprofile" => array("IMG"=> "plugins/fai/images/fai_profile.png",
177 "NAME"=>_("Profile") , "KZL"=> "P", "VAR"=>"ShowProfiles"),
178 "FAItemplate" => array("IMG"=> "plugins/fai/images/fai_template.png",
179 "NAME"=>_("Templates") , "KZL"=> "T", "VAR"=>"ShowTemplates"),
180 "opsi_netboot" => array("IMG"=> "plugins/opsi/images/netboot_package.png",
181 "NAME"=>_("OPSI netboot product") , "KZL"=> "ON", "VAR"=>"ShowOpsiNetboot"),
182 "opsi_local" => array("IMG"=> "plugins/opsi/images/local_package.png",
183 "NAME"=>_("OPSI localboot product") , "KZL"=> "OL", "VAR"=>"ShowOpsiLocal"));
185 $icon_list = "";
186 foreach($objects as $type => $type_data){
187 if(in_array($type, $classes)){
188 $icon_list .= "<input type='image' src='".$type_data['IMG']."' title='".$type_data['NAME']."'
189 alt='".$type_data['KZL']."' class='center' name='edit_".$row."_".$type."'>\n";
190 }else{
191 $icon_list .= "<img src='images/empty.png' alt=' ' class='center'>\n";
192 }
193 }
195 return $icon_list;
196 }
199 function get_type($array){
200 if(!isset($array['objectClass'])) return(array());
201 if(in_array("FAIpartitionTable",$array['objectClass'])){
202 return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS"));
203 }
204 if(in_array("FAIscript",$array['objectClass'])){
205 return(array("tabsScript","faiScript","FAISCRIPTTABS"));
206 }
207 if(in_array("FAItemplate",$array['objectClass'])){
208 return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS"));
209 }
210 if(in_array("FAIhook",$array['objectClass'])){
211 return(array("tabsHook","faiHook","FAIHOOKTABS"));
212 }
213 if(in_array("FAIvariable",$array['objectClass'])){
214 return(array("tabsVariable","faiVariable","FAIVARIABLETABS"));
215 }
216 if(in_array("FAIprofile",$array['objectClass'])){
217 return(array("tabsProfile","faiProfile","FAIPROFILETABS"));
218 }
219 if(in_array("FAIpackageList",$array['objectClass'])){
220 return(array("tabsPackage","faiPackage","FAIPACKAGETABS"));
221 }
222 return(array());
223 }
224 }
225 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
226 ?>