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_applicationManagement.inc 14766 2009-11-05 14:30:35Z 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 applicationManagement extends management
24 {
25 var $plHeadline = "Applications";
26 var $plDescription = "Application management";
27 var $plIcon = "plugins/goto/images/application.png";
29 var $app_release = ""; // The currently selected release while in release management mode!
31 // Tab definition
32 protected $tabClass = "apptabs";
33 protected $tabType = "APPSTABS";
34 protected $aclCategory = "application";
35 protected $aclPlugin = "application";
36 protected $objectName = "application";
38 function __construct($config,$ui)
39 {
40 $this->config = $config;
41 $this->ui = $ui;
43 if($this->IsReleaseManagementActivated()){
44 $this->app_release = get_ou('applicationRDN').$this->config->current['BASE'];
45 $filter_xml = "application-filter-release.xml";
46 $list_xml = "application-list-release.xml";
47 $this->storagePoints= array();
48 }else{
49 $filter_xml = "application-filter.xml";
50 $list_xml = "application-list.xml";
51 $this->storagePoints= array(get_ou("applicationRDN"));
52 }
54 // Build filter
55 if (session::global_is_set(get_class($this)."_filter")){
56 $filter= session::global_get(get_class($this)."_filter");
57 } else {
58 $filter = new filter(get_template_path($filter_xml, true));
59 $filter->setObjectStorage($this->storagePoints);
60 }
61 $this->setFilter($filter);
63 // Build headpage
64 $headpage = new listing(get_template_path($list_xml, true));
65 $headpage->setFilter($filter);
67 // Add copy&paste and snapshot handler.
68 if ($this->config->boolValueIsTrue("main", "copyPaste")){
69 $this->cpHandler = new CopyPasteHandler($this->config);
70 }
71 if($this->config->get_cfg_value("enableSnapshots") == "true"){
72 $this->snapHandler = new SnapshotHandler($this->config);
73 }
74 parent::__construct($config, $ui, "applications", $headpage);
76 $this->registerAction("edit_application","editEntry");
77 $this->registerAction("edit_environment","editEntry");
78 $this->registerAction("edit_appapplication","editEntry");
79 $this->registerAction("edit_mailapplication","editEntry");
80 }
82 function renderList()
83 {
84 $filter = $this->getFilter();
85 $headpage = $this->getHeadpage();
86 if($this->IsReleaseManagementActivated()){
87 $filter->setComboBoxOptions("RELEASE",$this->getReleaseList());
89 if(isset($_POST['RELEASE'])){
90 $this->app_release = get_post('RELEASE');
91 }
92 $headpage->setBase($this->app_release);
93 }
95 $headpage->update();
96 $display = $headpage->render();
97 return($this->getHeader().$display);
98 }
100 function getReleaseList($base = "", $prefix ="")
101 {
102 $list = array();
103 if(empty($base)){
104 $base = get_ou('applicationRDN').$this->config->current['BASE'];
105 $list[$base] = "/";
106 }
108 $ldap = $this->config->get_ldap_link();
109 $ldap->ls("(objectClass=FAIbranch)",$base,array("ou","FAIstate"));
110 while($release = $ldap->fetch()){
111 $list[$release['dn']] = $prefix.$release['ou'][0];
112 $list = array_merge($list,$this->getReleaseList($release['dn'],$prefix." "));
113 }
114 return($list);
115 }
118 function IsReleaseManagementActivated()
119 {
120 /* Check if we should enable the release selection */
121 $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
122 if(!empty($tmp)){
123 return(true);
124 }
125 return(false);
126 }
128 }
129 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
130 ?>