29 parent::initializeAttributes();
31 $this->attributes[
'type'] =
"user";
32 $this->attributes[
'name'] =
null;
33 $this->attributes[
'username'] =
null;
34 $this->attributes[
'password'] =
null;
35 $this->attributes[
'salt'] =
null;
36 $this->attributes[
'email'] =
null;
37 $this->attributes[
'language'] =
null;
38 $this->attributes[
'banned'] =
"no";
39 $this->attributes[
'admin'] =
'no';
40 $this->attributes[
'prev_last_action'] =
null;
41 $this->attributes[
'last_login'] =
null;
42 $this->attributes[
'prev_last_login'] =
null;
43 $this->tables_split = 2;
64 if (
$row instanceof stdClass) {
67 $msg =
"Failed to load new " . get_class() .
" for GUID:" .
$row->guid;
70 }
else if (is_string(
$row)) {
72 elgg_deprecated_notice(
'Passing a username to constructor is deprecated. Use get_user_by_username()', 1.9);
81 elgg_deprecated_notice(
'This type of usage of the ElggUser constructor was deprecated. Please use the clone method.', 1.7);
85 }
else if (is_numeric(
$row)) {
89 throw new IOException(
"Failed to load new " . get_class() .
" from GUID:" .
$row);
106 $attr_loader->secondary_loader =
'get_user_entity_as_row';
108 $attrs = $attr_loader->getRequiredAttributes(
$guid);
113 $this->attributes =
$attrs;
114 $this->tables_loaded = 2;
128 $guid = parent::create();
136 $query =
"INSERT into {$CONFIG->dbprefix}users_entity
137 (guid, name, username, password, salt, email, language)
138 values ($guid, '$name', '$username', '$password', '$salt', '$email', '$language')";
155 if (!parent::update()) {
159 $guid = (int)$this->guid;
167 $query =
"UPDATE {$CONFIG->dbprefix}users_entity
168 SET name='$name', username='$username', password='$password', salt='$salt',
169 email='$email', language='$language'
172 return $this->
getDatabase()->updateData($query) !==
false;
180 public function delete() {
205 $this->name = $displayName;
212 if (array_key_exists(
$name, $this->attributes)) {
214 case 'prev_last_action':
216 case 'prev_last_login':
220 $this->attributes[
$name] =
null;
249 public function ban($reason =
"") {
250 return ban_user($this->guid, $reason);
268 return $this->banned ==
'yes';
282 return $this->attributes[
'admin'] ==
'yes';
297 $this->attributes[
'admin'] =
'yes';
314 $this->attributes[
'admin'] =
'no';
345 if (is_numeric(
$site)) {
350 return parent::addToSite(
$site);
361 if (is_numeric(
$site)) {
366 return parent::removeFromSite(
$site);
454 $options[
'relationship'] =
'friend';
461 'relationship' =>
'friend',
462 'relationship_guid' => $this->guid,
485 $options[
'relationship'] =
'friend';
487 $options[
'inverse_relationship'] =
true;
493 'relationship' =>
'friend',
494 'relationship_guid' => $this->guid,
515 elgg_deprecated_notice(
'ElggUser::listFriends() is deprecated. Use elgg_list_entities_from_relationship()', 1.9);
518 'relationship' =>
'friend',
519 'relationship_guid' => $this->guid,
521 'full_view' =>
false,
548 'relationship' =>
'member',
549 'relationship_guid' => $this->guid,
559 $options[
'relationship'] =
'member';
577 elgg_deprecated_notice(
'Elgg::listGroups is deprecated. Use elgg_list_entities_from_relationship()', 1.9);
580 'relationship' =>
'member',
581 'relationship_guid' => $this->guid,
584 'full_view' =>
false,
614 'owner_guid' => $this->
getGUID(),
636 $options[
'relationship'] =
'friend';
638 $options[
'relationship_join_on'] =
'container_guid';
647 'relationship' =>
'friend',
648 'relationship_guid' => $this->
getGUID(),
649 'relationship_join_on' =>
'container_guid',
728 return array_merge(parent::getExportableValues(), array(
if($guid==elgg_get_logged_in_user_guid()) $name
$user_guid
Avatar remove action.
getDatabase()
Provides a pointer to the database object.
initialise_attributes($pre18_api=true)
Initialise the attributes array.
loadAdditionalSelectValues(array $data)
Stores non-attributes from the loading of the entity as volatile data.
getGUID()
Returns the guid.
create()
{Create a new entry in the entities table.Saves the base information in the entities table for the en...
isAdmin()
Is this user admin?
removeAdmin()
Remove the admin flag for user.
getFriendsOf($options=array(), $limit=10, $offset=0)
Gets users who have made this user a friend.
initializeAttributes()
Initialize the attributes array.
getOwner()
If a user's owner is blank, return its own GUID as the owner.
addToSite($site)
Add this user to a particular site.
addFriend($friend_guid)
Adds a user as a friend.
isFriendsWith($user_guid)
Determines whether this user is friends with another user.
countObjects($subtype="")
Counts the number of ElggObjects owned by this user.
canComment($user_guid=0)
Can a user comment on this user?
listGroups($subtype="", $limit=10, $offset=0)
Lists the user's groups.
getSites($options="", $limit=10, $offset=0)
Get sites that this user is a member of.
__set($name, $value)
{Set an attribute or metadata value for this entity.Anything that is not an attribute is saved as met...
removeFriend($friend_guid)
Removes a user as a friend.
getFriendsObjects($options=array(), $limit=10, $offset=0)
Get an array of ElggObjects owned by this user's friends.
getObjects($options=array(), $limit=10, $offset=0)
Get an array of ElggObject owned by this user.
removeFromSite($site)
Remove this user from a particular site.
load($guid)
Load the ElggUser data from the database.
prepareObject($object)
{Prepare an object copy for toObject()Object representation of the entity stdClass}
getFriends($options=array(), $limit=10, $offset=0)
Gets this user's friends.
getCollections($subtype="", $limit=10, $offset=0)
Get the collections associated with a user.
getOwnerGUID()
Get a user's owner GUID.
isBanned()
Is this user banned or not?
setDisplayName($displayName)
{Sets the title or name of this entity.The title or name of this entity. void}
update()
{Update the entity in the database.bool Whether the update was successful.}
__construct($row=null)
Construct a new user entity.
isFriend()
Determines whether or not this user is a friend of the currently logged in user.
getExportableValues()
Return an array of fields which can be exported.
makeAdmin()
Make the user an admin.
listFriends($subtype="", $limit=10, array $vars=array())
Lists the user's friends.
getGroups($options="", $limit=10, $offset=0)
Gets the user's groups.
ban($reason="")
Ban this user.
getDisplayName()
{Get the entity's display name.string The title or name of this entity.}
isFriendOf($user_guid)
Determines whether or not this user is another user's friend.
$CONFIG language
The current language for either the site or the user.
$guid
Removes an admin notice.
count_user_objects($user_guid, $subtype=ELGG_ENTITIES_ANY_VALUE, $timelower=0, $timeupper=0)
Counts the objects (optionally of a particular subtype) owned by a user.
remove_site_user($site_guid, $user_guid)
Remove a user from a site.
add_site_user($site_guid, $user_guid)
Add a user to a site.
get_user_sites($user_guid, $limit=10, $offset=0)
Get the sites this user is part of.
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Sends a notice about deprecated use of a function, view, etc.
remove_user_from_access_collection($user_guid, $collection_id)
Removes a user from an access collection.
get_user_access_collections($owner_guid, $site_guid=0)
Returns an array of database row objects of the access collections owned by $owner_guid.
sanitize_string($string)
Sanitize a string for database use.
_elgg_cache_entity(ElggEntity $entity)
Cache an entity.
elgg_get_entities(array $options=array())
Returns an array of entities with optional filtering.
clear_user_files($user)
Removes all user files.
elgg_list_entities_from_relationship(array $options=array())
Returns a viewable list of entities by relationship.
elgg_get_entities_from_relationship($options)
Return entities matching a given query joining against a relationship.
add_entity_relationship($guid_one, $relationship, $guid_two)
Create a relationship between two entities.
remove_entity_relationship($guid_one, $relationship, $guid_two)
Delete a relationship between two entities.
check_entity_relationship($guid_one, $relationship, $guid_two)
Check if a relationship exists between two entities.
elgg_get_logged_in_user_guid()
Return the current logged in user by guid.
if(file_exists($welcome)) $vars
unban_user($user_guid)
Unban a user.
get_user($guid)
Get a user object from a GUID.
global $USERNAME_TO_GUID_MAP_CACHE
Map a username to a cached GUID.
get_user_by_username($username)
Get user by username.
make_user_admin($user_guid)
Makes user $guid an admin.
remove_user_admin($user_guid)
Removes user $guid's admin flag.
ban_user($user_guid, $reason="")
Ban a user.
elgg menu widget elgg menu item delete
$language
@uses $vars['language'] @uses $vars['lc'] if present, client will be sent long expires headers