Commit 16005119 authored by webchick's avatar webchick

Issue #1496534 by cosmicdreams, alexpott, aspilicious, kim.pepper, acrollet,...

Issue #1496534 by cosmicdreams, alexpott, aspilicious, kim.pepper, acrollet, dagmar, beejeebus, wizonesolutions | heyrocker: Convert account settings to configuration system.
parent e599787b
......@@ -1704,7 +1704,7 @@ function comment_preview(Comment $comment) {
$comment->picture = $account->picture;
}
elseif (empty($comment->name)) {
$comment->name = variable_get('anonymous', t('Anonymous'));
$comment->name = config('user.settings')->get('anonymous');
}
$comment->created = !empty($comment->created) ? $comment->created : REQUEST_TIME;
......@@ -1839,7 +1839,7 @@ function theme_comment_post_forbidden($variables) {
$destination = array('destination' => "node/$node->nid#comment-form");
}
if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) {
if (config('user.settings')->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY) {
// Users can register themselves.
return t('<a href="@login">Log in</a> or <a href="@register">register</a> to post comments', array('@login' => url('user/login', array('query' => $destination)), '@register' => url('user/register', array('query' => $destination))));
}
......
......@@ -131,7 +131,7 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
break;
case 'name':
$name = ($comment->uid == 0) ? variable_get('anonymous', t('Anonymous')) : $comment->name;
$name = ($comment->uid == 0) ? config('user.settings')->get('anonymous') : $comment->name;
$replacements[$original] = $sanitize ? filter_xss($name) : $name;
break;
......
......@@ -85,7 +85,7 @@ public function form(array $form, array &$form_state, EntityInterface $comment)
'#default_value' => $author,
'#maxlength' => 60,
'#size' => 30,
'#description' => t('Leave blank for %anonymous.', array('%anonymous' => variable_get('anonymous', t('Anonymous')))),
'#description' => t('Leave blank for %anonymous.', array('%anonymous' => config('user.settings')->get('anonymous'))),
'#autocomplete_path' => 'user/autocomplete',
);
}
......@@ -284,7 +284,7 @@ public function submit(array $form, array &$form_state) {
// If the comment was posted by an anonymous user and no author name was
// required, use "Anonymous" by default.
if ($comment->is_anonymous && (!isset($comment->name) || $comment->name === '')) {
$comment->name = variable_get('anonymous', t('Anonymous'));
$comment->name = config('user.settings')->get('anonymous');
}
// Validate the comment's subject. If not specified, extract from comment
......
......@@ -21,7 +21,7 @@ public static function getInfo() {
function setUp() {
parent::setUp();
variable_set('user_register', USER_REGISTER_VISITORS);
config('user.settings')->set('register', USER_REGISTER_VISITORS)->save();
}
/**
......
......@@ -369,7 +369,7 @@ function testCommentNodeCommentStatistics() {
$this->assertEqual($node->comment_count, 1, t('The value of node comment_count is 1.'));
// Prepare for anonymous comment submission (comment approval enabled).
variable_set('user_register', USER_REGISTER_VISITORS);
config('user.settings')->set('register', USER_REGISTER_VISITORS)->save();
$this->drupalLogin($this->admin_user);
user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
'access comments' => TRUE,
......@@ -556,7 +556,7 @@ function setEnvironment(array $info) {
}
// Change user settings.
variable_set('user_register', $info['user_register']);
config('user.settings')->set('register', $info['user_register'])->save();
// Change user permissions.
$rid = ($this->loggedInUser ? DRUPAL_AUTHENTICATED_RID : DRUPAL_ANONYMOUS_RID);
......@@ -648,7 +648,7 @@ function assertCommentLinks(array $info) {
if (!$this->loggedInUser) {
if (user_access('post comments', $this->web_user)) {
// The note depends on whether users are actually able to register.
if ($info['user_register']) {
if ($info['user_register'] != USER_REGISTER_ADMINISTRATORS_ONLY) {
$this->assertText('Log in or register to post comments');
}
else {
......
......@@ -35,7 +35,7 @@ function testCommentPreview() {
// Login as web user and add a signature and a user picture.
$this->drupalLogin($this->web_user);
variable_set('user_signatures', 1);
config('user.settings')->set('signatures', 1)->save();
variable_set('user_pictures', 1);
$test_signature = $this->randomName();
$edit['signature[value]'] = '<a href="http://example.com/">' . $test_signature. '</a>';
......
......@@ -154,7 +154,7 @@ function filter_admin_format_form($form, &$form_state, $format) {
// If editing an existing text format, pre-select its current permissions.
$form['roles']['#default_value'] = array_keys(filter_get_roles_by_format($format));
}
elseif ($admin_role = variable_get('user_admin_role', 0)) {
elseif ($admin_role = config('user.settings')->get('admin_role')) {
// If adding a new text format and the site has an administrative role,
// pre-select that role so as to grant administrators access to the new
// text format permission by default.
......
......@@ -54,6 +54,7 @@ protected function prepareEntity(EntityInterface $node) {
* Overrides Drupal\entity\EntityFormController::form().
*/
public function form(array $form, array &$form_state, EntityInterface $node) {
$user_config = config('user.settings');
// Some special stuff when previewing a node.
if (isset($form_state['node_preview'])) {
$form['#prefix'] = $form_state['node_preview'];
......@@ -171,7 +172,7 @@ public function form(array $form, array &$form_state, EntityInterface $node) {
drupal_get_path('module', 'node') . '/node.js',
array(
'type' => 'setting',
'data' => array('anonymous' => variable_get('anonymous', t('Anonymous'))),
'data' => array('anonymous' => $user_config->get('anonymous')),
),
),
),
......@@ -185,7 +186,7 @@ public function form(array $form, array &$form_state, EntityInterface $node) {
'#autocomplete_path' => 'user/autocomplete',
'#default_value' => !empty($node->name) ? $node->name : '',
'#weight' => -1,
'#description' => t('Leave blank for %anonymous.', array('%anonymous' => variable_get('anonymous', t('Anonymous')))),
'#description' => t('Leave blank for %anonymous.', array('%anonymous' => $user_config->get('anonymous'))),
);
$form['author']['date'] = array(
......
......@@ -33,14 +33,14 @@ public static function getInfo() {
function setUp() {
parent::setUp();
variable_set('user_register', USER_REGISTER_VISITORS);
config('user.settings')->set('register', USER_REGISTER_VISITORS)->save();
}
/**
* Test OpenID auto-registration with e-mail verification enabled.
*/
function testRegisterUserWithEmailVerification() {
variable_set('user_email_verification', TRUE);
config('user.settings')->set('verify_mail', TRUE)->save();
variable_get('configurable_timezones', 1);
variable_set('date_default_timezone', 'Europe/Brussels');
......@@ -97,7 +97,7 @@ function testRegisterUserWithEmailVerification() {
* Test OpenID auto-registration with e-mail verification disabled.
*/
function testRegisterUserWithoutEmailVerification() {
variable_set('user_email_verification', FALSE);
config('user.settings')->set('verify_mail', FALSE)->save();
variable_get('configurable_timezones', 1);
variable_set('date_default_timezone', 'Europe/Brussels');
......@@ -229,7 +229,7 @@ function testRegisterUserWithoutSreg() {
* but no SREG.
*/
function testRegisterUserWithAXButNoSREG() {
variable_set('user_email_verification', FALSE);
config('user.settings')->set('verify_mail', FALSE)->save();
variable_set('date_default_timezone', 'Europe/Brussels');
// Tell openid_test.module to respond with these AX fields.
......
......@@ -86,7 +86,7 @@ function openid_help($path, $arg) {
function openid_user_insert($account) {
if (!empty($account->openid_claimed_id)) {
// The user has registered after trying to log in via OpenID.
if (variable_get('user_email_verification', TRUE)) {
if (config('user.settings')->get('verify_mail')) {
drupal_set_message(t('Once you have verified your e-mail address, you may log in via OpenID.'));
}
user_set_authmaps($account, array('authname_openid' => $account->openid_claimed_id));
......@@ -216,9 +216,9 @@ function openid_form_user_register_form_alter(&$form, &$form_state) {
$form['account']['mail']['#default_value'] = current($ax_mail_values);
}
// If user_email_verification is off, hide the password field and just fill
// If email verification is off, hide the password field and just fill
// with random password to avoid confusion.
if (!variable_get('user_email_verification', TRUE)) {
if (!config('user.settings')->get('verify_mail')) {
$form['account']['pass']['#type'] = 'hidden';
$form['account']['pass']['#value'] = user_password();
}
......@@ -709,7 +709,7 @@ function openid_authentication($response) {
$account = user_external_load($identity);
if (isset($account->uid)) {
if (!variable_get('user_email_verification', TRUE) || $account->login) {
if (!config('user.settings')->get('verify_mail') || $account->login) {
// Check if user is blocked.
$state['values']['name'] = $account->name;
user_login_name_validate(array(), $state);
......@@ -725,7 +725,7 @@ function openid_authentication($response) {
// Let other modules act on OpenID login
module_invoke_all('openid_response', $response, $account);
}
elseif (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) {
elseif (config('user.settings')->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY) {
// Register new user.
// Save response for use in openid_form_user_register_form_alter().
......
......@@ -32,7 +32,7 @@
*/
function hook_shortcut_default_set($account) {
// Use a special set of default shortcuts for administrators only.
if (in_array(variable_get('user_admin_role', 0), $account->roles)) {
if (in_array(config('user.settings')->get('admin_role'), $account->roles)) {
return variable_get('mymodule_shortcut_admin_default_set');
}
}
......
......@@ -23,7 +23,7 @@ public static function getInfo() {
function setUp() {
parent::setUp();
variable_set('user_register', USER_REGISTER_VISITORS);
config('user.settings')->set('register', USER_REGISTER_VISITORS)->save();
}
/**
......
......@@ -52,7 +52,7 @@ function setUp() {
),
);
field_create_instance($instance);
variable_set('user_register', USER_REGISTER_VISITORS);
config('user.settings')->set('register', USER_REGISTER_VISITORS)->save();
}
/**
......
......@@ -3785,7 +3785,7 @@ function hook_tokens($type, $tokens, array $data = array(), array $options = arr
// Default values for the chained tokens handled below.
case 'author':
$name = ($node->uid == 0) ? variable_get('anonymous', t('Anonymous')) : $node->name;
$name = ($node->uid == 0) ? config('user.settings')->get('anonymous') : $node->name;
$replacements[$original] = $sanitize ? filter_xss($name) : $name;
break;
......
admin_role: ''
anonymous: Anonymous
verify_mail: '1'
notify:
cancel_confirm: '1'
password_reset: '1'
status_activated: '1'
status_blocked: '0'
status_cancelled: '0'
register_admin_created: '1'
register_no_approval_required: '1'
register_pending_approval: '1'
register: visitors
signatures: '0'
......@@ -20,6 +20,7 @@ abstract class AccountFormController extends EntityFormController {
*/
public function form(array $form, array &$form_state, EntityInterface $account) {
global $user;
$config = config('user.settings');
$language_interface = language(LANGUAGE_TYPE_INTERFACE);
$register = empty($account->uid);
......@@ -101,7 +102,7 @@ public function form(array $form, array &$form_state, EntityInterface $account)
$form['#validate'][] = 'user_validate_current_pass';
}
}
elseif (!variable_get('user_email_verification', TRUE) || $admin) {
elseif (!$config->get('verify_mail') || $admin) {
$form['account']['pass'] = array(
'#type' => 'password_confirm',
'#size' => 25,
......@@ -114,7 +115,7 @@ public function form(array $form, array &$form_state, EntityInterface $account)
$status = isset($account->status) ? $account->status : 1;
}
else {
$status = $register ? variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) == USER_REGISTER_VISITORS : $account->status;
$status = $register ? $config->get('register') == USER_REGISTER_VISITORS : $account->status;
}
$form['account']['status'] = array(
......@@ -159,7 +160,7 @@ public function form(array $form, array &$form_state, EntityInterface $account)
'#type' => 'fieldset',
'#title' => t('Signature settings'),
'#weight' => 1,
'#access' => (!$register && variable_get('user_signatures', 0)),
'#access' => (!$register && $config->get('signatures')),
);
$form['signature_settings']['signature'] = array(
......
......@@ -74,7 +74,7 @@ protected function actions(array $form, array &$form_state) {
public function submit(array $form, array &$form_state) {
$admin = $form_state['values']['administer_users'];
if (!variable_get('user_email_verification', TRUE) || $admin) {
if (!config('user.settings')->get('verify_mail') || $admin) {
$pass = $form_state['values']['pass'];
}
else {
......@@ -121,7 +121,7 @@ public function save(array $form, array &$form_state) {
drupal_set_message(t('Created a new user account for <a href="@url">%name</a>. No e-mail has been sent.', array('@url' => url($uri['path'], $uri['options']), '%name' => $account->name)));
}
// No e-mail verification required; log in user immediately.
elseif (!$admin && !variable_get('user_email_verification', TRUE) && $account->status) {
elseif (!$admin && !config('user.settings')->get('verify_mail') && $account->status) {
_user_mail_notify('register_no_approval_required', $account);
$form_state['uid'] = $account->uid;
user_login_submit(array(), $form_state);
......
......@@ -250,7 +250,7 @@ function testUserAnonymize() {
$this->drupalGet('user/' . $account->uid . '/edit');
$this->drupalPost(NULL, NULL, t('Cancel account'));
$this->assertText(t('Are you sure you want to cancel your account?'), t('Confirmation form to cancel account displayed.'));
$this->assertRaw(t('Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.', array('%anonymous-name' => variable_get('anonymous', t('Anonymous')))), t('Informs that all content will be attributed to anonymous account.'));
$this->assertRaw(t('Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.', array('%anonymous-name' => config('user.settings')->get('anonymous'))), t('Informs that all content will be attributed to anonymous account.'));
// Confirm account cancellation.
$timestamp = time();
......
......@@ -25,7 +25,7 @@ public static function getInfo() {
function testUserEditedOwnAccount() {
// Change account setting 'Who can register accounts?' to Administrators
// only.
variable_set('user_register', USER_REGISTER_ADMINISTRATORS_ONLY);
config('user.settings')->set('register', USER_REGISTER_ADMINISTRATORS_ONLY)->save();
// Create a new user account and log in.
$account = $this->drupalCreateUser(array('change own username'));
......
......@@ -44,7 +44,7 @@ function testLabelCallback() {
// Setup a random anonymous name to be sure the name is used.
$name = $this->randomName();
variable_set('anonymous', $name);
config('user.settings')->set('anonymous', $name)->save();
$this->assertEqual($this->anonymous->label(), $name, t('The variable anonymous should be used for name of uid 0'));
}
......
......@@ -31,8 +31,7 @@ public static function getInfo() {
function setUp() {
parent::setUp();
variable_set('user_register', USER_REGISTER_VISITORS);
config('user.settings')->set('register', USER_REGISTER_VISITORS)->save();
}
/**
......
......@@ -27,16 +27,17 @@ public static function getInfo() {
}
function testRegistrationWithEmailVerification() {
$config = config('user.settings');
// Require e-mail verification.
variable_set('user_email_verification', TRUE);
$config->set('verify_mail', TRUE)->save();
// Set registration to administrator only.
variable_set('user_register', USER_REGISTER_ADMINISTRATORS_ONLY);
$config->set('register', USER_REGISTER_ADMINISTRATORS_ONLY)->save();
$this->drupalGet('user/register');
$this->assertResponse(403, t('Registration page is inaccessible when only administrators can create accounts.'));
// Allow registration by site visitors without administrator approval.
variable_set('user_register', USER_REGISTER_VISITORS);
$config->set('register', USER_REGISTER_VISITORS)->save();
$edit = array();
$edit['name'] = $name = $this->randomName();
$edit['mail'] = $mail = $edit['name'] . '@example.com';
......@@ -47,7 +48,7 @@ function testRegistrationWithEmailVerification() {
$this->assertTrue($new_user->status, t('New account is active after registration.'));
// Allow registration by site visitors, but require administrator approval.
variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);
$config->set('register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)->save();
$edit = array();
$edit['name'] = $name = $this->randomName();
$edit['mail'] = $mail = $edit['name'] . '@example.com';
......@@ -59,11 +60,14 @@ function testRegistrationWithEmailVerification() {
}
function testRegistrationWithoutEmailVerification() {
// Don't require e-mail verification.
variable_set('user_email_verification', FALSE);
$config = config('user.settings');
// Don't require e-mail verification and allow registration by site visitors
// without administrator approval.
$config
->set('verify_mail', FALSE)
->set('register', USER_REGISTER_VISITORS)
->save();
// Allow registration by site visitors without administrator approval.
variable_set('user_register', USER_REGISTER_VISITORS);
$edit = array();
$edit['name'] = $name = $this->randomName();
$edit['mail'] = $mail = $edit['name'] . '@example.com';
......@@ -85,7 +89,7 @@ function testRegistrationWithoutEmailVerification() {
$this->drupalLogout();
// Allow registration by site visitors, but require administrator approval.
variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);
$config->set('register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)->save();
$edit = array();
$edit['name'] = $name = $this->randomName();
$edit['mail'] = $mail = $edit['name'] . '@example.com';
......@@ -119,11 +123,12 @@ function testRegistrationWithoutEmailVerification() {
}
function testRegistrationEmailDuplicates() {
// Don't require e-mail verification.
variable_set('user_email_verification', FALSE);
// Allow registration by site visitors without administrator approval.
variable_set('user_register', USER_REGISTER_VISITORS);
// Don't require e-mail verification and allow registration by site visitors
// without administrator approval.
config('user.settings')
->set('verify_mail', FALSE)
->set('register', USER_REGISTER_VISITORS)
->save();
// Set up a user to check for duplicates.
$duplicate_user = $this->drupalCreateUser();
......@@ -144,11 +149,13 @@ function testRegistrationEmailDuplicates() {
}
function testRegistrationDefaultValues() {
// Allow registration by site visitors without administrator approval.
variable_set('user_register', USER_REGISTER_VISITORS);
// Don't require e-mail verification.
variable_set('user_email_verification', FALSE);
$config = config('user.settings');
// Don't require e-mail verification and allow registration by site visitors
// without administrator approval.
$config
->set('verify_mail', FALSE)
->set('register', USER_REGISTER_VISITORS)
->save();
// Set the default timezone to Brussels.
variable_set('configurable_timezones', 1);
......@@ -174,7 +181,7 @@ function testRegistrationDefaultValues() {
$this->assertEqual($new_user->theme, '', t('Correct theme field.'));
$this->assertEqual($new_user->signature, '', t('Correct signature field.'));
$this->assertTrue(($new_user->created > REQUEST_TIME - 20 ), t('Correct creation time.'));
$this->assertEqual($new_user->status, variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) == USER_REGISTER_VISITORS ? 1 : 0, t('Correct status field.'));
$this->assertEqual($new_user->status, $config->get('register') == USER_REGISTER_VISITORS ? 1 : 0, t('Correct status field.'));
$this->assertEqual($new_user->timezone, variable_get('date_default_timezone'), t('Correct time zone field.'));
$this->assertEqual($new_user->langcode, language_default()->langcode, t('Correct language field.'));
$this->assertEqual($new_user->preferred_langcode, language_default()->langcode, t('Correct preferred language field.'));
......
......@@ -33,7 +33,7 @@ function setUp() {
parent::setUp();
// Enable user signatures.
variable_set('user_signatures', 1);
config('user.settings')->set('signatures', 1)->save();
// Create Basic page node type.
$this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
......
......@@ -258,9 +258,10 @@ function user_admin_account_validate($form, &$form_state) {
* Form builder; Configure user settings for this site.
*
* @ingroup forms
* @see system_settings_form()
* @see user_admin_settings_submit()
*/
function user_admin_settings() {
function user_admin_settings($form, &$form_state) {
$config = config('user.settings');
// Settings for anonymous users.
$form['anonymous_settings'] = array(
'#type' => 'fieldset',
......@@ -269,7 +270,7 @@ function user_admin_settings() {
$form['anonymous_settings']['anonymous'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#default_value' => variable_get('anonymous', t('Anonymous')),
'#default_value' => $config->get('anonymous'),
'#description' => t('The name used to indicate anonymous users.'),
'#required' => TRUE,
);
......@@ -290,7 +291,7 @@ function user_admin_settings() {
$form['admin_role']['user_admin_role'] = array(
'#type' => 'select',
'#title' => t('Administrator role'),
'#default_value' => variable_get('user_admin_role', 0),
'#default_value' => $config->get('admin_role'),
'#options' => $roles,
'#description' => t('This role will be automatically assigned new permissions whenever a module is enabled. Changing this setting will not affect existing permissions.'),
);
......@@ -303,7 +304,7 @@ function user_admin_settings() {
$form['registration_cancellation']['user_register'] = array(
'#type' => 'radios',
'#title' => t('Who can register accounts?'),
'#default_value' => variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL),
'#default_value' => $config->get('register'),
'#options' => array(
USER_REGISTER_ADMINISTRATORS_ONLY => t('Administrators only'),
USER_REGISTER_VISITORS => t('Visitors'),
......@@ -313,7 +314,7 @@ function user_admin_settings() {
$form['registration_cancellation']['user_email_verification'] = array(
'#type' => 'checkbox',
'#title' => t('Require e-mail verification when a visitor creates an account.'),
'#default_value' => variable_get('user_email_verification', TRUE),
'#default_value' => $config->get('verify_mail'),
'#description' => t('New users will be required to validate their e-mail address prior to logging into the site, and will be assigned a system-generated password. With this setting disabled, users will be logged in immediately upon registering, and may select their own passwords during registration.')
);
module_load_include('inc', 'user', 'user.pages');
......@@ -343,7 +344,7 @@ function user_admin_settings() {
$form['personalization']['user_signatures'] = array(
'#type' => 'checkbox',
'#title' => t('Enable signatures.'),
'#default_value' => variable_get('user_signatures', 0),
'#default_value' => $config->get('signatures'),
);
// If picture support is enabled, check whether the picture directory exists.
if (variable_get('user_pictures', 0)) {
......@@ -433,7 +434,7 @@ function user_admin_settings() {
'#type' => 'fieldset',
'#title' => t('Welcome (new user created by administrator)'),
'#collapsible' => TRUE,
'#collapsed' => (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) != USER_REGISTER_ADMINISTRATORS_ONLY),
'#collapsed' => ($config->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY),
'#description' => t('Edit the welcome e-mail messages sent to new member accounts created by an administrator.') . ' ' . $email_token_help,
'#group' => 'email',
);
......@@ -454,7 +455,7 @@ function user_admin_settings() {
'#type' => 'fieldset',
'#title' => t('Welcome (awaiting approval)'),
'#collapsible' => TRUE,
'#collapsed' => (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) != USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL),
'#collapsed' => ($config->get('register') != USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL),
'#description' => t('Edit the welcome e-mail messages sent to new members upon registering, when administrative approval is required.') . ' ' . $email_token_help,
'#group' => 'email',
);
......@@ -475,7 +476,7 @@ function user_admin_settings() {
'#type' => 'fieldset',
'#title' => t('Welcome (no approval required)'),
'#collapsible' => TRUE,
'#collapsed' => (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) != USER_REGISTER_VISITORS),
'#collapsed' => ($config->get('register') != USER_REGISTER_VISITORS),
'#description' => t('Edit the welcome e-mail messages sent to new members upon registering, when no administrator approval is required.') . ' ' . $email_token_help,
'#group' => 'email',
);
......@@ -525,7 +526,7 @@ function user_admin_settings() {
$form['email_activated']['user_mail_status_activated_notify'] = array(
'#type' => 'checkbox',
'#title' => t('Notify user when account is activated.'),
'#default_value' => variable_get('user_mail_status_activated_notify', TRUE),
'#default_value' => $config->get('notify.status_activated'),
);
$form['email_activated']['settings'] = array(
'#type' => 'container',
......@@ -560,7 +561,7 @@ function user_admin_settings() {
$form['email_blocked']['user_mail_status_blocked_notify'] = array(
'#type' => 'checkbox',
'#title' => t('Notify user when account is blocked.'),
'#default_value' => variable_get('user_mail_status_blocked_notify', FALSE),
'#default_value' => $config->get('notify.status_blocked'),
);
$form['email_blocked']['settings'] = array(
'#type' => 'container',
......@@ -616,7 +617,7 @@ function user_admin_settings() {
$form['email_canceled']['user_mail_status_canceled_notify'] = array(
'#type' => 'checkbox',
'#title' => t('Notify user when account is canceled.'),
'#default_value' => variable_get('user_mail_status_canceled_notify', FALSE),
'#default_value' => $config->get('notify.status_canceled'),
);
$form['email_canceled']['settings'] = array(
'#type' => 'container',
......@@ -640,7 +641,23 @@ function user_admin_settings() {
'#rows' => 3,
);
return system_settings_form($form);
return system_config_form($form, $form_state);
}
/**
* Form submission handler for user_admin_settings().
*/
function user_admin_settings_submit($form, &$form_state) {
config('user.settings')
->set('anonymous', $form_state['values']['anonymous'])
->set('admin_role', $form_state['values']['user_admin_role'])
->set('register', $form_state['values']['user_register'])
->set('verify_mail', $form_state['values']['user_email_verification'])
->set('signatures', $form_state['values']['user_signatures'])
->set('notify.status_activated', $form_state['values']['user_mail_status_activated_notify'])
->set('notify.status_blocked', $form_state['values']['user_mail_status_blocked_notify'])
->set('notify.status_canceled', $form_state['values']['user_mail_status_canceled_notify'])
->save();
}
/**
......
......@@ -474,6 +474,37 @@ function user_update_8003() {
}
}
/**
* Moves account settings from variable to config.