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");
66 $this->registerAction("new_domain","newEntry");
67 $this->registerAction("new_country","newEntry");
68 $this->registerAction("new_locality","newEntry");
69 $this->registerAction("new_dcObject","newEntry");
70 $this->registerAction("new_organization","newEntry");
71 $this->registerAction("new_organizationalUnit","newEntry");
73 $this->registerAction("performRecMove","performRecMove");
74 $this->registerAction("tagDepartment","tagDepartment");
75 }
78 function detectPostActions()
79 {
80 $actions = management::detectPostActions();
81 if(isset($_GET['PerformRecMove'])) $action['action'] = "performRecMove";
82 if(isset($_GET['TagDepartment'])) $action['action'] = "tagDepartment";
83 return($actions);
84 }
86 function performRecMove()
87 {
88 if(isset($_GET['PerformRecMove'])){
89 $this->deptabs->move_me();
90 $this->DivListDepartment->selectedBase = $this->deptabs->by_object['department']->dn;
91 exit();
92 }
93 }
95 function tagDepartment()
96 {
97 if(isset($_GET['TagDepartment'])){
98 $base_name = $this->deptabs->base_name;
99 $this->deptabs->by_object[$base_name]->tag_objects();
100 exit();
101 }
102 }
105 function newEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
106 {
107 echo "Remember to add recursive move and department tagging again!";
108 $types= $this->get_support_departments();
109 $type = preg_replace("/^new_/","",$action);
110 return(management::newEntry($action,$target,$all,$this->tabClass,$types[$type]['TAB'],$this->aclCategory));
111 }
113 function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
114 {
115 $types= $this->get_support_departments();
116 $type = $this->headpage->getType($target[0]);
117 return(management::editEntry($action,$target,$all,$this->tabClass,$types[$type]['TAB'],$this->aclCategory));
118 }
120 protected function saveChanges()
121 {
122 management::saveChanges();
124 if($this->last_tabObject->am_i_moved()){
125 return($smarty->fetch(get_template_path("dep_move_confirm.tpl",TRUE)));
126 }
127 }
131 function openEntry($action,$entry)
132 {
133 $this->headpage->setBase(array_pop($entry));
134 }
136 protected function removeEntryRequested($action="",$target=array(),$all=array())
137 {
138 $target = array_remove_entries(array($this->config->current['BASE']),$target);
139 return(management::removeEntryRequested($action,$target,$all));
140 }
142 static function filterDepLabel($row,$dn,$params,$ou,$pid,$base)
143 {
144 $ou = $ou[0];
145 if($dn == $base){
146 $ou =".";
147 }
148 $dn= LDAP::fix(func_get_arg(1));
149 return("<a href='?plug=".$_GET['plug']."&PID=$pid&act=listing_open_$row' title='$dn'>$ou</a>");
150 }
153 /*! \brief Returns information about all container types that GOsa con handle.
154 @return Array Informations about departments supported by GOsa.
155 */
156 public static function get_support_departments()
157 {
158 /* Domain
159 */
160 $types = array();
161 $types['domain']['ACL'] = "domain";
162 $types['domain']['CLASS'] = "domain";
163 $types['domain']['ATTR'] = "dc";
164 $types['domain']['TAB'] = "DOMAIN_TABS";
165 $types['domain']['OC'] = "domain";
166 $types['domain']['IMG'] = "plugins/departments/images/domain.png";
167 $types['domain']['IMG_FULL']= "plugins/departments/images/domain.png";
168 $types['domain']['TITLE'] = _("Domain");
169 $types['domain']['TPL'] = "domain.tpl";
171 /* Domain component
172 */
173 $types['dcObject']['ACL'] = "dcObject";
174 $types['dcObject']['CLASS'] = "dcObject";
175 $types['dcObject']['ATTR'] = "dc";
176 $types['dcObject']['TAB'] = "DCOBJECT_TABS";
177 $types['dcObject']['OC'] = "dcObject";
178 $types['dcObject']['IMG'] = "plugins/departments/images/dc.png";
179 $types['dcObject']['IMG_FULL']= "plugins/departments/images/dc.png";
180 $types['dcObject']['TITLE'] = _("Domain Component");
181 $types['dcObject']['TPL'] = "dcObject.tpl";
183 /* Country object
184 */
185 $types['country']['ACL'] = "country";
186 $types['country']['CLASS'] = "country";
187 $types['country']['TAB'] = "COUNTRY_TABS";
188 $types['country']['ATTR'] = "c";
189 $types['country']['OC'] = "country";
190 $types['country']['IMG'] = "plugins/departments/images/country.png";
191 $types['country']['IMG_FULL']= "plugins/departments/images/country.png";
192 $types['country']['TITLE'] = _("Country");
193 $types['country']['TPL'] = "country.tpl";
195 /* Locality object
196 */
197 $types['locality']['ACL'] = "locality";
198 $types['locality']['CLASS'] = "locality";
199 $types['locality']['TAB'] = "LOCALITY_TABS";
200 $types['locality']['ATTR'] = "l";
201 $types['locality']['OC'] = "locality";
202 $types['locality']['IMG'] = "plugins/departments/images/locality.png";
203 $types['locality']['IMG_FULL']= "plugins/departments/images/locality.png";
204 $types['locality']['TITLE'] = _("Locality");
205 $types['locality']['TPL'] = "locality.tpl";
207 /* Organization
208 */
209 $types['organization']['ACL'] = "organization";
210 $types['organization']['CLASS'] = "organization";
211 $types['organization']['TAB'] = "ORGANIZATION_TABS";
212 $types['organization']['ATTR'] = "o";
213 $types['organization']['OC'] = "organization";
214 $types['organization']['IMG'] = "plugins/departments/images/organization.png";
215 $types['organization']['IMG_FULL']= "plugins/departments/images/organization.png";
216 $types['organization']['TITLE'] = _("Organization");
217 $types['organization']['TPL'] = "organization.tpl";
219 /* Department
220 */
221 $types['organizationalUnit']['ACL'] = "department";
222 $types['organizationalUnit']['CLASS'] = "department";
223 $types['organizationalUnit']['TAB'] = "DEPTABS";
224 $types['organizationalUnit']['ATTR'] = "ou";
225 $types['organizationalUnit']['OC'] = "organizationalUnit";
226 $types['organizationalUnit']['IMG'] = "images/lists/folder.png";//plugins/departments/images/department.png";
227 $types['organizationalUnit']['IMG_FULL']= "images/lists/folder-full.png";//:wplugins/departments/images/department.png";
228 $types['organizationalUnit']['TITLE'] = _("Department");
229 $types['organizationalUnit']['TPL'] = "generic.tpl";
230 return($types);
231 }
232 }
233 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
234 ?>