Code

reenabled filter caching
[gosa.git] / gosa-core / plugins / admin / departments / class_localityGeneric.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: class_departmentGeneric.inc 11085 2008-05-28 10:54:49Z hickert $$
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 locality extends department
24 {
25         /* attribute list for save action */
26         var $attributes     = array("l", "description", "ou", "gosaUnitTag", "manager");
27         var $objectclasses  = array("top", "gosaDepartment");
28   var $structuralOC   = array("locality");
30   var $description= "";
31   var $type       = "locality";
32   var $l          = "";
33   var $orig_l     = "";
34   var $namingAttr = "l";
36   var $manager_enabled = FALSE;
37   var $manager_name ="";
38   var $manager ="";
40   function check()
41   {
42     $message = plugin::check();
43     
44                 /* Check for presence of this department */
45                 $ldap= $this->config->get_ldap_link();
46     $ldap->ls ("(&(l=".$this->l.")(objectClass=locality))", $this->base, array('dn'));
47     if ($this->orig_l == "new" && $ldap->count()){
48                         $message[]= msgPool::duplicated(_("Name"));
49                 } elseif ($this->orig_dn != $this->dn && $ldap->count()){
50                         $message[]= msgPool::duplicated(_("Name"));
51                 }
53                 /* All required fields are set? */
54                 if ($this->l == ""){
55                         $message[]= msgPool::required(_("Name"));
56                 }elseif(tests::is_department_name_reserved($this->l,$this->base)){
57       $message[]= msgPool::reserved(_("Name"));
58     }elseif(preg_match ('/[#+:=>\\\\\/]/', $this->l)){
59                         $message[]= msgPool::invalid(_("Name"), $this->l, "/[^#+:=>\\\\\/]/");
60                 }
62     /* Check description */
63                 if ($this->description == ""){
64                         $message[]= msgPool::required(_("Description"));
65                 }
67     /* Check if we are allowed to create or move this object
68      */
69     if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
70       $message[] = msgPool::permCreate();
71     }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
72       $message[] = msgPool::permMove();
73     }
75     return($message);
76   }
79   /* Return plugin informations for acl handling */ 
80   static function plInfo()
81   {
82     return (array("plShortName"   => _("Locality"),
83           "plDescription" => _("Locality"),
84           "plSelfModify"  => FALSE,
85           "plPriority"    => 3,
86           "plDepends"     => array(),
87           "plSection"     => array("administration"),
88           "plCategory"    => array("department"),
90           "plProvidedAcls" => array(
91             "l"                 => _("Location"),
92             "description"       => _("Description"),
93             "manager"                 => _("Manager"),
94             "base"              => _("Base"),
95             "gosaUnitTag"       => _("Administrative settings"))
96           ));
97   }
98 }
100 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
101 ?>