You are here

function acquia_lift_get_option_set_for_targeting in Acquia Lift Connector 7.2

Same name and namespace in other branches
  1. 7 acquia_lift.admin.inc \acquia_lift_get_option_set_for_targeting()

Get the option set where targeting rules are defined.

The assumption here is that if you have multiple option sets then targeting is only defined on one of them as we currently do not support targeting for MVTs.

Parameters

$agent: A stdClass object representing the agent to get the option set for.

Return value

stdClass|NULL The option set to use for targeting rules or NULL if the agent has no option sets.

31 calls to acquia_lift_get_option_set_for_targeting()
AcquiaLiftTarget::errors in plugins/agent_types/AcquiaLiftTarget.inc
Implements PersonalizeAgentInterface::errors().
AcquiaLiftWebTestCampaignWizardTargeting::testNoTargeting in tests/acquia_lift.test
Test doing a straight test, i.e. all variations assigned to "Everyone Else".
AcquiaLiftWebTestCampaignWizardTargeting::testTargeting in tests/acquia_lift.test
Test the audience functionality.
AcquiaLiftWebTestFundamentals::testSiteNamePrefixAttach in tests/acquia_lift.test
AcquiaLiftWebTestReports::testReportPage in tests/acquia_lift.test

... See full list

File

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

Code

function acquia_lift_get_option_set_for_targeting($agent_name, $reset = TRUE) {
  $option_sets = personalize_option_set_load_by_agent($agent_name, $reset);
  if (empty($option_sets)) {
    return NULL;
  }
  $targeting_osid = $targeting = NULL;
  foreach ($option_sets as $option_set) {
    if (empty($targeting) && !empty($option_set->targeting)) {
      $targeting_osid = $option_set->osid;
      $targeting = $option_set->targeting;
    }

    // If we have a personalize_elements option set then this one should be
    // used because the option ids matter and should not be clobbered by
    // other option ids.
    if ($option_set->plugin == 'elements') {
      $targeting_osid = $option_set->osid;
      break;
    }
  }
  if ($targeting_osid) {
    return $option_sets[$targeting_osid];
  }
  return reset($option_sets);
}