$sess->set('lastAccess', time());
}
+ public static function getPreferredLanguages(): array {
+ return CRM_Core_I18n::uiLanguages(FALSE);
+ }
+
}
*
* 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;
'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' => [
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)];
])['values'][0]['contact_id'] ?? NULL;
// Confusingly, Civi stores it's *Contact* ID as *userID* on the session.
$session->set('userID', $contactID);
+ $this->applyLocaleFromUser($user);
}
}
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']);
+ }
+ }
+
}
<af-field name="uf_name" />
<af-field name="is_active" />
<af-field name="timezone" />
- <af-field name="language" />
+ <af-field name="language" defn="{help_pre: ts('Set the user interface language of this user. You can also leave it empty to use the default system language.'), input_attrs: {placeholder: ts('System default language')}}" />
</fieldset>
<button class="af-button btn btn-primary" crm-icon="fa-check" ng-click="afform.submit()">Submit</button>
</af-form>
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().
*
<type>varchar</type>
<length>5</length>
<comment>UI language preferred by the given user/contact</comment>
+ <pseudoconstant>
+ <callback>CRM_Standaloneusers_BAO_User::getPreferredLanguages</callback>
+ </pseudoconstant>
+ <html>
+ <type>Select</type>
+ </html>
<add>2.1</add>
</field>
<index>