Methods summary
public
|
#
__construct( )
Initialize MessengerManager
Initialize MessengerManager
Overrides
|
public
mixed
|
#
get( integer $messenger_id )
Fetches a single installed messenger including meta data
Fetches a single installed messenger including meta data
Parameters
- $messenger_id
- The ID of the messenger to fetch
Returns
mixed A stdClass object representing the installed messenger, false if no such messenger exists
|
public
array
|
#
getByDir( string $dir, integer $company_id = null )
Fetches a messenger for a given company, or all messengers installed in the system for the given messenger dir
Fetches a messenger for a given company, or all messengers installed in the system for the given messenger dir
Parameters
- $dir
- The dir name (in file_case)
- $company_id
- The ID of the company to fetch messengers for (optional, default null for all)
Returns
array An array of stdClass objects, each representing an installed messenger record
|
public
array
|
#
getAll( integer $company_id, string $sort_by = 'name', string $order = 'asc' )
Lists all installed messengers
Lists all installed messengers
Parameters
- $company_id
- The company ID
- $sort_by
- The field to sort by
- $order
- The direction to order results
Returns
array An array of stdClass objects representing installed messengers
|
public
stdClass
|
#
getMeta( integer $messenger_id, string $key = null )
Retrieves a list of messenger meta data for a given messenger ID
Retrieves a list of messenger meta data for a given messenger ID
Parameters
- $messenger_id
- The messenger ID
- $key
- The messenger meta key representing a specific meta value (optional)
Returns
stdClass An object representing all messenger meta info
|
public
boolean
|
#
isInstalled( string $dir, string $company_id = null )
Checks whether the given messenger is installed for the specified company
Checks whether the given messenger is installed for the specified company
Parameters
- $dir
- The messenger directory name (in file_case)
- $company_id
The ID of the company to fetch for (null
checks if the messenger is installed across any company)
Returns
boolean True if the messenger is installed, false otherwise
|
public
|
#
upgrade( integer $messenger_id )
Runs the messenger's upgrade method to upgrade the messenger to match that of the messenger's file version.
Sets errors in MessengerManager::errors() if any errors are set by the messenger's upgrade method.
Runs the messenger's upgrade method to upgrade the messenger to match that of the messenger's file version.
Sets errors in MessengerManager::errors() if any errors are set by the messenger's upgrade method.
Parameters
- $messenger_id
- The ID of the messenger to upgrade
See
|
public
integer
|
#
add( array $vars )
Adds the messenger to the system, executing the Messenger::install() method
Adds the messenger to the system, executing the Messenger::install() method
Parameters
- $vars
An array of messenger data including:
- company_id The company ID
- dir The messenger directory name
Returns
integer The ID of the messenger installed, void on error
|
public
|
#
delete( integer $messenger_id )
Permanently and completely removes the messenger from the database,
along with all messenger records. Executes the Messenger::uninstall() method
Permanently and completely removes the messenger from the database,
along with all messenger records. Executes the Messenger::uninstall() method
Parameters
- $messenger_id
- The ID of the messenger to permanently and completely remove
|
public
array
|
#
getAvailable( integer $company_id = null )
Lists all available messengers (those that exist on the file system)
Lists all available messengers (those that exist on the file system)
Parameters
- $company_id
- The ID of the company to get available messengers for
Returns
array An array of stdClass objects representing available messengers
|
public
|
#
setMeta( integer $messenger_id, array $vars )
Updates the meta data for the given messenger, removing all existing data and replacing it with the given data
Updates the meta data for the given messenger, removing all existing data and replacing it with the given data
Parameters
- $messenger_id
- The ID of the messenger to update
- $vars
A numerically indexed array of meta data containing:
- key The key for this meta field
- value The value for this key
- encrypted Whether or not this field should be encrypted (default 0, not encrypted)
|
public
Messenger
|
#
initMessenger( integer $messenger_id, integer $company_id = null )
Initializes the messenger if it has been installed and returns its instance
Initializes the messenger if it has been installed and returns its instance
Parameters
- $messenger_id
- The ID of the messenger to initialize
- $company_id
- If set will check to ensure the messenger belongs to the given company_id
Returns
Messenger An object of type Messenger if the requested messenger has been installed and exists, false otherwise
|
public
|
#
send( string $action, array $tags, array $user_ids )
Send a message for the given action
Send a message for the given action
Parameters
- $action
- The action for which to send a message
- $tags
- A list of tags to include in the message
- $user_ids
- A list of IDs for the users that should receive this message
|
public
string
|
#
buildMessage( string $text, integer $company_id, array $tags = null )
Parses message text using the given data ($tags)
Parses message text using the given data ($tags)
Parameters
- $text
- The initial text for a message to be parsed
- $company_id
- The company ID to send this message under
- $tags
An array of replacement tags containing the key/value
pairs for the replacements where the key is the tag to replace and the
value is the value to replace it with
Returns
string The parsed message template
|