Code

Added shortcuts
[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);
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");
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_organizationalUnit","newEntry");
71     $this->registerAction("performRecMove","performRecMove");
72     $this->registerAction("tagDepartment","tagDepartment");
73   }
75   // Inject additional actions here.
76   function detectPostActions()
77   {
78     $actions = management::detectPostActions();
79     if(isset($_GET['PerformRecMove'])) $actions['action'] = "performRecMove";
80     if(isset($_GET['TagDepartment'])) $actions['action'] = "tagDepartment";
81     return($actions);
82   }
84   // Action handler which allows department tagging - Creates the iframe contents.
85   function tagDepartment()
86   {
87     $plugname = $this->last_tabObject->base_name;
88     $this->last_tabObject->by_object[$plugname]->tag_objects();
89     exit();
90   }
92   // Overridden new handler - We've different types of departments to create!
93   function newEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
94   {
95     $types= $this->get_support_departments();
96     $type = preg_replace("/^new_/","",$action);
97     return(management::newEntry($action,$target,$all,$this->tabClass,$types[$type]['TAB'],$this->aclCategory));
98   }
100   // Overridden edit handler - We've different types of departments to edit!
101   function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
102   {
103     $types= $this->get_support_departments();
104     $type = $this->headpage->getType($target[0]);
105     return(management::editEntry($action,$target,$all,$this->tabClass,$types[$type]['TAB'],$this->aclCategory));
106   }
109   // Overriden save handler - We've to take care about the department tagging here.
110   protected function saveChanges()
111   {
112     management::saveChanges();
113   
114     global $config; 
115     $config->get_departments();
116     $config->make_idepartments();
117     $this->config = $config;
118     $this->headpage->refreshBasesList();
120     $plugname = $this->last_tabObject->base_name;
121     if($this->last_tabObject->by_object[$plugname]->must_be_tagged()){
122       $smarty = get_smarty();
123       $smarty->assign("src","?plug=".$_GET['plug']."&TagDepartment&no_output_compression");
124       $smarty->assign("message",_("As soon as the tag operation has finished, you can scroll down to end of the page and    press the 'Continue' button to continue with the department management dialog."));
125       return($smarty->fetch(get_template_path("dep_iframe.tpl",TRUE)));
126     }
127   }
128  
130   // An action handler which enables to switch into deparmtment by clicking the names.
131   function openEntry($action,$entry)
132   {
133     $this->headpage->setBase(array_pop($entry));
134   }
137   // Overridden remove request method - Avoid removal of the ldap base.
138   protected function removeEntryRequested($action="",$target=array(),$all=array())
139   {
140     $target = array_remove_entries(array($this->config->current['BASE']),$target);
141     return(management::removeEntryRequested($action,$target,$all)); 
142   }
145   // A filter which allows to open a department by clicking on the departments name.
146   static function filterDepLabel($row,$dn,$params,$ou,$pid,$base)
147   {
148     $ou = $ou[0];
149     if($dn == $base){
150       $ou =".";
151     }
152     $dn= LDAP::fix(func_get_arg(1));
153     return("<a href='?plug=".$_GET['plug']."&amp;PID=$pid&amp;act=listing_open_$row' title='$dn'>$ou</a>");
154   }
157   /*! \brief  Returns information about all container types that GOsa con handle.
158     @return Array   Informations about departments supported by GOsa.
159    */
160   public static function get_support_departments()
161   {
162     /* Domain 
163      */ 
164     $types = array();
165     $types['domain']['ACL']     = "domain"; 
166     $types['domain']['CLASS']   = "domain"; 
167     $types['domain']['ATTR']    = "dc"; 
168     $types['domain']['TAB']     = "DOMAIN_TABS"; 
169     $types['domain']['OC']      = "domain"; 
170     $types['domain']['IMG']     = "plugins/departments/images/domain.png"; 
171     $types['domain']['IMG_FULL']= "plugins/departments/images/domain.png"; 
172     $types['domain']['TITLE']   = _("Domain"); 
173     $types['domain']['TPL']     = "domain.tpl"; 
175     /* Domain component 
176      */
177     $types['dcObject']['ACL']     = "dcObject";
178     $types['dcObject']['CLASS']   = "dcObject";
179     $types['dcObject']['ATTR']    = "dc";
180     $types['dcObject']['TAB']     = "DCOBJECT_TABS";
181     $types['dcObject']['OC']      = "dcObject";
182     $types['dcObject']['IMG']     = "plugins/departments/images/dc.png";
183     $types['dcObject']['IMG_FULL']= "plugins/departments/images/dc.png";
184     $types['dcObject']['TITLE']   = _("Domain Component");
185     $types['dcObject']['TPL']     = "dcObject.tpl";
187     /* Country object
188      */
189     $types['country']['ACL']     = "country";
190     $types['country']['CLASS']   = "country";
191     $types['country']['TAB']     = "COUNTRY_TABS";
192     $types['country']['ATTR']    = "c";
193     $types['country']['OC']      = "country";
194     $types['country']['IMG']     = "plugins/departments/images/country.png";
195     $types['country']['IMG_FULL']= "plugins/departments/images/country.png";
196     $types['country']['TITLE']   = _("Country");
197     $types['country']['TPL']     = "country.tpl";
199     /* Locality object
200      */
201     $types['locality']['ACL']     = "locality";
202     $types['locality']['CLASS']   = "locality";
203     $types['locality']['TAB']     = "LOCALITY_TABS";
204     $types['locality']['ATTR']    = "l";
205     $types['locality']['OC']      = "locality";
206     $types['locality']['IMG']     = "plugins/departments/images/locality.png";
207     $types['locality']['IMG_FULL']= "plugins/departments/images/locality.png";
208     $types['locality']['TITLE']   = _("Locality");
209     $types['locality']['TPL']     = "locality.tpl";
211     /* Organization
212      */
213     $types['organization']['ACL']     = "organization";
214     $types['organization']['CLASS']   = "organization";
215     $types['organization']['TAB']     = "ORGANIZATION_TABS";
216     $types['organization']['ATTR']    = "o";
217     $types['organization']['OC']      = "organization";
218     $types['organization']['IMG']     = "plugins/departments/images/organization.png";
219     $types['organization']['IMG_FULL']= "plugins/departments/images/organization.png";
220     $types['organization']['TITLE']   = _("Organization");
221     $types['organization']['TPL']     = "organization.tpl";
223     /* Department
224      */
225     $types['organizationalUnit']['ACL']     = "department";
226     $types['organizationalUnit']['CLASS']   = "department";
227     $types['organizationalUnit']['TAB']     = "DEPTABS";
228     $types['organizationalUnit']['ATTR']    = "ou";
229     $types['organizationalUnit']['OC']      = "organizationalUnit";
230     $types['organizationalUnit']['IMG']     = "images/lists/folder.png";//plugins/departments/images/department.png";
231     $types['organizationalUnit']['IMG_FULL']= "images/lists/folder-full.png";//:wplugins/departments/images/department.png";
232     $types['organizationalUnit']['TITLE']   = _("Department");
233     $types['organizationalUnit']['TPL']     = "generic.tpl";
234     return($types);
235   }
236
237 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
238 ?>