Elgg  Version 1.8
Namespaces | Functions | Variables
engine/lib/users.php File Reference

Go to the source code of this file.

Namespaces

namespace  Elgg\Core
 

Activate a plugin or plugins.


Functions

 get_user_entity_as_row ($guid)
 Return the user specific details of a user by a row.
 create_user_entity ($guid, $name, $username, $password, $salt, $email, $language, $code)
 Create or update the entities table for a given user.
 disable_user_entities ($owner_guid)
 Disables all of a user's entities.
 ban_user ($user_guid, $reason="")
 Ban a user.
 unban_user ($user_guid)
 Unban a user.
 make_user_admin ($user_guid)
 Makes user $guid an admin.
 remove_user_admin ($user_guid)
 Removes user $guid's admin flag.
 get_user_sites ($user_guid, $limit=10, $offset=0)
 Get the sites this user is part of.
 user_add_friend ($user_guid, $friend_guid)
 Adds a user to another user's friends list.
 user_remove_friend ($user_guid, $friend_guid)
 Removes a user from another user's friends list.
 user_is_friend ($user_guid, $friend_guid)
 Determines whether or not a user is another user's friend.
 get_user_friends ($user_guid, $subtype=ELGG_ENTITIES_ANY_VALUE, $limit=10, $offset=0)
 Obtains a given user's friends.
 get_user_friends_of ($user_guid, $subtype=ELGG_ENTITIES_ANY_VALUE, $limit=10, $offset=0)
 Obtains the people who have made a given user a friend.
 get_user_friends_objects ($user_guid, $subtype=ELGG_ENTITIES_ANY_VALUE, $limit=10, $offset=0, $timelower=0, $timeupper=0)
 Obtains a list of objects owned by a user's friends.
 count_user_friends_objects ($user_guid, $subtype=ELGG_ENTITIES_ANY_VALUE, $timelower=0, $timeupper=0)
 Counts the number of objects owned by a user's friends.
 list_user_friends_objects ($user_guid, $subtype="", $limit=10, $full_view=true, $listtypetoggle=true, $pagination=true, $timelower=0, $timeupper=0)
 Displays a list of a user's friends' objects of a particular subtype, with navigation.
 get_user ($guid)
 Get a user object from a GUID.
 get_user_by_username ($username)
 Get user by username.
 get_user_by_code ($code)
 Get user by session code.
 get_user_by_email ($email)
 Get an array of users from an email address.
 find_active_users ($seconds=600, $limit=10, $offset=0, $count=false)
 A function that returns a maximum of $limit users who have done something within the last $seconds seconds or the total count of active users.
 send_new_password_request ($user_guid)
 Generate and send a password request email to a given user's registered email address.
 force_user_password_reset ($user_guid, $password)
 Low level function to reset a given user's password.
 execute_new_password_request ($user_guid, $conf_code)
 Validate and execute a password reset for a user.
 generate_random_cleartext_password ()
 Generate a random 12 character clear text password.
 _elgg_generate_password_salt ()
 Generate an 8 character Base64 URL salt for the password.
 generate_user_password (ElggUser $user, $password)
 Hash a password for storage.
 validate_username ($username)
 Simple function which ensures that a username contains only valid characters.
 validate_password ($password)
 Simple validation of a password.
 validate_email_address ($address)
 Simple validation of a email.
 register_user ($username, $password, $name, $email, $allow_multiple_emails=false, $friend_guid=0, $invitecode= '')
 Registers a user, returning false if the username already exists.
 generate_invite_code ($username)
 Generates a unique invite code for a user.
 elgg_set_user_validation_status ($user_guid, $status, $method= '')
 Set the validation status for a user.
 elgg_get_user_validation_status ($user_guid)
 Gets the validation status of a user.
 collections_submenu_items ()
 Adds collection submenu items.
 friends_page_handler ($segments, $handler)
 Page handler for friends-related pages.
 collections_page_handler ($page_elements)
 Page handler for friends collections.
 elgg_user_account_page_handler ($page_elements, $handler)
 Page handler for account related pages.
 set_last_action ($user_guid)
 Sets the last action time of the given user to right now.
 set_last_login ($user_guid)
 Sets the last logon time of the given user to right now.
 user_create_hook_add_site_relationship ($event, $object_type, $object)
 Creates a relationship between this site and the user.
 user_avatar_hook ($hook, $entity_type, $returnvalue, $params)
 Serves the user's avatar.
 elgg_user_hover_menu ($hook, $type, $return, $params)
 Setup the default user hover menu private.
 elgg_users_setup_entity_menu ($hook, $type, $return, $params)
 Setup the menu shown with an entity.
 elgg_profile_fields_setup ()
 This function loads a set of default fields into the profile, then triggers a hook letting other plugins to edit add and delete fields.
 elgg_avatar_page_handler ($page)
 Avatar page handler.
 elgg_profile_page_handler ($page)
 Profile page handler.
 users_pagesetup ()
 Sets up user-related menu items.
 users_init ()
 Users initialisation function, which establishes the page handler.
 users_test ($hook, $type, $value, $params)
 Runs unit tests for ElggObject.

