public
|
#
__construct( )
Initialize Emails
Overrides
|
public
mixed
|
#
get( integer $id )
Retrieves a single email template by ID, including email group tags
Retrieves a single email template by ID, including email group tags
Parameters
- $id
integer $id The ID of the email template to fetch
Returns
mixed A stdClass object representing the email template, false if no such template
exists
|
public
mixed
|
#
getByGroupId( integer $group_id )
Retrieves a signle email template by Group ID for the current company
Retrieves a signle email template by Group ID for the current company
Parameters
- $group_id
integer $group_id The email group ID to use to fetch the email tempalte for the current
company
Returns
mixed A stdClass object representing the email template, false if no such template
exists
|
private
Record
|
#
getEmails( )
Constructs a partial Record query used to fetch emails
Constructs a partial Record query used to fetch emails
Returns
Record
A partial Record query object used to fetch emails
|
public
mixed
|
#
getByType( integer $company_id, string $action, string $lang = null )
Fetches a single email template by company ID, type, and (optionally)
language
Fetches a single email template by company ID, type, and (optionally)
language
Parameters
- $company_id
integer $company_id The ID of the company to fetch the email for
- $action
string $action The email group action to fetch
- $lang
string $lang The language of template to fetch, defaults to default language
Returns
mixed A stdClass object representing the email template, false if no such template
exists
|
public
mixed
|
#
getList( integer $company_id, string $email_group_id )
Fetches a list of all email templates under a company for the given email
group in every available language
Fetches a list of all email templates under a company for the given email
group in every available language
Parameters
- $company_id
integer $company_id The company ID to fetch email templates for
- $email_group_id
string $email_group_id The email group ID
Returns
mixed An array of objects or false if no results.
|
public
integer
|
#
add( array $vars )
Adds an email with the given data
Adds an email with the given data
Parameters
- $vars
array $vars An array of email info including: - email_group_id The ID of the group
this email belongs to - company_id The company ID this email belongs to - lang
The language in ISO 636-1 2-char + "_" + ISO 3166-1 2-char (e.g. en_us)
(optional, default en_us) - from The address the message will be sent from -
from_name The name belonging to the from address - subject The subject of the
message - text The plain-text body of the message (if empty will be created
based on the html content) (optional, default null) - html The html body of the
message (optional, default null) - email_signature_id The signature to append to
the email (optional, default null) - status The status of this email 'active',
'inactive' (optional, default active)
Returns
integer The ID of the email, void on error
|
public
|
#
edit( integer $id, array $vars )
Updates the email with the given data
Updates the email with the given data
Parameters
- $id
integer $id The ID of the email to update
- $vars
array $vars An array of email info including: - email_group_id The ID of the group
this email belongs to - company_id The company ID this email belongs to - lang
The language in ISO 636-1 2-char + "_" + ISO 3166-1 2-char (e.g. en_us)
(optional, default en_us) - from The address the message will be sent from -
from_name The name belonging to the from address - subject The subject of the
message - text The plain-text body of the message (if empty will be created
based on the html content) (optional, default null) - html The html body of the
message (optional, default null) - email_signature_id The signature to append to
the email (optional, default null) - status The status of this email 'active',
'inactive' (optional, default active)
|
public
|
#
delete( integer $id )
Permanently removes the email from the system.
Permanently removes the email from the system.
Parameters
- $id
integer $id The ID of the email to delete
|
public
|
#
deleteAll( integer $email_group_id, integer $company_id )
Permanently removes all email templates of the given group from the
system.
Permanently removes all email templates of the given group from the
system.
Parameters
- $email_group_id
integer $email_group_id The ID of the email group to remove all email template from
- $company_id
integer $company_id The ID of the company to remove all email templates in this group
|
public
|
#
updateFromDomain( string $domain, integer $company_id )
Updates the domani portion of the from name for every email in the given
company.
Updates the domani portion of the from name for every email in the given
company.
Parameters
- $domain
string $domain The new domain to use
- $company_id
integer $company_id The ID of the company to update
|
public
array
|
#
getStatusTypes( )
Retrieves a list of email status types
Retrieves a list of email status types
Returns
array Key=>value pairs of email status types
|
public
|
#
addSignature( array $vars )
Adds the given signature to the system
Adds the given signature to the system
Parameters
- $vars
array $vars An array of signature info including: - company_id The company ID to
create the signature under - name The name of the signature - text The plaintext
signature - html The HTML signature
|
public
|
#
editSignature( mixed $email_signature_id, array $vars )
Updates an existing signature in the system
Updates an existing signature in the system
Parameters
- $email_signature_id
mixed $email_signature_id The ID of the signature in the system to update
- $vars
array $vars An array of signature info including: - name The name of the signature -
text The plaintext signature - html The HTML signature
|
public
|
#
deleteSignature( integer $email_signature_id )
Permanently removes an email signature from the system
Permanently removes an email signature from the system
Parameters
- $email_signature_id
integer $email_signature_id The ID of the email signature to delete
|
public
mixed
|
#
getSignature( integer $email_signature_id )
Fetches an email signature
Fetches an email signature
Parameters
- $email_signature_id
integer $email_signature_id The email signature ID
Returns
mixed An array of objects or false if no results.
|
public
mixed
|
#
getSignatureList( integer $company_id, integer $page = 1, string $order_by = array('name'=>"ASC") )
Fetches a list of all email signatures for a given company
Fetches a list of all email signatures for a given company
Parameters
- $company_id
integer $company_id The company ID
- $page
integer $page The page to return results for (optional, default 1)
- $order_by
string $order_by The sort and order conditions (e.g. array('sort_field'=>"ASC"),
optional)
Returns
mixed An array of objects or false if no results.
|
public
integer
|
#
getSignatureListCount( integer $company_id )
Fetches the total number of signatures returned from
Emails::getSignatureList(), useful in constructing pagination for the
getSignatureList() method.
Fetches the total number of signatures returned from
Emails::getSignatureList(), useful in constructing pagination for the
getSignatureList() method.
Parameters
- $company_id
integer $company_id The company ID to fetch email for
Returns
integer The total number of signatures
See
|
private
Record
|
#
getSignatures( integer $company_id )
Partially constructs the query required by both Emails::getSignatureList()
and Emails::getSignatureListCount()
Partially constructs the query required by both Emails::getSignatureList()
and Emails::getSignatureListCount()
Parameters
- $company_id
integer $company_id The company ID to fetch email for
Returns
Record
The partially constructed query Record object
|
public
mixed
|
#
getGroup( integer $email_group_id )
Fetches an email group
Parameters
- $email_group_id
integer $email_group_id The email group ID
Returns
mixed An array of objects or false if no results.
|
public
|
#
getGroupList( string $sortby = "action", string $order = "asc" )
Fetches all email groups
Parameters
- $sortby
string $sort_by The field to sort by
- $order
string $order The direction to order (asc, desc)
|
public
boolean
|
#
send( string $action, integer $company_id, string $lang, mixed $to, array $tags = null, mixed $cc = null, mixed $bcc = null, array $attachments = null, array $options = null )
Sends the given email using the criteria specified
Sends the given email using the criteria specified
Parameters
- $action
string $action The action that specifies the email group to use
- $company_id
integer $company_id The company ID to send this email under
- $lang
string $lang The language in ISO 636-1 2-char + "_" + ISO 3166-1 2-char (e.g. en_us) to
send, if no message found for this language will attempt to send using company's
default language
- $to
mixed $to The To address(es) to send to. A string, or an array of email addresses
- $tags
array $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
- $cc
mixed $cc The CC address(es) to send to. A string, or an array of email addresses
- $bcc
mixed $bcc The BCC address(es) to send to. A string, or an array of email addresses
- $attachments
array $attachments A multi-dimensional array of attachments containing: - path The
path to the attachment on the file system - name The name of the attachment
(optional, default '') - encoding The file encoding (optional, default 'base64')
- type The type of attachment (optional, default 'application/octet-stream')
- $options
array $options An array of options including: - to_client_id The ID of the client the
message was sent to - from_staff_id The ID of the staff member the message was
sent from
Returns
boolean Returns true if the message was successfully sent, false otherwise
|
public
boolean
|
#
sendCustom( string $from, string $from_name, mixed $to, string $subject, array $body, array $tags = null, mixed $cc = null, mixed $bcc = null, array $attachments = null, array $options = null )
Sends a custom email using the criteria specified
Sends a custom email using the criteria specified
Parameters
- $from
string $from The email address to send from.
- $from_name
string $from_name The name to send from.
- $to
mixed $to The To address(es) to send to. A string, or an array of email addresses
- $subject
string $subject The subject of the message. Tags provided in the subject will be
evaluated by the template parser
- $body
array $body An array containing the body in HTML and text of the email. Tags provided
in the body will be evaluated by the template parser: - html The HTML version of
the email (optional) - text The text version of the email (optional)
- $tags
array $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
- $cc
mixed $cc The CC address(es) to send to. A string, or an array of email addresses
- $bcc
mixed $bcc The BCC address(es) to send to. A string, or an array of email addresses
- $attachments
array $attachments A multi-dimensional array of attachments containing: - path The
path to the attachment on the file system - name The name of the attachment
(optional, default '') - encoding The file encoding (optional, default 'base64')
- type The type of attachment (optional, default 'application/octet-stream')
- $options
array $options An array of options including: - to_client_id The ID of the client the
message was sent to - from_staff_id The ID of the staff member the message was
sent from
Returns
boolean Returns true if the message was successfully sent, false otherwise
|
private
|
#
sendEmail( stdClass $email )
Performs the heavy lifting to send the given email and log it.
Performs the heavy lifting to send the given email and log it.
Parameters
- $email
stdClass
A stdClass object representing an email to send, containing all of the pertinent
information including: - to - cc - bcc - subject - text - html - tags - from -
from_name - attachments A numerically indexed array containing: - path The full
path to the file - name The name of the file - encoding (optional, defaults to
base64) - type (optional, defaults to application/octet-stream) - options An
array of options including: - to_client_id The ID of the client the message was
sent to - from_staff_id The ID of the staff member the message was sent from
|
public
mixed
|
#
buildEmail( string $action, integer $company_id, string $lang, array $tags = null )
Parses an Email stdClass object using the given data ($tags)
Parses an Email stdClass object using the given data ($tags)
Parameters
- $action
string $action The action that specifies the email group to use
- $company_id
integer $company_id The company ID to send this email under
- $lang
string $lang The language in ISO 636-1 2-char + "_" + ISO 3166-1 2-char (e.g. en_us) to
send, if no message found for this language will attempt to send using company's
default language
- $tags
array $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
mixed A stdClass object representing the parsed email template, false if no such
template exists
|
private
array
|
#
getSignatureRules( )
Returns the rule set for adding/editing signatures
Returns the rule set for adding/editing signatures
Returns
array Signature rules
|
private
array
|
#
getEmailRules( array $vars, boolean $edit = false )
Returns the rule set for adding/editing emails
Returns the rule set for adding/editing emails
Parameters
- $vars
array $vars The key/value pairs of vars
- $edit
boolean $edit True when editing an email, false otherwise
Returns
array Email rules
|
private
array
|
#
getSendEmailRules( array $vars, boolean $custom = false )
Returns the rule set for adding/editing emails
Returns the rule set for adding/editing emails
Parameters
- $vars
array $vars The key/value pairs of vars
- $custom
boolean $custom True to get the send custom email rules, false to get the default send
email rules (optional, default false)
Returns
array The send email rules
|
public
boolean
|
#
validateEmailGroupAction( string $action )
Validates that the given action is a valid email group action
Validates that the given action is a valid email group action
Parameters
- $action
string $action The email group action
Returns
boolean True if the action is valid, false otherwise
|
public
boolean
|
#
validateEmailAddresses( mixed $email_addresses )
Validates that each of the given email addresses provided are valid
Validates that each of the given email addresses provided are valid
Parameters
- $email_addresses
mixed A string representing a single email address, or an array of email addresses
Returns
boolean True if every email address is valid, false otherwise
|
public
|
#
validateAttachmentPaths( mixed $attachments )
Validates that the given attachments exist on the file system
Validates that the given attachments exist on the file system
|
public
boolean
|
#
validateStatus( string $status )
Validates the emails 'status' field
Validates the emails 'status' field
Parameters
- $status
string $status The status to check
Returns
boolean True if status validated, false otherwise
|
public
boolean
|
#
validateSignatureExists( integer $signature_id, integer $company_id = null )
Validates the email signature submitted exists and belongs to the company ID
given
Validates the email signature submitted exists and belongs to the company ID
given
Parameters
- $signature_id
integer $signature_id The email signature ID
- $company_id
integer $company_id The company ID (optional)
Returns
boolean True if the signature exists and belongs to the company ID given, false
otherwise
|
public
boolean
|
#
validateSignatureInUse( integer $signature_id )
Checks whether the email signature given is in use by any email
Checks whether the email signature given is in use by any email
Parameters
- $signature_id
integer $signature_id The email signature ID
Returns
boolean True if signature ID is in use, false otherwise
|
public
boolean
|
#
validateUnique( integer $company_id, integer $email_group_id, string $lang )
Validates the given company ID, email group ID, and language type are unique
for this email
Validates the given company ID, email group ID, and language type are unique
for this email
Parameters
- $company_id
integer $company_id The company ID
- $email_group_id
integer $email_group_id The email group ID
- $lang
string $lang The language in ISO 636-1 2-char + "_" + ISO 3166-1 2-char (e.g. en_us)
(optional, default en_us)
Returns
boolean True if the given info is unique, false otherwise
|