From c7a39c13e4397ffc7564af34b24f9fb9bd1b8658 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 26 Jun 2008 07:23:12 +0000 Subject: [PATCH] Added checks to new department classes git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11446 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../departments/class_countryGeneric.inc | 35 ++++++++++++++++++- .../admin/departments/class_dcObject.inc | 32 +++++++++++++++++ .../departments/class_localityGeneric.inc | 32 +++++++++++++++++ .../departments/class_organizationGeneric.inc | 32 +++++++++++++++++ 4 files changed, 130 insertions(+), 1 deletion(-) diff --git a/gosa-core/plugins/admin/departments/class_countryGeneric.inc b/gosa-core/plugins/admin/departments/class_countryGeneric.inc index b38fa2871..3bf6f2f80 100644 --- a/gosa-core/plugins/admin/departments/class_countryGeneric.inc +++ b/gosa-core/plugins/admin/departments/class_countryGeneric.inc @@ -34,6 +34,38 @@ class country extends department function check() { $message = plugin::check(); + + /* Check for presence of this department */ + $ldap= $this->config->get_ldap_link(); + $ldap->ls ("(&(c=".$this->c.")(objectClass=country))", $this->base, array('dn')); + if ($this->orig_c == "new" && $ldap->count()){ + $message[]= msgPool::duplicated(_("Name")); + } elseif ($this->orig_dn != $this->dn && $ldap->count()){ + $message[]= msgPool::duplicated(_("Name")); + } + + /* All required fields are set? */ + if ($this->c == ""){ + $message[]= msgPool::required(_("Name")); + }elseif(tests::is_department_name_reserved($this->c,$this->base)){ + $message[]= msgPool::reserved(_("Name")); + }elseif(preg_match ('/[#+:=>\\\\\/]/', $this->c)){ + $message[]= msgPool::invalid(_("Name"), $this->c, "/[^#+:=>\\\\\/]/"); + } + + /* Check description */ + if ($this->description == ""){ + $message[]= msgPool::required(_("Description")); + } + + /* Check if we are allowed to create or move this object + */ + if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){ + $message[] = msgPool::permCreate(); + }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){ + $message[] = msgPool::permMove(); + } + return($message); } @@ -41,7 +73,8 @@ class country extends department /* Return plugin informations for acl handling */ static function plInfo() { - return (array("plShortName" => _("Country"), + return (array( + "plShortName" => _("Country"), "plDescription" => _("Country"), "plSelfModify" => FALSE, "plPriority" => 2, diff --git a/gosa-core/plugins/admin/departments/class_dcObject.inc b/gosa-core/plugins/admin/departments/class_dcObject.inc index 39c81a1c1..dd7d053f4 100644 --- a/gosa-core/plugins/admin/departments/class_dcObject.inc +++ b/gosa-core/plugins/admin/departments/class_dcObject.inc @@ -34,6 +34,38 @@ class dcObject extends department function check() { $message = plugin::check(); + + /* Check for presence of this department */ + $ldap= $this->config->get_ldap_link(); + $ldap->ls ("(&(dc=".$this->dc.")(objectClass=dcObject))", $this->base, array('dn')); + if ($this->orig_dc == "new" && $ldap->count()){ + $message[]= msgPool::duplicated(_("Name")); + } elseif ($this->orig_dn != $this->dn && $ldap->count()){ + $message[]= msgPool::duplicated(_("Name")); + } + + /* All required fields are set? */ + if ($this->dc == ""){ + $message[]= msgPool::required(_("Name")); + }elseif(tests::is_department_name_reserved($this->dc,$this->base)){ + $message[]= msgPool::reserved(_("Name")); + }elseif(!preg_match ('/[a-z0-9 \.,\-_]/i', $this->dc)){ + $message[]= msgPool::invalid(_("Name"), $this->dc, "/[a-z0-9 \.,\-_]/"); + } + + /* Check description */ + if ($this->description == ""){ + $message[]= msgPool::required(_("Description")); + } + + /* Check if we are allowed to create or move this object + */ + if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){ + $message[] = msgPool::permCreate(); + }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){ + $message[] = msgPool::permMove(); + } + return($message); } diff --git a/gosa-core/plugins/admin/departments/class_localityGeneric.inc b/gosa-core/plugins/admin/departments/class_localityGeneric.inc index 0f563976e..f5f895cda 100644 --- a/gosa-core/plugins/admin/departments/class_localityGeneric.inc +++ b/gosa-core/plugins/admin/departments/class_localityGeneric.inc @@ -35,6 +35,38 @@ class locality extends department function check() { $message = plugin::check(); + + /* Check for presence of this department */ + $ldap= $this->config->get_ldap_link(); + $ldap->ls ("(&(l=".$this->l.")(objectClass=locality))", $this->base, array('dn')); + if ($this->orig_l == "new" && $ldap->count()){ + $message[]= msgPool::duplicated(_("Name")); + } elseif ($this->orig_dn != $this->dn && $ldap->count()){ + $message[]= msgPool::duplicated(_("Name")); + } + + /* All required fields are set? */ + if ($this->l == ""){ + $message[]= msgPool::required(_("Name")); + }elseif(tests::is_department_name_reserved($this->l,$this->base)){ + $message[]= msgPool::reserved(_("Name")); + }elseif(preg_match ('/[#+:=>\\\\\/]/', $this->l)){ + $message[]= msgPool::invalid(_("Name"), $this->l, "/[^#+:=>\\\\\/]/"); + } + + /* Check description */ + if ($this->description == ""){ + $message[]= msgPool::required(_("Description")); + } + + /* Check if we are allowed to create or move this object + */ + if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){ + $message[] = msgPool::permCreate(); + }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){ + $message[] = msgPool::permMove(); + } + return($message); } diff --git a/gosa-core/plugins/admin/departments/class_organizationGeneric.inc b/gosa-core/plugins/admin/departments/class_organizationGeneric.inc index 507b2a113..5d899b9df 100644 --- a/gosa-core/plugins/admin/departments/class_organizationGeneric.inc +++ b/gosa-core/plugins/admin/departments/class_organizationGeneric.inc @@ -66,6 +66,38 @@ class organization extends department function check() { $message = plugin::check(); + + /* Check for presence of this department */ + $ldap= $this->config->get_ldap_link(); + $ldap->ls ("(&(o=".$this->o.")(objectClass=organization))", $this->base, array('dn')); + if ($this->orig_o == "new" && $ldap->count()){ + $message[]= msgPool::duplicated(_("Name")); + } elseif ($this->orig_dn != $this->dn && $ldap->count()){ + $message[]= msgPool::duplicated(_("Name")); + } + + /* All required fields are set? */ + if ($this->o == ""){ + $message[]= msgPool::required(_("Name")); + }elseif(tests::is_department_name_reserved($this->o,$this->base)){ + $message[]= msgPool::reserved(_("Name")); + }elseif(preg_match ('/[#+:=>\\\\\/]/', $this->o)){ + $message[]= msgPool::invalid(_("Name"), $this->o, "/[^#+:=>\\\\\/]/"); + } + + /* Check description */ + if ($this->description == ""){ + $message[]= msgPool::required(_("Description")); + } + + /* Check if we are allowed to create or move this object + */ + if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){ + $message[] = msgPool::permCreate(); + }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){ + $message[] = msgPool::permMove(); + } + return($message); } -- 2.30.2