30 parent::initializeAttributes();
32 $this->attributes[
'type'] =
"user";
33 $this->attributes[
'name'] = null;
34 $this->attributes[
'username'] = null;
35 $this->attributes[
'password'] = null;
36 $this->attributes[
'salt'] = null;
37 $this->attributes[
'password_hash'] = null;
38 $this->attributes[
'email'] = null;
39 $this->attributes[
'language'] = null;
40 $this->attributes[
'banned'] =
"no";
41 $this->attributes[
'admin'] =
'no';
42 $this->attributes[
'prev_last_action'] = null;
43 $this->attributes[
'last_login'] = null;
44 $this->attributes[
'prev_last_login'] = null;
45 $this->tables_split = 2;
66 if (
$row instanceof \stdClass) {
69 $msg =
"Failed to load new " . get_class() .
" for GUID:" .
$row->guid;
70 throw new \IOException($msg);
72 }
else if (is_string(
$row)) {
74 elgg_deprecated_notice(
'Passing a username to constructor is deprecated. Use get_user_by_username()', 1.9);
83 elgg_deprecated_notice(
'This type of usage of the \ElggUser constructor was deprecated. Please use the clone method.', 1.7);
87 }
else if (is_numeric(
$row)) {
91 throw new \IOException(
"Failed to load new " . get_class() .
" from GUID:" .
$row);
94 throw new \InvalidParameterException(
"Unrecognized value passed to constuctor.");
107 $attr_loader = new \Elgg\AttributeLoader(get_class(),
'user', $this->attributes);
108 $attr_loader->secondary_loader =
'get_user_entity_as_row';
110 $attrs = $attr_loader->getRequiredAttributes(
$guid);
115 $this->attributes =
$attrs;
116 $this->tables_loaded = 2;
130 $guid = parent::create();
139 $query =
"INSERT into {$CONFIG->dbprefix}users_entity 140 (guid, name, username, password, salt, password_hash, email, language) 141 values ($guid, '$name', '$username', '$password', '$salt', '$password_hash', '$email', '$language')";
158 if (!parent::update()) {
162 $guid = (int)$this->guid;
171 $query =
"UPDATE {$CONFIG->dbprefix}users_entity 172 SET name='$name', username='$username', password='$password', salt='$salt', 173 password_hash='$password_hash', email='$email', language='$language' 176 return $this->
getDatabase()->updateData($query) !==
false;
184 public function delete() {
185 global $USERNAME_TO_GUID_MAP_CACHE;
188 if (isset($USERNAME_TO_GUID_MAP_CACHE[$this->username])) {
189 unset($USERNAME_TO_GUID_MAP_CACHE[$this->username]);
207 $this->
name = $displayName;
214 if (!array_key_exists(
$name, $this->attributes)) {
220 case 'prev_last_action':
222 case 'prev_last_login':
226 $this->attributes[
$name] = null;
232 elgg_deprecated_notice(
"Setting salt/password directly is deprecated. Use ElggUser::setPassword().",
"1.10");
236 $this->attributes[
'password_hash'] =
'';
241 case 'password_hash':
242 _elgg_services()->logger->error(
"password_hash is now an attribute of ElggUser and cannot be set.");
269 public function ban($reason =
"") {
270 return ban_user($this->guid, $reason);
288 return $this->banned ==
'yes';
302 return $this->attributes[
'admin'] ==
'yes';
317 $this->attributes[
'admin'] =
'yes';
334 $this->attributes[
'admin'] =
'no';
365 if (is_numeric(
$site)) {
370 return parent::addToSite(
$site);
381 if (is_numeric(
$site)) {
386 return parent::removeFromSite(
$site);
406 if ($create_river_item) {
408 'view' =>
'river/relationship/friend/create',
409 'action_type' =>
'friend',
410 'subject_guid' => $this->guid,
486 $options[
'relationship'] =
'friend';
493 'relationship' =>
'friend',
494 'relationship_guid' => $this->guid,
517 $options[
'relationship'] =
'friend';
519 $options[
'inverse_relationship'] =
true;
525 'relationship' =>
'friend',
526 'relationship_guid' => $this->guid,
547 elgg_deprecated_notice(
'\ElggUser::listFriends() is deprecated. Use elgg_list_entities_from_relationship()', 1.9);
550 'relationship' =>
'friend',
551 'relationship_guid' => $this->guid,
553 'full_view' =>
false,
580 'relationship' =>
'member',
581 'relationship_guid' => $this->guid,
591 $options[
'relationship'] =
'member';
609 elgg_deprecated_notice(
'Elgg::listGroups is deprecated. Use elgg_list_entities_from_relationship()', 1.9);
612 'relationship' =>
'member',
613 'relationship_guid' => $this->guid,
616 'full_view' =>
false,
646 'owner_guid' => $this->
getGUID(),
668 $options[
'relationship'] =
'friend';
670 $options[
'relationship_join_on'] =
'container_guid';
679 'relationship' =>
'friend',
680 'relationship_guid' => $this->
getGUID(),
681 'relationship_join_on' =>
'container_guid',
760 return array_merge(parent::getExportableValues(), array(
795 $this->attributes[
'salt'] =
"";
796 $this->attributes[
'password'] =
"";
load($guid)
Load the data from the database.
addFriend($friend_guid, $create_river_item=false)
Adds a user as a friend.
listFriends($subtype="", $limit=10, array $vars=array())
Lists the user's friends.
remove_site_user($site_guid, $user_guid)
Remove a user from a site.
getDatabase()
Provides a pointer to the database object.
make_user_admin($user_guid)
Makes user $guid an admin.
makeAdmin()
Make the user an admin.
loadAdditionalSelectValues(array $data)
Stores non-attributes from the loading of the entity as volatile data.
add_entity_relationship($guid_one, $relationship, $guid_two)
Create a relationship between two entities.
addToSite($site)
Add this user to a particular site.
setPassword($password)
Set the necessary attributes to store a hash of the user's password.
if($guid==elgg_get_logged_in_user_guid()) $name
remove_entity_relationship($guid_one, $relationship, $guid_two)
Delete a relationship between two entities.
_elgg_cache_entity(\ElggEntity $entity)
Cache an entity.
if(!$autoload_available) _elgg_services()
getGUID()
Returns the guid.
$guid
Removes an admin notice.
getGroups($options="", $limit=10, $offset=0)
Gets the user's groups.
add_site_user($site_guid, $user_guid)
Add a user to a site.
getExportableValues()
Return an array of fields which can be exported.
getFriends($options=array(), $limit=10, $offset=0)
Gets this user's friends.
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.
unban_user($user_guid)
Unban a user.
__construct($row=null)
Construct a new user entity.
initializeAttributes()
Initialize the attributes array.
remove_user_from_access_collection($user_guid, $collection_id)
Removes a user from an access collection.
sanitize_string($string)
Sanitize a string for database use.
get_user_by_username($username)
Get user by username.
ban_user($user_guid, $reason="")
Ban a user.
get_user_access_collections($owner_guid, $site_guid=0)
Returns an array of database row objects of the access collections owned by $owner_guid.
ban($reason="")
Ban this user.
elgg_create_river_item(array $options=array())
Adds an item to the river.
get_user($guid)
Get a user object from a GUID.
elgg menu widget elgg menu item delete
isFriend()
Determines whether or not this user is a friend of the currently logged in user.
initialise_attributes($pre18_api=true)
Initialise the attributes array.
elgg_get_entities(array $options=array())
Returns an array of entities with optional filtering.
isFriendOf($user_guid)
Determines whether or not this user is another user's friend.
check_entity_relationship($guid_one, $relationship, $guid_two)
Check if a relationship exists between two entities.
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Sends a notice about deprecated use of a function, view, etc.
getOwner()
If a user's owner is blank, return its own GUID as the owner.
elgg global
Pointer to the global context.
getObjects($options=array(), $limit=10, $offset=0)
Get an array of owned by this user.
getOwnerGUID()
Get a user's owner GUID.
canComment($user_guid=0)
Can a user comment on this user?
getFriendsOf($options=array(), $limit=10, $offset=0)
Gets users who have made this user a friend.
elgg_list_entities_from_relationship(array $options=array())
Returns a viewable list of entities by relationship.
listGroups($subtype="", $limit=10, $offset=0)
Lists the user's groups.
removeFriend($friend_guid)
Removes a user as a friend.
getFriendsObjects($options=array(), $limit=10, $offset=0)
Get an array of owned by this user's friends.
isAdmin()
Is this user admin?
removeFromSite($site)
Remove this user from a particular site.
$CONFIG language
The current language for either the site or the user.
getSites($options="", $limit=10, $offset=0)
Get sites that this user is a member of.
removeAdmin()
Remove the admin flag for user.
isBanned()
Is this user banned or not?
elgg_get_entities_from_relationship($options)
Return entities matching a given query joining against a relationship.
countObjects($subtype="")
Counts the number of owned by this user.
$user_guid
Avatar remove action.
$language
$vars['language'] $vars['lc'] if present, client will be sent long expires headers ...
getCollections($subtype="", $limit=10, $offset=0)
Get the collections associated with a user.
get_user_sites($user_guid, $limit=10, $offset=0)
Get the sites this user is part of.
remove_user_admin($user_guid)
Removes user $guid's admin flag.
isFriendsWith($user_guid)
Determines whether this user is friends with another user.
setDisplayName($displayName)
{}
if(file_exists($welcome)) $vars