include/SugarRouting/SugarRouting.php
\SugarRouting
Package: SugarCRM
SugarRouting class
Routing and Rules implementation, initially for Email 2.0.
Properties
$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 value
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',
)
Details- Type
- n/a
Methods
_checkCriteria(
object $bean, array $focusRule
)
:
bool
processes a rule's matching criteria, returns true on good match
Parameters
Returns
Name | Type | Description |
---|---|---|
$bean | object | SugarBean to process |
$focusRule | array | Ruleset to use matching criteria |
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. ****************************************************************** ****************************************************************** |
_executeAction(
$bean, $focusRule, $extraArgs
)
:
void
Parameters
Name | Type | Description |
---|---|---|
$bean | ||
$focusRule | ||
$extraArgs |
getRule(
string $id
)
:
array
Returns one rule's metadata
Parameters
Returns
Name | Type | Description |
---|---|---|
$id | string | ID of rule |
Type | Description |
---|---|
array |
getRulesList(
)
:
string
Renders the Rules List
Returns
Type | Description |
---|---|
string | HTML form insertable in a table cell or something similar |
processRule(
object $bean, $focusRule, $args
)
:
bool
Takes a bean and a rule key as an argument and processes the bean according to the rule
Parameters
Returns
Name | Type | Description |
---|---|---|
$bean | object | Focus bean |
$focusRule | ||
$args |
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 ), ), ), ), ); |
processRules(
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 |
renderRuleRow(
array $rule
)
:
string
provides HTML for 1 rule in the List
Parameters
Returns
Name | Type | Description |
---|---|---|
$rule | array | Metadata for a rule |
Type | Description |
---|---|
string | HTML |
save(
array $rules
)
:
void
Saves a rule
Parameters
Name | Type | Description |
---|---|---|
$rules | array | Passed $_REQUEST var |
saveRulesToFile(
)
:
void
Takes the values in $this->rules and writes it to the appropriate cache file