Commit d7908276 authored by Dries's avatar Dries

- Patch #144919 by dww: hide user picture settings when possible.

parent 2934a3d9
......@@ -438,3 +438,11 @@ thead div.sticky-header {
#clean-url.install {
display: none;
}
/*
** For anything you want to hide on page load when JS is enabled, so
** that you can use the JS to control visibility and avoid flicker.
*/
html.js .js-hide {
display: none;
}
/* $Id$ */
/**
* 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.
*/
if (Drupal.jsEnabled) {
$(document).ready(function () {
$('div.user-admin-picture-radios input[@type=radio]').click(function () {
$('div.user-admin-picture-settings')[['hide', 'show'][this.value]]();
});
});
}
......@@ -2625,7 +2625,6 @@ function user_admin_settings() {
'#title' => t('Signature support'),
'#default_value' => variable_get('user_signatures', 0),
'#options' => array(t('Disabled'), t('Enabled')),
'#description' => t('Enable signature support.'),
);
// If picture support is enabled, check whether the picture directory exists:
......@@ -2634,13 +2633,69 @@ function user_admin_settings() {
file_check_directory($picture_path, 1, 'user_picture_path');
}
$form['pictures'] = array('#type' => 'fieldset', '#title' => t('Pictures'));
$form['pictures']['user_pictures'] = array('#type' => 'radios', '#title' => t('Picture support'), '#default_value' => variable_get('user_pictures', 0), '#options' => array(t('Disabled'), t('Enabled')), '#description' => t('Enable picture support.'));
$form['pictures']['user_picture_path'] = array('#type' => 'textfield', '#title' => t('Picture image path'), '#default_value' => variable_get('user_picture_path', 'pictures'), '#size' => 30, '#maxlength' => 255, '#description' => t('Subdirectory in the directory %dir where pictures will be stored.', array('%dir' => file_directory_path() .'/')));
$form['pictures']['user_picture_default'] = array('#type' => 'textfield', '#title' => t('Default picture'), '#default_value' => variable_get('user_picture_default', ''), '#size' => 30, '#maxlength' => 255, '#description' => t('URL of picture to display for users with no custom picture selected. Leave blank for none.'));
$form['pictures']['user_picture_dimensions'] = array('#type' => 'textfield', '#title' => t('Picture maximum dimensions'), '#default_value' => variable_get('user_picture_dimensions', '85x85'), '#size' => 15, '#maxlength' => 10, '#description' => t('Maximum dimensions for pictures, in pixels.'));
$form['pictures']['user_picture_file_size'] = array('#type' => 'textfield', '#title' => t('Picture maximum file size'), '#default_value' => variable_get('user_picture_file_size', '30'), '#size' => 15, '#maxlength' => 10, '#description' => t('Maximum file size for pictures, in kB.'));
$form['pictures']['user_picture_guidelines'] = array('#type' => 'textarea', '#title' => t('Picture guidelines'), '#default_value' => variable_get('user_picture_guidelines', ''), '#description' => t("This text is displayed at the picture upload form in addition to the default guidelines. It's useful for helping or instructing your users."));
$form['pictures'] = array(
'#type' => 'fieldset',
'#title' => t('Pictures'),
);
$picture_support = variable_get('user_pictures', 0);
$form['pictures']['user_pictures'] = array(
'#type' => 'radios',
'#title' => t('Picture support'),
'#default_value' => $picture_support,
'#options' => array(t('Disabled'), t('Enabled')),
'#prefix' => '<div class="user-admin-picture-radios">',
'#suffix' => '</div>',
);
drupal_add_js(drupal_get_path('module', 'user') .'/user.js');
// If JS is enabled, and the radio is defaulting to off, hide all
// the settings on page load via .css using the js-hide class so
// that there's no flicker.
$css_class = 'user-admin-picture-settings';
if (!$picture_support) {
$css_class .= ' js-hide';
}
$form['pictures']['settings'] = array(
'#prefix' => '<div class="'. $css_class .'">',
'#suffix' => '</div>',
);
$form['pictures']['settings']['user_picture_path'] = array(
'#type' => 'textfield',
'#title' => t('Picture image path'),
'#default_value' => variable_get('user_picture_path', 'pictures'),
'#size' => 30,
'#maxlength' => 255,
'#description' => t('Subdirectory in the directory %dir where pictures will be stored.', array('%dir' => file_directory_path() .'/')),
);
$form['pictures']['settings']['user_picture_default'] = array(
'#type' => 'textfield',
'#title' => t('Default picture'),
'#default_value' => variable_get('user_picture_default', ''),
'#size' => 30,
'#maxlength' => 255,
'#description' => t('URL of picture to display for users with no custom picture selected. Leave blank for none.'),
);
$form['pictures']['settings']['user_picture_dimensions'] = array(
'#type' => 'textfield',
'#title' => t('Picture maximum dimensions'),
'#default_value' => variable_get('user_picture_dimensions', '85x85'),
'#size' => 15,
'#maxlength' => 10,
'#description' => t('Maximum dimensions for pictures, in pixels.'),
);
$form['pictures']['settings']['user_picture_file_size'] = array(
'#type' => 'textfield',
'#title' => t('Picture maximum file size'),
'#default_value' => variable_get('user_picture_file_size', '30'),
'#size' => 15,
'#maxlength' => 10,
'#description' => t('Maximum file size for pictures, in kB.'),
);
$form['pictures']['settings']['user_picture_guidelines'] = array(
'#type' => 'textarea',
'#title' => t('Picture guidelines'),
'#default_value' => variable_get('user_picture_guidelines', ''),
'#description' => t("This text is displayed at the picture upload form in addition to the default guidelines. It's useful for helping or instructing your users."),
);
return system_settings_form($form);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment