PHP Class Habari\User

Inheritance: extends QueryRecord, implements habari\FormStorage, implements IsContent
Afficher le fichier Open project: habari/system Class Usage Examples

Protected Properties

Свойство Type Description
$url_args

Méthodes publiques

Méthode Description
__construct ( array $paramarray = [] ) Constructor for the User class
__get ( string $name ) : mixed Capture requests for the info object so that it can be initialized properly when the constructor is bypassed (see PDO::FETCH_CLASS pecularities). Passes all other requests to parent.
add_to_group ( integer | string | UserGroup $group ) : null function add_to_group
anonymous ( ) : object Build and return the anonymous user
authenticate ( string $who, string $pw ) : User | boolean Check a user's credentials to see if they are legit -- calls all auth plugins BEFORE checking local database.
can ( string $token, string $access = 'any' ) : boolean Determine if a user has a specific token permission
can_any ( array $token_access = [] ) : boolean Determine if a user has any of a set of tokens
cannot ( string $token ) : boolean Determine if a user has been denied access to a specific token
commenter ( ) : Array Returns an array of information about the commenter If this is a logged-in user, then return details from their user profile.
content_type ( ) : array Returns the content type of the object instance
count_posts ( $status = false ) : integer Returns the number of posts written by this user
create ( $paramarray ) : User Creates a new user object and saves it to the database
default_fields ( ) : array Get default fields for this record.
delete ( ) Delete a user account
deny ( $tokens ) Deny permissions to one or more tokens to this user
field_load ( string $key ) : mixed Loads form values from an object
field_save ( string $key, mixed $value ) Stores a form value into the object
forget ( boolean $redirect = true ) Delete the user id from the session
get ( mixed $who ) : object Fetch a user from the database by name, ID, or email address.
get_by_email ( string $email ) : User Select a user from the database by its email address
get_by_id ( integer $id ) : User Select a user from the database by its id
get_by_name ( string $username ) : User Select a user from the database by its username
get_id ( mixed $user ) : integer Return the id of a user
get_url_args ( ) : array Returns a set of properties used by URL::get to create URLs
grant ( $tokens, $access = 'full' ) Assign permissions to one or more new tokens to this user
identify ( ) : User Check for the existence of a cookie, and return a user object of the user, if successful
in_group ( integer | string $group ) : boolean function in_group Whether or not this user is is in the specified group
insert ( ) Save a new user to the users table
remember ( ) Save the user id into the session
remove_from_group ( integer | string | UserGroup $group ) : null function remove_from_group removes this user from a group
revoke ( $tokens ) Remove permissions to one or more tokens from a user
update ( ) Updates an existing user in the users table

Private Methods

Méthode Description
get_info ( ) : UserInfo function get_info Gets the info object for this user, which contains data from the userinfo table related to this user.
list_groups ( $refresh = false ) : Array Returns an array of groups to which this user belongs

Method Details

__construct() public méthode

Constructor for the User class
public __construct ( array $paramarray = [] )
$paramarray array an associative array of initial User fields

__get() public méthode

Capture requests for the info object so that it can be initialized properly when the constructor is bypassed (see PDO::FETCH_CLASS pecularities). Passes all other requests to parent.
public __get ( string $name ) : mixed
$name string requested field name
Résultat mixed the requested field value

add_to_group() public méthode

function add_to_group
public add_to_group ( integer | string | UserGroup $group ) : null
$group integer | string | UserGroup A group ID, name, or UserGroup instance
Résultat null

anonymous() public static méthode

Build and return the anonymous user
public static anonymous ( ) : object
Résultat object user object

authenticate() public static méthode

Check a user's credentials to see if they are legit -- calls all auth plugins BEFORE checking local database.
public static authenticate ( string $who, string $pw ) : User | boolean
$who string A username
$pw string A password
Résultat User | boolean a User object, or false

can() public méthode

