Name

Restrictions — Using restrictions on tables.

Restrictions

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:

RES_AND

Takes an array with restrictions that must all be valid.

RES_OR

Expects an array with restrictions of which either one can be valid.

RES_NOT

Wants an array with a single restriction that must not be valid.

RES_CONTENT

Fuzzy search a property. The array must contain: FUZZYLEVEL, ULPROPTAG and VALUE. VALUE must be a string or binary. VALUE => array (tag => value)

RES_PROPERTY

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)

RES_COMPAREPROPS

Compares two props. Expects an array with the indexes: RELOP, ULPROPTAG1 and ULPROPTAG2.

RES_BITMASK

Applies a bitmask. The given array must contain: ULPROPTAG, ULTYPE and ULMASK.

RES_SIZE

Measures the size of a property. The array must have: ULPROPTAG, RELOP and CB.

RES_EXIST

Checks whether a property exists. Takes only ULPROPTAG in its array.

RES_SUBRESTRICTION

Places a restriction on a property. This is used on PR_MESSAGE_RECIPIENT properties with an RES_COMMENT restriction.

RES_COMMENT

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:

RELOP_LT

Less than.

RELOP_LE

Less than or equal to.

RELOP_GT

Greater than.

RELOP_GE

Greater than or equal to.

RELOP_EQ

Equal to.

RELOP_NE

Not equal to.

RELOP_RE

The attachment has just been created.

FUZZYLEVEL can be one or bitwise more of these:

FL_FULLSTRING

The property must be equal to this exact string.

FL_SUBSTRING

Full text search for substring.

FL_PREFIX

The value must start with this string.

FL_IGNORECASE

Case should be ignored.

FL_IGNORENONSPACE

Non-spaces should be ignored.

FL_LOOSE

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") )
					  )
				)
			)
		)
	);