Code

Removed show_ldap_error from gosa-core
[gosa.git] / gosa-core / plugins / admin / departments / class_departmentGeneric.inc
index 08c7f3b101b5cc4370570011d7a40acec93c8dd6..fc808e028976954813300647351b1fe8ef177690 100644 (file)
@@ -1,21 +1,23 @@
 <?php
 /*
-  This code is part of GOsa (https://gosa.gonicus.de)
-  Copyright (C) 2003  Cajus Pollmeier
-
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id$$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 class department extends plugin
@@ -184,7 +186,9 @@ class department extends plugin
                $ldap->cd ($this->dn);
                $ldap->recursive_remove();
     new log("remove","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-    show_ldap_error($ldap->get_error(), sprintf(_("Removing of department with dn '%s' failed."),$this->dn));
+    if (!$ldap->success()){
+      msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
+    }
 
                /* Optionally execute a command after we're done */
                $this->handle_post_events('remove');
@@ -243,31 +247,33 @@ class department extends plugin
                $ldap= $this->config->get_ldap_link();
     $ldap->ls ("(&(ou=".$this->ou.")(objectClass=organizationalUnit))", $this->base, array('dn'));
     if ($this->orig_dn == "new" && $ldap->count()){
-                       $message[]= _("Department with that 'Name' already exists.");
+                       $message[]= msgPool::duplicated(_("Name"));
                } elseif ($this->orig_dn != $this->dn && !($attrs === FALSE)){
-                       $message[]= _("Department with that 'Name' already exists.");
+                       $message[]= msgPool::duplicated(_("Name"));
                }
 
                /* All required fields are set? */
                if ($this->ou == ""){
                        $message[]= _("Required field 'Name' is not set.");
+                       $message[]= msgPool::required(_("Name"));
                }
                if ($this->description == ""){
                        $message[]= _("Required field 'Description' is not set.");
+                       $message[]= msgPool::required(_("Description"));
                }
 
     if(tests::is_department_name_reserved($this->ou,$this->base)){
-      $message[]= sprintf(_("The field 'Name' contains the reserved word '%s'. Please choose another name."),$this->ou);
+      $message[]= msgPool::reserved(_("Name"));
     }
 
                if (preg_match ('/[#+:=>\\\\\/]/', $this->ou)){
-                       $message[]= _("The field 'Name' contains invalid characters.");
+                       $message[]= msgPool::invalid(_("Name"), $this->ou, "/[^#+:=>\\\\\/]/");
                }
                if (!tests::is_phone_nr($this->telephoneNumber)){
-                       $message[]= _("The field 'Phone' contains an invalid phone number.");
+                       $message[]= msgPool::invalid(_("Phone"), $this->telephoneNumber, "/[\/0-9 ()+*-]/");
                }
                if (!tests::is_phone_nr($this->facsimileTelephoneNumber)){
-                       $message[]= _("The field 'Fax' contains an invalid phone number.");
+                       $message[]= msgPool::invalid(_("Fax"), $this->facsimileTelephoneNumber, "/[\/0-9 ()+*-]/");
                }
 
                return $message;
@@ -355,7 +361,9 @@ class department extends plugin
                        $this->handle_post_events('add');
       new log("create","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
                }
-    show_ldap_error($ldap->get_error(), sprintf(_("Saving of department with dn '%s' failed."),$this->dn));
+    if (!$ldap->success()){
+      msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
+    }
 
     /* The parameter forces only to set must_be_tagged, and don't touch any objects 
        This will be done later */
@@ -648,7 +656,9 @@ class department extends plugin
         $nattrs['objectClass'][]= "gosaAdministrativeUnitTag";
         $ldap->cd($dn);
         $ldap->modify($nattrs);
-        show_ldap_error($ldap->get_error(), sprintf(_("Handle object tagging with dn '%s' failed."),$dn));
+        if (!$ldap->success()){
+          msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
+        }
       } else {
         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not tagging ($tag) $dn - seems to have moved away", "Tagging");
       }
@@ -677,7 +687,9 @@ class department extends plugin
         }
         $ldap->cd($dn);
         $ldap->modify($nattrs);
-        show_ldap_error($ldap->get_error(), sprintf(_("Handle object tagging with dn '%s' failed."),$dn));
+        if (!$ldap->success()){
+          msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
+        }
       } else {
         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not removing tag ($tag) $dn - seems to have moved away", "Tagging");
       }