Name

Rules Functions — This section describes functions which are performed on the rules table.

Synopsis

array mapi_rules_gettable(resource $emt);
boolean mapi_rules_modifytable(resource $emt,
                               array $rows,
                               long $flags);

Details

mapi_rules_gettable ()

array mapi_rules_gettable(resource $emt)

Returns the rules table from an IExchangeModifyTable interface.

This function opens a table view on the rules table from the IExchangeModifyTable interface. Returns an mapi table object on success, or FALSE on failure.

$emt
The IExchangeModifyTable interface, retrieved from mapi_folder_openmodifytable().

Example 3.45. Retrieving the rules table

// Get the current rules
$emt = mapi_folder_openmodifytable($inbox);
$rtable = mapi_rules_gettable($emt);
$rules = mapi_table_queryallrows($rtable);
print_r($rules);
	  

mapi_rules_modifytable ()

boolean mapi_rules_modifytable(resource $emt, array $rows, long $flags)

Modifies the rules table using the IExchangeModifyTable interface.

This function alters the rules table with the current row set. The previous table can be cleared when the ROWLIST_REPLACE is passed in the flags parameter. Returns an TRUE on success, or FALSE on failure.

$emt
The IExchangeModifyTable interface, retrieved from mapi_folder_openmodifytable().
$rows
The rows that need to be added, modified or deleted.
$flags (optional)
Set this flag to ROWLIST_REPLACE to empty the current table before altering the table.

Example 3.46. Modifying the rules table

// Get the interface
$emt = mapi_folder_openmodifytable($inbox);

$restriction = array(RES_CONTENT,
	array( FUZZYLEVEL => FL_SUBSTRING | FL_IGNORECASE,
		   ULPROPTAG => PR_SUBJECT,
		   VALUE => array(PR_SUBJECT=>'spam'))
);
$action = array(
	array (
		'action' => OP_MOVE,
		'storeentryid' => $publicstore_entryid,
		'folderentryid' => $public_folder_entryid
	),
);
$rule = array(

	PR_RULE_ACTIONS => $action,
	PR_RULE_CONDITION => $restriction,
	PR_RULE_PROVIDER => 'RuleOrganizer',
	PR_RULE_STATE => ST_ENABLED,
	PR_RULE_NAME => 'move "spam" mails to "important" folder in the public store',
);

$rows = array( 0 => array(
		'rowflags' => ROW_ADD,
		'properties' => $rule
	)
);

$result = mapi_rules_modifytable($emt, $rows);

$rtable = mapi_rules_gettable($emt);
$rules = mapi_table_queryallrows($rtable);
print_r($rules);