MessageGroups extends AppModel
Message Groups
Table of Contents
Methods
| __construct() | Initialize MessageGroups |
| add() | Adds a message group |
| delete() | Deletes an existing message group |
| edit() | Edits an existing message group |
| get() | Fetches an existing message |
| getAll() | Fetches a full list of all message groups |
| getAllMessages() | Fetches a list of all messages and message groups under a company for a specific type and language |
| getByAction() | Fetches a message group |
| getTypes() | Returns a list of the supported message group types |
| getRules() | Rules to validate when adding or editing a message group |
Methods
__construct()
Initialize MessageGroups
public
__construct() : mixed
add()
Adds a message group
public
add(array<string|int, mixed> $vars) : int
Parameters
- $vars : array<string|int, mixed>
-
An array of message info including:
- action The message group action
- type The message group type
- plugin_dir The directory name of the plugin where the message group belongs (optional)
- tags Tags that apply to this group (optional, default null)
Return values
int —The ID for this message group
delete()
Deletes an existing message group
public
delete(int $message_group_id) : mixed
Parameters
- $message_group_id : int
-
The message group ID to delete
edit()
Edits an existing message group
public
edit(int $message_group_id, array<string|int, mixed> $vars) : mixed
Parameters
- $message_group_id : int
-
The ID of the message group to update
- $vars : array<string|int, mixed>
-
An array of message info including:
- action The message group action
- type The message group type
- plugin_dir The directory name of the plugin where the message group belongs (optional)
- tags Tags that apply to this group (optional, default null)
get()
Fetches an existing message
public
get(int $message_group_id) : mixed
Parameters
- $message_group_id : int
-
The ID of the message group to fetch
Return values
mixed —A stdClass object representing the message group if it exists, false otherwise
getAll()
Fetches a full list of all message groups
public
getAll([array<string|int, mixed> $filters = [] ]) : array<string|int, mixed>
Parameters
- $filters : array<string|int, mixed> = []
-
A list of parameters to filter by, including:
- plugin_dir The directory name of the plugin to fetch message groups for
Return values
array<string|int, mixed> —A list of stdClass objects representing all message groups
getAllMessages()
Fetches a list of all messages and message groups under a company for a specific type and language
public
getAllMessages(int $company_id[, string $type = 'client' ][, bool $core = true ][, string $lang = null ]) : array<string|int, mixed>
Parameters
- $company_id : int
-
The company ID to fetch message groups for
- $type : string = 'client'
-
The type of message group to get, "client", "staff", "shared" or null to fetch all types (optional, default "client")
- $core : bool = true
-
True to fetch all core message groups, or false to fetch all plugin-related message groups (optional, default true)
- $lang : string = null
-
The language in ISO 636-1 2-char + "_"
- ISO 3166-1 2-char (e.g. en_us) (optional, defaults to default language)
Return values
array<string|int, mixed> —A list of stdClass objects representing the messages
getByAction()
Fetches a message group
public
getByAction(string $action) : mixed
Parameters
- $action : string
-
The action of message group to fetch
Return values
mixed —An stdClass object representing the message group, or false if one does not exist
getTypes()
Returns a list of the supported message group types
public
getTypes() : array<string|int, mixed>
Return values
array<string|int, mixed> —A list of the supported message group types
getRules()
Rules to validate when adding or editing a message group
private
getRules([array<string|int, mixed> $vars = [] ][, bool $edit = false ]) : array<string|int, mixed>
Parameters
- $vars : array<string|int, mixed> = []
-
An array of input fields to validate against
- $edit : bool = false
-
Whether or not it's an edit (optional)
Return values
array<string|int, mixed> —Rules to validate