function acquia_lift_personalize_option_set_delete in Acquia Lift Connector 7.2
Same name and namespace in other branches
- 7 acquia_lift.module \acquia_lift_personalize_option_set_delete()
Implements hook_personalize_option_set_delete().
File
- ./
acquia_lift.module, line 1061 - acquia_lift.module Provides Acquia Lift-specific personalization functionality.
Code
function acquia_lift_personalize_option_set_delete($option_set) {
$agent = personalize_agent_load($option_set->agent);
if (acquia_lift_is_targeting_agent($agent) && !empty($option_set->targeting)) {
$option_sets = personalize_option_set_load_by_agent($option_set->agent, TRUE);
if (empty($option_sets)) {
// Ensure any nested tests are deleted too
foreach ($option_set->targeting as $target) {
if (isset($target['osid'])) {
$nested_os = personalize_option_set_load($target['osid'], TRUE);
// Delete the option set, then delete the agent.
personalize_option_set_delete($nested_os->osid);
personalize_agent_delete($nested_os->agent);
}
}
}
if (!empty($agent->data['locked_for_variation_sets'])) {
// Somehow an option set is being deleted for an already implemented campaign.
// This is not supported via the UI and can cause problems for running
// campaigns. Set the campaign's status to completed to avoid any problematic
// decision calls being made.
personalize_agent_set_status($agent->machine_name, PERSONALIZE_STATUS_COMPLETED);
drupal_set_message(t('The @agent_name personalization has been set to completed because one of its variation sets was deleted', array(
'@agent_name' => $agent->machine_name,
)), 'warning');
}
}
}