EmailParser
extends TextParser
in package
Email parser class.
Tags
Table of Contents
- VARIABLE_REGEX = '/\\$\\((\\w+) : ([,"\\+\\#\\%\\.\\:\\;\\=\\-\\[\\]\\&\\w\\s\\|\\)\\(\\:]+)\\)\\$/u'
- Variable parser regex.
- $emailoptout : mixed
- $isHtml : bool
- Is the parsing text content html?
- $moduleName : string
- Module name.
- $record : int
- Record id.
- $recordModel : Vtiger_Record_Model
- Record model.
- $relatedRecordSeparator : string
- Separator to display data when there are several values.
- $sourceModules : array<string|int, mixed>
- List of source modules.
- $type : string|null
- Parser type.
- $useExtension : bool
- Use extended parsing.
- $variableDates : array<string|int, string>
- Default date list.
- $variableEntity : array<string|int, mixed>
- Variables for entity modules.
- $variableExamples : array<string|int, mixed>
- Examples of supported variables.
- $variableGeneral : array<string|int, mixed>
- Variables for entity modules.
- $baseFunctions : array<string|int, string>
- List of available functions.
- $content : string
- Content.
- $language : string
- Language content.
- $largeDataUiTypes : array<string|int, string>
- $params : array<string|int, mixed>
- Additional params.
- $permissions : bool
- $rawContent : string
- Rwa content.
- $recordVariable : array<string|int, mixed>
- Record variables.
- $relatedVariable : array<string|int, mixed>
- Related variables.
- $relatedVariableLevel : array<string|int, mixed>
- Next level related variables.
- $sourceRecordModel : Vtiger_Record_Model
- Source record model.
- $withoutTranslations : bool
- without translations.
- $permissionToSend : mixed
- date() : string
- Function parse date.
- getBaseListVariable() : array<string|int, mixed>
- Get base modules list.
- getContent() : array<string|int, mixed>|string
- Get content parsed for emails.
- getGeneralVariable() : array<string|int, mixed>
- Get general variables.
- getInstance() : self
- Get clean instanace.
- getInstanceById() : self
- Get instanace by record id.
- getInstanceByModel() : self
- Get instanace by record model.
- getInventoryTable() : string
- Parsing inventory table.
- getParam() : mixed
- Get additional params.
- getRecordVariable() : array<string|int, mixed>
- Get record variables.
- getRelatedLevelVariable() : array<string|int, mixed>
- Get related variables.
- getRelatedListVariable() : array<string|int, mixed>
- Get related modules list.
- getRelatedVariable() : array<string|int, mixed>
- Get related variables.
- getSourceVariable() : array<string|int, mixed>
- Get source variables.
- getUserVariables() : array<string|int, mixed>
- Gets user variables.
- isVaribleToParse() : int
- Function checks if its TextParser type.
- parse() : $this
- All text parse function.
- parseData() : string
- Text parse function.
- parseFieldParam() : array<string|int, mixed>
- Parse custom params.
- parseTranslations() : $this
- Text parse function.
- setContent() : $this
- Set content.
- setExtensionState() : $this
- Set the active state of extended parsing functionality.
- setGlobalPermissions() : $this
- Set permissions condition.
- setLanguage() : $this
- Set language.
- setParam() : $this
- Set param value.
- setParams() : $this
- Set additional params.
- setSourceRecord() : $this
- Set source record.
- setType() : $this
- Set parser type.
- withoutTranslations() : $this
- Set without translations.
- barcode() : string
- Get an instance of barcode text parser.
- custom() : string
- Parsing custom.
- employee() : mixed
- Parsing employee detail.
- general() : mixed
- Parsing general data.
- getBaseGeneralVariable() : array<string|int, mixed>
- Get general variables base function.
- getComments() : string
- Get last comments.
- getDisplayValueByField() : array<string|int, mixed>|bool|mixed|string
- Get record display value.
- getDisplayValueByType() : array<string|int, mixed>|mixed|string
- Get record display value by type.
- getModuleGeneralVariable() : array<string|int, mixed>
- Get general variables module function.
- inventory() : string
- Parsing inventory.
- organization() : string
- Parsing organization detail.
- params() : string
- Parsing params.
- parseParams() : array<string|int, mixed>
- Get inventory param.
- parseVariable() : string
- Parse variable.
- record() : string
- Parsing record data.
- recordsList() : string
- Parsing records list.
- relatedRecord() : mixed
- Parsing related record data.
- relatedRecordLevel() : mixed
- Parsing related record data.
- relatedRecordsList() : string
- Parsing related records list.
- relatedRecordsListPrinter() : string
- Printer related records list.
- sourceRecord() : mixed
- Parsing source record data.
- translate() : string
- Parsing translations.
- userVariable() : string
- Parsing user variable.
- useValue() : bool
- Check if this content can be used.
Constants
VARIABLE_REGEX
Variable parser regex.
public
string
VARIABLE_REGEX
= '/\\$\\((\\w+) : ([,"\\+\\#\\%\\.\\:\\;\\=\\-\\[\\]\\&\\w\\s\\|\\)\\(\\:]+)\\)\\$/u'
Properties
$emailoptout
public
mixed
$emailoptout
= true
$isHtml
Is the parsing text content html?
public
bool
$isHtml
= true
$moduleName
Module name.
public
string
$moduleName
$record
Record id.
public
int
$record
$recordModel
Record model.
public
Vtiger_Record_Model
$recordModel
$relatedRecordSeparator
Separator to display data when there are several values.
public
string
$relatedRecordSeparator
= ','
$sourceModules
List of source modules.
public
static array<string|int, mixed>
$sourceModules
= ['Campaigns' => ['Leads', 'Accounts', 'Contacts', 'Vendors', 'Partners', 'Competition']]
$type
Parser type.
public
string|null
$type
$useExtension
Use extended parsing.
public
bool
$useExtension
= false
$variableDates
Default date list.
public
static array<string|int, string>
$variableDates
= ['LBL_DATE_TODAY' => '$(date : now)$', 'LBL_DATE_TOMORROW' => '$(date : tomorrow)$', 'LBL_DATE_YESTERDAY' => '$(date : yesterday)$', 'LBL_DATE_FIRST_DAY_OF_THIS_WEEK' => '$(date : monday this week)$', 'LBL_DATE_MONDAY_NEXT_WEEK' => '$(date : monday next week)$', 'LBL_DATE_FIRST_DAY_OF_THIS_MONTH' => '$(date : first day of this month)$', 'LBL_DATE_LAST_DAY_OF_THIS_MONTH' => '$(date : last day of this month)$', 'LBL_DATE_FIRST_DAY_OF_NEXT_MONTH' => '$(date : first day of next month)$']
$variableEntity
Variables for entity modules.
public
static array<string|int, mixed>
$variableEntity
= ['CrmDetailViewURL' => 'LBL_CRM_DETAIL_VIEW_URL', 'PortalDetailViewURL' => 'LBL_PORTAL_DETAIL_VIEW_URL', 'RecordId' => 'LBL_RECORD_ID', 'RecordLabel' => 'LBL_RECORD_LABEL', 'ChangesListChanges' => 'LBL_LIST_OF_CHANGES_IN_RECORD', 'ChangesListValues' => 'LBL_LIST_OF_NEW_VALUES_IN_RECORD', 'Comments' => 'LBL_RECORD_COMMENT', 'SummaryFields' => 'LBL_SUMMARY_FIELDS']
$variableExamples
Examples of supported variables.
public
static array<string|int, mixed>
$variableExamples
= ['LBL_ORGANIZATION_NAME' => '$(organization : company_name)$', 'LBL_ORGANIZATION_LOGO' => '$(organization : logo)$', 'LBL_EMPLOYEE_NAME' => '$(employee : last_name)$', 'LBL_CRM_DETAIL_VIEW_URL' => '$(record : CrmDetailViewURL)$', 'LBL_PORTAL_DETAIL_VIEW_URL' => '$(record : PortalDetailViewURL)$', 'LBL_RECORD_ID' => '$(record : RecordId)$', 'LBL_RECORD_LABEL' => '$(record : RecordLabel)$', 'LBL_LIST_OF_CHANGES_IN_RECORD' => '$(record : ChangesListChanges)$', 'LBL_LIST_OF_NEW_VALUES_IN_RECORD' => '$(record : ChangesListValues)$', 'LBL_RECORD_COMMENT' => '$(record : Comments 5)$, $(record : Comments)$', 'LBL_RELATED_RECORD_LABEL' => '$(relatedRecord : parent_id|email1|Accounts)$, $(relatedRecord : parent_id|email1)$', 'LBL_RELATED_NEXT_LEVEL_RECORD_LABEL' => '$(relatedRecordLevel : projectid|Project|linktoaccountscontacts|email1|Accounts)$', 'LBL_OWNER_EMAIL' => '$(relatedRecord : assigned_user_id|email1|Users)$', 'LBL_SOURCE_RECORD_LABEL' => '$(sourceRecord : RecordLabel)$', 'LBL_CUSTOM_FUNCTION' => '$(custom : ContactsPortalPass)$', 'LBL_RELATED_RECORDS_LIST' => '$(relatedRecordsList : Contacts|firstname,lastname,email|[[["firstname","a","Tom"]]]||5)$', 'LBL_RECORDS_LIST' => '$(recordsList : Contacts|firstname,lastname,email|[[["firstname","a","Tom"]]]||5)$', 'LBL_INVENTORY_TABLE' => '$(inventory : type=table columns=seq,name,qty,unit,price,total,net href=no)$', 'LBL_DYNAMIC_INVENTORY_TABLE' => '$(custom : dynamicInventoryColumnsTable)$', 'LBL_BARCODE' => '$(barcode : type=EAN13 class=DNS1D , value=12345678)$']
$variableGeneral
Variables for entity modules.
public
static array<string|int, mixed>
$variableGeneral
= ['LBL_CURRENT_DATE' => '$(general : CurrentDate)$', 'LBL_CURRENT_TIME' => '$(general : CurrentTime)$', 'LBL_BASE_TIMEZONE' => '$(general : BaseTimeZone)$', 'LBL_USER_TIMEZONE' => '$(general : UserTimeZone)$', 'LBL_SITE_URL' => '$(general : SiteUrl)$', 'LBL_PORTAL_URL' => '$(general : PortalUrl)$', 'LBL_TRANSLATE' => '$(translate : Accounts|LBL_COPY_BILLING_ADDRESS)$, $(translate : LBL_SECONDS)$']
$baseFunctions
List of available functions.
protected
static array<string|int, string>
$baseFunctions
= ['general', 'translate', 'record', 'relatedRecord', 'relatedRecordLevel', 'sourceRecord', 'organization', 'employee', 'params', 'custom', 'relatedRecordsList', 'recordsList', 'date', 'inventory', 'userVariable', 'barcode']
$content
Content.
protected
string
$content
= ''
$language
Language content.
protected
string
$language
$largeDataUiTypes
protected
array<string|int, string>
$largeDataUiTypes
= ['multiImage', 'image']
Uitypes with large data
$params
Additional params.
protected
array<string|int, mixed>
$params
$permissions
protected
bool
$permissions
= true
Permissions condition
$rawContent
Rwa content.
protected
string
$rawContent
$recordVariable
Record variables.
protected
static array<string|int, mixed>
$recordVariable
= []
$relatedVariable
Related variables.
protected
static array<string|int, mixed>
$relatedVariable
= []
$relatedVariableLevel
Next level related variables.
protected
static array<string|int, mixed>
$relatedVariableLevel
= []
$sourceRecordModel
Source record model.
protected
Vtiger_Record_Model
$sourceRecordModel
$withoutTranslations
without translations.
protected
bool
$withoutTranslations
= false
$permissionToSend
private
static mixed
$permissionToSend
= ['Accounts' => 'emailoptout', 'Contacts' => 'emailoptout', 'Users' => 'emailoptout', 'Leads' => 'noapprovalemails']
Methods
date()
Function parse date.
public
date(string $param) : string
Parameters
- $param : string
Return values
string —getBaseListVariable()
Get base modules list.
public
getBaseListVariable() : array<string|int, mixed>
Return values
array<string|int, mixed> —getContent()
Get content parsed for emails.
public
getContent([bool $trim = false ]) : array<string|int, mixed>|string
Parameters
- $trim : bool = false
Return values
array<string|int, mixed>|string —getGeneralVariable()
Get general variables.
public
getGeneralVariable() : array<string|int, mixed>
Return values
array<string|int, mixed> —getInstance()
Get clean instanace.
public
static getInstance([string $moduleName = '' ]) : self
Parameters
- $moduleName : string = ''
-
Module name
Return values
self —getInstanceById()
Get instanace by record id.
public
static getInstanceById(int $record[, string $moduleName = null ]) : self
Parameters
- $record : int
-
Record id
- $moduleName : string = null
-
Module name
Return values
self —getInstanceByModel()
Get instanace by record model.
public
static getInstanceByModel(Vtiger_Record_Model $recordModel) : self
Parameters
- $recordModel : Vtiger_Record_Model
Return values
self —getInventoryTable()
Parsing inventory table.
public
getInventoryTable(array<string|int, mixed> $config) : string
Parameters
- $config : array<string|int, mixed>
Return values
string —getParam()
Get additional params.
public
getParam(string $key) : mixed
Parameters
- $key : string
Return values
mixed —getRecordVariable()
Get record variables.
public
getRecordVariable([bool|string $fieldType = false ]) : array<string|int, mixed>
Parameters
- $fieldType : bool|string = false
Return values
array<string|int, mixed> —getRelatedLevelVariable()
Get related variables.
public
getRelatedLevelVariable([bool|string $fieldType = false ]) : array<string|int, mixed>
Parameters
- $fieldType : bool|string = false
Return values
array<string|int, mixed> —getRelatedListVariable()
Get related modules list.
public
getRelatedListVariable() : array<string|int, mixed>
Return values
array<string|int, mixed> —getRelatedVariable()
Get related variables.
public
getRelatedVariable([bool|string $fieldType = false ][, bool $skipEmpty = false ]) : array<string|int, mixed>
Parameters
- $fieldType : bool|string = false
- $skipEmpty : bool = false
Return values
array<string|int, mixed> —getSourceVariable()
Get source variables.
public
getSourceVariable() : array<string|int, mixed>
Return values
array<string|int, mixed> —getUserVariables()
Gets user variables.
public
getUserVariables(string $text[, bool $useRegex = true ]) : array<string|int, mixed>
Parameters
- $text : string
- $useRegex : bool = true
Return values
array<string|int, mixed> —isVaribleToParse()
Function checks if its TextParser type.
public
static isVaribleToParse(string $text) : int
Parameters
- $text : string
Return values
int —parse()
All text parse function.
public
parse() : $this
Return values
$this —parseData()
Text parse function.
public
parseData(string $content) : string
Parameters
- $content : string
Return values
string —parseFieldParam()
Parse custom params.
public
static parseFieldParam(string $param) : array<string|int, mixed>
Parameters
- $param : string
Return values
array<string|int, mixed> —parseTranslations()
Text parse function.
public
parseTranslations() : $this
Return values
$this —setContent()
Set content.
public
setContent(string $content) : $this
Parameters
- $content : string
Return values
$this —setExtensionState()
Set the active state of extended parsing functionality.
public
setExtensionState(bool $state) : $this
Parameters
- $state : bool
Return values
$this —setGlobalPermissions()
Set permissions condition.
public
setGlobalPermissions(bool $permitted) : $this
Parameters
- $permitted : bool
Return values
$this —setLanguage()
Set language.
public
setLanguage([string $name = true ]) : $this
Parameters
- $name : string = true
Return values
$this —setParam()
Set param value.
public
setParam(string $key, mixed $value) : $this
Parameters
- $key : string
- $value : mixed
Return values
$this —setParams()
Set additional params.
public
setParams(array<string|int, mixed> $params) : $this
Parameters
- $params : array<string|int, mixed>
Return values
$this —setSourceRecord()
Set source record.
public
setSourceRecord(int $record[, bool|string $moduleName = false ][, mixed $recordModel = false ]) : $this
Parameters
- $record : int
- $moduleName : bool|string = false
- $recordModel : mixed = false
Return values
$this —setType()
Set parser type.
public
setType(string $type) : $this
Parameters
- $type : string
Return values
$this —withoutTranslations()
Set without translations.
public
withoutTranslations([string $type = true ]) : $this
Parameters
- $type : string = true
Return values
$this —barcode()
Get an instance of barcode text parser.
protected
barcode(string $params) : string
Parameters
- $params : string
Return values
string —custom()
Parsing custom.
protected
custom(string $params) : string
Parameters
- $params : string
Return values
string —employee()
Parsing employee detail.
protected
employee(string $fieldName) : mixed
Parameters
- $fieldName : string
Return values
mixed —general()
Parsing general data.
protected
general(string $key) : mixed
Parameters
- $key : string
Return values
mixed —getBaseGeneralVariable()
Get general variables base function.
protected
getBaseGeneralVariable() : array<string|int, mixed>
Return values
array<string|int, mixed> —getComments()
Get last comments.
protected
getComments([mixed $params = false ]) : string
Parameters
- $params : mixed = false
Return values
string —getDisplayValueByField()
Get record display value.
protected
getDisplayValueByField(Vtiger_Field_Model $fieldModel[, bool|mixed|Vtiger_Record_Model $value = false ][, string $params = null ]) : array<string|int, mixed>|bool|mixed|string
Parameters
- $fieldModel : Vtiger_Field_Model
- $value : bool|mixed|Vtiger_Record_Model = false
- $params : string = null
Return values
array<string|int, mixed>|bool|mixed|string —getDisplayValueByType()
Get record display value by type.
protected
getDisplayValueByType(mixed $value, Vtiger_Record_Model $recordModel, Vtiger_Field_Model $fieldModel, string $params) : array<string|int, mixed>|mixed|string
Parameters
- $value : mixed
- $recordModel : Vtiger_Record_Model
- $fieldModel : Vtiger_Field_Model
- $params : string
Return values
array<string|int, mixed>|mixed|string —getModuleGeneralVariable()
Get general variables module function.
protected
getModuleGeneralVariable() : array<string|int, mixed>
Return values
array<string|int, mixed> —inventory()
Parsing inventory.
protected
inventory(string $params) : string
Parameters
- $params : string
Return values
string —organization()
Parsing organization detail.
protected
organization(string $params) : string
Parameters
- $params : string
Return values
string —params()
Parsing params.
protected
params(string $key) : string
Parameters
- $key : string
Return values
string —parseParams()
Get inventory param.
protected
parseParams(string $params) : array<string|int, mixed>
Parameters
- $params : string
Return values
array<string|int, mixed> —parseVariable()
Parse variable.
protected
parseVariable(string $variable, int $id) : string
Parameters
- $variable : string
- $id : int
Return values
string —record()
Parsing record data.
protected
record(string $params[, mixed $isPermitted = true ]) : string
Parameters
- $params : string
- $isPermitted : mixed = true
Return values
string —recordsList()
Parsing records list.
protected
recordsList(string $params) : string
Parameters
- $params : string
-
Parameter construction: ModuleName|Columns|Conditions|CustomViewIdOrName|Limit, Example: Contacts|firstname,lastname,modifiedtime|[[["firstname","a","Tom"]]]||2
Return values
string —relatedRecord()
Parsing related record data.
protected
relatedRecord(string $params) : mixed
Parameters
- $params : string
Return values
mixed —relatedRecordLevel()
Parsing related record data.
protected
relatedRecordLevel(string $params) : mixed
Parameters
- $params : string
Return values
mixed —relatedRecordsList()
Parsing related records list.
protected
relatedRecordsList(string $params) : string
Parameters
- $params : string
-
Parameter construction: RelatedModuleNameOrRelationId|Columns|Conditions|CustomViewIdOrName|Limit, Example: Contacts|firstname,lastname,modifiedtime|[[["firstname","a","Tom"]]]||2
Return values
string —relatedRecordsListPrinter()
Printer related records list.
protected
relatedRecordsListPrinter(Vtiger_RelationListView_Model $relationListView, Vtiger_Paging_Model $pagingModel, int $maxLength) : string
Parameters
- $relationListView : Vtiger_RelationListView_Model
- $pagingModel : Vtiger_Paging_Model
- $maxLength : int
Return values
string —sourceRecord()
Parsing source record data.
protected
sourceRecord(string $fieldName) : mixed
Parameters
- $fieldName : string
Return values
mixed —translate()
Parsing translations.
protected
translate(string $params) : string
Parameters
- $params : string
Return values
string —userVariable()
Parsing user variable.
protected
userVariable(string $params) : string
Parameters
- $params : string
Return values
string —useValue()
Check if this content can be used.
protected
useValue(Vtiger_Field_Model $fieldModel, string $moduleName) : bool
Parameters
- $fieldModel : Vtiger_Field_Model
- $moduleName : string