function acquia_lift_set_audience_for_test in Acquia Lift Connector 7
Same name and namespace in other branches
- 7.2 acquia_lift.admin.inc \acquia_lift_set_audience_for_test()
Saves a test to a particular targeting audience.
Parameters
$parent_agent: The machine name of the parent agent.
$old_audience: The target audience that currently has this test running.
$new_audience: The target audience to move the test to.
1 call to acquia_lift_set_audience_for_test()
- 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 1645 - acquia_lift.admin.inc Provides functions needed for the admin UI.
Code
function acquia_lift_set_audience_for_test($parent_agent, $old_audience, $new_audience) {
if ($old_audience == $new_audience) {
return;
}
$option_set = acquia_lift_get_option_set_for_targeting($parent_agent->machine_name);
if (isset($option_set->targeting[$old_audience]) && isset($option_set->targeting[$old_audience]['osid'])) {
$nested_osid = $option_set->targeting[$old_audience]['osid'];
unset($option_set->targeting[$old_audience]['osid']);
}
else {
return;
}
// Now add the test to the new audience.
if (isset($option_set->targeting[$new_audience])) {
// If this audience previously had a single option assigned to it, remove
// that option.
if (isset($option_set->targeting[$new_audience]['option_id'])) {
unset($option_set->targeting[$new_audience]['option_id']);
}
$option_set->targeting[$new_audience]['osid'] = $nested_osid;
}
personalize_option_set_save($option_set);
}