Commit 9a67fb99 authored by Dries's avatar Dries

- Patch #174972 by rfay, stBorchert, gaele: user creation setting should be...

- Patch #174972 by rfay, stBorchert, gaele: user creation setting should be 'Visitors, with admin approval'.
parent 654921c4
......@@ -1306,7 +1306,7 @@ function comment_update_index() {
* results.
*/
function comment_node_search_result($node) {
// Do not make a string if comments are hidden.
// Do not make a string if comments are hidden.
if ($node->comment != COMMENT_NODE_HIDDEN) {
$comments = db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = :nid', array('nid' => $node->nid))->fetchField();
// Do not make a string if comments are closed and there are currently
......@@ -2256,7 +2256,7 @@ function theme_comment_post_forbidden($variables) {
$destination = array('destination' => "node/$node->nid#comment-form");
}
if (variable_get('user_register', 1)) {
if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) {
// 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))));
}
......
......@@ -481,6 +481,11 @@ class CommentAnonymous extends CommentHelperCase {
);
}
function setUp() {
parent::setUp();
variable_set('user_register', USER_REGISTER_VISITORS);
}
/**
* Test anonymous comment functionality.
*/
......
......@@ -1321,6 +1321,7 @@ class LocaleUserCreationTest extends DrupalWebTestCase {
function setUp() {
parent::setUp('locale');
variable_set('user_register', USER_REGISTER_VISITORS);
}
/**
......
......@@ -589,7 +589,7 @@ function openid_authentication($response) {
drupal_set_message(t('You must validate your email address for this account before logging in via OpenID.'));
}
}
elseif (variable_get('user_register', 1)) {
elseif (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) {
// Register new user.
// Save response for use in openid_form_user_register_form_alter().
......
......@@ -240,6 +240,7 @@ class OpenIDRegistrationTestCase extends OpenIDWebTestCase {
function setUp() {
parent::setUp('openid', 'openid_test');
variable_set('user_register', USER_REGISTER_VISITORS);
}
/**
......
......@@ -10,7 +10,7 @@ class ProfileTestCase extends DrupalWebTestCase {
function setUp() {
parent::setUp('profile');
variable_set('user_register', 1);
variable_set('user_register', USER_REGISTER_VISITORS);
$this->admin_user = $this->drupalCreateUser(array('administer users', 'access user profiles'));
......
......@@ -292,6 +292,11 @@ class SimpleTestBrowserTestCase extends DrupalWebTestCase {
);
}
function setUp() {
parent::setUp();
variable_set('user_register', USER_REGISTER_VISITORS);
}
/**
* Test DrupalWebTestCase::getAbsoluteUrl().
*/
......
......@@ -1088,6 +1088,7 @@ class FormsArbitraryRebuildTestCase extends DrupalWebTestCase {
),
);
field_create_instance($instance);
variable_set('user_register', USER_REGISTER_VISITORS);
}
/**
......
......@@ -297,11 +297,11 @@ function user_admin_settings() {
$form['registration_cancellation']['user_register'] = array(
'#type' => 'radios',
'#title' => t('Who can register accounts?'),
'#default_value' => variable_get('user_register', 1),
'#default_value' => variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL),
'#options' => array(
t('Administrators only'),
t('Visitors'),
t('Visitors, but administrator approval is required'),
USER_REGISTER_ADMINISTRATORS_ONLY => t('Administrators only'),
USER_REGISTER_VISITORS => t('Visitors'),
USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL => t('Visitors, but administrator approval is required'),
)
);
$form['registration_cancellation']['user_email_verification'] = array(
......@@ -428,7 +428,7 @@ function user_admin_settings() {
'#type' => 'fieldset',
'#title' => t('Welcome (new user created by administrator)'),
'#collapsible' => TRUE,
'#collapsed' => (variable_get('user_register', 1) != 0),
'#collapsed' => (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) != 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',
);
......@@ -449,7 +449,7 @@ function user_admin_settings() {
'#type' => 'fieldset',
'#title' => t('Welcome (awaiting approval)'),
'#collapsible' => TRUE,
'#collapsed' => (variable_get('user_register', 1) != 2),
'#collapsed' => (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) != 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',
);
......@@ -470,7 +470,7 @@ function user_admin_settings() {
'#type' => 'fieldset',
'#title' => t('Welcome (no approval required)'),
'#collapsible' => TRUE,
'#collapsed' => (variable_get('user_register', 1) != 1),
'#collapsed' => (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) != 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',
);
......
......@@ -603,6 +603,16 @@ function user_update_7007() {
db_add_index('role', 'name_weight', array('name', 'weight'));
}
/**
* If 'user_register' variable was unset in Drupal 6, set it to be the same as
* the Drupal 6 default setting.
*/
function user_update_7008() {
if (!isset($GLOBALS['conf']['user_register'])) {
// Set to the Drupal 6 default, "visitors can create accounts".
variable_set('user_register', USER_REGISTER_VISITORS);
}
}
/**
* @} End of "defgroup user-updates-6.x-to-7.x"
* The next series of updates should start at 8000.
......
......@@ -16,6 +16,22 @@
*/
define('EMAIL_MAX_LENGTH', 254);
/**
* Only administrators can create user accounts.
*/
define('USER_REGISTER_ADMINISTRATORS_ONLY', 0);
/**
* Visitors can create their own accounts.
*/
define('USER_REGISTER_VISITORS', 1);
/**
* Visitors can create accounts, but they don't become active without
* administrative approval.
*/
define('USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL', 2);
/**
* Implement hook_help().
*/
......@@ -926,7 +942,7 @@ function user_user_view($account) {
/**
* Helper function to add default user account fields to user registration and edit form.
*
*
* @see user_account_form_validate()
* @see user_validate_current_pass()
* @see user_validate_picture()
......@@ -1021,7 +1037,7 @@ function user_account_form(&$form, &$form_state) {
$status = isset($account->status) ? $account->status : 1;
}
else {
$status = $register ? variable_get('user_register', 1) == 1 : $account->status;
$status = $register ? variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) == USER_REGISTER_VISITORS : $account->status;
}
$form['account']['status'] = array(
'#type' => 'radios',
......@@ -1104,7 +1120,7 @@ function user_account_form(&$form, &$form_state) {
/**
* Form validation handler for the current password on the user_account_form().
*
*
* @see user_account_form()
*/
function user_validate_current_pass(&$form, &$form_state) {
......@@ -1130,7 +1146,7 @@ function user_validate_current_pass(&$form, &$form_state) {
/**
* Form validation handler for user_account_form().
*
*
* @see user_account_form()
*/
function user_account_form_validate($form, &$form_state) {
......@@ -1230,7 +1246,7 @@ function user_login_block($form) {
'#value' => t('Log in'),
);
$items = array();
if (variable_get('user_register', 1)) {
if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) {
$items[] = l(t('Create new account'), 'user/register', array('attributes' => array('title' => t('Create a new user account.'))));
}
$items[] = l(t('Request new password'), 'user/password', array('attributes' => array('title' => t('Request new password via e-mail.'))));
......@@ -1432,7 +1448,7 @@ function user_is_logged_in() {
}
function user_register_access() {
return user_is_anonymous() && variable_get('user_register', 1);
return user_is_anonymous() && variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);
}
......
......@@ -15,12 +15,12 @@ class UserRegistrationTestCase extends DrupalWebTestCase {
variable_set('user_email_verification', TRUE);
// Set registration to administrator only.
variable_set('user_register', 0);
variable_set('user_register', USER_REGISTER_ADMINISTRATORS_ONLY);
$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', 1);
variable_set('user_register', USER_REGISTER_VISITORS);
$edit = array();
$edit['name'] = $name = $this->randomName();
$edit['mail'] = $mail = $edit['name'] . '@example.com';
......@@ -31,7 +31,7 @@ class UserRegistrationTestCase extends DrupalWebTestCase {
$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', 2);
variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);
$edit = array();
$edit['name'] = $name = $this->randomName();
$edit['mail'] = $mail = $edit['name'] . '@example.com';
......@@ -46,7 +46,7 @@ class UserRegistrationTestCase extends DrupalWebTestCase {
variable_set('user_email_verification', FALSE);
// Allow registration by site visitors without administrator approval.
variable_set('user_register', 1);
variable_set('user_register', USER_REGISTER_VISITORS);
$edit = array();
$edit['name'] = $name = $this->randomName();
$edit['mail'] = $mail = $edit['name'] . '@example.com';
......@@ -67,7 +67,7 @@ class UserRegistrationTestCase extends DrupalWebTestCase {
$this->drupalLogout();
// Allow registration by site visitors, but require administrator approval.
variable_set('user_register', 2);
variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);
$edit = array();
$edit['name'] = $name = $this->randomName();
$edit['mail'] = $mail = $edit['name'] . '@example.com';
......@@ -102,7 +102,7 @@ class UserRegistrationTestCase extends DrupalWebTestCase {
function testRegistrationDefaultValues() {
// Allow registration by site visitors without administrator approval.
variable_set('user_register', 1);
variable_set('user_register', USER_REGISTER_VISITORS);
// Don't require e-mail verification.
variable_set('user_email_verification', FALSE);
......@@ -131,7 +131,7 @@ class UserRegistrationTestCase extends DrupalWebTestCase {
$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', 1) == 1 ? 1 : 0, t('Correct status field.'));
$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->timezone, variable_get('date_default_timezone'), t('Correct time zone field.'));
$this->assertEqual($new_user->language, '', t('Correct language field.'));
$this->assertEqual($new_user->picture, '', t('Correct picture field.'));
......@@ -1450,7 +1450,7 @@ class UserEditedOwnAccountTestCase extends DrupalWebTestCase {
function testUserEditedOwnAccount() {
// Change account setting 'Who can register accounts?' to Administrators
// only.
variable_set('user_register', 0);
variable_set('user_register', USER_REGISTER_ADMINISTRATORS_ONLY);
// Create a new user account and log in.
$account = $this->drupalCreateUser(array('change own username'));
......
......@@ -66,6 +66,9 @@ function minimal_install() {
}
$query->execute();
// Allow visitor account creation, but with administrative approval.
variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);
// Enable default permissions for system roles.
user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access content'));
user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access content'));
......
......@@ -272,6 +272,9 @@ function standard_install() {
variable_set('user_picture_file_size', '800');
variable_set('user_picture_style', 'thumbnail');
// Allow visitor account creation with administrative approval.
variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);
// Create a default vocabulary named "Tags", enabled for the 'article' content type.
$description = st('Use tags to group articles on similar topics into categories.');
$help = st('Enter a comma-separated list of words to describe your content.');
......
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