Package base :: Package plugins :: Package user
[hide private]

Package user

source code

Enables the user registration and login system.
See Also:
Drupy Homepage, Drupal Homepage
Notes:

Author: Brendon Crawford

Copyright: 2008 Brendon Crawford

Contact: message144 at users dot sourceforge dot net

Version: 0.1

Functions [hide private]
 
plugin_invoke(type_, array_, user_, category=None)
Invokes hook_user() in every module.
source code
 
hook_theme() source code
 
external_load(authname) source code
 
external_login(account, edit=[])
Perform standard Drupal login operations for a user object.
source code
 
load(array_={})
Fetch a user object.
source code
 
save(account, array_={}, category='account')
Save changes to a user account or add a new user.
source code
 
validate_name(name)
Verify the syntax of the given name.
source code
 
validate_mail(mail) source code
 
validate_picture(form, form_state) source code
 
user_password(length=10)
Generate a random alphanumeric password.
source code
 
role_permissions(roles=[], reset=False)
Determine the permissions for one or more roles.
source code
 
access(string_, account=None, reset=False)
Determine whether the user has a given privilege.
source code
 
is_blocked(name)
Checks for usernames blocked by user administration.
source code
 
hook_perm()
Implementation of hook_perm().
source code
 
hook_file_download(file)
Implementation of hook_file_download().
source code
 
hook_search(op='search', keys=None, skip_access_check=False)
Implementation of hook_search().
source code
 
hook_elements()
Implementation of hook_elements().
source code
 
hook_user(type, edit, account, category=None)
Implementation of hook_user().
source code
 
login_block() source code
 
hook_block(op='list', delta='', edit=[])
Implementation of hook_block().
source code
 
template_preprocess_user_picture(variables)
Process variables for user-picture.tpl.php.
source code
 
theme_list(users, title=None)
Make a list of users.
source code
 
is_anonymous() source code
 
is_logged_in() source code
 
register_access() source code
 
view_access(account) source code
 
edit_access(account) source code
 
load_self(arg_) source code
 
hook_menu()
Implementation of hook_menu().
source code
 
hook_init() source code
 
uid_optional_load(arg) source code
 
category_load(uid, map_, index)
Return a user object after checking if any profile category in the path exists.
source code
 
uid_optional_to_arg(arg_)
Returns the user id of the currently logged in user.
source code
 
page_title(account)
Menu item title callback - use the user name if it's not the current user.
source code
 
get_authmaps(authname=None)
Discover which external authentication module(s) authenticated a username.
source code
 
set_authmaps(account, authmaps)
Save mappings of which external authentication module(s) authenticated a user.
source code
 
login(form_state)
Form builder; the main user login form.
source code
 
login_default_validators()
Set up a series for validators which check for blocked users, then authenticate against local database, then return an error if authentication fails.
source code
 
login_name_validate(form, form_state)
A FAPI validate handler.
source code
 
login_authenticate_validate(form, form_state)
A validate handler on the login form.
source code
 
login_final_validate(form, form_state)
A validate handler on the login form.
source code
 
authenticate(form_values=[])
Try to log in the user locally.
source code
 
authenticate_finalize(edit)
Finalize the login process.
source code
 
form_login_submit(form, form_state)
Submit handler for the login form.
source code
 
external_login_register(name, module)
Helper function for authentication modules.
source code
 
pass_reset_url(account) source code
 
pass_rehash(password, timestamp, login) source code
 
edit_form(form_state, uid, edit, register=False) source code
 
_edit_validate(uid, edit) source code
 
_edit_submit(uid, edit) source code
 
delete(edit, uid)
Delete a user.
source code
 
build_content(account)
Builds a structured array representing the profile content.
source code
 
hook_mail(key, message, params)
Implementation of hook_mail().
source code
 
_mail_text(key, language=None, variables=[])
Returns a mail string for a variable name.
source code
 
roles(membersonly=False, permission=None)
Retrieve an array of roles matching specified conditions.
source code
 
hook_user_operations(form_state=[])
Implementation of hook_user_operations().
source code
 
user_operations_unblock(accounts)
Callback function for admin mass unblocking users.
source code
 
user_operations_block(accounts)
Callback function for admin mass blocking users.
source code
 
multiple_role_edit(accounts, operation, rid)
Callback function for admin mass adding/deleting a user role.
source code
 
multiple_delete_confirm(form_state) source code
 
multiple_delete_confirm_submit(form, form_state) source code
 
hook_help(path, arg)
Implementation of hook_help().
source code
 
_categories(account)
Retrieve a list of all user setting/information categories and sort them by weight.
source code
 
