You are here

function acquia_lift_personalize_goal_save in Acquia Lift Connector 7

Implements hook_personalize_goal_save().

File

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

Code

function acquia_lift_personalize_goal_save($goal_info) {
  $agent = personalize_agent_load($goal_info['agent']);
  if (!acquia_lift_is_testing_agent($agent)) {
    return;
  }
  $old_goals = isset($agent->data['goals']) ? $agent->data['goals'] : array();
  $current_goals = personalize_goal_load_by_conditions(array(
    'agent' => $agent->machine_name,
  ));
  foreach ($current_goals as $goal) {
    $new_goals[$goal->action] = $goal->value;
  }

  // For the current goal, take the info from what was passed in, rather
  // than from the db.
  $new_goals[$goal_info['action']] = $goal_info['value'];
  acquia_lift_sync_goals($agent, $old_goals, $new_goals, TRUE);

  // This agent will need to be re-verified as the changes may have changed
  // whether or not it is valid.
  acquia_lift_agent_clear_verified_status($goal_info['agent']);
}