You are here

function acquia_lift_validate_minimum_targeting in Acquia Lift Connector 7.2

Validate that an agent has the minimum targeting required and add it if it is not available.

Targeting agents should have a default "Everyone else".

Parameters

stdClass $agent: The object representing the agent that owns the targeting option set.

1 call to acquia_lift_validate_minimum_targeting()
acquia_lift_personalize_option_set_save in ./acquia_lift.module
Implements hook_personalize_option_set_save().

File

./acquia_lift.admin.inc, line 2027
acquia_lift.admin.inc Provides functions needed for the admin UI.

Code

function acquia_lift_validate_minimum_targeting($agent, $option_set) {

  // Check and create the "Everyone else" audience if it doesn't exist.
  $targeting_option_set = acquia_lift_get_option_set_for_targeting($agent->machine_name);
  if ($targeting_option_set->osid == $option_set->osid) {
    $targeting_option_set = $option_set;
  }
  if (empty($targeting_option_set->targeting)) {
    $audience = _acquia_lift_personalize_campaign_wizard_everyone_else_audience();
    acquia_lift_target_audience_save($audience['name'], $agent->machine_name, $audience['contexts'], $audience['strategy'], $audience['weight'], $audience['id']);
  }
}