You are here

function acquia_lift_get_structure_from_targeting in Acquia Lift Connector 7

Same name and namespace in other branches
  1. 7.2 acquia_lift.admin.inc \acquia_lift_get_structure_from_targeting()

Returns a mapping of audiences to option IDs based on the targeting set-up.

Returns an array of option IDs for each audience, so if the audience is assigned a single option, then it's a single element array, if it's assigned a nested option set, we pull out the option IDs for the nested option set and return them as an array.

Parameters

$option_set: The option set to get the targeting structure for.

Return value

array An associative array whose keys are target audiences and whose values are arrays of option IDs.

3 calls to acquia_lift_get_structure_from_targeting()
acquia_lift_review_form in ./acquia_lift.admin.inc
Final review form for applying targeting changes.
acquia_lift_targeting_form in ./acquia_lift.admin.inc
Form for assigning options or tests to audiences.
acquia_lift_update_targeting in ./acquia_lift.admin.inc
Takes whatever is in the 'lift_targeting' data property and converts it into the required campaign structure (including nested tests where needed).

File

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

Code

function acquia_lift_get_structure_from_targeting($option_set) {
  $targeting_structure = array();
  foreach ($option_set->targeting as $name => $targ) {
    $targeting_structure[$name] = array();
    if (isset($targ['osid'])) {
      $nested_option_set = personalize_option_set_load($targ['osid']);
      foreach ($nested_option_set->options as $option) {
        $targeting_structure[$name][] = $option['option_id'];
      }
    }
    elseif (isset($targ['option_id'])) {
      $targeting_structure[$name][] = $targ['option_id'];
    }
  }
  return $targeting_structure;
}