summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/comment/comment.module4
-rw-r--r--modules/comment/comment.test5
-rw-r--r--modules/locale/locale.test1
-rw-r--r--modules/openid/openid.module2
-rw-r--r--modules/openid/openid.test1
-rw-r--r--modules/profile/profile.test2
-rw-r--r--modules/simpletest/simpletest.test5
-rw-r--r--modules/simpletest/tests/form.test1
-rw-r--r--modules/user/user.admin.inc14
-rw-r--r--modules/user/user.install10
-rw-r--r--modules/user/user.module28
-rw-r--r--modules/user/user.test16
-rw-r--r--profiles/minimal/minimal.install3
-rw-r--r--profiles/standard/standard.install3
14 files changed, 70 insertions, 25 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index c997ea2e5..d103e3a2d 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -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))));
}
diff --git a/modules/comment/comment.test b/modules/comment/comment.test
index 8213adcc6..d638184b3 100644
--- a/modules/comment/comment.test
+++ b/modules/comment/comment.test
@@ -481,6 +481,11 @@ class CommentAnonymous extends CommentHelperCase {
);
}
+ function setUp() {
+ parent::setUp();
+ variable_set('user_register', USER_REGISTER_VISITORS);
+ }
+
/**
* Test anonymous comment functionality.
*/
diff --git a/modules/locale/locale.test b/modules/locale/locale.test
index ee73054fa..ecc502d90 100644
--- a/modules/locale/locale.test
+++ b/modules/locale/locale.test
@@ -1321,6 +1321,7 @@ class LocaleUserCreationTest extends DrupalWebTestCase {
function setUp() {
parent::setUp('locale');
+ variable_set('user_register', USER_REGISTER_VISITORS);
}
/**
diff --git a/modules/openid/openid.module b/modules/openid/openid.module
index b678e92ae..a6f2cd6d0 100644
--- a/modules/openid/openid.module
+++ b/modules/openid/openid.module
@@ -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().
diff --git a/modules/openid/openid.test b/modules/openid/openid.test
index e0670710a..8d4ac5031 100644
--- a/modules/openid/openid.test
+++ b/modules/openid/openid.test
@@ -240,6 +240,7 @@ class OpenIDRegistrationTestCase extends OpenIDWebTestCase {
function setUp() {
parent::setUp('openid', 'openid_test');
+ variable_set('user_register', USER_REGISTER_VISITORS);
}
/**
diff --git a/modules/profile/profile.test b/modules/profile/profile.test
index 61709d34a..ce90e3e36 100644
--- a/modules/profile/profile.test
+++ b/modules/profile/profile.test
@@ -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'));
diff --git a/modules/simpletest/simpletest.test b/modules/simpletest/simpletest.test
index 8ad016579..b3522f962 100644
--- a/modules/simpletest/simpletest.test
+++ b/modules/simpletest/simpletest.test
@@ -292,6 +292,11 @@ class SimpleTestBrowserTestCase extends DrupalWebTestCase {
);
}
+ function setUp() {
+ parent::setUp();
+ variable_set('user_register', USER_REGISTER_VISITORS);
+ }
+
/**
* Test DrupalWebTestCase::getAbsoluteUrl().
*/
diff --git a/modules/simpletest/tests/form.test b/modules/simpletest/tests/form.test
index 0181dcafb..2cba9863a 100644
--- a/modules/simpletest/tests/form.test
+++ b/modules/simpletest/tests/form.test
@@ -1088,6 +1088,7 @@ class FormsArbitraryRebuildTestCase extends DrupalWebTestCase {
),
);
field_create_instance($instance);
+ variable_set('user_register', USER_REGISTER_VISITORS);
}
/**
diff --git a/modules/user/user.admin.inc b/modules/user/user.admin.inc
index 043ee97a4..eb202dee0 100644
--- a/modules/user/user.admin.inc
+++ b/modules/user/user.admin.inc
@@ -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',
);
diff --git a/modules/user/user.install b/modules/user/user.install
index 820cb6943..f7fc69303 100644
--- a/modules/user/user.install
+++ b/modules/user/user.install
@@ -604,6 +604,16 @@ function user_update_7007() {
}
/**
+ * 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.
*/
diff --git a/modules/user/user.module b/modules/user/user.module
index ad580dcc3..1420f83f0 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -17,6 +17,22 @@ define('USERNAME_MAX_LENGTH', 60);
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().
*/
function user_help($path, $arg) {
@@ -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);
}
diff --git a/modules/user/user.test b/modules/user/user.test
index 732782d6a..1401709e6 100644
--- a/modules/user/user.test
+++ b/modules/user/user.test
@@ -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'));
diff --git a/profiles/minimal/minimal.install b/profiles/minimal/minimal.install
index 1d6958276..49bb46da7 100644
--- a/profiles/minimal/minimal.install
+++ b/profiles/minimal/minimal.install
@@ -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'));
diff --git a/profiles/standard/standard.install b/profiles/standard/standard.install
index 79e85c7ad..cb1b45c66 100644
--- a/profiles/standard/standard.install
+++ b/profiles/standard/standard.install
@@ -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.');