include/SugarRouting/SugarRouting.php

Show: inherited
Table of Contents

\SugarRouting

Package: SugarCRM

SugarRouting class

Routing and Rules implementation, initially for Email 2.0.

Properties

Propertypublic  $actions= 'array( // array containing function names defined in baseActions.php //'delete_bean', //'delete_file', 'move_mail', 'copy_mail', '_break', 'forward', 'reply', '_break', 'mark_read', 'mark_unread', 'mark_flagged', '_break', 'delete_mail', )'
Default valuearray( // array containing function names defined in baseActions.php //'delete_bean', //'delete_file', 'move_mail', 'copy_mail', '_break', 'forward', 'reply', '_break', 'mark_read', 'mark_unread', 'mark_flagged', '_break', 'delete_mail', )Details
Type
n/a
Propertypublic  $bean= ''
Details
Type
n/a
Propertypublic  $customActions= ''
Details
Type
n/a
Propertypublic  $rules= ''
Details
Type
n/a
Propertypublic  $rulesCache= ''
Details
Type
n/a
Propertypublic  $user= ''
Details
Type
n/a

Methods

methodpublicSugarRouting(  $bean,  $user ) : void

Sole constructor

Parameters
Name Type Description
$bean
$user
methodpublic_checkCriteria( object $bean, array $focusRule ) : bool

processes a rule's matching criteria, returns true on good match

Parameters
Name Type Description
$bean object

SugarBean to process

$focusRule array

Ruleset to use matching criteria

Returns
Type Description
bool ****************************************************************** ****************************************************************** DO NOT CHANGE THIS METHOD UNLESS CHRIS (OR CURRENT OWNER) IS FULLY AWARE. THIS IS THE MOST DELICATE CALL IN THIS CLASS. ****************************************************************** ******************************************************************
methodpublic_executeAction(  $bean,  $focusRule,  $extraArgs ) : void

Parameters
Name Type Description
$bean
$focusRule
$extraArgs
methodpublicdeleteRule(  $rule_id ) : void

Deletes a rule

Parameters
Name Type Description
$rule_id
methodpublicgetActionsDOM( ) : void

methodpublicgetMatchDOM( ) : void

methodpublicgetMatchTypeDOM( ) : void

methodpublicgetRule( string $id ) : array

Returns one rule's metadata

Parameters
Name Type Description
$id string

ID of rule

Returns
Type Description
array
methodpublicgetRulesList( ) : string

Renders the Rules List

Returns
Type Description
string HTML form insertable in a table cell or something similar
methodpublicgetStrings( ) : void

Generates strings for Routing

methodpublicloadRules( ) : void

Tries to load a rule set based on passed bean

methodpublicpreflightCache( ) : void

Prepares cache dir for a ruleset.

Sets $this->rulesCache

methodpublicprocessRule( object $bean,  $focusRule,  $args ) : bool

Takes a bean and a rule key as an argument and processes the bean according to the rule

Parameters
Name Type Description
$bean object

Focus bean

$focusRule
$args
Returns
Type Description
bool rule format: $routingRules['1'] = array( 0 => array( 'id' => 'xxxxxxxxxxxxxxxx', 'name' => 'Move Email to Sugar Folder [test]', 'active' => true, 'all' => true, 'criteria' => array( array( 'type' => 'match', 'field' => 'name', 'regex' => '/test/i', 'action' => array( 'crit0' => 'name', 'crit1' => 'notmatch', 'crit2' => '/test/i', ), ), array( 'type' => 'match', 'field' => 'from_addr', 'regex' => '/chris@sugarcrm.com/i', 'action' => array( 'crit0' => 'from_addr', 'crit1' => 'match', 'crit2' => '/chris@sugarcrm.com/i', ), ), ), 'actions' => array( 0 => array( 'function' => 'move_mail', 'type' => 'move', 'class' => 'mail', 'action' => array( 'action0' => 'move_mail', 'action1' => 'sugar::9e559ad1-a900-3c38-d846-464c931908be', ), 'args' => array( 'mailbox_id', // passed in sugarbean 'uid', // temporarily assigned UID attribute ), ), 1 => array( 'function' => 'move_mail', 'type' => 'move', 'class' => 'mail', 'action' => array( 'action0' => 'move_mail', 'action1' => 'remote::6694aa20-0036-ffa7-ea7f-464c936db8cf::INBOX::test', ), 'args' => array( 'mailbox_id', // passed in sugarbean 'uid', // temporarily assigned UID attribute ), ), ), ), 1 => array( 'id' => 'yyyyyyyyyyyyyyyyyyy', 'name' => 'Move Email to IMAP Folder [test]', 'active' => false, 'all' => true, 'criteria' => array( array( 'type' => 'match', 'field' => 'name', 'regex' => '/move/i', ), array( 'type' => 'match', 'field' => 'from_addr', 'regex' => '/chris@sugarcrm.com/i', ), ), 'actions' => array( array( 'function' => 'move_mail', 'type' => 'move', 'class' => 'mail', 'action' => array( 'action0' => 'move_mail', 'action1' => 'remote::6694aa20-0036-ffa7-ea7f-464c936db8cf::INBOX::test', ), 'args' => array( 'mailbox_id', // passed in sugarbean 'uid', // temporarily assigned UID attribute ), ), ), ), );
methodpublicprocessRules( object $bean, mixed $args = null ) : void

Iterates through all rulesets to apply them to a given message

Parameters
Name Type Description
$bean object

SugarBean to be manipulated

$args mixed

Extra arguments if needed

methodpublicrenderRuleRow( array $rule ) : string

provides HTML for 1 rule in the List

Parameters
Name Type Description
$rule array

Metadata for a rule

Returns
Type Description
string HTML
methodpublicsave( array $rules ) : void

Saves a rule

Parameters
Name Type Description
$rules array

Passed $_REQUEST var

methodpublicsaveRulesToFile( ) : void

Takes the values in $this->rules and writes it to the appropriate cache file

methodpublicsetRuleStatus(  $id,  $status ) : void

Enables/disables a rule

Parameters
Name Type Description
$id
$status
Documentation was generated by DocBlox 0.18.1.