You are here

function acquia_lift_personalize_agent_date_form_alter in Acquia Lift Connector 7

Implements hook_personalize_agent_date_form_alter().

File

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

Code

function acquia_lift_personalize_agent_date_form_alter(&$form, $agent_name) {
  if (empty($agent_name)) {
    return;
  }
  $agent = personalize_agent_load($agent_name);

  // If this is a Lift agent, we need to add the "Run until a winner is found"
  // option to the campaign end dropdown.
  if (acquia_lift_is_testing_agent($agent)) {
    $data = $agent->data;
    $options = $form['campaign_end']['#options'];

    // The "specified" needs to be the last option, because of the date
    // picker element that goes with it.
    $specified = $options['specified'];
    unset($options['specified']);
    $options['auto'] = t('End when campaign thresholds are reached');
    $form['campaign_end']['auto'] = array(
      '#description' => t('This option changes the campaign\'s status to complete when both the campaign !duration and !decisions thresholds are reached. The variation with highest number of completed goals at that time is the winning variation for display.', array(
        '!duration' => l(t('duration'), 'admin/config/content/personalize/acquia_lift'),
        '!decisions' => l(t('decisions'), 'admin/config/content/personalize/acquia_lift'),
      )),
    );
    $options['specified'] = $specified;
    $form['campaign_end']['#options'] = $options;
    if (isset($data['auto_stop']) && $data['auto_stop']) {
      $form['campaign_end']['#default_value'] = 'auto';
    }
  }
}