Code

Updated department Management
[gosa.git] / gosa-core / plugins / admin / departments / class_countryGeneric.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 country extends department
24 {
25         /* attribute list for save action */
26         var $attributes     = array( "c", "ou", "description","gosaUnitTag");
27         var $objectclasses  = array("top", "gosaDepartment");
28   var $structuralOC   = array("country");
29   var $type   ="country";
30   var $c      ="";
31   var $orgi_c ="";
33   var $namingAttr = "c";
35   function check()
36   {
37     $message = plugin::check();
38     
39                 /* Check for presence of this department */
40                 $ldap= $this->config->get_ldap_link();
41     $ldap->ls ("(&(c=".$this->c.")(objectClass=country))", $this->base, array('dn'));
42     if ($this->orig_c == "new" && $ldap->count()){
43                         $message[]= msgPool::duplicated(_("Name"));
44                 } elseif ($this->orig_dn != $this->dn && $ldap->count()){
45                         $message[]= msgPool::duplicated(_("Name"));
46                 }
48                 /* All required fields are set? */
49                 if ($this->c == ""){
50                         $message[]= msgPool::required(_("Name"));
51                 }elseif(tests::is_department_name_reserved($this->c,$this->base)){
52       $message[]= msgPool::reserved(_("Name"));
53     }elseif(preg_match ('/[#+:=>\\\\\/]/', $this->c)){
54                         $message[]= msgPool::invalid(_("Name"), $this->c, "/[^#+:=>\\\\\/]/");
55                 }
57     /* Check description */
58                 if ($this->description == ""){
59                         $message[]= msgPool::required(_("Description"));
60                 }
62     /* Check if we are allowed to create or move this object
63      */
64     if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
65       $message[] = msgPool::permCreate();
66     }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
67       $message[] = msgPool::permMove();
68     }
70     return($message);
71   }
74   /* Return plugin informations for acl handling */ 
75   static function plInfo()
76   {
77     return (array(
78           "plShortName"   => _("Country"),
79           "plDescription" => _("Country"),
80           "plSelfModify"  => FALSE,
81           "plPriority"    => 2,
82           "plDepends"     => array(),
83           "plSection"     => array("administration"),
84           "plCategory"    => array("department"),
86           "plProvidedAcls" => array(
87             "c"                 => _("Country name"),
88             "description"       => _("Description"),
89             "base"              => _("Base"),
90             "gosaUnitTag"       => _("Administrative settings"))
91           ));
92   }
93 }
95 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
96 ?>