Blesta
  • Package
  • Class
  • Tree
  • Deprecated

Packages

  • blesta
    • app
      • controllers
      • models
    • components
      • areyouahuman
      • auth
        • motp
        • oath
      • delivery
        • interfax
        • postal
          • methods
      • download
      • email
      • events
        • default
      • exchange
        • rates
          • google
            • finance
          • yahoo
            • finance
      • gateway
        • payments
      • gateways
      • invoice
        • delivery
        • templates
          • quickbooks
            • invoice
      • json
      • modules
      • net
        • amazon
          • s3
        • http
        • net
          • geo
            • ip
      • plugins
      • recaptcha
      • reports
        • aging
          • invoices
        • custom
          • report
        • invoice
          • creation
        • tax
          • liability
        • transactions
          • applied
          • received
      • security
      • session
        • cart
      • settingscollection
      • upgrades
        • tasks
      • upload
      • vcard
    • helpers
      • currency
        • format
      • data
        • structure
          • array
          • string
      • text
        • parser
      • widget
        • client
  • minPHP
    • components
      • input
      • record
    • helpers
      • color
      • data
        • structure
      • date
      • form
      • html
      • javascript
      • xml
    • lib
  • None
  • PHP

Classes

  • Accounts
  • ApiKeys
  • CalendarEvents
  • ClientGroups
  • Clients
  • Companies
  • Contacts
  • Countries
  • Coupons
  • CronTasks
  • Currencies
  • EmailGroups
  • Emails
  • Encryption
  • GatewayManager
  • Invoices
  • InvoiceTemplateManager
  • Languages
  • Logs
  • Marketplace
  • ModuleClientMeta
  • ModuleManager
  • Navigation
  • PackageGroups
  • PackageOptionGroups
  • PackageOptions
  • Packages
  • Payments
  • Permissions
  • PluginManager
  • Pricings
  • ReportManager
  • ServiceChanges
  • Services
  • Settings
  • Staff
  • StaffGroups
  • States
  • Taxes
  • Themes
  • Transactions
  • Users

Class Emails

Email management

Model
Extended by AppModel
Extended by Emails
Package: blesta\app\models
Copyright: Copyright (c) 2010, Phillips Data, Inc.
License: The Blesta License Agreement
Link: Blesta
Located at app/models/emails.php

Methods summary

public
# __construct( )

Initialize Emails

Initialize Emails

Overrides

AppModel::__construct
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, string $lang = null )

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
$lang
string
$lang The language in ISO 636-1 2-char + "_" + ISO 3166-1 2-char (e.g. en_us) (optional, defaults to default language)

Returns

mixed
A stdClass object representing the email template, false if no such template exists
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) - include_attachments 1 to include attachments when the email is sent, 0 to not send attachments with the email (optional, default 1) - 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) - include_attachments 1 to include attachments when the email is sent, 0 to not send attachments with the email (optional) - 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 array
# 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 whose signatures to fetch
$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

array
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 whose signatures to fetch

Returns

integer
The total number of signatures

See

Emails::getList()
public array
# getAllSignatures( integer $company_id )

Retrieves a list of all signatures for this company

Retrieves a list of all signatures for this company

Parameters

$company_id
integer
$company_id The company ID whose signatures to fetch

Returns

array
An array of stdClass objects each representing a signature
public mixed
# getGroup( integer $email_group_id )

Fetches an email group

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

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 - from The from address - from_name The from name - reply_to The reply to address

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 - reply_to The reply to address

Returns

boolean
Returns true if the message was successfully sent, false otherwise
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
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
public
# validateParse( string $str )

Validate that the given string parses template parsing

Validate that the given string parses template parsing

Parameters

$str
string
$str The string to test

Methods inherited from AppModel

_(), boolToInt(), currencyToDecimal(), dateToUtc(), errors(), getPerPage(), ifSet(), loadCrypto(), setDefaultIfEmpty(), setPerPage(), setRulesIfSet(), strToBool(), systemDecrypt(), systemEncrypt(), systemHash(), truncateDecimal(), validateExists(), validateStateCountry()

Methods inherited from Model

affectedRows(), begin(), commit(), getConnection(), lastInsertId(), makeDSN(), prepare(), query(), rollBack(), setAttribute(), setFetchMode()

Magic methods summary

Properties summary

Properties inherited from AppModel

$replacement_keys

Blesta API documentation generated by ApiGen 2.8.0