username_check.module in Username originality AJAX check 7
Same filename and directory in other branches
Checks user name availability on registration page.
File
username_check.moduleView source
<?php
/**
* @file
* Checks user name availability on registration page.
*/
/**
* Implementation of hook_menu().
*/
function username_check_menu() {
$items = array();
$items['username_check/isunique'] = array(
'type' => MENU_CALLBACK,
'page callback' => 'username_check_callback',
'access arguments' => array(
'access content',
),
'file' => 'username_check.unique.inc',
);
$items['username_check/isuniqueprofile'] = array(
'type' => MENU_CALLBACK,
'page callback' => 'username_check_profile_callback',
'access arguments' => array(
'access content',
),
'file' => 'username_check.unique.inc',
);
$items['username_check/isuniquemail'] = array(
// TODO: find a way to block use of this by hackers/spammers to search for email addys
'type' => MENU_CALLBACK,
'page callback' => 'username_check_mail_callback',
'access arguments' => array(
'access content',
),
'file' => 'username_check.unique.inc',
);
$items['admin/config/system/username_check'] = array(
'title' => 'Username check',
'type' => MENU_NORMAL_ITEM,
'page callback' => 'drupal_get_form',
'page arguments' => array(
'username_check_settings',
),
'access arguments' => array(
'administer site configuration',
),
'file' => 'username_check.admin.inc',
);
return $items;
}
function username_check_form_user_register_form_alter(&$form) {
$mode = variable_get('username_check_mode', 'auto');
$mailmode = variable_get('username_check_mail_mode', 'auto');
if ($mode != 'off') {
_username_check_load_resources($mode);
$form['account']['name']['#field_suffix'] = '<span id="username-check-informer"> </span>';
$form['account']['name']['#suffix'] = '<div id="username-check-message"></div>';
}
if ($mailmode != 'off') {
_username_check_mail_load_resources($mailmode);
$form['account']['mail']['#field_suffix'] = '<span id="mail-check-informer"> </span>';
$form['account']['mail']['#suffix'] = '<div id="mail-check-message"></div>';
}
}
function username_check_form_user_profile_form_alter(&$form) {
$mode = variable_get('username_check_mode', 'auto');
if ($mode != 'off') {
_username_check_profile_load_resources($mode);
$form['account']['name']['#field_suffix'] = '<span id="profile-check-informer"> </span>';
$form['account']['name']['#suffix'] = '<div id="profile-check-message"></div>';
}
}
/**
* Load username_check resources.
*/
function _username_check_load_resources($mode) {
$module_path = drupal_get_path('module', 'username_check');
drupal_add_css($module_path . '/username_check.css');
drupal_add_js($module_path . '/username_check.js');
drupal_add_js(array(
'usernameCheck' => array(
'ajaxUrl' => url('username_check/isunique', array(
'absolute' => TRUE,
)),
'delay' => variable_get('username_check_delay', 1),
),
), 'setting');
}
function _username_check_profile_load_resources($mode) {
$module_path = drupal_get_path('module', 'username_check');
drupal_add_css($module_path . '/username_check.css');
drupal_add_js($module_path . '/username_check_profile.js');
drupal_add_js(array(
'profileCheck' => array(
'ajaxUrl' => url('username_check/isuniqueprofile', array(
'absolute' => TRUE,
)),
'delay' => variable_get('username_check_delay', 1),
),
), 'setting');
}
function _username_check_mail_load_resources($mode) {
$module_path = drupal_get_path('module', 'username_check');
drupal_add_css($module_path . '/username_check.css');
drupal_add_js($module_path . '/username_check_mail.js');
drupal_add_js(array(
'mailCheck' => array(
'ajaxUrl' => url('username_check/isuniquemail', array(
'absolute' => TRUE,
)),
'delay' => variable_get('username_check_delay', 1),
),
), 'setting');
}
Functions
Name | Description |
---|---|
username_check_form_user_profile_form_alter | |
username_check_form_user_register_form_alter | |
username_check_menu | Implementation of hook_menu(). |
_username_check_load_resources | Load username_check resources. |
_username_check_mail_load_resources | |
_username_check_profile_load_resources |