diff --git a/drupal/sites/all/features/boinc_standard/boinc_standard.features.menu_links.inc b/drupal/sites/all/features/boinc_standard/boinc_standard.features.menu_links.inc index 013a98b204..fb30f84bbe 100644 --- a/drupal/sites/all/features/boinc_standard/boinc_standard.features.menu_links.inc +++ b/drupal/sites/all/features/boinc_standard/boinc_standard.features.menu_links.inc @@ -66,7 +66,7 @@ function boinc_standard_menu_default_menu_links() { 'menu_name' => 'primary-links', 'link_path' => 'user/me/edit', 'router_path' => 'user/%/edit', - 'link_title' => 'Account Info', + 'link_title' => 'Credentials', 'options' => array( 'attributes' => array( 'title' => '', @@ -82,7 +82,7 @@ function boinc_standard_menu_default_menu_links() { ); // Translatables // Included for use with string extractors like potx. - t('Account Info'); + t('Credentials'); t('BOINC'); t('Dashboard'); t('Home'); diff --git a/drupal/sites/default/boinc/modules/boincuser/boincuser.module b/drupal/sites/default/boinc/modules/boincuser/boincuser.module index 8d801a233d..ae8bbe7681 100644 --- a/drupal/sites/default/boinc/modules/boincuser/boincuser.module +++ b/drupal/sites/default/boinc/modules/boincuser/boincuser.module @@ -436,26 +436,16 @@ function boincuser_form_alter(&$form, $form_state, $form_id) { $form['account']['name']['#size'] = 40; $form['account']['mail']['#size'] = 40; + $form['account']['pass']['#size'] = 17; - // Add the BOINC user name (non-unique, user editable) - if (!$edit['boincuser_name']) $edit['boincuser_name'] = $account->boincuser_name; - $form['account']['boincuser_name'] = array( - '#type' => 'textfield', - '#title' => t('Name'), - '#default_value' => $edit['boincuser_name'], - '#maxlength' => USERNAME_MAX_LENGTH, - '#required' => TRUE, - '#description' => t(''), - '#size' => 40 - ); if (!$reset_pass AND ($user->uid == $account->uid OR !user_access('administer users'))) { // Add a password authenticator, required to change email or pw $form['account']['current_pass'] = array( '#type' => 'password', - '#title' => t('Current password'), + '#title' => t('Enter your password to save changes'), '#description' => t('Enter your current password if changing your email address or password.'), - '#size' => 25 + '#size' => 17 ); } @@ -489,24 +479,29 @@ function boincuser_form_alter(&$form, $form_state, $form_id) { ', ); + $form['account']['separator_bottom'] = array( + '#value' => '
' + ); + $form['submit']['#value'] = t('Save changes'); + // Rearrange form elements - $form['account']['boincuser_name']['#weight'] = 0; $form['account']['mail']['#weight'] = 5; - $form['account']['current_pass']['#weight'] = 10; $form['account']['pass']['#weight'] = 15; $form['account']['user_id']['#weight'] = 50; $form['account']['account_key']['#weight'] = 55; $form['account']['weak_account_key']['#weight'] = 60; $form['account']['cpid']['#weight'] = 65; + $form['account']['separator_bottom']['#weight'] = 999; + $form['account']['current_pass']['#weight'] = 1000; // Remove redundant / unnecessary form elements - //echo '
' . print_r($form, true) . '
'; unset($form['theme_select']); // These are on the Community preferences form (boincwork module) - unset($form['signature_settings']); unset($form['enable_pm_mail']); unset($form['friend_notification']); + unset($form['signature_settings']); + unset($form['timezone']); // Internal fields to indicate where these user changes are taking place array_unshift($form, array( @@ -601,6 +596,27 @@ function boincuser_form_alter(&$form, $form_state, $form_id) { } } +/** + * Implementation of hook_elements() + * @see http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_elements/6 + */ +function boincuser_elements() { + $type['password_confirm']['#process'][] = 'boincuser_process_password_confirm'; + return $type; +} + +/** + * This madness is required to change the password field label on the user + * profile form + */ +function boincuser_process_password_confirm($element) { + // Check if parent element is "account". + if ($element['#array_parents'][0] == 'account') { + $element['pass1']['#title'] = t('Change password'); + } + return $element; +} + /** * Implementation of hook_theme() * Register theme functions for use in this module. diff --git a/drupal/sites/default/boinc/modules/boincwork/includes/boincwork.forms.inc b/drupal/sites/default/boinc/modules/boincwork/includes/boincwork.forms.inc index 631a7c8c21..96203fb260 100644 --- a/drupal/sites/default/boinc/modules/boincwork/includes/boincwork.forms.inc +++ b/drupal/sites/default/boinc/modules/boincwork/includes/boincwork.forms.inc @@ -513,7 +513,7 @@ function boincwork_generalprefs_form(&$form_state, $venue, $prefs_preset = null, $form['prefs']['form control tabs'] = array( '#value' => '
  • ' . l(t('Cancel'), $_GET['q']) . '
  • ' ); - if ($venue != 'generic') { + if ($venue AND $venue != 'generic') { global $base_path; $form['prefs']['form control tabs']['#value'] .= '
  • ' . l(t('Clear'), "account/prefs/computing/clear/{$venue}", @@ -527,7 +527,10 @@ function boincwork_generalprefs_form(&$form_state, $venue, $prefs_preset = null, ) . '
  • '; } $form['prefs']['view control'] = array( - '#value' => '
  • ' . l('(' . t('Show comparison view') . ')', 'account/prefs/computing/combined') . '
  • ' + '#value' => '
  • ' . l('(' . t('Show comparison view') . ')', 'account/prefs/computing/combined') . '
  • ' + ); + $form['prefs']['form control tabs suffix'] = array( + '#value' => '' ); $form['#submit'][] = 'boincwork_generalprefs_form_submit'; @@ -875,7 +878,7 @@ function boincwork_projectprefs_form(&$form_state, $venue) { $form['prefs']['form control tabs'] = array( '#value' => '
  • ' . l(t('Cancel'), $_GET['q']) . '
  • ' ); - if ($venue != 'generic') { + if ($venue AND $venue != 'generic') { global $base_path; $form['prefs']['form control tabs']['#value'] .= '
  • ' . l(t('Clear'), "account/prefs/project/clear/{$venue}", @@ -889,7 +892,10 @@ function boincwork_projectprefs_form(&$form_state, $venue) { ) . '
  • '; } $form['prefs']['view control'] = array( - '#value' => '
  • ' . l('(' . t('Show comparison view') . ')', 'account/prefs/project/combined') . '
  • ' + '#value' => '
  • ' . l('(' . t('Show comparison view') . ')', 'account/prefs/project/combined') . '
  • ' + ); + $form['prefs']['form control tabs suffix'] = array( + '#value' => '' ); return $form; @@ -1024,6 +1030,7 @@ function boincwork_projectprefs_form_submit($form, &$form_state) { */ function communityprefs_form(&$form_state) { global $user; + $account = user_load($user->uid); $form = array(); // Standard option sets @@ -1034,10 +1041,40 @@ function communityprefs_form(&$form_state) { $default = array( 'pm_send_notification' => '', // This is set already in pm_email_notify_user - 'friend_notification' => isset($user->friend_notification) ? $user->friend_notification : 0, - 'comments_per_page' => (isset($user->comments_per_page) AND $user->comments_per_page) ? $user->comments_per_page : variable_get('comment_default_per_page_forum', 50) + 'friend_notification' => isset($account->friend_notification) ? $account->friend_notification : 0, + 'comments_per_page' => (isset($account->comments_per_page) AND $account->comments_per_page) ? $account->comments_per_page : variable_get('comment_default_per_page_forum', 50) ); + // General options + $form['general'] = array( + '#type' => 'fieldset', + '#title' => t('General settings'), + '#weight' => 0, + '#collapsible' => TRUE, + '#collapsed' => FALSE + ); + // Add the BOINC user name (non-unique, user editable) + $form['general']['boincuser_name'] = array( + '#type' => 'textfield', + '#title' => t('Name'), + '#default_value' => $account->boincuser_name, + '#maxlength' => USERNAME_MAX_LENGTH, + '#required' => TRUE, + '#description' => t(''), + '#size' => 40 + ); + // Time zone + if (variable_get('configurable_timezones', 1)) { + $zones = _system_zonelist(); + $form['general']['timezone'] = array( + '#type' => 'select', + '#title' => t('Time zone'), + '#default_value' => ($account->timezone !== NULL) ? $account->timezone : variable_get('date_default_timezone', 0), + '#options' => $zones, + '#description' => '', + ); + } + // Notification options $form['notifications'] = array( '#type' => 'fieldset', @@ -1047,7 +1084,7 @@ function communityprefs_form(&$form_state) { '#collapsed' => FALSE ); // Pull in private message notification handling and tweak the form - $pm_notify = pm_email_notify_user('form', $edit, $user, 'account'); + $pm_notify = pm_email_notify_user('form', $edit, $account, 'account'); $form['notifications']['pm_send_notifications'] = array_replace( $pm_notify['enable_pm_mail']['pm_send_notifications'], array( @@ -1091,29 +1128,37 @@ function communityprefs_form(&$form_state) { '#type' => 'textarea', '#title' => t('Signature'), '#description' => t('Your signature will be publicly displayed at the end of your comments.'), - '#default_value' => $user->signature + '#default_value' => $account->signature ); // Prevent a "validation error" message when the user attempts to save with a default value they // do not have access to. - if (!filter_access($user->signature_format) && empty($_POST)) { + if (!filter_access($account->signature_format) && empty($_POST)) { drupal_set_message(t("The signature input format has been set to a format you don't have access to. It will be changed to a format you have access to when you save this page.")); $edit['signature_format'] = FILTER_FORMAT_DEFAULT; } - $form['forums']['signature_format'] = filter_form($user->signature_format, NULL, array('signature_format')); + $form['forums']['signature_format'] = filter_form($account->signature_format, NULL, array('signature_format')); } + $form['separator_bottom'] = array( + '#value' => '
    ', + '#weight' => 999, + ); + // Form control - $form['prefs']['form control tabs prefix'] = array( + $form['form control tabs prefix'] = array( '#value' => '' + $form['form control tabs'] = array( + '#value' => '
  • ' . l(t('Cancel'), $_GET['q']) . '
  • ' + ); + $form['form control tabs suffix'] = array( + '#value' => '' ); return $form; @@ -1123,12 +1168,25 @@ function communityprefs_form(&$form_state) { * Handle post-validation submission of community preferences form. */ function communityprefs_form_submit($form, &$form_state) { + require_boinc('db'); global $user; + $account = user_load($user->uid); + $boinc_user = lookup_user_id($account->boincuser_id); $edit= $form_state['values']; + // Display name + if ($edit['boincuser_name'] != $boinc_user->name) { + $boincuser_name = $edit['boincuser_name']; + $result = $boinc_user->update( + "name='{$boincuser_name}'" + ); + } + // Private message settings pm_email_notify_user('submit', $edit, $user); + // All other settings user_save($user, array( 'signature' => $edit['signature'], 'signature_format' => $edit['signature_format'], + 'timezone' => $edit['timezone'], 'friend_notification' => $edit['friend_notification'], 'comments_per_page' => $edit['comments_per_page'] )); @@ -1185,6 +1243,10 @@ function boincwork_privacyprefs_form(&$form_state) { '#default_value' => $default['privacy']['show_hosts'] ); + $form['prefs']['separator_bottom'] = array( + '#value' => '
    ' + ); + // Form control $form['prefs']['form control tabs prefix'] = array( '#value' => '' + '#value' => '
  • ' . l(t('Cancel'), $_GET['q']) . '
  • ' + ); + $form['prefs']['form control tabs suffix'] = array( + '#value' => '' ); return $form;