Chyrp

Group

The Group model.

See Also

Model

Summary
Group The Group model.
Variables
$permissionCache Caches the permissions of every group so they don’t have to be parsed on every grab.
Functions
__construct Model::grab
find Model::search
can Checks if the group can perform the specified functions.
add Adds a group to the database with the passed Name and Permissions array.
update Updates a group with the given name and permissions, and passes arguments to the update_group trigger..
delete Deletes a given group.  Calls the “delete_group” trigger and passes the Group as an argument.
add_permission Adds a permission to the Groups table.
remove_permission Removes a permission from the Groups table.
size Returns the amount of users in the.
members Returns all the members of the group.
edit_link Outputs an edit link for the group, if the user can.
delete_link Outputs an delete link for the group, if the user can.

Variables

$permissionCache

Caches the permissions of every group so they don’t have to be parsed on every grab.

Functions

__construct

public function __construct( $group_id  =  null,
$options  =  array() )

See Also

Model::grab

find

static function find( $options  =  array(),
$options_for_object  =  array() )

See Also

Model::search

can

public function can()

Checks if the group can perform the specified functions.

add

static function add( $name,
$permissions )

Adds a group to the database with the passed Name and Permissions array.

Calls the add_group trigger with the ID, name, and permissions or the new group.

Parameters

$name The group’s name
$permissions An array of the permissions.

See Also

update

update

public function update( $name,
$permissions )

Updates a group with the given name and permissions, and passes arguments to the update_group trigger..

Parameters

$group_id The group to update.
$name The new Name to set.
$permissions An array of the new permissions to set.

delete

static function delete( $id )

Deletes a given group.  Calls the “delete_group” trigger and passes the Group as an argument.

Parameters

$id The group to delete.

add_permission

static function add_permission( $id,   
$name  =  null )

Adds a permission to the Groups table.

Parameters

$id The ID for the permission, like “can_do_something”.
$name The name for the permission, like “Can Do Something”.  Defaults to the camelized ID while keeping spaces.

remove_permission

static function remove_permission( $id )

Removes a permission from the Groups table.

Parameters

$id The ID of the permission to remove.

size

public function size()

Returns the amount of users in the.

members

public function members()

Returns all the members of the group.

edit_link

public function edit_link( $text  =  null,
$before  =  null,
$after  =  null )

Outputs an edit link for the group, if the user can.

Parameters

$text The text to show for the link.
$before If the link can be shown, show this before it.
$after If the link can be shown, show this after it.

delete_link

public function delete_link( $text  =  null,
$before  =  null,
$after  =  null )

Outputs an delete link for the group, if the user can.

Parameters

$text The text to show for the link.
$before If the link can be shown, show this before it.
$after If the link can be shown, show this after it.