33 parent::initializeAttributes();
35 $this->attributes[
'type'] =
"user";
36 $this->attributes += self::getExternalAttributes();
53 'password_hash' => null,
58 'prev_last_action' => null,
60 'prev_last_login' => null,
82 $msg =
"Failed to load new " . get_class() .
" for GUID:" .
$row->guid;
83 throw new \IOException($msg);
85 }
else if (is_string(
$row)) {
87 elgg_deprecated_notice(
'Passing a username to constructor is deprecated. Use get_user_by_username()', 1.9);
94 }
else if (is_numeric(
$row)) {
98 throw new \IOException(
"Failed to load new " . get_class() .
" from GUID:" .
$row);
101 throw new \InvalidParameterException(
"Unrecognized value passed to constuctor.");
114 $attr_loader = new \Elgg\AttributeLoader(get_class(),
'user', $this->attributes);
115 $attr_loader->secondary_loader =
'get_user_entity_as_row';
117 $attrs = $attr_loader->getRequiredAttributes(
$guid);
122 $this->attributes =
$attrs;
136 $guid = parent::create();
145 $query =
"INSERT into {$CONFIG->dbprefix}users_entity 146 (guid, name, username, password, salt, password_hash, email, language) 147 values ($guid, '$name', '$username', '$password', '$salt', '$password_hash', '$email', '$language')";
164 if (!parent::update()) {
168 $guid = (int)$this->guid;
177 $query =
"UPDATE {$CONFIG->dbprefix}users_entity 178 SET name='$name', username='$username', password='$password', salt='$salt', 179 password_hash='$password_hash', email='$email', language='$language' 182 return $this->
getDatabase()->updateData($query) !==
false;
196 $this->
name = $displayName;
203 if (!array_key_exists(
$name, $this->attributes)) {
209 case 'prev_last_action':
211 case 'prev_last_login':
215 $this->attributes[
$name] = null;
221 elgg_deprecated_notice(
"Setting salt/password directly is deprecated. Use ElggUser::setPassword().",
"1.10");
225 $this->attributes[
'password_hash'] =
'';
230 case 'password_hash':
231 _elgg_services()->logger->error(
"password_hash is now an attribute of ElggUser and cannot be set.");
257 public function ban($reason =
"") {
258 return ban_user($this->guid, $reason);
276 return $this->banned ==
'yes';
290 return $this->attributes[
'admin'] ==
'yes';
310 $this->attributes[
'admin'] =
'yes';
332 $this->attributes[
'admin'] =
'no';
354 if ($create_river_item) {
356 'view' =>
'river/relationship/friend/create',
357 'action_type' =>
'friend',
358 'subject_guid' => $this->guid,
434 $options[
'relationship'] =
'friend';
441 'relationship' =>
'friend',
442 'relationship_guid' => $this->guid,
465 $options[
'relationship'] =
'friend';
467 $options[
'inverse_relationship'] =
true;
473 'relationship' =>
'friend',
474 'relationship_guid' => $this->guid,
498 'relationship' =>
'member',
499 'relationship_guid' => $this->guid,
509 $options[
'relationship'] =
'member';
536 'owner_guid' => $this->
getGUID(),
558 $options[
'relationship'] =
'friend';
560 $options[
'relationship_join_on'] =
'container_guid';
569 'relationship' =>
'friend',
570 'relationship_guid' => $this->
getGUID(),
571 'relationship_join_on' =>
'container_guid',
631 return array_merge(parent::getExportableValues(), array(
667 $this->attributes[
'salt'] =
"";
668 $this->attributes[
'password'] =
"";
680 $this->{
"notification:method:$method"} = (int)
$enabled;
681 return (
bool) $this->
save();
700 foreach ($methods as
$method) {
load($guid)
Load the data from the database.
addFriend($friend_guid, $create_river_item=false)
Adds a user as a friend.
$object
These two snippets demonstrates triggering an event and how to register for that event.
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.
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.
setNotificationSetting($method, $enabled=true)
Enable or disable a notification delivery method.
getGUID()
Returns the guid.
$guid
Removes an admin notice.
getGroups($options="", $limit=10, $offset=0)
Gets the user's groups.
getExportableValues()
Return an array of fields which can be exported.
getFriends($options=array(), $limit=10, $offset=0)
Gets this user's friends.
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)
Sanitizes a string for use in a query.
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.
isFriend()
Determines whether or not this user is a friend of the currently logged in user.
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.
elgg global
Pointer to the global context.
getObjects($options=array(), $limit=10, $offset=0)
Get an array of owned by this user.
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
getOwnerGUID()
Get a user's owner GUID.
getFriendsOf($options=array(), $limit=10, $offset=0)
Gets users who have made this user a friend.
getNotificationSettings()
Returns users's notification settings [ 'email' => true, // enabled 'ajax' => false, // disabled ]
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?
$CONFIG language
The current language for either the site or the user.
removeAdmin()
Remove the admin flag for user.
isBanned()
Is this user banned or not?
canComment($user_guid=0, $default=null)
Can a user comment on this user?
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.
$enabled
CI CLI installer script.
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)
{}