Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • None
  • system
    • base
    • caching
    • console
    • db
      • ar
      • schema
    • validators
    • web
      • actions
      • auth
      • helpers
      • widgets
        • captcha
        • pagers
  • zii
    • widgets
      • grid

Classes

  • ActionMetaData
  • ActionText
  • Admin
  • AmorphousModel
  • ApiHook
  • APIModel
  • ChartSetting
  • ContactForm
  • ContactList
  • Credentials
  • Criteria
  • Dropdowns
  • Events
  • EventsData
  • Fields
  • FormLayout
  • Imports
  • InlineEmail
  • LeadRouting
  • Locations
  • LoginForm
  • Maps
  • Modules
  • Notes
  • Notification
  • PhoneNumber
  • Profile
  • Record
  • Relationships
  • Roles
  • RoleToPermission
  • RoleToUser
  • RoleToWorkflow
  • Rules
  • Session
  • SessionLog
  • Social
  • Tags
  • TempFile
  • Tips
  • Tours
  • TrackEmail
  • TriggerLog
  • URL
  • ViewLog
  • Widgets
  • X2List
  • X2ListCriterion
  • X2ListItem
  • X2Model
  • Overview
  • Package
  • Class
  • Tree

Class InlineEmail

InlineEmail class. InlineEmail is the data structure for taking in and processing data for outbound email, specifically from the inline email widget.

It is used by the InlineEmailForm widget and site/inlineEmail, and is designed around this principle: that the email is being sent in some context that is dictated by a "target model". Special cases for behavior of the class have been built this way, i.e. when the target model is a Quote, the insertable attributes should include those of both associated contact and account as well as the quote, and when the email is sent, the action history record that gets created should appropriately describe the event happened, i.e. by saying that "Quote #X was issued by email" rather than merely "user X has sent contact Y an email."

The following describes the scenarios of this model:

  • "custom" is used when a modified email has been submitted for processing or sending
  • "template" is used when the form has been submitted to re-create the email based on a template.
  • Blank/empty string is for when there's a new and blank email (i.e. initial rendering of the inline email widget InlineEmailForm)
CComponent
Extended by CModel implements IteratorAggregate, ArrayAccess
Extended by CFormModel
Extended by InlineEmail

Direct known subclasses

TestEmailActionForm
Package: application\models
Located at x2engine/protected/models/InlineEmail.php
Methods summary
public array
# rules( )

Declares the validation rules. The rules state that username and password are required, and password needs to be authenticated.

Declares the validation rules. The rules state that username and password are required, and password needs to be authenticated.

Returns

array

Overrides

CModel::rules()
public
# relations( )
public array
# attributeLabels( )

Declares attribute labels.

Declares attribute labels.

Returns

array

Overrides

CModel::attributeLabels()
public array
# behaviors( )

Returns a list of behaviors that this model should behave as. The return value should be an array of behavior configurations indexed by behavior names. Each behavior configuration can be either a string specifying the behavior class or an array of the following structure:

'behaviorName'=>array(
    'class'=>'path.to.BehaviorClass',
    'property1'=>'value1',
    'property2'=>'value2',
)

Returns a list of behaviors that this model should behave as. The return value should be an array of behavior configurations indexed by behavior names. Each behavior configuration can be either a string specifying the behavior class or an array of the following structure:

'behaviorName'=>array(
    'class'=>'path.to.BehaviorClass',
    'property1'=>'value1',
    'property2'=>'value2',
)

Note, the behavior classes must implement IBehavior or extend from CBehavior. Behaviors declared in this method will be attached to the model when it is instantiated.

For more details about behaviors, see CComponent.

Returns

array
the behavior configurations (behavior name=>behavior configuration)

Overrides

CModel::behaviors()
public static
# insertedPattern( string $name, string $inside, boolean $re = 0, string $reFlags = '' )

Creates a pattern for finding or inserting content into the email body.

Creates a pattern for finding or inserting content into the email body.

Parameters

$name
string
$name The name of the pattern to use. There should be a constant defined that is the name in upper case followed by "TAG" that specifies the name to use in comments that demarcate the inserted content.
$inside
string
$inside The content to be inserted between comments.
$re
boolean
$re Whether to return the pattern as a regular expression
$reFlags
string
$reFlags PCRE flags to use in the expression, if $re is enabled.
public type
# getActionHeader( )

