30 parent::initializeAttributes();
32 $this->attributes[
'type'] =
"user";
33 $this->attributes += self::getExternalAttributes();
34 $this->tables_split = 2;
51 'password_hash' => null,
56 'prev_last_action' => null,
58 'prev_last_login' => null,
80 if (
$row instanceof \stdClass) {
83 $msg =
"Failed to load new " . get_class() .
" for GUID:" .
$row->guid;
84 throw new \IOException($msg);
86 }
else if (is_string(
$row)) {
88 elgg_deprecated_notice(
'Passing a username to constructor is deprecated. Use get_user_by_username()', 1.9);
97 elgg_deprecated_notice(
'This type of usage of the \ElggUser constructor was deprecated. Please use the clone method.', 1.7);
101 }
else if (is_numeric(
$row)) {
105 throw new \IOException(
"Failed to load new " . get_class() .
" from GUID:" .
$row);
108 throw new \InvalidParameterException(
"Unrecognized value passed to constuctor.");
121 $attr_loader = new \Elgg\AttributeLoader(get_class(),
'user', $this->attributes);
122 $attr_loader->secondary_loader =
'get_user_entity_as_row';
124 $attrs = $attr_loader->getRequiredAttributes(
$guid);
129 $this->attributes =
$attrs;
130 $this->tables_loaded = 2;
144 $guid = parent::create();
153 $query =
"INSERT into {$CONFIG->dbprefix}users_entity 154 (guid, name, username, password, salt, password_hash, email, language) 155 values ($guid, '$name', '$username', '$password', '$salt', '$password_hash', '$email', '$language')";
172 if (!parent::update()) {
176 $guid = (int)$this->guid;
185 $query =
"UPDATE {$CONFIG->dbprefix}users_entity 186 SET name='$name', username='$username', password='$password', salt='$salt', 187 password_hash='$password_hash', email='$email', language='$language' 190 return $this->
getDatabase()->updateData($query) !==
false;
198 public function delete() {
199 global $USERNAME_TO_GUID_MAP_CACHE;
202 if (isset($USERNAME_TO_GUID_MAP_CACHE[$this->
username])) {
203 unset($USERNAME_TO_GUID_MAP_CACHE[$this->username]);
221 $this->
name = $displayName;
228 if (!array_key_exists(
$name, $this->attributes)) {
234 case 'prev_last_action':
236 case 'prev_last_login':
240 $this->attributes[
$name] = null;
246 elgg_deprecated_notice(
"Setting salt/password directly is deprecated. Use ElggUser::setPassword().",
"1.10");
250 $this->attributes[
'password_hash'] =
'';
255 case 'password_hash':
256 _elgg_services()->logger->error(
"password_hash is now an attribute of ElggUser and cannot be set.");
283 public function ban($reason =
"") {
284 return ban_user($this->guid, $reason);
302 return $this->banned ==
'yes';
316 return $this->attributes[
'admin'] ==
'yes';
331 $this->attributes[
'admin'] =
'yes';
348 $this->attributes[
'admin'] =
'no';
379 if (is_numeric(
$site)) {
384 return parent::addToSite(
$site);
395 if (is_numeric(
$site)) {
400 return parent::removeFromSite(
$site);
420 if ($create_river_item) {
422 'view' =>
'river/relationship/friend/create',
423 'action_type' =>
'friend',
424 'subject_guid' => $this->guid,
500 $options[
'relationship'] =
'friend';
507 'relationship' =>
'friend',
508 'relationship_guid' => $this->guid,
531 $options[
'relationship'] =
'friend';
533 $options[
'inverse_relationship'] =
true;
539 'relationship' =>
'friend',
540 'relationship_guid' => $this->guid,
561 elgg_deprecated_notice(
'\ElggUser::listFriends() is deprecated. Use elgg_list_entities_from_relationship()', 1.9);
564 'relationship' =>
'friend',
565 'relationship_guid' => $this->guid,
567 'full_view' =>
false,
594 'relationship' =>
'member',
595 'relationship_guid' => $this->guid,
605 $options[
'relationship'] =
'member';
623 elgg_deprecated_notice(
'Elgg::listGroups is deprecated. Use elgg_list_entities_from_relationship()', 1.9);
626 'relationship' =>
'member',
627 'relationship_guid' => $this->guid,
630 'full_view' =>
false,
660 'owner_guid' => $this->
getGUID(),
682 $options[
'relationship'] =
'friend';
684 $options[
'relationship_join_on'] =
'container_guid';
693 'relationship' =>
'friend',
694 'relationship_guid' => $this->
getGUID(),
695 'relationship_join_on' =>
'container_guid',
774 return array_merge(parent::getExportableValues(), array(
809 $this->attributes[
'salt'] =
"";
810 $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.
static getExternalAttributes()
Get default values for attributes stored in a separate table.
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.
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)
Log 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']
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