StaffGroups extends AppModel
Staff group management
Table of Contents
Methods
| __construct() | Initialize Staff Groups |
| add() | Adds a new staff group |
| addNotice() | Adds a staff group notice |
| cloneGroup() | Clone an existing staff group to the given company |
| delete() | Deletes a staff group |
| deleteNotice() | Deletes the given staff group notice |
| edit() | Updates a staff group |
| get() | Fetches a staff group |
| getAll() | Fetches all staff groups belonging to a given company, or all companies if not given |
| getList() | Retrieves a list of plugins installed under a particular company |
| getListCount() | Returns the total number of staff groups returned from StaffGroups::getList(), useful in constructing pagination for the getList() method. |
| getNotices() | Fetches all staff group notices |
| getStaffGroupByStaff() | Fetches the staff group for the given staff member and company |
| getUsersGroups() | Fetch all groups and companies this staff user is associated with |
| grantPermission() | Grant access to every permission allowed by the given plugin to the given staff group |
| deleteGroupNotices() | Deletes the staff group notices |
| getGroups() | Partially constructs the query required by StaffGroups::getList(), StaffGroups::getListCount(), and StaffGroups::getAll() |
| getNoticeRules() | Fetches the rules for adding/editing a staff group notice |
| getRules() | Fetches the rules for adding/editing a staff group |
| setPermissions() | Removes any existing entries in the ACL for this ACO and adds "allow" entires for all of the given permission groups and permission fields. |
Methods
__construct()
Initialize Staff Groups
public
__construct() : mixed
add()
Adds a new staff group
public
add(array<string|int, mixed> $vars) : int
Parameters
- $vars : array<string|int, mixed>
-
An array of staff group information including:
- company_id The company ID
- name The name of this staff group
- session_lock Set whether or not the IP set for the session must match the user's IP
- notices An array of email group actions representing BCC notices available to this group
- permission_group A numerically indexed array of permission group IDs to allow access to
- permission A numerically indexed array of permission field IDs to allow access to
Tags
Return values
int —The staff group ID created, void on error
addNotice()
Adds a staff group notice
public
addNotice(array<string|int, mixed> $vars) : mixed
Parameters
- $vars : array<string|int, mixed>
-
An array of staff group information including:
- staff_group_id The ID of the staff group this notice will be added to
- action The email group action
cloneGroup()
Clone an existing staff group to the given company
public
cloneGroup(int $staff_group_id, int $company_id) : int
Parameters
- $staff_group_id : int
-
The ID of the staff group to clone
- $company_id : int
-
The ID of the company to assign the cloned staff group to
Return values
int —The ID of the new staff group
delete()
Deletes a staff group
public
delete(int $staff_group_id) : mixed
Parameters
- $staff_group_id : int
-
The staff group ID
deleteNotice()
Deletes the given staff group notice
public
deleteNotice(int $staff_group_id[, string $action = null ]) : mixed
Parameters
- $staff_group_id : int
-
The ID of the staff group the notice belongs to
- $action : string = null
-
The email group action to remove (optional, default null to delete all notices)
edit()
Updates a staff group
public
edit(int $staff_group_id, array<string|int, mixed> $vars) : int
Parameters
- $staff_group_id : int
-
The staff group ID
- $vars : array<string|int, mixed>
-
An array of staff group information including:
- company_id The company ID
- name The name of this staff group
- session_lock Set whether or not the IP set for the session must match the user's IP
- notices An array of email group actions representing BCC notices available to this group
- permission_group A numerically indexed array of permission group IDs to allow access to
- permission A numerically indexed array of permission field IDs to allow access to
Tags
Return values
int —The staff group ID created, void on error
get()
Fetches a staff group
public
get(int $staff_group_id) : mixed
Parameters
- $staff_group_id : int
-
The staff group ID to fetch
Return values
mixed —An array of stdClass objects representing the staff group, false if it does not exist
getAll()
Fetches all staff groups belonging to a given company, or all companies if not given
public
getAll([int $company_id = null ]) : mixed
Parameters
- $company_id : int = null
-
The ID of the company whose staff groups to fetch (optional, default null)
Return values
mixed —An array of stdClass objects representing the staff groups of a company, or false if none exist
getList()
Retrieves a list of plugins installed under a particular company
public
getList(int $company_id[, int $page = 1 ][, string $order_by = ['name' => 'ASC'] ]) : mixed
Parameters
- $company_id : int
-
The company ID
- $page : int = 1
-
The page of results to fetch (optional, default 1)
- $order_by : string = ['name' => 'ASC']
-
The sort and order conditions (e.g. array('sort_field'=>"ASC"), optional)
Return values
mixed —An array of stdClass objects representing staff groups, or false if none exist
getListCount()
Returns the total number of staff groups returned from StaffGroups::getList(), useful in constructing pagination for the getList() method.
public
getListCount(int $company_id) : int
Parameters
- $company_id : int
-
The company ID
Tags
Return values
int —The total number of staff groups
getNotices()
Fetches all staff group notices
public
getNotices(int $staff_group_id) : array<string|int, mixed>
Parameters
- $staff_group_id : int
-
The ID of the staff group
Return values
array<string|int, mixed> —A list of all staff group notices
getStaffGroupByStaff()
Fetches the staff group for the given staff member and company
public
getStaffGroupByStaff(int $staff_id, int $company_id) : stdClass
Parameters
- $staff_id : int
-
The ID of the staff member to fetch the group for
- $company_id : int
-
The ID of the company to fetch the staff group for
Return values
stdClass —A stdClass representation of the staff group
getUsersGroups()
Fetch all groups and companies this staff user is associated with
public
getUsersGroups(int $user_id) : array<string|int, mixed>
Parameters
- $user_id : int
-
The ID of the user to fetch staff group info for
Return values
array<string|int, mixed> —An array of stdClass objects representing a particular staff group/staff member association
grantPermission()
Grant access to every permission allowed by the given plugin to the given staff group
public
grantPermission(int $staff_group_id, int $plugin_id) : mixed
Parameters
- $staff_group_id : int
-
The staff group ID to grant access for
- $plugin_id : int
-
The ID of the plugin to grant access to
deleteGroupNotices()
Deletes the staff group notices
private
deleteGroupNotices(int $staff_group_id[, string $action = null ]) : mixed
Parameters
- $staff_group_id : int
-
The ID of the staff group
- $action : string = null
-
The email group action (optional)
getGroups()
Partially constructs the query required by StaffGroups::getList(), StaffGroups::getListCount(), and StaffGroups::getAll()
private
getGroups([int $company_id = null ]) : Record
Parameters
- $company_id : int = null
-
The company ID (optional, default null)
Return values
Record —The partially constructed query Record object
getNoticeRules()
Fetches the rules for adding/editing a staff group notice
private
getNoticeRules(array<string|int, mixed> $vars) : array<string|int, mixed>
Parameters
- $vars : array<string|int, mixed>
-
A list of input vars
Return values
array<string|int, mixed> —The staff group notice rules
getRules()
Fetches the rules for adding/editing a staff group
private
getRules() : array<string|int, mixed>
Return values
array<string|int, mixed> —The staff group rules
setPermissions()
Removes any existing entries in the ACL for this ACO and adds "allow" entires for all of the given permission groups and permission fields.
private
setPermissions(string $aro, array<string|int, mixed> $vars, int $company_id) : mixed
Parameters
- $aro : string
-
The ARO to set "allow" access permissions in the ACL
- $vars : array<string|int, mixed>
-
An array containing the following:
- permission_group A numerically indexed array of permission group IDs to allow access to
- permission A numerically indexed array of permission field IDs to allow access to
- $company_id : int
-
The ID of the company to set permissions under