Code

Do not allow to remove the ldap base:
[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 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;
39    
40     $this->storagePoints = array("");
41  
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");
67   }
70   function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
71   {
72     $types= $this->get_support_departments();
73     $type = $this->headpage->getType($target[0]);
74     return(management::editEntry($action,$target,$all,$this->tabClass,$types[$type]['TAB'],$this->aclCategory));
75   }
77   
78   function openEntry($action,$entry)
79   {
80     $this->headpage->setBase(array_pop($entry));
81   }
83   protected function removeEntryRequested($action="",$target=array(),$all=array())
84   {
85     $target = array_remove_entries(array($this->config->current['BASE']),$target);
86     return(management::removeEntryRequested($action,$target,$all)); 
87   }
89   static function filterDepLabel($row,$dn,$params,$ou,$pid,$base)
90   {
91     $ou = $ou[0];
92     if($dn == $base){
93       $ou =".";
94     }
95     $dn= LDAP::fix(func_get_arg(1));
96     return("<a href='?plug=".$_GET['plug']."&amp;PID=$pid&amp;act=listing_open_$row' title='$dn'>$ou</a>");
97   }
100   /*! \brief  Returns information about all container types that GOsa con handle.
101     @return Array   Informations about departments supported by GOsa.
102    */
103   public static function get_support_departments()
104   {
105     /* Domain 
106      */ 
107     $types = array();
108     $types['domain']['ACL']     = "domain"; 
109     $types['domain']['CLASS']   = "domain"; 
110     $types['domain']['ATTR']    = "dc"; 
111     $types['domain']['TAB']     = "DOMAIN_TABS"; 
112     $types['domain']['OC']      = "domain"; 
113     $types['domain']['IMG']     = "plugins/departments/images/domain.png"; 
114     $types['domain']['IMG_FULL']= "plugins/departments/images/domain.png"; 
115     $types['domain']['TITLE']   = _("Domain"); 
116     $types['domain']['TPL']     = "domain.tpl"; 
118     /* Domain component 
119      */
120     $types['dcObject']['ACL']     = "dcObject";
121     $types['dcObject']['CLASS']   = "dcObject";
122     $types['dcObject']['ATTR']    = "dc";
123     $types['dcObject']['TAB']     = "DCOBJECT_TABS";
124     $types['dcObject']['OC']      = "dcObject";
125     $types['dcObject']['IMG']     = "plugins/departments/images/dc.png";
126     $types['dcObject']['IMG_FULL']= "plugins/departments/images/dc.png";
127     $types['dcObject']['TITLE']   = _("Domain Component");
128     $types['dcObject']['TPL']     = "dcObject.tpl";
130     /* Country object
131      */
132     $types['country']['ACL']     = "country";
133     $types['country']['CLASS']   = "country";
134     $types['country']['TAB']     = "COUNTRY_TABS";
135     $types['country']['ATTR']    = "c";
136     $types['country']['OC']      = "country";
137     $types['country']['IMG']     = "plugins/departments/images/country.png";
138     $types['country']['IMG_FULL']= "plugins/departments/images/country.png";
139     $types['country']['TITLE']   = _("Country");
140     $types['country']['TPL']     = "country.tpl";
142     /* Locality object
143      */
144     $types['locality']['ACL']     = "locality";
145     $types['locality']['CLASS']   = "locality";
146     $types['locality']['TAB']     = "LOCALITY_TABS";
147     $types['locality']['ATTR']    = "l";
148     $types['locality']['OC']      = "locality";
149     $types['locality']['IMG']     = "plugins/departments/images/locality.png";
150     $types['locality']['IMG_FULL']= "plugins/departments/images/locality.png";
151     $types['locality']['TITLE']   = _("Locality");
152     $types['locality']['TPL']     = "locality.tpl";
154     /* Organization
155      */
156     $types['organization']['ACL']     = "organization";
157     $types['organization']['CLASS']   = "organization";
158     $types['organization']['TAB']     = "ORGANIZATION_TABS";
159     $types['organization']['ATTR']    = "o";
160     $types['organization']['OC']      = "organization";
161     $types['organization']['IMG']     = "plugins/departments/images/organization.png";
162     $types['organization']['IMG_FULL']= "plugins/departments/images/organization.png";
163     $types['organization']['TITLE']   = _("Organization");
164     $types['organization']['TPL']     = "organization.tpl";
166     /* Department
167      */
168     $types['organizationalUnit']['ACL']     = "department";
169     $types['organizationalUnit']['CLASS']   = "department";
170     $types['organizationalUnit']['TAB']     = "DEPTABS";
171     $types['organizationalUnit']['ATTR']    = "ou";
172     $types['organizationalUnit']['OC']      = "organizationalUnit";
173     $types['organizationalUnit']['IMG']     = "images/lists/folder.png";//plugins/departments/images/department.png";
174     $types['organizationalUnit']['IMG_FULL']= "images/lists/folder-full.png";//:wplugins/departments/images/department.png";
175     $types['organizationalUnit']['TITLE']   = _("Department");
176     $types['organizationalUnit']['TPL']     = "generic.tpl";
177     return($types);
178   }
179
180 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
181 ?>