suggested user names must be in lower case, replace umlauts

This commit is contained in:
Roland Gruber 2013-06-17 18:38:42 +00:00
parent b3af716ced
commit 96a9b7c2e6
1 changed files with 11 additions and 8 deletions

View File

@ -66,6 +66,12 @@ class posixAccount extends baseModule implements passwordService {
private $cachedUIDList = null; private $cachedUIDList = null;
/** caches the list of known user names */ /** caches the list of known user names */
private $cachedUserNameList = null; private $cachedUserNameList = null;
/** replacements for common umlauts */
private $umlautReplacements = array(
'ä' => 'ae', 'Ä' => 'Ae', 'ö' => 'oe', 'Ö' => 'Oe', 'ü' => 'ue', 'Ü' => 'Ue',
'ß' => 'ss', 'é' => 'e', 'è' => 'e', 'ô' => 'o', 'ç' => 'c'
);
/** /**
* This function fills the error message array with messages. * This function fills the error message array with messages.
@ -1081,14 +1087,11 @@ class posixAccount extends baseModule implements passwordService {
* @return string attribute value with replaced non-ASCII characters * @return string attribute value with replaced non-ASCII characters
*/ */
function checkASCII($attribute) { function checkASCII($attribute) {
// convert UTF8 to ASCII if ($attribute == null) {
$convert = array ( 'ä' => 'ae', 'Ä' => 'Ae', 'ö' => 'oe', 'Ö' => 'Oe', 'ü' => 'ue', 'Ü' => 'Ue', return '';
'ß' => 'ss', 'é' => 'e', 'è' => 'e', 'ô' => 'o', 'ç' => 'c'
);
// replace special characters
foreach ($convert as $key => $value) {
$attribute = str_replace($key, $value, $attribute);
} }
// replace special characters
$attribute = str_replace(array_keys($this->umlautReplacements), array_values($this->umlautReplacements), $attribute);
// remove remaining UTF-8 characters // remove remaining UTF-8 characters
for ($c = 0; $c < strlen($attribute); $c++) { for ($c = 0; $c < strlen($attribute); $c++) {
if (ord($attribute[$c]) > 127) { if (ord($attribute[$c]) > 127) {
@ -2715,7 +2718,7 @@ class posixAccount extends baseModule implements passwordService {
$format = str_replace('%' . $wc . '%', $value, $format); $format = str_replace('%' . $wc . '%', $value, $format);
} }
} }
return $format; return str_replace(array_keys($this->umlautReplacements), array_values($this->umlautReplacements), strtolower($format));
} }
/** /**