Code

Removed storage point selection
[gosa.git] / gosa-core / plugins / admin / departments / class_departmentManagement.inc
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;
40    
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);
53     // Add copy&paste and snapshot handler.
54     if ($this->config->boolValueIsTrue("main", "copyPaste")){
55       $this->cpHandler = new CopyPasteHandler($this->config);
56     }
57     if($this->config->get_cfg_value("enableSnapshots") == "true"){
58       $this->snapHandler = new SnapshotHandler($this->config);
59     }
61     parent::__construct($config, $ui, "departments", $headpage);
63     $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_department","newEntry");
72     $this->registerAction("performRecMove","performRecMove");
73     $this->registerAction("tagDepartment","tagDepartment");
74   }
77   function detectPostActions()
78   {
79     $actions = management::detectPostActions();
80     if(isset($_GET['PerformRecMove'])) $action['action'] = "performRecMove";
81     if(isset($_GET['TagDepartment'])) $action['action'] = "tagDepartment";
82     return($actions);
83   }
85   function performRecMove()
86   {
87     if(isset($_GET['PerformRecMove'])){
88       $this->deptabs->move_me();
89       $this->DivListDepartment->selectedBase = $this->deptabs->by_object['department']->dn;
90       exit();
91     }
92   }
94   function tagDepartment()
95   {
96     if(isset($_GET['TagDepartment'])){
97       $base_name = $this->deptabs->base_name;
98       $this->deptabs->by_object[$base_name]->tag_objects();
99       exit();
100     }
101   }
104   function newEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
105   {
106     echo "Remember to add recursive move and department tagging again!";
107     $types= $this->get_support_departments();
108     $type = preg_replace("/^new_/","",$action);
109     return(management::newEntry($action,$target,$all,$this->tabClass,$types[$type]['TAB'],$this->aclCategory));
110   }
112   function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
113   {
114     $types= $this->get_support_departments();
115     $type = $this->headpage->getType($target[0]);
116     return(management::editEntry($action,$target,$all,$this->tabClass,$types[$type]['TAB'],$this->aclCategory));
117   }
119   
120   function openEntry($action,$entry)
121   {
122     $this->headpage->setBase(array_pop($entry));
123   }
125   protected function removeEntryRequested($action="",$target=array(),$all=array())
126   {
127     $target = array_remove_entries(array($this->config->current['BASE']),$target);
128     return(management::removeEntryRequested($action,$target,$all)); 
129   }
131   static function filterDepLabel($row,$dn,$params,$ou,$pid,$base)
132   {
133     $ou = $ou[0];
134     if($dn == $base){
135       $ou =".";
136     }
137     $dn= LDAP::fix(func_get_arg(1));
138     return("<a href='?plug=".$_GET['plug']."&amp;PID=$pid&amp;act=listing_open_$row' title='$dn'>$ou</a>");
139   }
142   /*! \brief  Returns information about all container types that GOsa con handle.
143     @return Array   Informations about departments supported by GOsa.
144    */
145   public static function get_support_departments()
146   {
147     /* Domain 
148      */ 
149     $types = array();
150     $types['domain']['ACL']     = "domain"; 
151     $types['domain']['CLASS']   = "domain"; 
152     $types['domain']['ATTR']    = "dc"; 
153     $types['domain']['TAB']     = "DOMAIN_TABS"; 
154     $types['domain']['OC']      = "domain"; 
155     $types['domain']['IMG']     = "plugins/departments/images/domain.png"; 
156     $types['domain']['IMG_FULL']= "plugins/departments/images/domain.png"; 
157     $types['domain']['TITLE']   = _("Domain"); 
158     $types['domain']['TPL']     = "domain.tpl"; 
160     /* Domain component 
161      */
162     $types['dcObject']['ACL']     = "dcObject";
163     $types['dcObject']['CLASS']   = "dcObject";
164     $types['dcObject']['ATTR']    = "dc";
165     $types['dcObject']['TAB']     = "DCOBJECT_TABS";
166     $types['dcObject']['OC']      = "dcObject";
167     $types['dcObject']['IMG']     = "plugins/departments/images/dc.png";
168     $types['dcObject']['IMG_FULL']= "plugins/departments/images/dc.png";
169     $types['dcObject']['TITLE']   = _("Domain Component");
170     $types['dcObject']['TPL']     = "dcObject.tpl";
172     /* Country object
173      */
174     $types['country']['ACL']     = "country";
175     $types['country']['CLASS']   = "country";
176     $types['country']['TAB']     = "COUNTRY_TABS";
177     $types['country']['ATTR']    = "c";
178     $types['country']['OC']      = "country";
179     $types['country']['IMG']     = "plugins/departments/images/country.png";
180     $types['country']['IMG_FULL']= "plugins/departments/images/country.png";
181     $types['country']['TITLE']   = _("Country");
182     $types['country']['TPL']     = "country.tpl";
184     /* Locality object
185      */
186     $types['locality']['ACL']     = "locality";
187     $types['locality']['CLASS']   = "locality";
188     $types['locality']['TAB']     = "LOCALITY_TABS";
189     $types['locality']['ATTR']    = "l";
190     $types['locality']['OC']      = "locality";
191     $types['locality']['IMG']     = "plugins/departments/images/locality.png";
192     $types['locality']['IMG_FULL']= "plugins/departments/images/locality.png";
193     $types['locality']['TITLE']   = _("Locality");
194     $types['locality']['TPL']     = "locality.tpl";
196     /* Organization
197      */
198     $types['organization']['ACL']     = "organization";
199     $types['organization']['CLASS']   = "organization";
200     $types['organization']['TAB']     = "ORGANIZATION_TABS";
201     $types['organization']['ATTR']    = "o";
202     $types['organization']['OC']      = "organization";
203     $types['organization']['IMG']     = "plugins/departments/images/organization.png";
204     $types['organization']['IMG_FULL']= "plugins/departments/images/organization.png";
205     $types['organization']['TITLE']   = _("Organization");
206     $types['organization']['TPL']     = "organization.tpl";
208     /* Department
209      */
210     $types['organizationalUnit']['ACL']     = "department";
211     $types['organizationalUnit']['CLASS']   = "department";
212     $types['organizationalUnit']['TAB']     = "DEPTABS";
213     $types['organizationalUnit']['ATTR']    = "ou";
214     $types['organizationalUnit']['OC']      = "organizationalUnit";
215     $types['organizationalUnit']['IMG']     = "images/lists/folder.png";//plugins/departments/images/department.png";
216     $types['organizationalUnit']['IMG_FULL']= "images/lists/folder-full.png";//:wplugins/departments/images/department.png";
217     $types['organizationalUnit']['TITLE']   = _("Department");
218     $types['organizationalUnit']['TPL']     = "generic.tpl";
219     return($types);
220   }
221
222 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
223 ?>