d6e7a63d9a
This patch replaces all homegrown timezone stuff with standard PHP date/time code. The main change is the introduction of core_date class that returns normalised user and server timezones. From now on nobody should be using $CFG->timezone or $user->timezone directly! Other new features and fixes: * admins are prompted for timezone during install * editing of other users is finally fixed * timezones are displayed in user profile * new $this->setTimezone() in phpunit * time locale is now automatically reset in phpunit * timezone is now automatically reset in phpunit * phpunit has Australia/Perth as default timezone
39 lines
2.3 KiB
PHP
39 lines
2.3 KiB
PHP
<?php
|
|
|
|
if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
|
|
|
// "locations" settingpage
|
|
$temp = new admin_settingpage('locationsettings', new lang_string('locationsettings', 'admin'));
|
|
|
|
$current = isset($CFG->timezone) ? $CFG->timezone : null;
|
|
$options = core_date::get_list_of_timezones($current, false);
|
|
$default = core_date::get_default_php_timezone();
|
|
if ($current == 99) {
|
|
// Do not show 99 unless it is current value, we want to get rid of it over time.
|
|
$options['99'] = new lang_string('timezonephpdefault', 'core_admin', $default);
|
|
}
|
|
if ($default === 'UTC') {
|
|
// Nobody really wants UTC, so instead default selection to the country that is confused by the UTC the most.
|
|
$default = 'Europe/London';
|
|
}
|
|
$temp->add(new admin_setting_configselect('timezone', new lang_string('timezone', 'admin'),
|
|
new lang_string('configtimezone', 'admin'), $default, $options));
|
|
|
|
$options = core_date::get_list_of_timezones(isset($CFG->forcetimezone) ? $CFG->forcetimezone : null, true);
|
|
$options[99] = new lang_string('timezonenotforced', 'admin');
|
|
$temp->add(new admin_setting_configselect('forcetimezone', new lang_string('forcetimezone', 'admin'),
|
|
new lang_string('helpforcetimezone', 'admin'), 99, $options));
|
|
|
|
$temp->add(new admin_settings_country_select('country', new lang_string('country', 'admin'), new lang_string('configcountry', 'admin'), 0));
|
|
$temp->add(new admin_setting_configtext('defaultcity', new lang_string('defaultcity', 'admin'), new lang_string('defaultcity_help', 'admin'), ''));
|
|
|
|
$temp->add(new admin_setting_heading('iplookup', new lang_string('iplookup', 'admin'), new lang_string('iplookupinfo', 'admin')));
|
|
$temp->add(new admin_setting_configfile('geoipfile', new lang_string('geoipfile', 'admin'), new lang_string('configgeoipfile', 'admin', $CFG->dataroot.'/geoip/'), $CFG->dataroot.'/geoip/GeoLiteCity.dat'));
|
|
$temp->add(new admin_setting_configtext('googlemapkey3', new lang_string('googlemapkey3', 'admin'), new lang_string('googlemapkey3_help', 'admin'), '', PARAM_RAW, 60));
|
|
|
|
$temp->add(new admin_setting_configtext('allcountrycodes', new lang_string('allcountrycodes', 'admin'), new lang_string('configallcountrycodes', 'admin'), '', '/^(?:\w+(?:,\w+)*)?$/'));
|
|
|
|
$ADMIN->add('location', $temp);
|
|
|
|
} // end of speedup
|