diff --git a/ext/standaloneusers/CRM/Standaloneusers/BAO/User.php b/ext/standaloneusers/CRM/Standaloneusers/BAO/User.php
index 70f96fd1fb1b..2522b9d91f77 100644
--- a/ext/standaloneusers/CRM/Standaloneusers/BAO/User.php
+++ b/ext/standaloneusers/CRM/Standaloneusers/BAO/User.php
@@ -29,4 +29,8 @@ public static function updateLastAccessed() {
$sess->set('lastAccess', time());
}
+ public static function getPreferredLanguages(): array {
+ return CRM_Core_I18n::uiLanguages(FALSE);
+ }
+
}
diff --git a/ext/standaloneusers/CRM/Standaloneusers/DAO/User.php b/ext/standaloneusers/CRM/Standaloneusers/DAO/User.php
index 8ebd081ab473..b1e6f21b31ee 100644
--- a/ext/standaloneusers/CRM/Standaloneusers/DAO/User.php
+++ b/ext/standaloneusers/CRM/Standaloneusers/DAO/User.php
@@ -6,7 +6,7 @@
*
* Generated from standaloneusers/xml/schema/CRM/Standaloneusers/User.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:0b0cd1d01573ad0e5adc1a3e92f9638b)
+ * (GenCodeChecksum:bb2c741901a689ff804ab65d05c7795b)
*/
use CRM_Standaloneusers_ExtensionUtil as E;
@@ -526,6 +526,12 @@ public static function &fields() {
'entity' => 'User',
'bao' => 'CRM_Standaloneusers_DAO_User',
'localizable' => 0,
+ 'html' => [
+ 'type' => 'Select',
+ ],
+ 'pseudoconstant' => [
+ 'callback' => 'CRM_Standaloneusers_BAO_User::getPreferredLanguages',
+ ],
'add' => '2.1',
],
'password_reset_token' => [
diff --git a/ext/standaloneusers/Civi/Standalone/Security.php b/ext/standaloneusers/Civi/Standalone/Security.php
index 34b4efca4ea1..2f041d671b1c 100644
--- a/ext/standaloneusers/Civi/Standalone/Security.php
+++ b/ext/standaloneusers/Civi/Standalone/Security.php
@@ -210,6 +210,8 @@ public function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realP
return FALSE;
}
+ $this->applyLocaleFromUser($user);
+
// Note: random_int is more appropriate for cryptographical use than mt_rand
// The long number is the max 32 bit value.
return [$user['contact_id'], $user['id'], random_int(0, 2147483647)];
@@ -235,6 +237,7 @@ public function loginAuthenticatedUserRecord(array $user, bool $withSession) {
])['values'][0]['contact_id'] ?? NULL;
// Confusingly, Civi stores it's *Contact* ID as *userID* on the session.
$session->set('userID', $contactID);
+ $this->applyLocaleFromUser($user);
}
}
@@ -452,4 +455,17 @@ public function preparePasswordResetWorkflow(array $user, string $token): ?CRM_S
return $workflowMessage;
}
+ /**
+ * Applies the locale from the user record.
+ *
+ * @param array $user
+ * @return void
+ */
+ private function applyLocaleFromUser(array $user) {
+ $session = CRM_Core_Session::singleton();
+ if (!empty($user['language'])) {
+ $session->set('lcMessages', $user['language']);
+ }
+ }
+
}
diff --git a/ext/standaloneusers/ang/afformEditUserAccount.aff.html b/ext/standaloneusers/ang/afformEditUserAccount.aff.html
index 53e67473d196..209509dde5da 100644
--- a/ext/standaloneusers/ang/afformEditUserAccount.aff.html
+++ b/ext/standaloneusers/ang/afformEditUserAccount.aff.html
@@ -6,7 +6,7 @@
-
+
diff --git a/ext/standaloneusers/standaloneusers.php b/ext/standaloneusers/standaloneusers.php
index 2b7b2e793125..fda5e61e7233 100644
--- a/ext/standaloneusers/standaloneusers.php
+++ b/ext/standaloneusers/standaloneusers.php
@@ -10,6 +10,22 @@
use CRM_Standaloneusers_ExtensionUtil as E;
// phpcs:enable
+/**
+ * Hide the inherit CMS language on the Settings - Localization form.
+ *
+ * Implements hook_civicrm_buildForm().
+ *
+ * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_buildForm/
+ */
+function standaloneusers_civicrm_buildForm($formName, CRM_Core_Form $form) {
+ // Administer / Localization / Languages, Currency, Locations
+ if ($formName == 'CRM_Admin_Form_Setting_Localization') {
+ if ($inheritLocaleElement = $form->getElement('inheritLocale')) {
+ $inheritLocaleElement->freeze();
+ }
+ }
+}
+
/**
* Implements hook_civicrm_config().
*
diff --git a/ext/standaloneusers/xml/schema/CRM/Standaloneusers/User.xml b/ext/standaloneusers/xml/schema/CRM/Standaloneusers/User.xml
index fb5fd1ab2117..8b9917f48c54 100644
--- a/ext/standaloneusers/xml/schema/CRM/Standaloneusers/User.xml
+++ b/ext/standaloneusers/xml/schema/CRM/Standaloneusers/User.xml
@@ -183,6 +183,12 @@
varchar
5
UI language preferred by the given user/contact
+
+ CRM_Standaloneusers_BAO_User::getPreferredLanguages
+
+
+ Select
+
2.1