From b5216eb39c3051ae688dd810c738de7836247d0d Mon Sep 17 00:00:00 2001 From: cajus Date: Mon, 3 Mar 2008 15:35:52 +0000 Subject: [PATCH] Added unified messages git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9252 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/html/password.php | 8 ++++---- gosa-core/include/class_SnapShotDialog.inc | 2 +- gosa-core/include/class_plugin.inc | 11 +++++----- gosa-core/include/utils/class_msgPool.inc | 14 ++++++++++++- .../departments/class_departmentGeneric.inc | 14 +++++++------ .../admin/groups/class_groupGeneric.inc | 20 +++++++++++-------- .../plugins/admin/ogroups/class_ogroup.inc | 6 +++--- .../admin/users/class_userManagement.inc | 14 ++++++------- gosa-core/plugins/personal/generic/main.inc | 2 +- 9 files changed, 54 insertions(+), 37 deletions(-) diff --git a/gosa-core/html/password.php b/gosa-core/html/password.php index c7896deaa..0d807407f 100644 --- a/gosa-core/html/password.php +++ b/gosa-core/html/password.php @@ -195,7 +195,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['apply'])){ $message[]= _("The passwords you've entered as 'New password' and 'Repeated new password' do not match."); } else { if ($_POST['new_password'] == ""){ - $message[]= _("The password you've entered as 'New password' is empty."); + $message[]= msgPool::required(_("New password")); } } @@ -213,10 +213,10 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['apply'])){ } /* Validate */ - if (!ereg("^[A-Za-z0-9_.-]+$", $uid)){ - $message[]= _("Please specify a valid username!"); + if (!tests::is_uid($uid)){ + $message[]= msgPool::invalid(_("Login")); } elseif (mb_strlen($_POST["current_password"], 'UTF-8') == 0){ - $message[]= _("Please specify your password!"); + $message[]= msgPool::required(_("Current password")); } else { /* Do we have the selected user somewhere? */ diff --git a/gosa-core/include/class_SnapShotDialog.inc b/gosa-core/include/class_SnapShotDialog.inc index 00e1f870d..258a1b2e9 100644 --- a/gosa-core/include/class_SnapShotDialog.inc +++ b/gosa-core/include/class_SnapShotDialog.inc @@ -146,7 +146,7 @@ class SnapShotDialog extends plugin $message = plugin::check(); if(!$this->display_restore_dialog){ if(empty($this->CurrentDescription)){ - $message[] = _("Please specify a valid description for this snapshot."); + $message[]= msgPool::invalid(_("Description")); } } return($message); diff --git a/gosa-core/include/class_plugin.inc b/gosa-core/include/class_plugin.inc index 6bf6e73db..de49eb40d 100644 --- a/gosa-core/include/class_plugin.inc +++ b/gosa-core/include/class_plugin.inc @@ -431,8 +431,7 @@ class plugin if ($command != ""){ if (!check_command($command)){ - $message[]= sprintf(_("Command '%s', specified as CHECK hook for plugin '%s' doesn't seem to exist."), $command, - get_class($this)); + $message[]= msgPool::cmdnotfound("CHECK", get_class($this)); } else { /* Generate "ldif" for check hook */ @@ -485,7 +484,7 @@ class plugin $current_csn = getEntryCSN($this->dn); if($current_csn != $this->entryCSN && !empty($this->entryCSN) && !empty($current_csn)){ $this->entryCSN = $current_csn; - $message[] = _("The object has changed since opened in GOsa. Please ensure that nobody has done serious changes that may get lost if you save this entry."); + $message[] = _("The object has changed since opened in GOsa. All changes that may be done by others get lost if you save this entry!"); } } return ($message); @@ -618,7 +617,7 @@ class plugin exec($command); } else { - $message= sprintf(_("Command '%s', specified as POSTCREATE for plugin '%s' doesn't seem to exist."), $command, get_class($this)); + $message[]= msgPool::cmdnotfound("POSTCREATE", get_class($this)); msg_dialog::display(_("Error"), $message, ERROR_DIALOG); } } @@ -650,7 +649,7 @@ class plugin exec($command); } else { - $message= sprintf(_("Command '%s', specified as POSTMODIFY for plugin '%s' doesn't seem to exist."), $command, get_class($this)); + $message[]= msgPool::cmdnotfound("POSTMODIFY", get_class($this)); msg_dialog::display(_("Error"), $message, ERROR_DIALOG); } } @@ -681,7 +680,7 @@ class plugin exec($command); } else { - $message= sprintf(_("Command '%s', specified as POSTREMOVE for plugin '%s' doesn't seem to exist."), $command, get_class($this)); + $message[]= msgPool::cmdnotfound("POSTREMOVE", get_class($this)); msg_dialog::display(_("Error"), $message, ERROR_DIALOG); } } diff --git a/gosa-core/include/utils/class_msgPool.inc b/gosa-core/include/utils/class_msgPool.inc index c5eec8021..8e2484c80 100644 --- a/gosa-core/include/utils/class_msgPool.inc +++ b/gosa-core/include/utils/class_msgPool.inc @@ -3,6 +3,18 @@ class msgPool { + public static function reserved($name) + { + return (sprintf(_("The field '%s' contains a reserved keyword!"), $name)); + } + + + public static function cmdnotfound($type, $plugin) + { + return (sprintf(_("Command specified as %s hook for plugin '%s' does not exist!"), $type, $plugin)); + } + + public static function toobig($name, $min= "") { if ($min == ""){ @@ -69,7 +81,7 @@ class msgPool if (preg_match("$regex", $currentChar)){ $result.= $currentChar; } else { - $result.= "".htmlentities($currentChar).""; + $result.= "".htmlentities($currentChar).""; $mismatch.= $currentChar; } } diff --git a/gosa-core/plugins/admin/departments/class_departmentGeneric.inc b/gosa-core/plugins/admin/departments/class_departmentGeneric.inc index 08c7f3b10..0f9ec67cf 100644 --- a/gosa-core/plugins/admin/departments/class_departmentGeneric.inc +++ b/gosa-core/plugins/admin/departments/class_departmentGeneric.inc @@ -243,31 +243,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; diff --git a/gosa-core/plugins/admin/groups/class_groupGeneric.inc b/gosa-core/plugins/admin/groups/class_groupGeneric.inc index eed50c61d..5f0a1c861 100644 --- a/gosa-core/plugins/admin/groups/class_groupGeneric.inc +++ b/gosa-core/plugins/admin/groups/class_groupGeneric.inc @@ -524,7 +524,7 @@ class group extends plugin /* If more than max users are found, display a message to warn the user */ if($i == $MaxUser){ - msg_dialog::display(_("Configuration error"), sprintf(_("Search returned too many results. Not displaying more than %s entries."), $MaxUser), ERROR_DIALOG); + msg_dialog::display(_("Configuration error"), sprintf(_("Search returned too many results. Not displaying more than %s entries!"), $MaxUser), ERROR_DIALOG); } /* Sort lists */ @@ -845,12 +845,16 @@ class group extends plugin /* must: cn */ if ($this->cn == "" && $this->acl_is_writeable("cn")){ - $message[]= "The required field 'Name' is not set."; + $message[]= msgPool::required(_("Name")); } /* Check for valid input */ if (!tests::is_uid($this->cn)){ - $message[]= _("The field 'Name' contains invalid characters. Lowercase, numbers and dashes are allowed."); + if (strict_uid_mode()){ + $message[]= msgPool::invalid(_("Name"), $this->cn, "/[a-z0-9_-]/"); + } else { + $message[]= msgPool::invalid(_("Name"), $this->cn, "/[a-z0-9_-]/i"); + } } if($this->allowGroupsWithSameNameInOtherSubtrees == true){ @@ -861,7 +865,7 @@ class group extends plugin $ldap->cd(get_groups_ou().$this->base); $ldap->ls("(&(|(objectClass=gosaGroupOfNames)(objectClass=posixGroup))(cn=$this->cn))",get_groups_ou().$this->base,array("cn")); if ($ldap->count() != 0){ - $message[]= _("Value specified as 'Name' is already used."); + $message[]= msgPool::duplicated(_("Name")); } } @@ -875,14 +879,14 @@ class group extends plugin /* New entry? */ if ($this->dn == 'new'){ - $message[]= _("Value specified as 'Name' is already used."); + $message[]= msgPool::duplicated(_("Name")); } /* Moved? */ elseif ($new_dn != $this->orig_dn){ $ldap->fetch(); if ($ldap->getDN() != $this->orig_dn){ - $message[]= _("Value specified as 'Name' is already used."); + $message[]= msgPool::duplicated(_("Name")); } } } @@ -891,10 +895,10 @@ class group extends plugin /* Check ID */ if ($this->force_gid == "1"){ if (!tests::is_id($this->gidNumber)){ - $message[]= _("Value specified as 'GID' is not valid."); + $message[]= msgPool::invalid(_("GID"), $this->gidNumber, "/[0-9]/"); } else { if ($this->gidNumber < $this->config->current['MINID']){ - $message[]= _("Value specified as 'GID' is too small."); + $message[]= msgPool::toosmall(_("GID"), $this->config->current['MINID']); } } diff --git a/gosa-core/plugins/admin/ogroups/class_ogroup.inc b/gosa-core/plugins/admin/ogroups/class_ogroup.inc index ca2ef6969..b36a79cf4 100644 --- a/gosa-core/plugins/admin/ogroups/class_ogroup.inc +++ b/gosa-core/plugins/admin/ogroups/class_ogroup.inc @@ -592,7 +592,7 @@ class ogroup extends plugin } if($ldap->count() !=0){ - $message[]= _("There is already an object with this cn."); + $message[]= msgPool::duplicated(_("Name")); } /* Set new acl base */ @@ -602,12 +602,12 @@ class ogroup extends plugin /* must: cn */ if ($this->cn == ""){ - $message[]= "The required field 'Name' is not set."; + $message[]= msgPool::required(_("Name")); } /* To many different object types? */ if (strlen($this->gosaGroupObjects) > 4){ - $message[]= _("You can combine two different object types at maximum only!"); + $message[]= _("You can combine two different object types at maximum, only!"); } return ($message); diff --git a/gosa-core/plugins/admin/users/class_userManagement.inc b/gosa-core/plugins/admin/users/class_userManagement.inc index 04a17bc48..0d7a5f698 100644 --- a/gosa-core/plugins/admin/users/class_userManagement.inc +++ b/gosa-core/plugins/admin/users/class_userManagement.inc @@ -236,7 +236,7 @@ class userManagement extends plugin /* Empty password is not permitted by default. */ if ($_POST['new_password'] == ""){ - $message[]= _("The password you've entered as 'New password' is empty."); + msgPool::required(_("New password")); } } @@ -725,13 +725,13 @@ class userManagement extends plugin if (isset($_POST['template_continue'])){ $message = array(); if(!isset($_POST['template']) || (empty($_POST['template']))){ - $message[] = _("Please select a valid template."); + $message[]= msgPool::invalid(_("Template")); } if(!isset($_POST['sn']) || (empty($_POST['sn']))){ - $message[]= _("The required field 'Name' is not set."); + $message[]= msgPool::required(_("Name")); } if(!isset($_POST['givenName']) || (empty($_POST['givenName']))){ - $message[]= _("The required field 'Given name' is not set."); + $message[]= msgPool::required(_("Given name")); } /* Show error message / continue editing */ @@ -806,10 +806,10 @@ class userManagement extends plugin /* Check for requred values */ $message= array(); if ($this->sn == "") { - $message[]= _("The required field 'Name' is not set."); + $message[]= msgPool::required(_("Name")); } if ($this->givenName == "") { - $message[]= _("The required field 'Given name' is not set."); + $message[]= msgPool::required(_("Given name")); } /* Check if dn is used */ @@ -818,7 +818,7 @@ class userManagement extends plugin $ldap->cd ($dn); $ldap->search ("(&(sn=".normalizeLdap($this->sn).")(givenName=".normalizeLdap($this->givenName)."))", array("givenName")); if ($ldap->count () != 0){ - $message[]= _("A person with the choosen name is already used in this tree."); + msgPool::duplicated(_("Name")); } /* Show error message / continue editing */ diff --git a/gosa-core/plugins/personal/generic/main.inc b/gosa-core/plugins/personal/generic/main.inc index beafad1e8..753e8d412 100644 --- a/gosa-core/plugins/personal/generic/main.inc +++ b/gosa-core/plugins/personal/generic/main.inc @@ -82,7 +82,7 @@ if (!$remove_lock){ /* Empty password is not permitted by default. */ if ($_POST['new_password'] == ""){ - $message[]= _("The password you've entered as 'New password' is empty."); + $message[]= msgPool::required(_("New password")); } } -- 2.30.2