Public Member Functions | Static Public Member Functions | Protected Member Functions

UserGroup Class Reference

Inheritance diagram for UserGroup:
Collaboration diagram for UserGroup:

List of all members.

Public Member Functions

 __construct ($paramarray=array())
 insert ()
 update ()
 delete ()
 __get ($param)
 add ($users)
 remove ($users)
 grant ($tokens, $access= 'full')
 deny ($tokens)
 revoke ($tokens)
 can ($token, $access= 'full')
 get_access ($token)
 get_tokens ()
 clear_permissions_cache ()
 load_permissions_cache ()
 member ($user_id)

Static Public Member Functions

static default_fields ()
static create ($paramarray)
static get ($group)
static get_by_id ($id)
static get_by_name ($name)
static exists ($group)
static name ($id)
static id ($name)

Protected Member Functions

 set_member_list ()
 load_member_cache ($refresh=false)

Detailed Description

Habari UserGroup Class

Definition at line 17 of file usergroup.php.


Constructor & Destructor Documentation

UserGroup::__construct ( paramarray = array()  ) 

Constructor for the UserGroup class

Parameters:
array $paramarray an associative array of UserGroup fields

Reimplemented from QueryRecord.

Definition at line 40 of file usergroup.php.


Member Function Documentation

UserGroup::__get ( param  ) 

function __get magic get function for returning virtual properties of the class

Parameters:
mixed the property to get
Returns:
mixed the property

Reimplemented from QueryRecord.

Definition at line 170 of file usergroup.php.

UserGroup::add ( users  ) 

Add one or more users to this group

Parameters:
mixed $users a user ID or name, or an array of the same

Definition at line 198 of file usergroup.php.

UserGroup::can ( token,
access = 'full' 
)

Determine whether members of a group can do something. This function should not be used to determine composite permissions among several groups

Parameters:
mixed a permission ID or name
Returns:
boolean If this group has been granted and not denied this permission, return true. Otherwise, return false.
See also:
ACL::group_can()
ACL::user_can()

Definition at line 277 of file usergroup.php.

UserGroup::clear_permissions_cache (  ) 

Clear permissions cache.

Definition at line 317 of file usergroup.php.

static UserGroup::create ( paramarray  )  [static]

Create a new UserGroup object and save it to the database

Parameters:
array $paramarray An associative array of UserGroup fields
Returns:
UserGroup the UserGroup that was created
Todo:
Make this function accept only a name, since you can't set an id into an autoincrement field, and we don't try.

Definition at line 58 of file usergroup.php.

Referenced by AdminGroupsHandler::do_add_group(), ACL::rebuild_permissions(), and AdminGroupsHandler::update_groups().

static UserGroup::default_fields (  )  [static]

get default fields for this record

Returns:
array an array of the fields used in the UserGroup table

Definition at line 28 of file usergroup.php.

Referenced by UserGroups::get().

UserGroup::delete (  ) 

Delete a UserGroup

Reimplemented from QueryRecord.

Definition at line 142 of file usergroup.php.

UserGroup::deny ( tokens  ) 

Deny one or more permission tokens to this group

Parameters:
mixed The permission ID or name to be denied, or an array of the same

Definition at line 250 of file usergroup.php.

static UserGroup::exists ( group  )  [static]

Determine whether a group exists

Parameters:
mixed The name or ID of the group
Returns:
bool Whether the group exists or not

Definition at line 381 of file usergroup.php.

Referenced by User::insert(), AdminGroupsHandler::update_groups(), and FormValidators::validate_groupname().

static UserGroup::get ( group  )  [static]

Fetch a group from the database by ID or name. This is a wrapper for get_by_id() and get_by_name()

Parameters:
integer|string|UserGroup $group A group ID, name, or UserGroup
Returns:
UserGroup|boolean UserGroup object, or boolean false

Definition at line 343 of file usergroup.php.

Referenced by ACL::create_token(), and member().

UserGroup::get_access ( token  ) 

Return the access bitmask for a specific token for this group.

Parameters:
string $token The
Returns:

Definition at line 293 of file usergroup.php.

static UserGroup::get_by_id ( id  )  [static]

Select a group from the DB by its ID

Parameters:
int A group ID
Returns:
mixed A UserGroup object, or boolean false

Definition at line 361 of file usergroup.php.

Referenced by AdminGroupsHandler::ajax_groups(), get(), AdminGroupsHandler::get_group(), ACL::grant_group(), AdminGroupsHandler::post_group(), ACL::revoke_group_token(), and AdminGroupsHandler::update_groups().

static UserGroup::get_by_name ( name  )  [static]

Select a group from the DB by its name

Parameters:
string A group name
Returns:
mixed A UserGroup object, or boolean false

Definition at line 371 of file usergroup.php.

Referenced by Menus::action_plugin_activation(), create(), get(), Users::get(), and ACL::rebuild_permissions().

UserGroup::get_tokens (  ) 

Returns an array of token ids and bitmask permissions that are associated with this group

Returns:
array An array of token ids

Definition at line 308 of file usergroup.php.

UserGroup::grant ( tokens,
access = 'full' 
)

Assign one or more new permission tokens to this group

Parameters:
mixed A permission token ID, name, or array of the same

Definition at line 234 of file usergroup.php.

Referenced by deny().

static UserGroup::id ( name  )  [static]

Given a group's name, return its ID

Parameters:
string|UserGroup a group's name or a group object
Returns:
int the group's ID, or false if the group doesn't exist

Definition at line 403 of file usergroup.php.

Referenced by ACL::get_group_token_access(), and User::in_group().

UserGroup::insert (  ) 

Save a new UserGroup to the UserGroup table

Reimplemented from QueryRecord.

Definition at line 79 of file usergroup.php.

UserGroup::load_member_cache ( refresh = false  )  [protected]

Cache the member ids that belong to this group

Parameters:
boolean $refresh Optional. If true, refresh the cache

Definition at line 441 of file usergroup.php.

Referenced by __get(), add(), remove(), and set_member_list().

UserGroup::load_permissions_cache (  ) 

Load permissions cache.

Definition at line 326 of file usergroup.php.

Referenced by __get(), can(), get_access(), and get_tokens().

UserGroup::member ( user_id  ) 

Determine whether the specified user is a member of the group

Parameters:
mixed A user ID or name
Returns:
bool True if the user is in the group, otherwise false

Definition at line 423 of file usergroup.php.

static UserGroup::name ( id  )  [static]

Given a group's ID, return its friendly name

Parameters:
int a group's ID
Returns:
string the group's name or false if the group doesn't exist

Definition at line 391 of file usergroup.php.

Referenced by add(), insert(), remove(), set_member_list(), and update().

UserGroup::remove ( users  ) 

Remove one or more user from this group

Parameters:
mixed $users A user ID or name, or an array of the same

Definition at line 217 of file usergroup.php.

UserGroup::revoke ( tokens  ) 

Remove one or more permissions from a group

Parameters:
mixed a permission ID, name, or array of the same

Definition at line 259 of file usergroup.php.

UserGroup::set_member_list (  )  [protected]

Set the member list for this group

Definition at line 126 of file usergroup.php.

Referenced by insert(), and update().

UserGroup::update (  ) 

Updates an existing UserGroup in the DB

Reimplemented from QueryRecord.

Definition at line 107 of file usergroup.php.

Referenced by add(), and remove().


The documentation for this class was generated from the following file: