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!
30 var $app_base = ""; // The currently selected release while in release management mode!
32 // Tab definition
33 protected $tabClass = "apptabs";
34 protected $tabType = "APPSTABS";
35 protected $aclCategory = "application";
36 protected $aclPlugin = "application";
37 protected $objectName = "application";
39 var $releaseSelector = NULL;
41 function __construct($config,$ui)
42 {
43 $this->config = $config;
44 $this->ui = $ui;
45 $this->app_base = get_ou('applicationRDN').$this->config->current['BASE'];
46 $this->app_release = get_ou('applicationRDN').$this->config->current['BASE'];
48 if($this->IsReleaseManagementActivated()){
49 $filter_xml = "application-filter-release.xml";
50 $list_xml = "application-list-release.xml";
51 $this->storagePoints= array("");
52 $releases = faiManagement::getReleaseStates($this->config,$this->app_base);
53 $this->releaseSelector = new releaseSelector($releases, $this->app_release, $this->app_release);
54 }else{
55 $filter_xml = "application-filter.xml";
56 $list_xml = "application-list.xml";
57 $this->storagePoints= array(get_ou("applicationRDN"));
58 }
60 // Build filter
61 if (session::global_is_set(get_class($this)."_filter")){
62 $filter= session::global_get(get_class($this)."_filter");
63 } else {
64 $filter = new filter(get_template_path($filter_xml, true));
65 $filter->setObjectStorage($this->storagePoints);
66 }
67 $this->setFilter($filter);
69 // Build headpage
70 $headpage = new listing(get_template_path($list_xml, true));
71 $headpage->setFilter($filter);
73 // Add copy&paste and snapshot handler.
74 if ($this->config->boolValueIsTrue("main", "copyPaste")){
75 $this->cpHandler = new CopyPasteHandler($this->config);
76 }
77 if($this->config->get_cfg_value("enableSnapshots") == "true"){
78 $this->snapHandler = new SnapshotHandler($this->config);
79 }
80 parent::__construct($config, $ui, "applications", $headpage);
82 $this->registerAction("edit_application","editEntry");
83 $this->registerAction("edit_environment","editEntry");
84 $this->registerAction("edit_appapplication","editEntry");
85 $this->registerAction("edit_mailapplication","editEntry");
86 }
89 /*! \brief Someone wants to remove some object(s)
90 * ask for a confirmation now.
91 */
92 function removeEntryRequested($action="",$target=array(),$all=array(),
93 $altTabClass ="", $altTabType = "", $altAclCategory="")
94 {
95 // Close dialogs and remove locks for currently handled dns
96 $this->cancelEdit();
98 // Do not allow to remove objects with state freeezed
99 $errors = $disallowed = array();
100 $headpage = $this->getHeadpage();
101 foreach($target as $dn){
103 $obj = $headpage->getEntry($dn);
104 $acl = $this->ui->get_permissions($obj['dn'],"application/application");
105 if(!preg_match("/d/",$acl)){
106 $disallowed[] = $obj['dn'];
107 }elseif(isset($obj['FAIstate']) && preg_match('/freeze/i', $obj['FAIstate'][0])){
108 $errors[] = $obj['dn'];
109 }else{
110 $this->dns[] = $obj['dn'];
111 }
112 }
113 if(count($errors)){
114 msg_dialog::display(_("Branch locked"),
115 sprintf(_("The following entries are locked, you can't remove them %s."),
116 msgPool::buildList($errors)),INFO_DIALOG);
117 }
118 if(count($disallowed)){
119 msg_dialog::display(_("Permission error"), msgPool::permDelete($disallowed), ERROR_DIALOG);
120 }
121 return(management::removeEntryRequested($action, $this->dns));
122 }
125 /*! \brief This method opens an existing object or a list of existing objects to be edited.
126 *
127 *
128 * @param String 'action' The name of the action which was the used as trigger.
129 * @param Array 'target' A list of object dns, which should be affected by this method.
130 * @param Array 'all' A combination of both 'action' and 'target'.
131 */
132 function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
133 {
134 management::editEntry($action,$target,$all,$altTabClass,$altTabType,$altAclCategory);
135 if($this->tabObject){
136 if(isset($this->tabObject->by_object['application']->attrs['FAIstate'][0])){
137 $state = $this->tabObject->by_object['application']->attrs['FAIstate'][0];
138 $this->tabObject->setReadOnly(preg_match("/freeze/i", $state));
139 }
140 }
141 }
144 /*! \brief Overridden render method of class mangement.
145 * this allows us to add a release selection box.
146 */
147 function renderList()
148 {
149 $smarty = get_smarty();
150 $filter = $this->getFilter();
151 $headpage = $this->getHeadpage();
153 // Display release selector
154 if($this->IsReleaseManagementActivated()){
155 $this->releaseSelector->update();
156 $this->app_release = $this->releaseSelector->getBase();
157 $headpage->setBase($this->app_release);
158 $smarty->assign("RELEASE", $this->releaseSelector->render());
159 }
161 $headpage->update();
162 $display = $headpage->render();
163 return($this->getHeader().$display);
164 }
167 function IsReleaseManagementActivated()
168 {
169 /* Check if we should enable the release selection */
170 $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
171 if(!empty($tmp)){
172 return(true);
173 }
174 return(false);
175 }
177 }
178 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
179 ?>