_sort(a, b) source code
 
filters()
List user administration filters that can be applied.
source code
 
build_filter_query()
Build query for user administration filters based on session.
source code
 
hook_forms()
Implementation of hook_forms().
source code
 
comment(comment_, op)
Implementation of hook_comment().
source code
 
theme_signature(signature)
Theme output of user signature.
source code
 
mail_tokens(account, language)
Return an array of token to value mappings for user e-mail messages.
source code
 
preferred_language(account, default=None)
Get the language object preferred by the user.
source code
 
_mail_notify(op, account, language=None)
Conditionally create and send a notification email when a certain operation happens on the given user account.
source code
 
_password_dynamic_validation()
Add javascript and string translations for dynamic password validation (strength and confirmation checking).
source code
 
hook_hook_info()
Implementation of hook_hook_info().
source code
 
hook_action_info()
Implementation of hook_action_info().
source code
 
block_user_action(object_, context=[])
Implementation of a Drupal action.
source code
 
form_register_submit(form, form_state)
Submit handler for the user registration form.
source code
 
register()
Form builder; The user registration form.
source code
 
register_validate(form, form_state) source code
 
_forms(edit, account, category, hook='form')
Retrieve a list of all form elements for the specified category.
source code
Variables [hide private]
  __version__ = '$Revision: 1 $'
  USERNAME_MAX_LENGTH = 60
  EMAIL_MAX_LENGTH = 64
Function Details [hide private]

plugin_invoke(type_, array_, user_, category=None)

source code 
Invokes hook_user() in every module. We cannot use plugin_invoke() for this, because the arguments need to be passed by reference.

external_login(account, edit=[])

source code 
Perform standard Drupal login operations for a user object. The user object must already be authenticated. This function verifies that the user account is not blocked and then performs the login, updates the login timestamp in the database, invokes hook_user('login'), and regenerates the session.
Parameters:
  • account - An authenticated user object to be set as the currently logged in user.
  • edit - The array of form values submitted by the user, if any. This array is passed to hook_user op login.
Returns:
boolean True if the login succeeds, False otherwise.

load(array_={})

source code 
Fetch a user object.
Parameters:
  • array - An associative array of attributes to search for in selecting the user, such as user name or e-mail address.
Returns:
A fully-loaded user object upon successful user load or False if user cannot be loaded.

save(account, array_={}, category='account')

source code 
Save changes to a user account or add a new user.
Parameters:
  • account - The user object for the user to modify or add. If user.uid is omitted, a new user will be added.
  • array - An array of fields and values to save. For example array('name' : 'My name'). Keys that do not belong to columns in the user-related tables are added to the a serialized array in the 'data' column and will be loaded in the user.data array by user_load(). Setting a field to None deletes it from the data column.
  • category - (optional) The category for storing profile information in.
Returns:
A fully-loaded user object upon successful save or False if the save failed.

role_permissions(roles=[], reset=False)

source code 
Determine the permissions for one or more roles.
Parameters:
  • roles - An array whose keys are the role IDs of interest, such as user.roles.
  • reset - Optional parameter - if True data in the static variable is rebuilt.
Returns:
An array indexed by role ID. Each value is an array whose keys are the permission strings for the given role ID.

access(string_, account=None, reset=False)

source code 
Determine whether the user has a given privilege.
Parameters:
  • string - The permission, such as "administer nodes", being checked for.
  • account - (optional) The account to check, if not given use currently logged in user.
  • reset - (optional) Resets the user's permissions cache, which will result in a recalculation of the user's permissions. This is necessary to support dynamically added user roles.
Returns:
Boolean True if the current user has the requested permission. All permission checks in Drupal should go through this function. This way, we guarantee consistent behavior, and ensure that the superuser can perform all actions.

is_blocked(name)

source code 
Checks for usernames blocked by user administration.
Returns:
boolean True for blocked users, False for active.

hook_file_download(file)

source code 
Implementation of hook_file_download(). Ensure that user pictures (avatars) are always downloadable.

template_preprocess_user_picture(variables)

source code 
Process variables for user-picture.tpl.php. The variables array contains the following arguments: - account

See Also:  

theme_list(users, title=None)

source code 
Make a list of users.
Parameters:
  • users - An array with user objects. Should contain at least the name and uid.
  • title - (optional) Title to pass on to theme_item_list().

get_authmaps(authname=None)

source code 
Discover which external authentication module(s) authenticated a username.
Parameters:
  • authname - A username used by an external authentication module.
Returns:
An associative array with module as key and username as value.

set_authmaps(account, authmaps)