Variables

global $USERNAME_TO_GUID_MAP_CACHE = array()
 Map a username to a cached GUID.
global $CODE_TO_GUID_MAP_CACHE = array()
 Map a user code to a cached GUID.

Function Documentation

Generate an 8 character Base64 URL salt for the password.

Returns:
string private

Definition at line 781 of file users.php.

ban_user ( user_guid,
reason = "" 
)

Ban a user.

Parameters:
int$user_guidThe user guid
string$reasonA reason
Returns:
bool

Definition at line 136 of file users.php.

collections_page_handler ( page_elements)

Page handler for friends collections.

Parameters:
array$page_elementsPage elements
Returns:
bool private

Definition at line 1105 of file users.php.

Adds collection submenu items.

Returns:
void private

Definition at line 1054 of file users.php.

count_user_friends_objects ( user_guid,
subtype = ELGG_ENTITIES_ANY_VALUE,
timelower = 0,
timeupper = 0 
)

Counts the number of objects owned by a user's friends.

Parameters:
int$user_guidThe GUID of the user to get the friends of
string$subtypeOptionally, the subtype of objects
int$timelowerThe earliest time the entity can have been created. Default: all
int$timeupperThe latest time the entity can have been created. Default: all
Returns:
int The number of objects

Definition at line 463 of file users.php.

create_user_entity ( guid,
name,
username,
password,
salt,
email,
language,
code 
)

Create or update the entities table for a given user.

Call create_entity first.

Parameters:
int$guidThe user's GUID
string$nameThe user's display name
string$usernameThe username
string$passwordThe password
string$saltA salt for the password
string$emailThe user's email address
string$languageThe user's default language
string$codeA code
Returns:
bool private

Definition at line 49 of file users.php.

disable_user_entities ( owner_guid)

Disables all of a user's entities.

Parameters:
int$owner_guidThe owner GUID
Returns:
bool Depending on success

Definition at line 109 of file users.php.

Avatar page handler.

/avatar/edit/<username> /avatar/view/<username>/<size>/<icontime>

Parameters:
array$page
Returns:
bool private

Definition at line 1426 of file users.php.

Gets the validation status of a user.

Parameters:
int$user_guidThe user's GUID
Returns:
bool|null Null means status was not set for this user.
Since:
1.8.0

Definition at line 1032 of file users.php.

This function loads a set of default fields into the profile, then triggers a hook letting other plugins to edit add and delete fields.

Note: This is a secondary system:init call and is run at a super low priority to guarantee that it is called after all other plugins have initialised. private

Definition at line 1369 of file users.php.

Profile page handler.

Parameters:
array$page
Returns:
bool private

Definition at line 1452 of file users.php.

elgg_set_user_validation_status ( user_guid,
status,
method = '' 
)

Set the validation status for a user.

Parameters:
int$user_guidThe user's GUID
bool$statusValidated (true) or unvalidated (false)
string$methodOptional method to say how a user was validated
Returns:
bool
Since:
1.8.0

Definition at line 1015 of file users.php.

elgg_user_account_page_handler ( page_elements,
handler 
)

Page handler for account related pages.

Parameters:
array$page_elementsPage elements
string$handlerThe handler string
Returns:
bool private

Definition at line 1139 of file users.php.

elgg_user_hover_menu ( hook,
type,
return,
params 
)

Setup the default user hover menu private.

Definition at line 1237 of file users.php.

elgg_users_setup_entity_menu ( hook,
type,
return,
params 
)

Setup the menu shown with an entity.

Parameters:
string$hook
string$type
array$return
array$params
Returns:
array

private

Definition at line 1324 of file users.php.

execute_new_password_request ( user_guid,
conf_code 
)

Validate and execute a password reset for a user.

Parameters:
int$user_guidThe user id
string$conf_codeConfirmation code as sent in the request email.
Returns:
mixed

Definition at line 738 of file users.php.

find_active_users ( seconds = 600,
limit = 10,
offset = 0,
count = false 
)

A function that returns a maximum of $limit users who have done something within the last $seconds seconds or the total count of active users.

