2239e5a964fb02f819ed479b9f7430dbe585c276
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$$
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 departmentManagement extends management
24 {
25 var $plHeadline = "Departments";
26 var $plDescription = "Manage Departments";
27 var $plIcon = "plugins/departments/images/plugin.png";
29 // Tab definition
30 protected $tabClass = "deptabs";
31 protected $tabType = "DEPTABS";
32 protected $aclCategory = "departement";
33 protected $aclPlugin = "generic";
34 protected $objectName = "department";
36 function __construct($config,$ui)
37 {
38 $this->config = $config;
39 $this->ui = $ui;
41 // Build filter
42 if (session::global_is_set(get_class($this)."_filter")){
43 $filter= session::global_get(get_class($this)."_filter");
44 } else {
45 $filter = new filter(get_template_path("dep-filter.xml", true));
46 }
48 // Build headpage
49 $headpage = new listing(get_template_path("dep-list.xml", true));
50 $headpage->registerElementFilter("depLabel", "departmentManagement::filterDepLabel");
51 $headpage->setFilter($filter);
52 $this->setFilter($filter);
54 // Add copy&paste and snapshot handler.
55 if ($this->config->boolValueIsTrue("main", "copyPaste")){
56 $this->cpHandler = new CopyPasteHandler($this->config);
57 }
58 if($this->config->get_cfg_value("enableSnapshots") == "true"){
59 $this->snapHandler = new SnapshotHandler($this->config);
60 }
62 parent::__construct($config, $ui, "departments", $headpage);
64 $this->registerAction("open","openEntry");
65 $this->registerAction("new_domain","newEntry");
66 $this->registerAction("new_country","newEntry");
67 $this->registerAction("new_locality","newEntry");
68 $this->registerAction("new_dcObject","newEntry");
69 $this->registerAction("new_organization","newEntry");
70 $this->registerAction("new_organizationalUnit","newEntry");
71 $this->registerAction("performRecMove","performRecMove");
72 $this->registerAction("tagDepartment","tagDepartment");
73 }
75 // Inject additional actions here.
76 function detectPostActions()
77 {
78 $actions = management::detectPostActions();
79 if(isset($_GET['PerformRecMove'])) $actions['action'] = "performRecMove";
80 if(isset($_GET['TagDepartment'])) $actions['action'] = "tagDepartment";
81 return($actions);
82 }
84 // Action handler which allows department tagging - Creates the iframe contents.
85 function tagDepartment()
86 {
87 $plugname = $this->last_tabObject->base_name;
88 $this->last_tabObject->by_object[$plugname]->tag_objects();
89 exit();
90 }
92 // Overridden new handler - We've different types of departments to create!
93 function newEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
94 {
95 $types= $this->get_support_departments();
96 $type = preg_replace("/^new_/","",$action);
97 return(management::newEntry($action,$target,$all,$this->tabClass,$types[$type]['TAB'],$this->aclCategory));
98 }
100 // Overridden edit handler - We've different types of departments to edit!
101 function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
102 {
103 $types= $this->get_support_departments();
104 $headpage = $this->getHeadpage();
105 $type = $headpage->getType($target[0]);
106 return(management::editEntry($action,$target,$all,$this->tabClass,$types[$type]['TAB'],$this->aclCategory));
107 }
110 // Overriden save handler - We've to take care about the department tagging here.
111 protected function saveChanges()
112 {
113 $str = management::saveChanges();
114 if(!empty($str)) return($str);
117 global $config;
118 $config->get_departments();
119 $config->make_idepartments();
120 $this->config = $config;
121 $headpage = $this->getHeadpage();
122 $headpage->refreshBasesList();
124 $plugname = $this->last_tabObject->base_name;
125 if($this->last_tabObject->by_object[$plugname]->must_be_tagged()){
126 $smarty = get_smarty();
127 $smarty->assign("src","?plug=".$_GET['plug']."&TagDepartment&no_output_compression");
128 $smarty->assign("message",_("As soon as the tag operation has finished, you can scroll down to end of the page and press the 'Continue' button to continue with the department management dialog."));
129 return($smarty->fetch(get_template_path("dep_iframe.tpl",TRUE)));
130 }
131 }
134 // An action handler which enables to switch into deparmtment by clicking the names.
135 function openEntry($action,$entry)
136 {
137 $headpage = $this->getHeadpage();
138 $headpage->setBase(array_pop($entry));
139 }
142 // Overridden remove request method - Avoid removal of the ldap base.
143 protected function removeEntryRequested($action="",$target=array(),$all=array())
144 {
145 $target = array_remove_entries(array($this->config->current['BASE']),$target);
146 return(management::removeEntryRequested($action,$target,$all));
147 }
150 // A filter which allows to open a department by clicking on the departments name.
151 static function filterDepLabel($row,$dn,$params,$ou,$pid,$base)
152 {
153 $ou = $ou[0];
154 if($dn == $base){
155 $ou =".";
156 }
157 $dn= LDAP::fix(func_get_arg(1));
158 return("<a href='?plug=".$_GET['plug']."&PID=$pid&act=listing_open_$row' title='$dn'>$ou</a>");
159 }
162 /*! \brief Returns information about all container types that GOsa con handle.
163 @return Array Informations about departments supported by GOsa.
164 */
165 public static function get_support_departments()
166 {
167 /* Domain
168 */
169 $types = array();
170 $types['domain']['ACL'] = "domain";
171 $types['domain']['CLASS'] = "domain";
172 $types['domain']['ATTR'] = "dc";
173 $types['domain']['TAB'] = "DOMAIN_TABS";
174 $types['domain']['OC'] = "domain";
175 $types['domain']['IMG'] = "plugins/departments/images/domain.png";
176 $types['domain']['IMG_FULL']= "plugins/departments/images/domain.png";
177 $types['domain']['TITLE'] = _("Domain");
178 $types['domain']['TPL'] = "domain.tpl";
180 /* Domain component
181 */
182 $types['dcObject']['ACL'] = "dcObject";
183 $types['dcObject']['CLASS'] = "dcObject";
184 $types['dcObject']['ATTR'] = "dc";
185 $types['dcObject']['TAB'] = "DCOBJECT_TABS";
186 $types['dcObject']['OC'] = "dcObject";
187 $types['dcObject']['IMG'] = "plugins/departments/images/dc.png";
188 $types['dcObject']['IMG_FULL']= "plugins/departments/images/dc.png";
189 $types['dcObject']['TITLE'] = _("Domain Component");
190 $types['dcObject']['TPL'] = "dcObject.tpl";
192 /* Country object
193 */
194 $types['country']['ACL'] = "country";
195 $types['country']['CLASS'] = "country";
196 $types['country']['TAB'] = "COUNTRY_TABS";
197 $types['country']['ATTR'] = "c";
198 $types['country']['OC'] = "country";
199 $types['country']['IMG'] = "plugins/departments/images/country.png";
200 $types['country']['IMG_FULL']= "plugins/departments/images/country.png";
201 $types['country']['TITLE'] = _("Country");
202 $types['country']['TPL'] = "country.tpl";
204 /* Locality object
205 */
206 $types['locality']['ACL'] = "locality";
207 $types['locality']['CLASS'] = "locality";
208 $types['locality']['TAB'] = "LOCALITY_TABS";
209 $types['locality']['ATTR'] = "l";
210 $types['locality']['OC'] = "locality";
211 $types['locality']['IMG'] = "plugins/departments/images/locality.png";
212 $types['locality']['IMG_FULL']= "plugins/departments/images/locality.png";
213 $types['locality']['TITLE'] = _("Locality");
214 $types['locality']['TPL'] = "locality.tpl";
216 /* Organization
217 */
218 $types['organization']['ACL'] = "organization";
219 $types['organization']['CLASS'] = "organization";
220 $types['organization']['TAB'] = "ORGANIZATION_TABS";
221 $types['organization']['ATTR'] = "o";
222 $types['organization']['OC'] = "organization";
223 $types['organization']['IMG'] = "plugins/departments/images/organization.png";
224 $types['organization']['IMG_FULL']= "plugins/departments/images/organization.png";
225 $types['organization']['TITLE'] = _("Organization");
226 $types['organization']['TPL'] = "organization.tpl";
228 /* Department
229 */
230 $types['organizationalUnit']['ACL'] = "department";
231 $types['organizationalUnit']['CLASS'] = "department";
232 $types['organizationalUnit']['TAB'] = "DEPTABS";
233 $types['organizationalUnit']['ATTR'] = "ou";
234 $types['organizationalUnit']['OC'] = "organizationalUnit";
235 $types['organizationalUnit']['IMG'] = "images/lists/folder.png";//plugins/departments/images/department.png";
236 $types['organizationalUnit']['IMG_FULL']= "images/lists/folder-full.png";//:wplugins/departments/images/department.png";
237 $types['organizationalUnit']['TITLE'] = _("Department");
238 $types['organizationalUnit']['TPL'] = "generic.tpl";
239 return($types);
240 }
241 }
242 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
243 ?>