PHP Class ElggUser, Elgg

Representation of a "user" in the system.
Inheritance: extends ElggEntity, implements Friendable
ファイルを表示 Open project: elgg/elgg Class Usage Examples

Public Methods

Method Description
__construct ( stdClass $row = null ) Construct a new user entity
__set ( $name, $value )
addFriend ( integer $friend_guid, boolean $create_river_item = false ) : boolean Adds a user as a friend
ban ( string $reason = "" ) : boolean Ban this user.
canComment ( integer $user_guid, boolean $default = null ) : boolean Can a user comment on this user?
getDisplayName ( )
getExternalAttributes ( ) : array Get default values for attributes stored in a separate table
getFriends ( array $options = [] )
getFriendsObjects ( array $options = [] )
getFriendsOf ( array $options = [] )
getGroups ( array $options = [] ) : array | false Gets the user's groups
getNotificationSettings ( ) : array Returns users's notification settings [ 'email' => true, // enabled 'ajax' => false, // disabled ]
getObjects ( array $options = [] )
getOwnerGUID ( ) : integer Get a user's owner GUID
isAdmin ( ) : boolean Is this user admin?
isBanned ( ) : boolean Is this user banned or not?
isFriend ( ) : boolean Determines whether or not this user is a friend of the currently logged in user
isFriendOf ( integer $user_guid ) : boolean Determines whether or not this user is another user's friend
isFriendsWith ( integer $user_guid ) : boolean Determines whether this user is friends with another user
makeAdmin ( ) : boolean Make the user an admin
removeAdmin ( ) : boolean Remove the admin flag for user
removeFriend ( integer $friend_guid ) : boolean Removes a user as a friend
setDisplayName ( $displayName )
setNotificationSetting ( string $method, boolean $enabled = true ) : boolean Enable or disable a notification delivery method
setPassword ( string $password ) : void Set the necessary attribute to store a hash of the user's password.
unban ( ) : boolean Unban this user.

Protected Methods

Method Description
create ( )
initializeAttributes ( ) : void Initialize the attributes array.
load ( mixed $guid ) : boolean Load the \ElggUser data from the database
prepareObject ( $object )
update ( )

Method Details

__construct() public method

Plugin developers should only use the constructor to create a new entity. To retrieve entities, use get_entity() and the elgg_get_entities* functions.
public __construct ( stdClass $row = null )
$row stdClass Database row result. Default is null to create a new user.

__set() public method

public __set ( $name, $value )

addFriend() public method

Adds a user as a friend
public addFriend ( integer $friend_guid, boolean $create_river_item = false ) : boolean
$friend_guid integer The GUID of the user to add
$create_river_item boolean Create the river item announcing this friendship
return boolean

ban() public method

Ban this user.
public ban ( string $reason = "" ) : boolean
$reason string Optional reason
return boolean

canComment() public method

Can a user comment on this user?
See also: ElggEntity::canComment()
Since: 1.8.0
public canComment ( integer $user_guid, boolean $default = null ) : boolean
$user_guid integer User guid (default is logged in user)
$default boolean Default permission
return boolean

create() protected method

protected create ( )

getDisplayName() public method

public getDisplayName ( )

getExternalAttributes() final public static method

Get default values for attributes stored in a separate table
See also: Elgg\Database\EntityTable::getEntities
final public static getExternalAttributes ( ) : array
return array

getFriends() public method

public getFriends ( array $options = [] )
$options array

getFriendsObjects() public method

public getFriendsObjects ( array $options = [] )
$options array

getFriendsOf() public method

public getFriendsOf ( array $options = [] )
$options array

getGroups() public method

Gets the user's groups
public getGroups ( array $options = [] ) : array | false
$options array Options array.
return array | false Array of \ElggGroup, or false, depending on success

getNotificationSettings() public method

Returns users's notification settings [ 'email' => true, // enabled 'ajax' => false, // disabled ]
public getNotificationSettings ( ) : array
return array

getObjects() public method

public getObjects ( array $options = [] )
$options array

getOwnerGUID() public method

Returns it's own GUID if the user is not owned.
public getOwnerGUID ( ) : integer
return integer

initializeAttributes() protected method

This is vital to distinguish between metadata and base attributes.
protected initializeAttributes ( ) : void
return void

isAdmin() public method

Is this user admin?
public isAdmin ( ) : boolean
return boolean

isBanned() public method

Is this user banned or not?
public isBanned ( ) : boolean
return boolean

isFriend() public method

Determines whether or not this user is a friend of the currently logged in user
public isFriend ( ) : boolean
return boolean

isFriendOf() public method

Determines whether or not this user is another user's friend
public isFriendOf ( integer $user_guid ) : boolean
$user_guid integer The GUID of the user to check against
return boolean

isFriendsWith() public method

Determines whether this user is friends with another user
public isFriendsWith ( integer $user_guid ) : boolean
$user_guid integer The GUID of the user to check against
return boolean

load() protected method

Load the \ElggUser data from the database
protected load ( mixed $guid ) : boolean
$guid mixed \ElggUser GUID or \stdClass database row from entity table
return boolean

makeAdmin() public method

Make the user an admin
public makeAdmin ( ) : boolean
return boolean

prepareObject() protected method

protected prepareObject ( $object )

removeAdmin() public method

Remove the admin flag for user
public removeAdmin ( ) : boolean
return boolean

removeFriend() public method

Removes a user as a friend
public removeFriend ( integer $friend_guid ) : boolean
$friend_guid integer The GUID of the user to remove
return boolean

setDisplayName() public method

public setDisplayName ( $displayName )

setNotificationSetting() public method

Enable or disable a notification delivery method
public setNotificationSetting ( string $method, boolean $enabled = true ) : boolean
$method string Method name
$enabled boolean Enabled or disabled
return boolean

setPassword() public method

Set the necessary attribute to store a hash of the user's password.
Since: 1.10.0
public setPassword ( string $password ) : void
$password string The password to be hashed
return void

unban() public method

Unban this user.
public unban ( ) : boolean
return boolean

update() protected method

protected update ( )