You are here

function acquia_lift_report_goal_dropdown in Acquia Lift Connector 7

Same name and namespace in other branches
  1. 7.2 acquia_lift.admin.inc \acquia_lift_report_goal_dropdown()

Returns the drop-down for filtering reports by goal.

Parameters

$agent_name: The machine name of the campaign.

$selected: The selected goal action.

Return value

array A form element array to be used as the dropdown.

2 calls to acquia_lift_report_goal_dropdown()
acquia_lift_report_ab in ./acquia_lift.admin.inc
Form build function for an A/B Acquia Lift agent report.
acquia_lift_report_custom in ./acquia_lift.admin.inc
Form build function for a custom Acquia Lift agent report.

File

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

Code

function acquia_lift_report_goal_dropdown($agent_name, $selected = NULL) {
  $goals = personalize_goal_load_by_conditions(array(
    'agent' => $agent_name,
  ));

  // There should always be at least one goal in an Acquia Lift report.
  if (empty($goals)) {
    return array();
  }
  if (count($goals) == 1) {
    $goal = current($goals);
    return array(
      '#type' => 'hidden',
      '#value' => $goal->action,
    );
  }
  else {
    $actions = visitor_actions_get_actions();
    foreach ($goals as $goal) {
      $options[$goal->action] = $actions[$goal->action]['label'];
    }
    return array(
      '#title' => t('Goals'),
      '#type' => 'select',
      '#options' => $options,
      '#default_value' => $selected,
      '#empty_option' => t('All goals'),
    );
  }
}