-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
16 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,9 +121,9 @@ public static function getUserData(Container $container, int $id, array $options | |
//Normalized format s.name (example mail usage : [email protected] ) | ||
//FIXME: why don't use email directly? | ||
$norm_login = | ||
mb_substr(self::stripAccents(mb_strtolower($member->surname)), 0, 1) . | ||
mb_substr(self::stripAccents($member->surname), 0, 1) . | ||
'.' . | ||
self::stripAccents(mb_strtolower($nameFPart)); | ||
self::stripAccents($nameFPart); | ||
|
||
$etat_adhesion = ($member->isActive() && $member->isUp2Date()) || $member->isAdmin(); | ||
|
||
|
@@ -181,7 +181,7 @@ public static function getUserData(Container $container, int $id, array $options | |
$group = trim($group); | ||
$group = str_replace([' ', '/', '(', ')'], ['_', '', '', ''], $group); | ||
$group = str_replace('__', '_', $group); | ||
$group = mb_strtolower(self::stripAccents($group)); | ||
$group = self::stripAccents($group); | ||
} | ||
$groups = implode(',', $groups); | ||
|
||
|
@@ -245,15 +245,19 @@ public static function mergeOptions(Config $config, $client_id, array $oauth_sco | |
// 'email' => '[email protected]', 'emailVerified' => NULL, 'phone' => NULL, | ||
// 'address' => NULL, 'country' => NULL, 'region' => NULL, 'city' => NULL, 'zip' => NULL | ||
|
||
/** | ||
* Strips accented characters, lower string | ||
* | ||
* @param string $str | ||
* @return string | ||
*/ | ||
public static function stripAccents(string $str): string | ||
{ | ||
//FIXME: there is probably a better way to go. | ||
//try with something like transliterator_transliterate("Any-Latin; Latin-ASCII; [^a-zA-Z0-9\.\ -_] Remove;", $str); | ||
//see https://www.matthecat.com/supprimer-les-accents-d-une-chaine-avec-php.html and https://stackoverflow.com/a/35177682 | ||
return strtr( | ||
$str, | ||
'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïñòóôõöøùúûüýÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƒƠơƯưǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǺǻǼǽǾǿ', | ||
'AAAAAAAECEEEEIIIIDNOOOOOOUUUUYsaaaaaaaeceeeeiiiinoooooouuuuyyAaAaAaCcCcCcCcDdDdEeEeEeEeEeGgGgGgGgHhHhIiIiIiIiIiIJijJjKkLlLlLlLlllNnNnNnnOoOoOoOEoeRrRrRrSsSsSsSsTtTtTtUuUuUuUuUuUuWwYyYZzZzZzsfOoUuAaIiOoUuUuUuUuUuAaAEaeOo' | ||
return mb_strtolower( | ||
transliterator_transliterate( | ||
"Any-Latin; Latin-ASCII; [^a-zA-Z0-9\.\ -_] Remove;", | ||
$str | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters