Resolves smart-campaign rules array to one or more QB instances with correct constraints, and merges the results.

Rules array structure:

array(
   'type' => 'AND',
   'classes' => array
   (
       array
       (
           'type' => 'OR',
           'class' => 'org_openpsa_contacts_person_dba',
           'rules' => array
           (
               array
               (
                   'property' => 'email',
                   'match' => 'LIKE',
                   'value' => '%@%'
               ),
               array
               (
                   'property' => 'handphone',
                   'match' => '<>',
                   'value' => ''
               ),
           ),
       ),
       array
       (
           'type' => 'AND',
           'class' => 'midgard_parameter',
           'rules' => array
           (
               array
               (
                   'property' => 'domain',
                   'match' => '=',
                   'value' => 'openpsa_test'
               ),
               array
               (
                   'property' => 'name',
                   'match' => '=',
                   'value' => 'param_match'
               ),
               array
               (
                   'property' => 'value',
                   'match' => '=',
                   'value' => 'bar'
               ),
           ),
       ),
   ),
),

NOTE: subgroups are processed before rules, subgroups must match class of parent group until midgard core has the new infinite JOINs system. The root level group array is named 'classes' because there should never be be two groups on this level using the same class

package org.openpsa.directmarketing

 Methods

__construct ()

add_group_rule (array $rule)

Adds a group-rule to the querybuilder

Parameters

$rule

arraycontains the group-rule

add_misc_rule (array $rule, string $class, string $person_property)

Adds a passed rule for the passed class to the querybuilder

Parameters

$rule

arraycontains the rule

$class

stringname of the class the rule will be added to

$person_property

stringcontains the name of the property of the passed class which links to the person

add_parameter_rule (array $rules)

Adds parameter rule to the querybuilder

Parameters

$rules

arrayarray containing rules for the paramter

add_person_rule (array $rule)

Adds rule directly to the querybuilder

Parameters

$rule

arraycontains the rule

add_rules (array $rules, string $class)

Iterates over passed rules for given class and calls functions to add rules to the querybuilder/collector

Parameters

$rules

arrayarray containing rules

$class

stringcontaining name of class for the rules

execute ()

Executes the QBs instanced via resolve, merges results and returns single array of persons (or false in case of failure)

list_object_properties (\midcom_core_dbaobject $object, \midcom_services_i18n_l10n $l10n)

List object's properties for JS rule builder
Static

PONDER: Should we support schema somehow (only for non-parameter keys), this would practically require manual parsing...

Parameters

$object

\midcom_core_dbaobject

$l10n

\midcom_services_i18n_l10n

resolve (array $rules)

Recurses trough the rules array and creates QB instances & constraints as needed

Parameters

$rules

arrayrules array

Returns

booleanindicating success/failure

_resolve_rule_group (array $group, string $match_class)

Resolves the rules in a single rule group

Parameters

$group

arraysingle group from rules array

$match_class

stringwanted class in group

Returns

booleanindicating success/failure

 Properties

 

mixed $_result_mc

 

mixed $_rules