*/
public function getTimeZoneString() {
$timezone = date_default_timezone_get();
+ $userId = Security::singleton()->getLoggedInUfID();
+ if ($userId) {
+ $user = Security::singleton()->loadUserByID($userId);
+ if ($user && !empty($user['timezone'])) {
+ $timezone = $user['timezone'];
+ }
+ }
return $timezone;
}
return CRM_Core_I18n::uiLanguages(FALSE);
}
+ public static function getTimeZones(): array {
+ $timeZones = [];
+ foreach (\DateTimeZone::listIdentifiers() as $timezoneId) {
+ $timeZones[$timezoneId] = $timezoneId;
+ }
+ return $timeZones;
+ }
+
}
*
* Generated from standaloneusers/xml/schema/CRM/Standaloneusers/User.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:08b152ee7b327be88d44e2fce7c528ea)
+ * (GenCodeChecksum:889ac5b24fb6913d046bd2e52dcb65ea)
*/
use CRM_Standaloneusers_ExtensionUtil as E;
'bao' => 'CRM_Standaloneusers_DAO_User',
'localizable' => 0,
'html' => [
- 'type' => 'Text',
+ 'type' => 'Select',
+ ],
+ 'pseudoconstant' => [
+ 'callback' => 'CRM_Standaloneusers_BAO_User::getTimeZones',
],
'add' => NULL,
],
<af-field name="username" />
<af-field name="uf_name" />
<af-field name="is_active" />
- <af-field name="timezone" />
+ <af-field name="timezone" defn="{help_pre: ts('Set the timezone of the user. Date and times will be shown in this timezone. You can also leave it empty to use the default system timezone (which is a server setting).'), input_attrs: {placeholder: ts('Server default timezone')}}" />
<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>
<length>32</length>
<required>false</required>
<comment>User's timezone</comment>
+ <pseudoconstant>
+ <callback>CRM_Standaloneusers_BAO_User::getTimeZones</callback>
+ </pseudoconstant>
<html>
- <type>Text</type>
+ <type>Select</type>
</html>
</field>