function acquia_lift_element_variation_delete_complete_callback in Acquia Lift Connector 7
Same name and namespace in other branches
- 7.2 acquia_lift.admin.unibar.inc \acquia_lift_element_variation_delete_complete_callback()
Ctools form processing complete handler for deletion of an element variation.
See also
acquia_lift_create_ctools_form().
1 string reference to 'acquia_lift_element_variation_delete_complete_callback'
- acquia_lift_element_variation_delete_modal_callback in ./
acquia_lift.admin.unibar.inc - Page callback to generate an element variation delete confirm modal window.
File
Code
function acquia_lift_element_variation_delete_complete_callback($form, $form_state) {
$settings = array();
$form_option_set = $form_state['values']['option_set'];
$osid = $form_option_set->osid;
$option_sets = personalize_option_set_load_by_agent($form_state['values']['agent_name']);
$updated = NULL;
foreach ($option_sets as $option_set) {
if ($option_set->osid === $osid) {
$updated = $option_set;
break;
}
}
if ($updated) {
// The variation has been deleted, but the option set still has more.
$message = t('The variation has been deleted.');
$settings = _personalize_convert_option_set_to_js_setting($updated);
}
else {
$message = t('The variation set has been deleted.');
if (empty($option_sets)) {
// There are no more option sets in the agent.
$settings['empty'] = $form_state['values']['agent_name'];
}
else {
// The last variation was removed from the option set, but the agent
// still has other option sets.
$settings[personalize_stringify_osid($osid)] = 'empty';
}
}
$campaign_settings['acquia_lift']['campaigns'] = acquia_lift_get_campaign_details(variable_get('acquia_lift_unibar_allow_status_change', TRUE));
$commands = array(
ajax_command_settings($campaign_settings, TRUE),
ctools_modal_command_dismiss(),
acquia_lift_command_messagebox($message, 10),
acquia_lift_command_option_set_updates($settings),
acquia_lift_command_process_queue(),
);
return $commands;
}