You are here

function acquia_lift_targeting_form_submit in Acquia Lift Connector 7

Submit callback for the targeting form.

File

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

Code

function acquia_lift_targeting_form_submit($form, &$form_state) {
  $agent = personalize_agent_load($form_state['values']['agent']);
  if ($form_state['triggering_element']['#value'] == t('Revert changes')) {

    // Execute the revert action.
    if ($form_state['values']['revert_changes'] === TRUE) {
      return acquia_lift_confirm_revert_changes_submit($form, $form_state);
    }

    // Rebuild the form to confirm the revert action.
    $form_state['rebuild'] = TRUE;
    $form_state['confirm_revert_changes'] = TRUE;
    return;
  }
  $targeting = array();
  foreach ($form_state['values']['targeting'] as $audience => $options) {
    $targeting[$audience] = array();
    foreach ($options as $option) {
      if (!empty($option)) {
        $targeting[$audience][] = $option;
      }
    }
  }
  acquia_lift_save_targeting_structure($agent, $targeting);
}