Blesta Source Documentation

Messages extends AppModel

Messages

Table of Contents

Methods

__construct() Initialize Messages
add() Adds a new message
delete() Deletes an existing message
edit() Edits an existing message
get() Fetches an existing message
getAll() Fetches a full list of all messages for a given company
getByGroup() Fetches a messages for a given message group and language
getMessageContent() Gets the content from an specific message
getMessageGroupEnabledTypes() Returns a list of all the types enabled for a message group
getStatusTypes() Retrieves a list of message status types
getTypes() Returns a list of the supported message types
setMessageContent() Sets the message content of an existing message
getRules() Rules to validate when adding or editing a message
Methods

__construct()

Initialize Messages

public __construct() : mixed

add()

Adds a new message

public add(array<string|int, mixed> $vars) : int
Parameters
$vars : array<string|int, mixed>

An array of message info including:

  • message_group_id The message group ID where the message belongs
  • company_id The company ID
  • type The message type (optional, "sms" by default)
  • status The message status (optional, "active" by default)
  • content A numerically indexed array each containing the message content for each language on the system
    • lang The language of the message content
    • content The message content
Return values
int —

The ID for this message, void on error

delete()

Deletes an existing message

public delete(int $message_id) : mixed
Parameters
$message_id : int

The message ID to delete

edit()

Edits an existing message

public edit(int $message_id, array<string|int, mixed> $vars) : int
Parameters
$message_id : int

The message ID to update

$vars : array<string|int, mixed>

An array of message info including:

  • message_group_id The message group ID where the message belongs
  • type The message type (optional, "sms" by default)
  • status The message status (optional, "active" by default)
  • content A numerically indexed array each containing the message content for each language on the system
    • lang The language of the message content
    • content The message content
Return values
int —

The ID for this message, void on error

get()

Fetches an existing message

public get(int $message_id) : mixed
Parameters
$message_id : int

The ID of the message to fetch

Return values
mixed —

A stdClass object representing the message if it exists, false otherwise

getAll()

Fetches a full list of all messages for a given company

public getAll([int $company_id = null ][, array<string|int, mixed> $filters = [] ]) : mixed
Parameters
$company_id : int = null

The ID of the company to fetch messages for

$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
mixed —

An array of stdClass objects representing all messages, or false if no messages found

getByGroup()

Fetches a messages for a given message group and language

public getByGroup(string $message_group_id[, string $lang = null ][, int $company_id = null ]) : stdClass
Parameters
$message_group_id : string

The ID of the message group

$lang : string = null

The language in ISO 636-1 2-char + "_"

  • ISO 3166-1 2-char (e.g. en_us) (optional)
$company_id : int = null

The ID of the company to fetch messages for (optional)

Return values
stdClass —

An stdClass object representing the message group with their messages, or false if no messages found

getMessageContent()

Gets the content from an specific message

public getMessageContent(int $message_id[, string $lang = null ]) : array<string|int, mixed>
Parameters
$message_id : int

The message ID to fetch the message content

$lang : string = null

The language in ISO 636-1 2-char + "_"

  • ISO 3166-1 2-char (e.g. en_us) (optional)
Return values
array<string|int, mixed> —

An array of stdClass objects, containing each the message content

getMessageGroupEnabledTypes()

Returns a list of all the types enabled for a message group

public getMessageGroupEnabledTypes(string $message_group_id) : array<string|int, mixed>
Parameters
$message_group_id : string

The ID of the message group

Return values
array<string|int, mixed> —

A list containing the enabled types for the given message

getStatusTypes()

Retrieves a list of message status types

public getStatusTypes() : array<string|int, mixed>
Return values
array<string|int, mixed> —

Key=>value pairs of email status types

getTypes()

Returns a list of the supported message types

public getTypes() : array<string|int, mixed>
Return values
array<string|int, mixed> —

A list of the supported message types

setMessageContent()

Sets the message content of an existing message

public setMessageContent(int $message_id, array<string|int, mixed> $vars) : mixed
Parameters
$message_id : int

The message ID where the message content belongs

$vars : array<string|int, mixed>

A numerically indexed array each containing the message content for each language on the system

  • lang The language of the message content
  • content The message content

getRules()

Rules to validate when adding or editing a message

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

Tags
subpackage

app.models

copyright

Copyright (c) 2020, Phillips Data, Inc.

license

http://www.blesta.com/license/ The Blesta License Agreement

link

Blesta


        
On this page

Search results