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 $this->storagePoints = array("");
43 // Build filter
44 if (session::global_is_set(get_class($this)."_filter")){
45 $filter= session::global_get(get_class($this)."_filter");
46 } else {
47 $filter = new filter(get_template_path("dep-filter.xml", true));
48 $filter->setObjectStorage($this->storagePoints);
49 }
51 // Build headpage
52 $headpage = new listing(get_template_path("dep-list.xml", true));
53 $headpage->registerElementFilter("depLabel", "departmentManagement::filterDepLabel");
54 $headpage->setFilter($filter);
56 // Add copy&paste and snapshot handler.
57 if ($this->config->boolValueIsTrue("main", "copyPaste")){
58 $this->cpHandler = new CopyPasteHandler($this->config);
59 }
60 if($this->config->get_cfg_value("enableSnapshots") == "true"){
61 $this->snapHandler = new SnapshotHandler($this->config);
62 }
64 parent::__construct($config, $ui, "departments", $headpage);
66 $this->registerAction("open","openEntry");
68 $this->registerAction("new_domain","newEntry");
69 $this->registerAction("new_country","newEntry");
70 $this->registerAction("new_locality","newEntry");
71 $this->registerAction("new_dcObject","newEntry");
72 $this->registerAction("new_organization","newEntry");
73 $this->registerAction("new_department","newEntry");
75 $this->registerAction("performRecMove","performRecMove");
76 $this->registerAction("tagDepartment","tagDepartment");
77 }
80 function detectPostActions()
81 {
82 $actions = management::detectPostActions();
83 if(isset($_GET['PerformRecMove'])) $action['action'] = "performRecMove";
84 if(isset($_GET['TagDepartment'])) $action['action'] = "tagDepartment";
85 return($actions);
86 }
88 function performRecMove()
89 {
90 if(isset($_GET['PerformRecMove'])){
91 $this->deptabs->move_me();
92 $this->DivListDepartment->selectedBase = $this->deptabs->by_object['department']->dn;
93 exit();
94 }
95 }
97 function tagDepartment()
98 {
99 if(isset($_GET['TagDepartment'])){
100 $base_name = $this->deptabs->base_name;
101 $this->deptabs->by_object[$base_name]->tag_objects();
102 exit();
103 }
104 }
107 function newEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
108 {
109 echo "Remember to add recursive move and department tagging again!";
110 $types= $this->get_support_departments();
111 $type = preg_replace("/^new_/","",$action);
112 return(management::newEntry($action,$target,$all,$this->tabClass,$types[$type]['TAB'],$this->aclCategory));
113 }
115 function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
116 {
117 $types= $this->get_support_departments();
118 $type = $this->headpage->getType($target[0]);
119 return(management::editEntry($action,$target,$all,$this->tabClass,$types[$type]['TAB'],$this->aclCategory));
120 }
123 function openEntry($action,$entry)
124 {
125 $this->headpage->setBase(array_pop($entry));
126 }
128 protected function removeEntryRequested($action="",$target=array(),$all=array())
129 {
130 $target = array_remove_entries(array($this->config->current['BASE']),$target);
131 return(management::removeEntryRequested($action,$target,$all));
132 }
134 static function filterDepLabel($row,$dn,$params,$ou,$pid,$base)
135 {
136 $ou = $ou[0];
137 if($dn == $base){
138 $ou =".";
139 }
140 $dn= LDAP::fix(func_get_arg(1));
141 return("<a href='?plug=".$_GET['plug']."&PID=$pid&act=listing_open_$row' title='$dn'>$ou</a>");
142 }
145 /*! \brief Returns information about all container types that GOsa con handle.
146 @return Array Informations about departments supported by GOsa.
147 */
148 public static function get_support_departments()
149 {
150 /* Domain
151 */
152 $types = array();
153 $types['domain']['ACL'] = "domain";
154 $types['domain']['CLASS'] = "domain";
155 $types['domain']['ATTR'] = "dc";
156 $types['domain']['TAB'] = "DOMAIN_TABS";
157 $types['domain']['OC'] = "domain";
158 $types['domain']['IMG'] = "plugins/departments/images/domain.png";
159 $types['domain']['IMG_FULL']= "plugins/departments/images/domain.png";
160 $types['domain']['TITLE'] = _("Domain");
161 $types['domain']['TPL'] = "domain.tpl";
163 /* Domain component
164 */
165 $types['dcObject']['ACL'] = "dcObject";
166 $types['dcObject']['CLASS'] = "dcObject";
167 $types['dcObject']['ATTR'] = "dc";
168 $types['dcObject']['TAB'] = "DCOBJECT_TABS";
169 $types['dcObject']['OC'] = "dcObject";
170 $types['dcObject']['IMG'] = "plugins/departments/images/dc.png";
171 $types['dcObject']['IMG_FULL']= "plugins/departments/images/dc.png";
172 $types['dcObject']['TITLE'] = _("Domain Component");
173 $types['dcObject']['TPL'] = "dcObject.tpl";
175 /* Country object
176 */
177 $types['country']['ACL'] = "country";
178 $types['country']['CLASS'] = "country";
179 $types['country']['TAB'] = "COUNTRY_TABS";
180 $types['country']['ATTR'] = "c";
181 $types['country']['OC'] = "country";
182 $types['country']['IMG'] = "plugins/departments/images/country.png";
183 $types['country']['IMG_FULL']= "plugins/departments/images/country.png";
184 $types['country']['TITLE'] = _("Country");
185 $types['country']['TPL'] = "country.tpl";
187 /* Locality object
188 */
189 $types['locality']['ACL'] = "locality";
190 $types['locality']['CLASS'] = "locality";
191 $types['locality']['TAB'] = "LOCALITY_TABS";
192 $types['locality']['ATTR'] = "l";
193 $types['locality']['OC'] = "locality";
194 $types['locality']['IMG'] = "plugins/departments/images/locality.png";
195 $types['locality']['IMG_FULL']= "plugins/departments/images/locality.png";
196 $types['locality']['TITLE'] = _("Locality");
197 $types['locality']['TPL'] = "locality.tpl";
199 /* Organization
200 */
201 $types['organization']['ACL'] = "organization";
202 $types['organization']['CLASS'] = "organization";
203 $types['organization']['TAB'] = "ORGANIZATION_TABS";
204 $types['organization']['ATTR'] = "o";
205 $types['organization']['OC'] = "organization";
206 $types['organization']['IMG'] = "plugins/departments/images/organization.png";
207 $types['organization']['IMG_FULL']= "plugins/departments/images/organization.png";
208 $types['organization']['TITLE'] = _("Organization");
209 $types['organization']['TPL'] = "organization.tpl";
211 /* Department
212 */
213 $types['organizationalUnit']['ACL'] = "department";
214 $types['organizationalUnit']['CLASS'] = "department";
215 $types['organizationalUnit']['TAB'] = "DEPTABS";
216 $types['organizationalUnit']['ATTR'] = "ou";
217 $types['organizationalUnit']['OC'] = "organizationalUnit";
218 $types['organizationalUnit']['IMG'] = "images/lists/folder.png";//plugins/departments/images/department.png";
219 $types['organizationalUnit']['IMG_FULL']= "images/lists/folder-full.png";//:wplugins/departments/images/department.png";
220 $types['organizationalUnit']['TITLE'] = _("Department");
221 $types['organizationalUnit']['TPL'] = "generic.tpl";
222 return($types);
223 }
224 }
225 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
226 ?>