updated modules
views friendly_register serial address_field i18n
This commit is contained in:
@@ -16,10 +16,18 @@ links to the login or reset password pages.
|
||||
|
||||
Installation
|
||||
------------
|
||||
* Install this module into the appropriate modules directory.
|
||||
* Enable this module.
|
||||
* Install this module into the appropriate modules directory and enable it.
|
||||
See: https://drupal.org/node/895232 for more information.
|
||||
* Make sure you have cron running on a regular basis (at least once per 24 hours)
|
||||
|
||||
Verification
|
||||
------------
|
||||
* On your site, log out.
|
||||
* Try to create an account using a pre-existing user name or email address.
|
||||
* If the module is working, an immediate error message should appear below that
|
||||
field stating either the user name is unavailable or that the email is
|
||||
already registered.
|
||||
|
||||
Permissions
|
||||
-----------
|
||||
There is only one permission for this module and it is completely optional. Set
|
||||
|
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Hooks provided by the friendly_register module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup hooks
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Allows you to provide your own validation routines for email addresses
|
||||
* beyond the valid_email_address() call.
|
||||
*
|
||||
* @param string $address
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function hook_validate_email_address($address) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows you to provide your own validation routines for the user name.
|
||||
*
|
||||
* @param string $username
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function hook_validate_user_name($username) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup hooks".
|
||||
*/
|
@@ -2,9 +2,9 @@ name = Friendly Register
|
||||
description = "Allows for users to see if a username or email is available before submitting the registration form."
|
||||
core = 7.x
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-10-20
|
||||
version = "7.x-1.1"
|
||||
; Information added by Drupal.org packaging script on 2015-05-06
|
||||
version = "7.x-1.2"
|
||||
core = "7.x"
|
||||
project = "friendly_register"
|
||||
datestamp = "1382296452"
|
||||
datestamp = "1430918950"
|
||||
|
||||
|
@@ -85,9 +85,19 @@ function friendly_register_load_resources() {
|
||||
drupal_add_css($path . '/css/friendly_register.css');
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON callback to check the email address.
|
||||
*
|
||||
* @param $address
|
||||
*/
|
||||
function friendly_register_check_email($address) {
|
||||
$email_is_valid = TRUE;
|
||||
$all_email_checks = module_invoke_all('validate_email_address', $address);
|
||||
foreach ($all_email_checks as $check) {
|
||||
$email_is_valid = $check && $email_is_valid;
|
||||
}
|
||||
// Check if it is a valid email address. No need to check if it is not
|
||||
if (valid_email_address($address)) {
|
||||
if ($email_is_valid) {
|
||||
drupal_json_output(_friendly_register_check_field('mail', $address));
|
||||
}
|
||||
else {
|
||||
@@ -97,10 +107,44 @@ function friendly_register_check_email($address) {
|
||||
}
|
||||
}
|
||||
|
||||
function friendly_register_check_user($username) {
|
||||
drupal_json_output(_friendly_register_check_field('name', $username));
|
||||
/**
|
||||
* Implements hook_validate_email_address().
|
||||
*
|
||||
* @param string $address
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function friendly_register_validate_email_address($address) {
|
||||
return valid_email_address($address);
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON callback to check the username.
|
||||
*
|
||||
* @param string $username
|
||||
*/
|
||||
function friendly_register_check_user($username) {
|
||||
$user_is_valid = TRUE;
|
||||
$all_user_checks = module_invoke_all('validate_user_name', $username);
|
||||
foreach ($all_user_checks as $check) {
|
||||
$user_is_valid = $check && $user_is_valid;
|
||||
}
|
||||
if ($user_is_valid) {
|
||||
drupal_json_output(_friendly_register_check_field('name', $username));
|
||||
}
|
||||
else {
|
||||
drupal_json_output(array('available' => 'invalid'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the value of a field on the user table.
|
||||
*
|
||||
* @param string $field_name
|
||||
* @param string $value
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function _friendly_register_check_field($field_name, $value) {
|
||||
if (_friendly_register_check_flood()) {
|
||||
$result = db_query("SELECT uid FROM {users} WHERE " . $field_name . " = :value", array(':value' => $value))->fetchField();
|
||||
@@ -111,6 +155,11 @@ function _friendly_register_check_field($field_name, $value) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the user has too many requests (flood).
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function _friendly_register_check_flood() {
|
||||
if (user_access('ignore flood')) {
|
||||
return TRUE;
|
||||
@@ -120,7 +169,7 @@ function _friendly_register_check_flood() {
|
||||
$q = 'SELECT hits FROM {friendly_register_flood} WHERE ip = :ip';
|
||||
$hits = db_query($q, array(':ip' => $ip))->fetchField();
|
||||
if ($hits == NULL) {
|
||||
$id = db_insert('friendly_register_flood')
|
||||
db_insert('friendly_register_flood')
|
||||
->fields(array(
|
||||
'ip' => $ip,
|
||||
'hits' => 1,
|
||||
|
@@ -6,7 +6,7 @@
|
||||
Drupal.friendly_register.timeout = null;
|
||||
|
||||
Drupal.friendly_register.checkUserName = function (userName) {
|
||||
$.getJSON(userName.ajaxPath + userName.oldValue, function(data) {
|
||||
$.getJSON(userName.ajaxPath + encodeURIComponent(userName.oldValue), function(data) {
|
||||
if (!data.flood) {
|
||||
var message;
|
||||
var cssclass;
|
||||
@@ -19,6 +19,7 @@
|
||||
}
|
||||
$('#edit-name-check').remove();
|
||||
userName.field.after('<div id="edit-name-check" class="' + cssclass + '"><span class="text">' + message + '</span></div>');
|
||||
Drupal.attachBehaviors();
|
||||
} else {
|
||||
Drupal.friendly_register.flood = true;
|
||||
$('#edit-name-check').remove();
|
||||
@@ -28,7 +29,7 @@
|
||||
};
|
||||
|
||||
Drupal.friendly_register.checkEmail = function (email) {
|
||||
$.getJSON(email.ajaxPath + email.oldValue, function(data) {
|
||||
$.getJSON(email.ajaxPath + encodeURIComponent(email.oldValue), function(data) {
|
||||
if (!data.flood) {
|
||||
if (data.available == 'incomplete') {
|
||||
$('#edit-mail-check').remove();
|
||||
@@ -44,6 +45,7 @@
|
||||
}
|
||||
$('#edit-mail-check').remove();
|
||||
email.field.after('<div id="edit-mail-check" class="' + cssclass + '"><span class="text">' + message + '</span></div>');
|
||||
Drupal.attachBehaviors();
|
||||
} else {
|
||||
Drupal.friendly_register.flood = true;
|
||||
$('#edit-mail-check').remove();
|
||||
@@ -71,7 +73,7 @@
|
||||
email.avail = Drupal.t('This email address has not been used.');
|
||||
email.notAvail = Drupal.t('This email address is already in use, please <a href="@login">try logging in</a> with that email address or <a href="@reset">resetting your password</a>.', {'@login': loginURL, '@reset': resetURL});
|
||||
|
||||
userName.field.focus(function () {
|
||||
userName.field.once('friendly-register').focus(function () {
|
||||
if (Drupal.friendly_register.flood) {
|
||||
return;
|
||||
}
|
||||
@@ -92,7 +94,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
email.field.focus(function () {
|
||||
email.field.once('friendly-register').focus(function () {
|
||||
if (Drupal.friendly_register.flood) {
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user