コード例 #1
0
ファイル: bloom.php プロジェクト: Brandonsmith23/prodgyr
 /**
  * Calculates and returns the ID of optin which should be displayed if A/B testing is enabled
  * @return string
  */
 public static function choose_form_ab_test($optin_id, $optins_set, $update_option = true)
 {
     $chosen_form = $optin_id;
     if (!empty($optins_set[$optin_id]['child_optins']) && 'active' == $optins_set[$optin_id]['test_status']) {
         $chosen_form = '-1' != $optins_set[$optin_id]['next_optin'] || empty($optins_set[$optin_id]['next_optin']) ? $optins_set[$optin_id]['next_optin'] : $optin_id;
         if ('-1' == $optins_set[$optin_id]['next_optin']) {
             $next_optin = $optins_set[$optin_id]['child_optins'][0];
         } else {
             $child_forms_count = count($optins_set[$optin_id]['child_optins']);
             for ($i = 0; $i < $child_forms_count; $i++) {
                 if ($optins_set[$optin_id]['next_optin'] == $optins_set[$optin_id]['child_optins'][$i]) {
                     $current_optin_number = $i;
                 }
             }
             if ($child_forms_count - 1 == $current_optin_number) {
                 $next_optin = '-1';
             } else {
                 $next_optin = $optins_set[$optin_id]['child_optins'][$current_optin_number + 1];
             }
         }
         if (true === $update_option) {
             $update_test_optin[$optin_id] = $optins_set[$optin_id];
             $update_test_optin[$optin_id]['next_optin'] = $next_optin;
             ET_Bloom::update_bloom_options($update_test_optin);
         }
     }
     return $chosen_form;
 }