Parameters:
int$secondsNumber of seconds (default 600 = 10min)
int$limitLimit, default 10.
int$offsetOffset, default 0.
bool$countCount, default false.
Returns:
mixed

Definition at line 649 of file users.php.

force_user_password_reset ( user_guid,
password 
)

Low level function to reset a given user's password.

This can only be called from execute_new_password_request().

Parameters:
int$user_guidThe user.
string$passwordText (which will then be converted into a hash and stored)
Returns:
bool

Definition at line 712 of file users.php.

friends_page_handler ( segments,
handler 
)

Page handler for friends-related pages.

Parameters:
array$segmentsURL segments
string$handlerThe first segment in URL used for routing
Returns:
bool private

Definition at line 1074 of file users.php.

generate_invite_code ( username)

Generates a unique invite code for a user.

Parameters:
string$usernameThe username of the user sending the invitation
Returns:
string Invite code

Definition at line 1001 of file users.php.

Generate a random 12 character clear text password.

Returns:
string

Definition at line 771 of file users.php.

generate_user_password ( ElggUser user,
password 
)

Hash a password for storage.

Currently salted MD5.

Parameters:
ElggUser$userThe user this is being generated for.
string$passwordPassword in clear text
Returns:
string

Definition at line 793 of file users.php.

get_user ( guid)

Get a user object from a GUID.

This function returns an ElggUser from a given GUID.

Parameters:
int$guidThe GUID
Returns:
ElggUser|false

Definition at line 529 of file users.php.

get_user_by_code ( code)

Get user by session code.

Parameters:
string$codeThe session code
Returns:
ElggUser|false Depending on success

Definition at line 591 of file users.php.

get_user_by_email ( email)

Get an array of users from an email address.

Parameters:
string$emailEmail address.
Returns:
array

Definition at line 624 of file users.php.

get_user_by_username ( username)

Get user by username.

Parameters:
string$usernameThe user's username
Returns:
ElggUser|false Depending on success

Definition at line 553 of file users.php.

Return the user specific details of a user by a row.

Parameters:
int$guidThe ElggUser guid
Returns:
mixed private

Definition at line 26 of file users.php.

get_user_friends ( user_guid,
subtype = ELGG_ENTITIES_ANY_VALUE,
limit = 10,
offset = 0 
)

Obtains a given user's friends.

Parameters:
int$user_guidThe user's GUID
string$subtypeThe subtype of users, if any
int$limitNumber of results to return (default 10)
int$offsetIndexing offset, if any
Returns:
ElggUser[]|false Either an array of ElggUsers or false, depending on success

Definition at line 382 of file users.php.

get_user_friends_objects ( user_guid,
subtype = ELGG_ENTITIES_ANY_VALUE,
limit = 10,
offset = 0,
timelower = 0,
timeupper = 0 
)

Obtains a list of objects owned by a user's friends.

Parameters:
int$user_guidThe GUID of the user to get the friends of
string$subtypeOptionally, the subtype of objects
int$limitThe number of results to return (default 10)
int$offsetIndexing offset, if any
int$timelowerThe earliest time the entity can have been created. Default: all
int$timeupperThe latest time the entity can have been created. Default: all
Returns:
ElggObject[]|false An array of ElggObjects or false, depending on success

Definition at line 431 of file users.php.

get_user_friends_of ( user_guid,
subtype = ELGG_ENTITIES_ANY_VALUE,
limit = 10,
offset = 0 
)

Obtains the people who have made a given user a friend.

Parameters:
int$user_guidThe user's GUID
string$subtypeThe subtype of users, if any
int$limitNumber of results to return (default 10)
int$offsetIndexing offset, if any
Returns:
ElggUser[]|false Either an array of ElggUsers or false, depending on success

Definition at line 405 of file users.php.

get_user_sites ( user_guid,
limit = 10,
offset = 0 
)

Get the sites this user is part of.

Parameters:
int$user_guidThe user's GUID
int$limitNumber of results to return
int$offsetAny indexing offset
Returns:
ElggSite[]|false On success, an array of ElggSites

Definition at line 295 of file users.php.

list_user_friends_objects ( user_guid,
subtype = "",
limit = 10,
full_view = true,
listtypetoggle = true,
pagination = true,
timelower = 0,
timeupper = 0 
)

Displays a list of a user's friends' objects of a particular subtype, with navigation.

See also:
elgg_view_entity_list
Parameters:
int$user_guidThe GUID of the user
string$subtypeThe object subtype
int$limitThe number of entities to display on a page
bool$full_viewWhether or not to display the full view (default: true)
bool$listtypetoggleWhether or not to allow you to flip to gallery mode (default: true)
bool$paginationWhether to display pagination (default: true)
int$timelowerThe earliest time the entity can have been created. Default: all
int$timeupperThe latest time the entity can have been created. Default: all
Returns:
string

