/**
  * Test kp_runRecommender returns the same results as the the recommender
  **/
 public function test8()
 {
     kp_resetVisitData();
     try {
         // Set up test data in database
         $testData = new kp_testData();
         $testPostIDs = $testData->insertTestPosts(10);
         $tK = array_keys($testPostIDs);
         // User Group #1
         $user1 = new kp_testUser(array($tK[0], $tK[1], $tK[2]), array());
         $user2 = new kp_testUser(array($tK[0], $tK[1], $tK[2], $tK[3]), array());
         // User Group #2
         $user3 = new kp_testUser(array($tK[4], $tK[5], $tK[6]), array());
         $user4 = new kp_testUser(array($tK[4], $tK[5], $tK[6]), array());
         // Get the recommendation from the recommender
         $user1->recommender->run(1, 1);
         // Get the recommendation from the lib function
         $posts = kp_getRecommendedWP_Posts(1, $user1->ipAddress, $user1->userAgent);
         $test = $user1->recommender->posts[0]->post_id == $posts[0]->post_id;
         $user1->deleteVisitData();
         $user2->deleteVisitData();
         $user3->deleteVisitData();
         $user4->deleteVisitData();
         $testData->deleteAllTestPosts();
     } catch (Exception $e) {
         $test = false;
     }
     $testObj = new kp_test("Test 8", $test, "results from recommendation function match results from recommendation engine", "results from recommendation function do not match results from recommendation engine");
     $testObj->render();
     kp_resetVisitData();
 }
 /**
  * Delete the posts that this user has visited
  *
  * @return null
  **/
 public function deleteVisitData()
 {
     kp_resetVisitData($this->ipAddress, $this->userAgent);
 }
/**
 * Output the settings page
 *
 * @return Html: The form
 **/
function kp_settingsPage()
{
    global $visitTbl, $wpdb;
    global $kp_pluginUrl, $kp_helpUrl, $kp_donationUrl;
    global $kp_defaultCollectStatistics, $kp_defaultAttemptToBlockBotVisits, $kp_defaultAdminTestMode;
    $CollectStatistics = get_option("kp_CollectStatistics", (string) $kp_defaultCollectStatistics);
    $AttemptToBlockBotVisits = get_option("kp_AttemptToBlockBotVisits", (string) $kp_defaultAttemptToBlockBotVisits);
    $AdminTestMode = get_option("kp_AdminTestMode", (string) $kp_defaultAdminTestMode);
    // Check if the admin wants to switch to test mode
    if (isset($_GET['settings-updated']) && $_GET['settings-updated'] == "true") {
        if ($AdminTestMode == "true") {
            // They switched to test mode
            // Check if we have test mode data already, if so, do not insert more
            if (!kp_haveTestModeData()) {
                kp_insertTestModeData();
            }
        } else {
            // They removed test mode
            kp_deleteTestModeData();
        }
    }
    $alert = "";
    if (isset($_SESSION["kp_alert"])) {
        $alert = $_SESSION["kp_alert"];
        unset($_SESSION["kp_alert"]);
    }
    // Check if the admin wanted to delete visit data
    if (isset($_POST["delete"]) && $_POST["delete"] == "all") {
        kp_resetVisitData();
        $alert = __("Visit data has been removed");
    }
    if (kp_performDeleteVisitChecks()) {
        $alert = __("Visit data from bots or ignored IP addresses have been removed");
    }
    ?>
	<div class="wrap">

	<h2><?php 
    _e("Kindred Posts by Ai Spork");
    ?>
</h2>	
	
	<?php 
    // Display the alert
    if ($alert != "") {
        ?>
	<div id="setting-error-settings_updated" class="updated settings-error">
		<p>
			<strong><?php 
        echo $alert;
        ?>
</strong>
		</p>
	</div>	
	<?php 
    }
    ?>
	
	
	<div>
		<a target="_blank" href="<?php 
    echo $kp_pluginUrl;
    ?>
"><?php 
    _e('Plugin Homepage');
    ?>
</a>
		&nbsp; | &nbsp;
		<a target="_blank" href="<?php 
    echo $kp_helpUrl;
    ?>
"><?php 
    _e('Support Forum');
    ?>
</a>
		&nbsp; | &nbsp;
		<a target="_blank" href="<?php 
    echo $kp_donationUrl;
    ?>
" style="color:#DF01D7;"><?php 
    _e('Donate');
    ?>
</a>
	</div>
	
	<h3><strong><?php 
    _e('Plugin Status:');
    ?>
	<?php 
    if (get_option("kp_CollectStatistics", "true") == "true") {
        ?>
		<span style="color:green;">
			<?php 
        _e('Collecting Data');
        if (get_option("kp_AdminTestMode", "false") == "true") {
            _e(': In Test Mode');
        }
        ?>
		</span>
	<?php 
    } else {
        ?>
		<span style="color:red;">
			<?php 
        _e('Not Collecting Data');
        if (get_option("kp_AdminTestMode", "false") == "true") {
            _e(': In Test Mode');
        }
        ?>
		</span>
	<?php 
    }
    ?>
</strong></h3>
	
	<?php 
    // Start left-side container
    ?>
	<div class="postbox-container" style="width:65%; min-width:300px;">
	<?php 
    // Start Settings box
    kp_settingsBox();
    // End Settings box
    // Start Advanced Settings Box
    kp_advancedSettingsBox();
    // End Advanced Settings Box
    ?>
	</div>
	<?php 
    // End left-side container
    ?>
	
	<?php 
    // Start right-side containers
    ?>
	<div class="postbox-container" style="float:right; margin-left:15px; margin-right:15px; width:300px;">
	<?php 
    // Start User Visit Data box
    kp_userVisitBox();
    // End User Visit Data box
    // Start Found Bug Box
    kp_foundBugBox();
    // End Found Bug Box
    // Start Feedback Box
    kp_feedbackBox();
    // End Feedback Box
    // End Right Column
    ?>
	</div>
	</div>
<?php 
}