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 (0 && 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."),msgPool::buildList($errors)), INFO_DIALOG);
116 }
117 if(count($disallowed)){
118 msg_dialog::display(_("Permission error"), msgPool::permDelete($disallowed), ERROR_DIALOG);
119 }
120 return(management::removeEntryRequested($action, $this->dns));
121 }
124 /*! \brief This method opens an existing object or a list of existing objects to be edited.
125 *
126 *
127 * @param String 'action' The name of the action which was the used as trigger.
128 * @param Array 'target' A list of object dns, which should be affected by this method.
129 * @param Array 'all' A combination of both 'action' and 'target'.
130 */
131 function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
132 {
133 management::editEntry($action,$target,$all,$altTabClass,$altTabType,$altAclCategory);
134 if($this->tabObject){
135 if(isset($this->tabObject->by_object['application']->attrs['FAIstate'][0])){
136 $state = $this->tabObject->by_object['application']->attrs['FAIstate'][0];
137 $this->tabObject->setReadOnly(preg_match("/freeze/i", $state));
138 }
139 }
140 }
143 /*! \brief Overridden render method of class mangement.
144 * this allows us to add a release selection box.
145 */
146 function renderList()
147 {
148 $smarty = get_smarty();
149 $filter = $this->getFilter();
150 $headpage = $this->getHeadpage();
152 // Display release selector
153 if($this->IsReleaseManagementActivated()){
154 $this->releaseSelector->update();
155 $this->app_release = $this->releaseSelector->getBase();
156 $headpage->setBase($this->app_release);
157 $smarty->assign("RELEASE", $this->releaseSelector->render());
158 }
160 $headpage->update();
161 $display = $headpage->render();
162 return($this->getHeader().$display);
163 }
166 function IsReleaseManagementActivated()
167 {
168 /* Check if we should enable the release selection */
169 $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
170 if(!empty($tmp)){
171 return(true);
172 }
173 return(false);
174 }
176 }
177 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
178 ?>