Magic getter for actionHeader

Magic getter for actionHeader

Composes an informative header for the action record.

Returns

type
public array
# getInsertableAttributes( )

Magic getter for insertableAttributes.

Magic getter for insertableAttributes.

Herein is defined how the insertable attributes are put together for each different model class.

Returns

array
public
# getRecipientContacts( )

Magic getter for recipientContacts

Magic getter for recipientContacts

public array
# getRecipients( )

Magic getter for recipients

Magic getter for recipients

Returns

array
public boolean
# checkDoNotEmailFields( )

Returns

boolean
false if any one of the recipient contacts has their doNotEmail field set to true, true otherwise
public string
# getSignature( )

Magic getter for signature

Magic getter for signature

Retrieves the email signature from the preexisting body, or from the user's profile if none can be found.

Returns

string
public
# getTargetModel( )

Magic getter for targetModel

Magic getter for targetModel

public
# setTargetModel( X2Model $model )
public type
# getTemplateModel( mixed $id = null )

Magic getter for templateModel

Magic getter for templateModel

Returns

type
public type
# getTrackingImage( )

Magic getter for trackingImage

Magic getter for trackingImage

Returns

type
public
# getUniqueId( )

Magic setter for uniqueId

Magic setter for uniqueId

public
# setUniqueId( string $value )

Magic setter for uniqueId

Magic setter for uniqueId

Parameters

$value
string
$value
public
# parseMailingList( string $attribute, array $params = array() )

Validation function for lists of email addresses.

Validation function for lists of email addresses.

Parameters

$attribute
string
$attribute
$params
array
$params
public
# insertSignature( array $wrap = array('<br /><br />', '') )

Inserts a signature into the body, if none can be found.

Inserts a signature into the body, if none can be found.

Parameters

$wrap
array
$wrap Wrap the signature in tags (index 0 opens, index 1 closes)
public
# insertTrackingImage( boolean $replace = false )

Search for an existing tracking image and insert a new one if none are present.

Search for an existing tracking image and insert a new one if none are present.

Parses the tracking image and unique ID out of the body if there are any.

The email will be tracked, but only if one and only one of the recipients corresponds to a contact in X2Engine (remember, the user can switch the recipient list at the last minute by modifying the "To:" field).

Otherwise, there's absolutely no way of telling with any certainty who exactly opened the email (all recipients will be sent the same email, so any one of them could be the one who opens the email and accesses the email tracking image). Thus, in such cases, it is pointless to create an event/action that says "so-and so has opened an email" because who opened the email is ambiguous and practically unknowable, and thus impractical to create an email tracking record.

Parameters

$replace
boolean
$replace reset the image markup and unique ID, and replace the existing tracking image.
public static
# extractTrackingUid( mixed $body )
public
# insertInBody( string $content, boolean $beginning = 0, boolean $return = 0 )

Inserts something near the end of the body in the HTML email.

Inserts something near the end of the body in the HTML email.

Parameters

$content
string
$content The markup/text to be inserted.
$beginning
boolean
$beginning True to insert at the beginning, false to insert at the end.
$return
boolean
$return True to modify InlineEmail::$message; false to return the modified body instead.
public static
# emptyBody( string $content = null )

Generate a blank HTML document.

Generate a blank HTML document.

Parameters

$content
string
$content Optional content to start with.
public
# prepareBody( mixed $postReplace = 0 )

Prepare the email body for sending or customization by the user.

Prepare the email body for sending or customization by the user.

public array
# send( mixed $createEvent = true )

Performs a send (or stage, or some other action).

Performs a send (or stage, or some other action).

The tracking image is inserted at the very last moment before sending, so that there is no chance of the user altering the body and deleting it accidentally.

Returns

array
public
# trackEmail( integer $actionId )

Save the tracking record for this email, but only if an image was inserted.

Save the tracking record for this email, but only if an image was inserted.

Parameters

$actionId
integer
$actionId ID of the email-type action corresponding to the record.
public
# recordEmailSent( mixed $makeEvent = true )

Make records of the email in every shape and form.

Make records of the email in every shape and form.

This method is to be called only once the email has been sent.