Definition at line 500 of file users.php.

make_user_admin ( user_guid)

Makes user $guid an admin.

Parameters:
int$user_guidUser guid
Returns:
bool

Definition at line 221 of file users.php.

register_user ( username,
password,
name,
email,
allow_multiple_emails = false,
friend_guid = 0,
invitecode = '' 
)

Registers a user, returning false if the username already exists.

Parameters:
string$usernameThe username of the new user
string$passwordThe password
string$nameThe user's display name
string$emailTheir email address
bool$allow_multiple_emailsAllow the same email address to be registered multiple times?
int$friend_guidGUID of a user to friend once fully registered
string$invitecodeAn invite code from a friend
Returns:
int|false The new user's GUID; false on failure
Exceptions:
RegistrationException

Definition at line 919 of file users.php.

remove_user_admin ( user_guid)

Removes user $guid's admin flag.

Parameters:
int$user_guidUser GUID
Returns:
bool

Definition at line 257 of file users.php.

send_new_password_request ( user_guid)

Generate and send a password request email to a given user's registered email address.

Parameters:
int$user_guidUser GUID
Returns:
bool

Definition at line 680 of file users.php.

set_last_action ( user_guid)

Sets the last action time of the given user to right now.

Parameters:
int$user_guidThe user GUID
Returns:
void

Definition at line 1168 of file users.php.

set_last_login ( user_guid)

Sets the last logon time of the given user to right now.

Parameters:
int$user_guidThe user GUID
Returns:
void

Definition at line 1187 of file users.php.

unban_user ( user_guid)

Unban a user.

Parameters:
int$user_guidUnban a user.
Returns:
bool

Definition at line 182 of file users.php.

user_add_friend ( user_guid,
friend_guid 
)

Adds a user to another user's friends list.

Parameters:
int$user_guidThe GUID of the friending user
int$friend_guidThe GUID of the user to friend
Returns:
bool Depending on success

Definition at line 319 of file users.php.

user_avatar_hook ( hook,
entity_type,
returnvalue,
params 
)

Serves the user's avatar.

Parameters:
string$hook
string$entity_type
string$returnvalue
array$params
Returns:
string private

Definition at line 1222 of file users.php.

user_create_hook_add_site_relationship ( event,
object_type,
object 
)

Creates a relationship between this site and the user.

Parameters:
string$eventcreate
string$object_typeuser
ElggUser$objectUser object
Returns:
void private

Definition at line 1208 of file users.php.

user_is_friend ( user_guid,
friend_guid 
)

Determines whether or not a user is another user's friend.

Parameters:
int$user_guidThe GUID of the user
int$friend_guidThe GUID of the friend
Returns:
bool

Definition at line 368 of file users.php.

user_remove_friend ( user_guid,
friend_guid 
)

Removes a user from another user's friends list.

Parameters:
int$user_guidThe GUID of the friending user
int$friend_guidThe GUID of the user on the friends list
Returns:
bool Depending on success

Definition at line 345 of file users.php.

Users initialisation function, which establishes the page handler.

Returns:
void private

Definition at line 1556 of file users.php.

Sets up user-related menu items.

Returns:
void private

Definition at line 1471 of file users.php.

users_test ( hook,
type,
value,
params 
)

Runs unit tests for ElggObject.

Parameters:
string$hookunit_test
string$typesystem
mixed$valueArray of tests
mixed$paramsParams
Returns:
array private

Definition at line 1609 of file users.php.

validate_email_address ( address)

Simple validation of a email.

Parameters:
string$addressEmail address
Exceptions:
RegistrationExceptionon invalid
Returns:
bool

Definition at line 893 of file users.php.

validate_password ( password)

Simple validation of a password.

Parameters:
string$passwordClear text password
Returns:
bool
Exceptions:
RegistrationExceptionon invalid

Definition at line 868 of file users.php.

validate_username ( username)

Simple function which ensures that a username contains only valid characters.

This should only permit chars that are valid on the file system as well.

Parameters:
string$usernameUsername
Returns:
bool
Exceptions:
RegistrationExceptionon invalid

Definition at line 807 of file users.php.


Variable Documentation

$CODE_TO_GUID_MAP_CACHE = array()

Map a user code to a cached GUID.

Definition at line 15 of file users.php.

$USERNAME_TO_GUID_MAP_CACHE = array()

Map a username to a cached GUID.

Definition at line 11 of file users.php.

 All Classes Namespaces Files Functions Variables Enumerations