summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--install.php2
-rw-r--r--modules/system/system.js7
-rw-r--r--modules/user/user.js8
-rw-r--r--modules/user/user.module22
4 files changed, 31 insertions, 8 deletions
diff --git a/install.php b/install.php
index cc8b3199b..0268ae6e1 100644
--- a/install.php
+++ b/install.php
@@ -914,7 +914,7 @@ function install_configure_form() {
if (Drupal.jsEnabled) {
$(document).ready(function() {
Drupal.cleanURLsInstallCheck();
- Drupal.installDefaultTimezone();
+ Drupal.setDefaultTimezone();
});
}', 'inline');
diff --git a/modules/system/system.js b/modules/system/system.js
index 3e0e3a501..d261b49e1 100644
--- a/modules/system/system.js
+++ b/modules/system/system.js
@@ -60,11 +60,6 @@ Drupal.cleanURLsInstallCheck = function() {
$("#clean-url").addClass('clean-url-processed');
};
-Drupal.installDefaultTimezone = function() {
- var offset = new Date().getTimezoneOffset() * -60;
- $("#edit-date-default-timezone").val(offset);
-};
-
/**
* Show/hide custom format sections on the date-time settings page.
*/
@@ -85,4 +80,4 @@ Drupal.behaviors.dateTime = function(context) {
// Trigger the event handler to show the form input if necessary.
$('select.date-format', context).trigger('change');
-}; \ No newline at end of file
+};
diff --git a/modules/user/user.js b/modules/user/user.js
index bdfa06b43..aa5cf34a3 100644
--- a/modules/user/user.js
+++ b/modules/user/user.js
@@ -168,6 +168,14 @@ Drupal.evaluatePasswordStrength = function(value) {
};
/**
+ * Set the client's system timezone as default values of form fields.
+ */
+Drupal.setDefaultTimezone = function() {
+ var offset = new Date().getTimezoneOffset() * -60;
+ $("#edit-date-default-timezone, #edit-user-register-timezone").val(offset);
+};
+
+/**
* On the admin/user/settings page, conditionally show all of the
* picture-related form elements depending on the current value of the
* "Picture support" radio buttons.
diff --git a/modules/user/user.module b/modules/user/user.module
index fa6b41e28..418a451e5 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -269,7 +269,7 @@ function user_save($account, $array = array(), $category = 'account') {
$values[] = md5($value);
$s[] = "'%s'";
break;
- case 'mode': case 'sort':
+ case 'mode': case 'sort': case 'timezone':
case 'threshold': case 'created': case 'access':
case 'login': case 'status':
$fields[] = $key;
@@ -1360,6 +1360,26 @@ function user_register() {
else {
$form = array_merge($form, $extra);
}
+
+ if (variable_get('configurable_timezones', 1)) {
+ // Override field ID, so we only change timezone on user registration,
+ // and never touch it on user edit pages.
+ $form['timezone'] = array(
+ '#type' => 'hidden',
+ '#default_value' => variable_get('date_default_timezone', NULL),
+ '#id' => 'edit-user-register-timezone',
+ );
+
+ // Add the JavaScript callback to automatically set the timezone.
+ drupal_add_js('
+// Global Killswitch
+if (Drupal.jsEnabled) {
+ $(document).ready(function() {
+ Drupal.setDefaultTimezone();
+ });
+}', 'inline');
+ }
+
$form['submit'] = array('#type' => 'submit', '#value' => t('Create new account'), '#weight' => 30);
$form['#validate'][] = 'user_register_validate';