You are here

function acquia_lift_personalize_campaign_wizard_variations_submit in Acquia Lift Connector 7.2

Submit function for variations form.

File

./acquia_lift.admin.wizard.inc, line 2155
acquia_lift.admin.wizard.inc Functions specific to the Acquia Lift alteration of the campaign creation wizard.

Code

function acquia_lift_personalize_campaign_wizard_variations_submit(&$form, &$form_state, &$agent_data, $agent_instance) {
  if (!empty($form_state['storage']['acquia_lift_variation_set_handling'])) {
    $agent_data->data['variation_set_handling'] = $form_state['storage']['acquia_lift_variation_set_handling'];
    $agent_data = personalize_agent_save($agent_data);
  }

  // Save any existing option sets.
  if (!empty($form_state['values']['variations']['editing']['option_sets'])) {
    foreach ($form_state['values']['variations']['editing']['option_sets'] as $option_set_values) {
      $option_set = $option_set_values['option_set'];
      switch ($option_set_values['option_set']->plugin) {
        case "block":
          _acquia_lift_personalize_campaign_wizard_block_single_save($option_set_values['content'], $option_set, $form_state);
          break;
        case "elements":
          _acquia_lift_personalize_campaign_wizard_element_single_save($option_set_values, $option_set);
          break;
        default:
      }

      // Save general and advanced option set data.
      _acquia_lift_personalize_campaign_wizard_variations_single_save_general($option_set_values, $option_set);
    }
  }

  // Create any new option sets.
  if (!empty($form_state['new_option_sets'])) {
    foreach ($form_state['new_option_sets'] as $delta => $type) {
      if ($type !== 'block') {
        continue;
      }
      _acquia_lift_personalize_campaign_wizard_block_single_save($form_state['values']['variations']['editing']['new'][$delta]['block']['content'], NULL, $form_state);
    }
  }
}