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 departmentw";
28 // Tab definition
29 protected $tabClass = "deptabs";
30 protected $tabType = "DEPTABS";
31 protected $aclCategory = "departement";
32 protected $aclPlugin = "generic";
33 protected $objectName = "department";
35 function __construct($config,$ui)
36 {
37 $this->config = $config;
38 $this->ui = $ui;
40 $this->storagePoints = array("");
42 // Build filter
43 #if (session::global_is_set(get_class($this)."_filter")){
44 $filter= session::global_get(get_class($this)."_filter");
45 # } else {
46 $filter = new filter(get_template_path("dep-filter.xml", true));
47 # $filter->setObjectStorage($this->storagePoints);
48 # }
49 $this->setFilter($filter);
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 }
77 function newEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
78 {
79 $types= $this->get_support_departments();
80 $type = preg_replace("/^new_/","",$action);
81 return(management::newEntry($action,$target,$all,$this->tabClass,$types[$type]['TAB'],$this->aclCategory));
82 }
84 function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
85 {
86 $types= $this->get_support_departments();
87 $type = $this->headpage->getType($target[0]);
88 return(management::editEntry($action,$target,$all,$this->tabClass,$types[$type]['TAB'],$this->aclCategory));
89 }
92 function openEntry($action,$entry)
93 {
94 $this->headpage->setBase(array_pop($entry));
95 }
97 protected function removeEntryRequested($action="",$target=array(),$all=array())
98 {
99 $target = array_remove_entries(array($this->config->current['BASE']),$target);
100 return(management::removeEntryRequested($action,$target,$all));
101 }
103 static function filterDepLabel($row,$dn,$params,$ou,$pid,$base)
104 {
105 $ou = $ou[0];
106 if($dn == $base){
107 $ou =".";
108 }
109 $dn= LDAP::fix(func_get_arg(1));
110 return("<a href='?plug=".$_GET['plug']."&PID=$pid&act=listing_open_$row' title='$dn'>$ou</a>");
111 }
114 /*! \brief Returns information about all container types that GOsa con handle.
115 @return Array Informations about departments supported by GOsa.
116 */
117 public static function get_support_departments()
118 {
119 /* Domain
120 */
121 $types = array();
122 $types['domain']['ACL'] = "domain";
123 $types['domain']['CLASS'] = "domain";
124 $types['domain']['ATTR'] = "dc";
125 $types['domain']['TAB'] = "DOMAIN_TABS";
126 $types['domain']['OC'] = "domain";
127 $types['domain']['IMG'] = "plugins/departments/images/domain.png";
128 $types['domain']['IMG_FULL']= "plugins/departments/images/domain.png";
129 $types['domain']['TITLE'] = _("Domain");
130 $types['domain']['TPL'] = "domain.tpl";
132 /* Domain component
133 */
134 $types['dcObject']['ACL'] = "dcObject";
135 $types['dcObject']['CLASS'] = "dcObject";
136 $types['dcObject']['ATTR'] = "dc";
137 $types['dcObject']['TAB'] = "DCOBJECT_TABS";
138 $types['dcObject']['OC'] = "dcObject";
139 $types['dcObject']['IMG'] = "plugins/departments/images/dc.png";
140 $types['dcObject']['IMG_FULL']= "plugins/departments/images/dc.png";
141 $types['dcObject']['TITLE'] = _("Domain Component");
142 $types['dcObject']['TPL'] = "dcObject.tpl";
144 /* Country object
145 */
146 $types['country']['ACL'] = "country";
147 $types['country']['CLASS'] = "country";
148 $types['country']['TAB'] = "COUNTRY_TABS";
149 $types['country']['ATTR'] = "c";
150 $types['country']['OC'] = "country";
151 $types['country']['IMG'] = "plugins/departments/images/country.png";
152 $types['country']['IMG_FULL']= "plugins/departments/images/country.png";
153 $types['country']['TITLE'] = _("Country");
154 $types['country']['TPL'] = "country.tpl";
156 /* Locality object
157 */
158 $types['locality']['ACL'] = "locality";
159 $types['locality']['CLASS'] = "locality";
160 $types['locality']['TAB'] = "LOCALITY_TABS";
161 $types['locality']['ATTR'] = "l";
162 $types['locality']['OC'] = "locality";
163 $types['locality']['IMG'] = "plugins/departments/images/locality.png";
164 $types['locality']['IMG_FULL']= "plugins/departments/images/locality.png";
165 $types['locality']['TITLE'] = _("Locality");
166 $types['locality']['TPL'] = "locality.tpl";
168 /* Organization
169 */
170 $types['organization']['ACL'] = "organization";
171 $types['organization']['CLASS'] = "organization";
172 $types['organization']['TAB'] = "ORGANIZATION_TABS";
173 $types['organization']['ATTR'] = "o";
174 $types['organization']['OC'] = "organization";
175 $types['organization']['IMG'] = "plugins/departments/images/organization.png";
176 $types['organization']['IMG_FULL']= "plugins/departments/images/organization.png";
177 $types['organization']['TITLE'] = _("Organization");
178 $types['organization']['TPL'] = "organization.tpl";
180 /* Department
181 */
182 $types['organizationalUnit']['ACL'] = "department";
183 $types['organizationalUnit']['CLASS'] = "department";
184 $types['organizationalUnit']['TAB'] = "DEPTABS";
185 $types['organizationalUnit']['ATTR'] = "ou";
186 $types['organizationalUnit']['OC'] = "organizationalUnit";
187 $types['organizationalUnit']['IMG'] = "images/lists/folder.png";//plugins/departments/images/department.png";
188 $types['organizationalUnit']['IMG_FULL']= "images/lists/folder-full.png";//:wplugins/departments/images/department.png";
189 $types['organizationalUnit']['TITLE'] = _("Department");
190 $types['organizationalUnit']['TPL'] = "generic.tpl";
191 return($types);
192 }
193 }
194 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
195 ?>