requests_collection_filter

Allows adding of custom request filters.

Helpdesk

Input (passed by reference)

$params['collection'] helpdeskRequestsCollection Requests collection class instance.
$params['filter_name'] string Filter name.
$params['filter_op'] string Filter operator: ':', '>=', or '<='.
$params['filter_params'] array Filter values.
… your plugin code …

Output

%plugin_id%
A plugin must return true to allow the app to accept plugin’s custom filter.
Helpdesk

Plugin code example

PHP

public function requestsCollectionFilter($params)
{
    // process URL #/requests/search/myplugin/
    if ($params['filter_name'] == 'myplugin') {
        $collection = $params['collection'];
        $model = new waModel();

        $collection->header = _wp('Error reports');
        // show only requests containign the word "error"
        $collection->where[] = 'LOWER(summary) REGEXP "' . $model->escape(mb_strtolower(_wp('error'))) . '"
            OR LOWER(text) REGEXP "' . $model->escape(mb_strtolower(_wp('error'))) . '"';

        return true;
    }
}