You are here

function acquia_lift_form_personalize_campaign_wizard_alter in Acquia Lift Connector 7.2

Implements hook_form_FORM_ID_alter().

File

./acquia_lift.module, line 2551
acquia_lift.module Provides Acquia Lift-specific personalization functionality.

Code

function acquia_lift_form_personalize_campaign_wizard_alter(&$form, &$form_state, $form_id) {
  if ($form_state['storage']['step'] == 'results') {
    unset($form['actions']);
  }

  // Add in the basic functionality.
  $agent = $form['#agent'];
  if (!acquia_lift_is_configured()) {
    drupal_set_message(t('Your Acquia Lift account info has not been configured. Acquia Lift personalizations can not be created until you configure your account info !here', array(
      '!here' => l('here', 'admin/config/content/personalize/acquia_lift'),
    )), 'error');
    $form['agent_basic_info']['create']['#disabled'] = TRUE;
  }

  // Stylize the create campaign button for new campaigns.
  $form['agent_basic_info']['create']['#attributes']['class'][] = 'acquia-lift-submit-button';
  if (empty($agent->machine_name)) {
    $form['agent_basic_info']['agent_type'] = array(
      '#type' => 'value',
      '#value' => 'acquia_lift_target',
    );
    $form['agent_basic_info']['title']['#attributes']['placeholder'] = t('Example: Q3 Summer Promotions');

    // All other modifications only apply to the edit form.
    return;
  }

  // Only reports can be shown for legacy campaigns.
  $legacy_campaigns = variable_get('acquia_lift_legacy_agents', array());
  if (in_array($agent->machine_name, $legacy_campaigns)) {
    module_load_include('inc', 'personalize', 'personalize_admin');
    $form = drupal_get_form('acquia_lift_report', $agent);
    return;
  }
  if (!acquia_lift_is_targeting_agent($agent)) {
    return;
  }
  module_load_include('inc', 'acquia_lift', 'acquia_lift.admin.wizard');
  acquia_lift_personalize_campaign_wizard_alter($form, $form_state, $agent);
}