source code 
Save mappings of which external authentication module(s) authenticated a user. Maps external usernames to user ids in the users table.
Parameters:
  • account - A user object.
  • authmaps - An associative array with a compound key and the username as the value. The key is made up of 'authname_' plus the name of the external authentication module.

See Also: user_external_login_register

login_default_validators()

source code 
Set up a series for validators which check for blocked users, then authenticate against local database, then return an error if authentication fails. Distributed authentication modules are welcome to use hook_form_alter() to change this series in order to authenticate against their user database instead of the local users table. We use three validators instead of one since external authentication modules usually only need to alter the second validator.
Returns:
array A simple list of validate functions.
See Also:
, ,

login_name_validate(form, form_state)

source code 
A FAPI validate handler. Sets an error if supplied username has been blocked.

login_authenticate_validate(form, form_state)

source code 
A validate handler on the login form. Check supplied username/password against local users table. If successful, sets the global user object.

login_final_validate(form, form_state)

source code 
A validate handler on the login form. Should be the last validator. Sets an error if user has not been authenticated yet.

authenticate(form_values=[])

source code 
Try to log in the user locally.
Parameters:
  • form_values - Form values with at least 'name' and 'pass' keys, as well as anything else which should be passed along to hook_user op 'login'.
Returns:
A user object, if successful.

authenticate_finalize(edit)

source code 
Finalize the login process. Must be called when logging in a user. The function records a watchdog message about the new session, saves the login timestamp, calls hook_user op 'login' and generates a new session. param edit This array is passed to hook_user op login.

form_login_submit(form, form_state)

source code 
Submit handler for the login form. Redirects the user to a page. The user is redirected to the My Account page. Setting the destination in the query string (as done by the user login block) overrides the redirect.

external_login_register(name, module)

source code 
Helper function for authentication modules. Either login in or registers the current user, based on username. Either way, the global user object is populated based on name.

delete(edit, uid)

source code 
Delete a user.
Parameters:
  • edit - An array of submitted form values.
  • uid - The user ID of the user to delete.

build_content(account)

source code 
Builds a structured array representing the profile content.
Parameters:
  • account - A user object.
Returns:
A structured array containing the individual elements of the profile.

_mail_text(key, language=None, variables=[])

source code 
Returns a mail string for a variable name. Used by user_mail() and the settings forms to retrieve strings.

roles(membersonly=False, permission=None)

source code 
Retrieve an array of roles matching specified conditions.
Parameters:
  • membersonly - Set this to True to exclude the 'anonymous' role.
  • permission - A string containing a permission. If set, only roles containing that permission are returned.
Returns:
An associative array with the role id as the key and the role name as value.

mail_tokens(account, language)

source code 
Return an array of token to value mappings for user e-mail messages.
Parameters:
  • account - The user object of the account being notified. Must contain at least the fields 'uid', 'name', and 'mail'.
  • language - Language object to generate the tokens with.
Returns:
Array of mappings from token names to values (for use with strtr()).

preferred_language(account, default=None)

source code 
Get the language object preferred by the user. This user preference can be set on the user account editing page, and is only available if there are more than one languages enabled on the site. If the user did not choose a preferred language, or is the anonymous user, the default value, or if it is not set, the site default language will be returned.
Parameters:
  • account - User account to look up language for.
  • default - Optional default language object to return if the account has no valid language.

_mail_notify(op, account, language=None)

source code 
Conditionally create and send a notification email when a certain operation happens on the given user account.
Parameters:
  • op - The operation being performed on the account. Possible values: 'register_admin_created': Welcome message for user created by the admin 'register_no_approval_required': Welcome message when user self-registers 'register_pending_approval': Welcome message, user pending admin approval 'password_reset': Password recovery request 'status_activated': Account activated 'status_blocked': Account blocked 'status_deleted': Account deleted
  • account - The user object of the account being notified. Must contain at least the fields 'uid', 'name', and 'mail'.
  • language - Optional language to use for the notification, overriding account language.
Returns:
The return value from drupal_mail_send(), if ends up being called.
See Also:
,

_password_dynamic_validation()

source code 
Add javascript and string translations for dynamic password validation (strength and confirmation checking). This is an internal function that makes it easier to manage the translation strings that need to be passed to the javascript code.

block_user_action(object_, context=[])

source code 
Implementation of a Drupal action. Blocks the current user.

form_register_submit(form, form_state)

source code 
Submit handler for the user registration form. This function is shared by the installation form and the normal registration form, which is why it can't be in the user.pages.inc file.

register()

source code 
Form builder; The user registration form.
See Also:
, user_register_submit