Code

Readded department tagging.
[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");
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'])) $actions['action'] = "performRecMove";
82     if(isset($_GET['TagDepartment'])) $actions['action'] = "tagDepartment";
83     return($actions);
84   }
86   function tagDepartment()
87   {
88     $plugname = $this->last_tabObject->base_name;
89     $this->last_tabObject->by_object[$plugname]->tag_objects();
90     exit();
91   }
94   function newEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
95   {
96     $types= $this->get_support_departments();
97     $type = preg_replace("/^new_/","",$action);
98     return(management::newEntry($action,$target,$all,$this->tabClass,$types[$type]['TAB'],$this->aclCategory));
99   }
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   }
108   protected function saveChanges()
109   {
110     management::saveChanges();
111   
112     global $config; 
113     $config->get_departments();
114     $config->make_idepartments();
115     $this->config = $config;
117     $plugname = $this->last_tabObject->base_name;
118     if($this->last_tabObject->by_object[$plugname]->must_be_tagged()){
119       $smarty = get_smarty();
120       $smarty->assign("src","?plug=".$_GET['plug']."&TagDepartment&no_output_compression");
121       $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."));
122       return($smarty->fetch(get_template_path("dep_iframe.tpl",TRUE)));
123     }
124   }
125   
126  
127  
128   function openEntry($action,$entry)
129   {
130     $this->headpage->setBase(array_pop($entry));
131   }
133   protected function removeEntryRequested($action="",$target=array(),$all=array())
134   {
135     $target = array_remove_entries(array($this->config->current['BASE']),$target);
136     return(management::removeEntryRequested($action,$target,$all)); 
137   }
139   static function filterDepLabel($row,$dn,$params,$ou,$pid,$base)
140   {
141     $ou = $ou[0];
142     if($dn == $base){
143       $ou =".";
144     }
145     $dn= LDAP::fix(func_get_arg(1));
146     return("<a href='?plug=".$_GET['plug']."&amp;PID=$pid&amp;act=listing_open_$row' title='$dn'>$ou</a>");
147   }
150   /*! \brief  Returns information about all container types that GOsa con handle.
151     @return Array   Informations about departments supported by GOsa.
152    */
153   public static function get_support_departments()
154   {
155     /* Domain 
156      */ 
157     $types = array();
158     $types['domain']['ACL']     = "domain"; 
159     $types['domain']['CLASS']   = "domain"; 
160     $types['domain']['ATTR']    = "dc"; 
161     $types['domain']['TAB']     = "DOMAIN_TABS"; 
162     $types['domain']['OC']      = "domain"; 
163     $types['domain']['IMG']     = "plugins/departments/images/domain.png"; 
164     $types['domain']['IMG_FULL']= "plugins/departments/images/domain.png"; 
165     $types['domain']['TITLE']   = _("Domain"); 
166     $types['domain']['TPL']     = "domain.tpl"; 
168     /* Domain component 
169      */
170     $types['dcObject']['ACL']     = "dcObject";
171     $types['dcObject']['CLASS']   = "dcObject";
172     $types['dcObject']['ATTR']    = "dc";
173     $types['dcObject']['TAB']     = "DCOBJECT_TABS";
174     $types['dcObject']['OC']      = "dcObject";
175     $types['dcObject']['IMG']     = "plugins/departments/images/dc.png";
176     $types['dcObject']['IMG_FULL']= "plugins/departments/images/dc.png";
177     $types['dcObject']['TITLE']   = _("Domain Component");
178     $types['dcObject']['TPL']     = "dcObject.tpl";
180     /* Country object
181      */
182     $types['country']['ACL']     = "country";
183     $types['country']['CLASS']   = "country";
184     $types['country']['TAB']     = "COUNTRY_TABS";
185     $types['country']['ATTR']    = "c";
186     $types['country']['OC']      = "country";
187     $types['country']['IMG']     = "plugins/departments/images/country.png";
188     $types['country']['IMG_FULL']= "plugins/departments/images/country.png";
189     $types['country']['TITLE']   = _("Country");
190     $types['country']['TPL']     = "country.tpl";
192     /* Locality object
193      */
194     $types['locality']['ACL']     = "locality";
195     $types['locality']['CLASS']   = "locality";
196     $types['locality']['TAB']     = "LOCALITY_TABS";
197     $types['locality']['ATTR']    = "l";
198     $types['locality']['OC']      = "locality";
199     $types['locality']['IMG']     = "plugins/departments/images/locality.png";
200     $types['locality']['IMG_FULL']= "plugins/departments/images/locality.png";
201     $types['locality']['TITLE']   = _("Locality");
202     $types['locality']['TPL']     = "locality.tpl";
204     /* Organization
205      */
206     $types['organization']['ACL']     = "organization";
207     $types['organization']['CLASS']   = "organization";
208     $types['organization']['TAB']     = "ORGANIZATION_TABS";
209     $types['organization']['ATTR']    = "o";
210     $types['organization']['OC']      = "organization";
211     $types['organization']['IMG']     = "plugins/departments/images/organization.png";
212     $types['organization']['IMG_FULL']= "plugins/departments/images/organization.png";
213     $types['organization']['TITLE']   = _("Organization");
214     $types['organization']['TPL']     = "organization.tpl";
216     /* Department
217      */
218     $types['organizationalUnit']['ACL']     = "department";
219     $types['organizationalUnit']['CLASS']   = "department";
220     $types['organizationalUnit']['TAB']     = "DEPTABS";
221     $types['organizationalUnit']['ATTR']    = "ou";
222     $types['organizationalUnit']['OC']      = "organizationalUnit";
223     $types['organizationalUnit']['IMG']     = "images/lists/folder.png";//plugins/departments/images/department.png";
224     $types['organizationalUnit']['IMG_FULL']= "images/lists/folder-full.png";//:wplugins/departments/images/department.png";
225     $types['organizationalUnit']['TITLE']   = _("Department");
226     $types['organizationalUnit']['TPL']     = "generic.tpl";
227     return($types);
228   }
229
230 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
231 ?>