The basic principle behind what all is happening here: emails are getting sent to people. Since the "To:" field in the inline email form is not read-only, the emails could be sent to completely different people. Thus, creating action and event records must be based exclusively on who the email is addressed to and not the model from whose view the inline email form (if that's how this model is being used) is submitted.

public
# deliver( )
public
# appendDoNotEmailLink( Contacts $contact )

Insert a "Do Not Email" link into the body of the email message. The link contains the contact's trackingKey in it's get parameters. When clicked, the contact's doNotEmail field will be set to 1.

Insert a "Do Not Email" link into the body of the email message. The link contains the contact's trackingKey in it's get parameters. When clicked, the contact's doNotEmail field will be set to 1.

Parameters

$contact
Contacts
$contact
Methods inherited from CFormModel
__construct(), attributeNames(), init()
Methods inherited from CModel
addError(), addErrors(), afterConstruct(), afterValidate(), beforeValidate(), clearErrors(), createValidators(), generateAttributeLabel(), getAttributeLabel(), getAttributes(), getError(), getErrors(), getIterator(), getSafeAttributeNames(), getScenario(), getValidatorList(), getValidators(), hasErrors(), isAttributeRequired(), isAttributeSafe(), offsetExists(), offsetGet(), offsetSet(), offsetUnset(), onAfterConstruct(), onAfterValidate(), onBeforeValidate(), onUnsafeAttribute(), setAttributes(), setScenario(), unsetAttributes(), validate()
Methods inherited from CComponent
__call(), __get(), __isset(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Constants summary
string SIGNATURETAG 'Signature'
#
string TRACKTAG 'OpenedEmail'
#
string AHTAG 'ActionHeader'
#
string UIDREGEX '/uid.([0-9a-f]{32})/'
#
Properties summary
public string $to
#

Email address of the addressees

Email address of the addressees

public string $cc
#

CC email address(es), if applicable

CC email address(es), if applicable

public string $bcc
#

BCC email address(es), if applicable

BCC email address(es), if applicable

public string $subject
#

Email subject

Email subject

public string $message
#

Email body/content

Email body/content

public strng $emailSendTime ''
#

Email Send Time

Email Send Time

public integer $emailSendTimeParsed 0
#

Email Send Time in unix timestamp format

Email Send Time in unix timestamp format

public integer $template 0
#

Template ID

Template ID

public string $modelName
#

Stores the name of the model associated with the email i.e. Contacts or Quote.

Stores the name of the model associated with the email i.e. Contacts or Quote.

public integer $modelId
#
public boolean $contactFlag true
#

Asssociate emails with the linked Contact (true) or the record itself (false)

Asssociate emails with the linked Contact (true) or the record itself (false)

public array $mailingList array()
#
public array $attachments array()
#
public string $emailBody ''
#
public boolean $preview false
#
public boolean $stageEmail false
#
public boolean $requireSubjectOnCustom true
#

$requireSubjectOnCustom Allows subject requirement to be bypassed. TODO: remove this once scenario code is refactored

$requireSubjectOnCustom Allows subject requirement to be bypassed. TODO: remove this once scenario code is refactored

Magic properties summary
public string $actionHeader
#

(read-only) A mock-up of the email's header fields to be inserted into the email actions' bodies, for display purposes.

(read-only) A mock-up of the email's header fields to be inserted into the email actions' bodies, for display purposes.

public array $insertableAttributes
#

(read-only) Attributes for the inline email editor that can be inserted into the message.

(read-only) Attributes for the inline email editor that can be inserted into the message.

public array $recipientContacts
#

(read-only) an array of contact records identified by recipient email address.

(read-only) an array of contact records identified by recipient email address.

public array $recipients
#

(read-only) an array of all recipients of the email.

(read-only) an array of all recipients of the email.

public string $signature
#

Signature of the user sending the email, if any

Signature of the user sending the email, if any

public X2Model $targetModel
#

The model associated with this email, i.e. Contacts or Quote

The model associated with this email, i.e. Contacts or Quote

public Docs $templateModel
#

(read-only) template, if any, to use.

(read-only) template, if any, to use.

public string $trackingImage
#

(read-only) Markup for the tracking image to be placed in the email

(read-only) Markup for the tracking image to be placed in the email

public string $uniqueId
#

A unique ID used for the tracking record and tracking image URL

A unique ID used for the tracking record and tracking image URL

Magic properties inherited from CModel
$attributes, $errors, $iterator, $safeAttributeNames, $scenario, $validatorList, $validators
X2CRM Documentation API documentation generated by ApiGen 2.8.0