Determine if a user has a specific token permission
public can ( string $token, string $access = 'any' ) : boolean
$token string The name of the token for which to check permission
$access string The type of access to check for (read, write, full, etc.)
Résultat boolean True if this user has the requested access, false if not

can_any() public méthode

Determine if a user has any of a set of tokens
public can_any ( array $token_access = [] ) : boolean
$token_access array An array of tokens and the permissions to check for each of them.
Résultat boolean True if this user has the requested access, false if not

cannot() public méthode

Determine if a user has been denied access to a specific token
public cannot ( string $token ) : boolean
$token string The name of the token to detect
Résultat boolean True if this user has been denied access to the requested token, false if not

commenter() public static méthode

If this is a returning commenter, then return details from their cookie otherwise return empty strings.
public static commenter ( ) : Array
Résultat Array an array of name, email and URL

content_type() public méthode

Returns the content type of the object instance
public content_type ( ) : array
Résultat array An array of content types that this object represents, starting with the most specific

count_posts() public méthode

Returns the number of posts written by this user
public count_posts ( $status = false ) : integer
Résultat integer The number of posts written by this user

create() public static méthode

Creates a new user object and saves it to the database
public static create ( $paramarray ) : User
Résultat User the User object that was created

default_fields() public static méthode

Get default fields for this record.
public static default_fields ( ) : array
Résultat array an array of the fields used in the User table

delete() public méthode

Delete a user account
public delete ( )

deny() public méthode

Deny permissions to one or more tokens to this user
public deny ( $tokens )

field_load() public méthode

Loads form values from an object
public field_load ( string $key ) : mixed
$key string The name of a form component that will be loaded
Résultat mixed The stored value returned

field_save() public méthode

Stores a form value into the object
public field_save ( string $key, mixed $value )
$key string The name of a form component that will be stored
$value mixed The value of the form component to store

forget() public méthode

Delete the user id from the session
public forget ( boolean $redirect = true )
$redirect boolean Redirect the user to base_url after destroying session?

get() public static méthode

This is a wrapper function that will invoke the appropriate get_by_* method.
public static get ( mixed $who ) : object
$who mixed user ID, username, or e-mail address
Résultat object User object, or false

get_by_email() public static méthode

Select a user from the database by its email address
public static get_by_email ( string $email ) : User
$email string The email address of a user
Résultat User The User object of the specified user

get_by_id() public static méthode

Select a user from the database by its id
public static get_by_id ( integer $id ) : User
$id integer The id of a user
Résultat User The User object of the specified user

get_by_name() public static méthode

Select a user from the database by its username
public static get_by_name ( string $username ) : User
$username string The name of a user
Résultat User The User object of the specified user

get_id() public static méthode

Return the id of a user
public static get_id ( mixed $user ) : integer
$user mixed The id, name, or email address of a user
Résultat integer The id of the specified user or false if that user doesn't exist

get_url_args() public méthode

Returns a set of properties used by URL::get to create URLs
public get_url_args ( ) : array
Résultat array Properties of this post used to build a URL

grant() public méthode

Assign permissions to one or more new tokens to this user
public grant ( $tokens, $access = 'full' )

identify() public static méthode

Check for the existence of a cookie, and return a user object of the user, if successful
public static identify ( ) : User
Résultat User user object, or false if no valid cookie exists

in_group() public méthode

function in_group Whether or not this user is is in the specified group
public in_group ( integer | string $group ) : boolean
$group integer | string a group ID or name
Résultat boolean Whether or not this user is in the specified group

insert() public méthode

Save a new user to the users table
public insert ( )

remember() public méthode

Save the user id into the session
public remember ( )

remove_from_group() public méthode

function remove_from_group removes this user from a group
public remove_from_group ( integer | string | UserGroup $group ) : null
$group integer | string | UserGroup A group ID, name, or UserGroup instance
Résultat null

revoke() public méthode

Remove permissions to one or more tokens from a user
public revoke ( $tokens )

update() public méthode

Updates an existing user in the users table
public update ( )

Property Details

$url_args protected_oe property

protected $url_args