Restrictions — Using restrictions on tables.
Restrictions limit the rows queried using a set of conditions. This way messages can be selected on specific properties, such as the existance of a certain property, a property's value larger than a certain value, etc..
A restriction is specified with an array with one value with the restriction type and one value with an array with the restriction specific properties.
Restriction types:
Takes an array with restrictions that must all be valid.
Expects an array with restrictions of which either one can be valid.
Wants an array with a single restriction that must not be valid.
Fuzzy search a property. The array must contain: FUZZYLEVEL, ULPROPTAG and VALUE. VALUE must be a string or binary. VALUE => array (tag => value)
Takes an array with properties of a property which must be valid. This array must contain: RELOP, ULPROPTAG and VALUE. The property and VALUE can have different types. VALUE => array (tag => value)
Compares two props. Expects an array with the indexes: RELOP, ULPROPTAG1 and ULPROPTAG2.
Applies a bitmask. The given array must contain: ULPROPTAG, ULTYPE and ULMASK.
Measures the size of a property. The array must have: ULPROPTAG, RELOP and CB.
Checks whether a property exists. Takes only ULPROPTAG in its array.
Places a restriction on a property. This is used on PR_MESSAGE_RECIPIENT properties with an RES_COMMENT restriction.
A comment restriction can be used to add comments to the restriction structure, or in a special case with the RES_SUBRESTRICTION. The RES_COMMENT structure holds a RES_PROPERTY restriction, which applies on the given properties list in the structure.
RELOP can be:
Less than.
Less than or equal to.
Greater than.
Greater than or equal to.
Equal to.
Not equal to.
The attachment has just been created.
FUZZYLEVEL can be one or bitwise more of these:
The property must be equal to this exact string.
Full text search for substring.
The value must start with this string.
Case should be ignored.
Non-spaces should be ignored.
The string is allowed to match loosely.
Example 2.5. Simple restriction example
// Example for restrictions $testrestriction = Array(RES_OR, Array(Array(RES_PROPERTY, Array(RELOP => RELOP_LE, ULPROPTAG => PR_BODY, VALUE => array(PR_BODY =>"test") )), Array(RES_PROPERTY, Array(RELOP => RELOP_LE, ULPROPTAG => PR_SUBJECT, VALUE => array(PR_SUBJECT => "bericht"))))); $contents = mapi_table_queryallrows($table, $props, $sizerestriction); foreach ($contents as $row) { echo $row[PR_SUBJECT]; echo "\n"; }
Example 2.6. RES_SUBRESTRICTION + RES_COMMENT example
$restriction = array(RES_SUBRESTRICTION, array(ULPROPTAG => PR_MESSAGE_RECIPIENTS, // this is the subobject RESTRICTION => array(RES_COMMENT, array(PROPS => array(), // probably need to add outlook data RESTRICTION => array(RES_PROPERTY, array(RELOP => RELOP_EQ, ULPROPTAG => PR_SEARCH_KEY, VALUE => array(PR_SEARCH_KEY => "one-off entryid") ) ) ) ) ) );