From eed253bd2fcaee8ebc8fb4c60f74366e3017f688 Mon Sep 17 00:00:00 2001 From: snipe Date: Sat, 13 Jul 2024 15:15:18 +0100 Subject: [PATCH 1/4] Use app helped instead of facade Signed-off-by: snipe --- app/Http/Middleware/CheckLocale.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Middleware/CheckLocale.php b/app/Http/Middleware/CheckLocale.php index 412a423f22..68a9c48c34 100644 --- a/app/Http/Middleware/CheckLocale.php +++ b/app/Http/Middleware/CheckLocale.php @@ -45,7 +45,7 @@ class CheckLocale } - \App::setLocale(Helper::mapLegacyLocale($language)); + app()->setLocale(Helper::mapLegacyLocale($language)); return $next($request); } } From f91ad6b2db19a3fea75c823680c00fecb9a6ac40 Mon Sep 17 00:00:00 2001 From: snipe Date: Sat, 13 Jul 2024 15:15:44 +0100 Subject: [PATCH 2/4] =?UTF-8?q?Use=20app()->getLocale()=20to=20determine?= =?UTF-8?q?=20imported=20user=E2=80=99s=20language?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: snipe --- app/Console/Commands/LdapSync.php | 1 + app/Models/Ldap.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Console/Commands/LdapSync.php b/app/Console/Commands/LdapSync.php index 1856bf10fc..c90c3c2a92 100755 --- a/app/Console/Commands/LdapSync.php +++ b/app/Console/Commands/LdapSync.php @@ -232,6 +232,7 @@ class LdapSync extends Command $item['department'] = $results[$i][$ldap_result_dept][0] ?? ''; $item['manager'] = $results[$i][$ldap_result_manager][0] ?? ''; $item['location'] = $results[$i][$ldap_result_location][0] ?? ''; + $item['locale'] = app()->getLocale(); // ONLY if you are using the "ldap_location" option *AND* you have an actual result if ($ldap_result_location && $item['location']) { diff --git a/app/Models/Ldap.php b/app/Models/Ldap.php index dd3920b56a..ecce46d82a 100644 --- a/app/Models/Ldap.php +++ b/app/Models/Ldap.php @@ -229,6 +229,7 @@ class Ldap extends Model $item['department'] = $ldapattributes[$ldap_result_dept][0] ?? ''; $item['manager'] = $ldapattributes[$ldap_result_manager][0] ?? ''; $item['location'] = $ldapattributes[$ldap_result_location][0] ?? ''; + $item['locale'] = app()->getLocale(); return $item; } @@ -239,7 +240,7 @@ class Ldap extends Model * @author [A. Gianotto] [] * @since [v3.0] * @param $ldapatttibutes - * @return array|bool + * @return User | bool */ public static function createUserFromLdap($ldapatttibutes, $password) { @@ -252,6 +253,7 @@ class Ldap extends Model $user->last_name = $item['lastname']; $user->username = $item['username']; $user->email = $item['email']; + $user->locale = $item['locale']; $user->password = $user->noPassword(); if (Setting::getSettings()->ldap_pw_sync == '1') { From 24e58d14558b32e98e160dc004696e1d3418fb83 Mon Sep 17 00:00:00 2001 From: snipe Date: Sat, 13 Jul 2024 15:20:04 +0100 Subject: [PATCH 3/4] Do not update users who already exist since that locale may have been overirrden manually Signed-off-by: snipe --- app/Console/Commands/LdapSync.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Console/Commands/LdapSync.php b/app/Console/Commands/LdapSync.php index c90c3c2a92..676d207c22 100755 --- a/app/Console/Commands/LdapSync.php +++ b/app/Console/Commands/LdapSync.php @@ -232,7 +232,6 @@ class LdapSync extends Command $item['department'] = $results[$i][$ldap_result_dept][0] ?? ''; $item['manager'] = $results[$i][$ldap_result_manager][0] ?? ''; $item['location'] = $results[$i][$ldap_result_location][0] ?? ''; - $item['locale'] = app()->getLocale(); // ONLY if you are using the "ldap_location" option *AND* you have an actual result if ($ldap_result_location && $item['location']) { @@ -252,6 +251,7 @@ class LdapSync extends Command // Creating a new user. $user = new User; $user->password = $user->noPassword(); + $item['locale'] = app()->getLocale(); $user->activated = 1; // newly created users can log in by default, unless AD's UAC is in use, or an active flag is set (below) $item['createorupdate'] = 'created'; } From ab6b8f520e203b86385109d870292e14b1c48339 Mon Sep 17 00:00:00 2001 From: snipe Date: Sat, 13 Jul 2024 15:25:37 +0100 Subject: [PATCH 4/4] Fixed field name Signed-off-by: snipe --- app/Console/Commands/LdapSync.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Console/Commands/LdapSync.php b/app/Console/Commands/LdapSync.php index 676d207c22..845db27ef9 100755 --- a/app/Console/Commands/LdapSync.php +++ b/app/Console/Commands/LdapSync.php @@ -251,7 +251,7 @@ class LdapSync extends Command // Creating a new user. $user = new User; $user->password = $user->noPassword(); - $item['locale'] = app()->getLocale(); + $user->locale = app()->getLocale(); $user->activated = 1; // newly created users can log in by default, unless AD's UAC is in use, or an active flag is set (below) $item['createorupdate'] = 'created'; }