AuthMixIn — A mixin for the User module that provides user groups and auth options
AuthMixIn is part of the User package.
class AuthMixIn extends UserMixIn { public array $auth public string $db_auth_options public string $db_groups public string $db_group_auth public string $db_user_auth public string $db_user_groups public array $group public void destroy ( void ); public void init ( User &$user ); private void load_defaults ( void ); public void start ( void ); }
UserMixIn +----AuthMixIn
A mixin for the User module that provides user groups and auth options
This mixin provides the ability to add users to groups. Both users and groups can be assigned auth options. Options can be set to AUTH_DEFAULT, AUTH_YES and AUTH_NO. User-specific options override group-specific options, which override default options. The AUTH_NO option supercedes the AUTH_YES option. E.g, when the default for an option is AUTH_NO but one of the user groups sets the option to AUTH_YES, the setting AUTH_NO on the another group overrides the AUTH_YES setting. This allows you to easily override options provided by groups.The default options in the auth_options table should be filled with the permissions used for unauthenticated users.This mixin requires five database tables. The names of the tables can be overridden by the $db_* attributes.
CREATE TABLE groups ( group_id INTEGER PRIMARY KEY AUTOINCREMENT, group_name VARCHAR(64) ) CREATE TABLE auth_options ( auth_name VARCHAR(32), auth_default TINYINT ) CREATE TABLE user_groups ( user_id INTEGER, group_id INTEGER ) CREATE TABLE user_auth ( user_id INTEGER, auth_name VARCHAR(32), auth_value TINYINT DEFAULT 2 ) CREATE TABLE group_auth ( group_id INTEGER, auth_name VARCHAR(32), auth_value TINYINT DEFAULT 2 )
public array $auth
An assocative array that holds all the auth_options for the user. Should not be written to.
Default value: empty string
public string $db_auth_options
The database table names
Default value: empty string
public string $db_groups
The database table names
Default value: empty string
public string $db_group_auth
The database table names
Default value: empty string
public string $db_user_auth
The database table names
Default value: empty string
public string $db_user_groups
The database table names
Default value: empty string
public array $group
An array that holds all the groups that the user is a member of. Group ID's are the keys and group names are the values.
Default value: empty string
public void destroy ( void );
Destroy the group and auth options, setting the defaults
public void init ( User &$user );
Initialize the mixin and load $auth with the default values
private void load_defaults ( void );
Load the default auth options and clear the groups
public void start ( void );
Load a user's groups and auth options