Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CRM/Utils/System/Standalone.php
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,9 @@ public function getTimeZoneString() {
return $user['timezone'];
}
}
return date_default_timezone_get();
// Fallback in case the setting is not yet set during the initial upgrade
// (or cache flush)
Comment on lines +584 to +585

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be...

Suggested change
// Fallback in case the setting is not yet set during the initial upgrade
// (or cache flush)
// Global fallback if no timezone specified at user level

?

return Civi::settings()->get('standalone_timezone_default') ?? date_default_timezone_get();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions ext/standaloneusers/ang/afformEditMyAccount.aff.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<div class="af-markup"></div>
<af-field name="username" />
<af-field name="uf_name" defn="{help_pre: 'Email used for password resets.'}" />
<af-field name="timezone" defn="{help_pre: 'Set your local timezone. Date and times will be shown in this timezone when you are logged in. You can also leave it empty to use the default system timezone (which is a server setting).', input_attrs: {placeholder: 'Server default timezone'}}" />
<af-field name="language" defn="{help_pre: 'Set your user interface language. You can also leave it empty to use the default system language.', input_attrs: {placeholder: 'System default language'}}" />
<af-field name="timezone" defn="{help_pre: 'Set your local timezone. Date and times will be shown in this timezone when you are logged in. You can also leave it empty to use the default timezone (see Login Settings).', input_attrs: {placeholder: 'Default timezone'}}" />
<af-field name="language" defn="{help_pre: 'Set your user interface language. You can also leave it empty to use the default system language.', input_attrs: {placeholder: 'Default language'}}" />
<div class="af-container af-container-style-pane">
<af-field name="roles" defn="{input_type: 'DisplayOnly', input_attrs: {}}" />
</div>
Expand Down
2 changes: 1 addition & 1 deletion ext/standaloneusers/ang/afformEditUserAccount.aff.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<af-field name="contact_id" defn="{required: true, input_attrs: {quickAdd: ['civicrm/quick-add/Individual']}}" />
<af-field name="uf_name" defn="{help_pre: ts('Email used for password resets.'), input_attrs: {placeholder: ts('Leave blank to use the primary email from the selected contact')}}" />
<af-field name="is_active" />
<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="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 timezone (see Login Settings).'), input_attrs: {placeholder: ts('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>
Expand Down
17 changes: 17 additions & 0 deletions ext/standaloneusers/settings/standaloneusers.setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@
use CRM_Standaloneusers_ExtensionUtil as E;

return [
'standalone_timezone_default' => [

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe also we can use settings_pages key to put this on a different page from Login settings. I'm not sure whether localization or date (the latter is date formats atm)?

'name' => 'standalone_timezone_default',
'group' => 'standaloneusers',
'type' => 'String',
'default' => date_default_timezone_get(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would avoid this kind of dynamic default. There's lots of ways it gets confusing:

  • you change the server timezone and its not reflected because this default has been cached
  • you go to the settings page and it shows as set to the specific timezone of your server, then the server timezone changes and you go back and its something else
  • same thing except you saved on the settings page so the server value literal was saved to civi db, now the server changes and it's not reflected
  • you have any kind of horizontally scaled deployment with different server timezones

All this is to say, I think it might be better to have an empty default, with a placeholder like "- use server timezone -"?

'html_type' => 'select',
'html_attributes' => [
'class' => 'huge crm-select2',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something like this for the placeholder?

Suggested change
'class' => 'huge crm-select2',
'class' => 'huge crm-select2',
'placeholder' => E::ts('Use server timezone - currently %1', [1 => date_default_timezone_get()]),

],
'title' => E::ts('Default Timezone'),
'is_domain' => 1,
'is_contact' => 0,
'description' => E::ts('Default timezone for anonymous users and for users using the default timezone.'),
Comment on lines +14 to +17

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'title' => E::ts('Default Timezone'),
'is_domain' => 1,
'is_contact' => 0,
'description' => E::ts('Default timezone for anonymous users and for users using the default timezone.'),
'title' => E::ts('System Timezone'),
'is_domain' => 1,
'is_contact' => 0,
'description' => E::ts('Timezone to use for dates and times - unless overridden at user-level.'),

I think "default" is confusing here, because there's a default value for Default timezone; and the default value of User timezone is "use the default timezone" and...

'pseudoconstant' => [
'callback' => ['CRM_Standaloneusers_BAO_User', 'getTimeZones'],
],
],
'standaloneusers_session_max_lifetime' => [
'name' => 'standaloneusers_session_max_lifetime',
'group' => 'standaloneusers',
Expand Down