PHP Класс Habari\User

Наследование: extends QueryRecord, implements habari\FormStorage, implements IsContent
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$url_args

Открытые методы

Метод Описание
__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

Приватные методы

Метод Описание
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

Описание методов

__construct() публичный Метод

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

__get() публичный Метод

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
Результат mixed the requested field value

add_to_group() публичный Метод

function add_to_group
public add_to_group ( integer | string | UserGroup $group ) : null
$group integer | string | UserGroup A group ID, name, or UserGroup instance
Результат null

anonymous() публичный статический Метод

Build and return the anonymous user
public static anonymous ( ) : object
Результат object user object

authenticate() публичный статический Метод

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
Результат User | boolean a User object, or false

can() публичный Метод

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.)
Результат boolean True if this user has the requested access, false if not

can_any() публичный Метод

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.
Результат boolean True if this user has the requested access, false if not

cannot() публичный Метод

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
Результат boolean True if this user has been denied access to the requested token, false if not

commenter() публичный статический Метод

If this is a returning commenter, then return details from their cookie otherwise return empty strings.
public static commenter ( ) : Array
Результат Array an array of name, email and URL

content_type() публичный Метод

Returns the content type of the object instance
public content_type ( ) : array
Результат array An array of content types that this object represents, starting with the most specific

count_posts() публичный Метод

Returns the number of posts written by this user
public count_posts ( $status = false ) : integer
Результат integer The number of posts written by this user

create() публичный статический Метод

Creates a new user object and saves it to the database
public static create ( $paramarray ) : User
Результат User the User object that was created

default_fields() публичный статический Метод

Get default fields for this record.
public static default_fields ( ) : array
Результат array an array of the fields used in the User table

delete() публичный Метод

Delete a user account
public delete ( )

deny() публичный Метод

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

field_load() публичный Метод

Loads form values from an object
public field_load ( string $key ) : mixed
$key string The name of a form component that will be loaded
Результат mixed The stored value returned

field_save() публичный Метод

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() публичный Метод

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

get() публичный статический Метод

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
Результат object User object, or false

get_by_email() публичный статический Метод

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
Результат User The User object of the specified user

get_by_id() публичный статический Метод

Select a user from the database by its id
public static get_by_id ( integer $id ) : User
$id integer The id of a user
Результат User The User object of the specified user

get_by_name() публичный статический Метод

Select a user from the database by its username
public static get_by_name ( string $username ) : User
$username string The name of a user
Результат User The User object of the specified user

get_id() публичный статический Метод

Return the id of a user
public static get_id ( mixed $user ) : integer
$user mixed The id, name, or email address of a user
Результат integer The id of the specified user or false if that user doesn't exist

get_url_args() публичный Метод

Returns a set of properties used by URL::get to create URLs
public get_url_args ( ) : array
Результат array Properties of this post used to build a URL

grant() публичный Метод

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

identify() публичный статический Метод

Check for the existence of a cookie, and return a user object of the user, if successful
public static identify ( ) : User
Результат User user object, or false if no valid cookie exists

in_group() публичный Метод

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
Результат boolean Whether or not this user is in the specified group

insert() публичный Метод

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

remember() публичный Метод

Save the user id into the session
public remember ( )

remove_from_group() публичный Метод

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
Результат null

revoke() публичный Метод

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

update() публичный Метод

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

Описание свойств

$url_args защищенное свойство

protected $url_args