Code

Added checks to new department classes
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 26 Jun 2008 07:23:12 +0000 (07:23 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 26 Jun 2008 07:23:12 +0000 (07:23 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11446 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/admin/departments/class_countryGeneric.inc
gosa-core/plugins/admin/departments/class_dcObject.inc
gosa-core/plugins/admin/departments/class_localityGeneric.inc
gosa-core/plugins/admin/departments/class_organizationGeneric.inc

index b38fa2871c5c789446a408951696bd9325a96d90..3bf6f2f801bb9af479bd5858df556395260f0838 100644 (file)
@@ -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,
index 39c81a1c1533260bcdcf5fbc417b1297a7841102..dd7d053f4284db24050e9a4e07967ade3e72d0d8 100644 (file)
@@ -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);
   }
 
index 0f563976e7120e7f0cb64b8f32877066cb7523ff..f5f895cdaf5ec37f2953ebeb57ebb5fb3123d967 100644 (file)
@@ -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);
   }
 
index 507b2a1131f5a6d9ceddabbcb786db3c057573c4..5d899b9dfdf158f9be9e21f905e9913dbe278f77 100644 (file)
@@ -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);
   }