function _setLimitations($type, $index, $aItems, $aCaps) { MAX_Delivery_log_ensureIntegerSet($aCaps['block'], $index); MAX_Delivery_log_ensureIntegerSet($aCaps['capping'], $index); MAX_Delivery_log_ensureIntegerSet($aCaps['session_capping'], $index); MAX_Delivery_cookie_setCapping($type, $aItems[$index], $aCaps['block'][$index], $aCaps['capping'][$index], $aCaps['session_capping'][$index]); }
$aCapCampaign['capping'] = MAX_Delivery_log_getArrGetVariable('capCampaign'); $aCapCampaign['session_capping'] = MAX_Delivery_log_getArrGetVariable('sessionCapCampaign'); $aCapZone['block'] = MAX_Delivery_log_getArrGetVariable('blockZone'); $aCapZone['capping'] = MAX_Delivery_log_getArrGetVariable('capZone'); $aCapZone['session_capping'] = MAX_Delivery_log_getArrGetVariable('sessionCapZone'); $aSetLastSeen = MAX_Delivery_log_getArrGetVariable('lastView'); // Loop over the ads to be logged (there may be more than one due to internal re-directs) // and log each ad, and th en set any capping cookies required $countAdIds = count($aAdIds); for ($index = 0; $index < $countAdIds; $index++) { // Ensure that each ad to be logged has campaign, creative and zone // values set, and that all values are integers MAX_Delivery_log_ensureIntegerSet($aAdIds, $index); MAX_Delivery_log_ensureIntegerSet($aCampaignIds, $index); MAX_Delivery_log_ensureIntegerSet($aCreativeIds, $index); MAX_Delivery_log_ensureIntegerSet($aZoneIds, $index); if ($aAdIds[$index] >= -1) { $adId = $aAdIds[$index]; // Log the ad impression, if required if ($GLOBALS['_MAX']['CONF']['logging']['adImpressions']) { MAX_Delivery_log_logAdImpression($adId, $aZoneIds[$index]); } if ($aAdIds[$index] == $adId) { // Set the capping cookies, if required MAX_Delivery_log_setAdLimitations($index, $aAdIds, $aCapAd); MAX_Delivery_log_setCampaignLimitations($index, $aCampaignIds, $aCapCampaign); MAX_Delivery_log_setLastAction($index, $aAdIds, $aZoneIds, $aSetLastSeen); if ($aZoneIds[$index] != 0) { MAX_Delivery_log_setZoneLimitations($index, $aZoneIds, $aCapZone); } }
/** * A "private" function to set delivery blocking and/or capping cookies. * * @access private * @param string $type The type of blocking/capping cookies to set. One of * 'Ad', 'Campaign' or 'Zone'. * @param integer $index The index to the item and item limitation * arrays that corresponds with the item to set capping * cookies for. * @param array $aItems An array of item IDs, indexed by $index. * @param array $aCaps An array of arrays, indexed by the strings * "block", "capping" and "session_capping", then * indexed by $index, containing the cap values. */ function _setLimitations($type, $index, $aItems, $aCaps) { // Ensure that the capping values for this item are set MAX_Delivery_log_ensureIntegerSet($aCaps['block'], $index); MAX_Delivery_log_ensureIntegerSet($aCaps['capping'], $index); MAX_Delivery_log_ensureIntegerSet($aCaps['session_capping'], $index); // Set the capping cookies MAX_Delivery_cookie_setCapping($type, $aItems[$index], $aCaps['block'][$index], $aCaps['capping'][$index], $aCaps['session_capping'][$index]); }
/** * A method to test the MAX_Delivery_log_ensureIntegerSet() function. * * Requirements: * Test 1: Test using something that is not an array, and ensure that * array and value are set. * Test 2: Test with an array and nothing set, and ensure that value * is set. * Test 3: Test with an array and integer set, and ensure nothing changed. * Test 4: Test with an array and string set, and ensure string converted. */ function test_MAX_Delivery_log_ensureIntegerSet() { // Test 1 $aArray = 'string'; MAX_Delivery_log_ensureIntegerSet($aArray, 5); $this->assertTrue(is_array($aArray)); $this->assertEqual(count($aArray), 1); $this->assertEqual($aArray[5], 0); // Test 2 $aArray = array(); MAX_Delivery_log_ensureIntegerSet($aArray, 5); $this->assertTrue(is_array($aArray)); $this->assertEqual(count($aArray), 1); $this->assertEqual($aArray[5], 0); // Test 3 $aArray = array(); $aArray[5] = 10; MAX_Delivery_log_ensureIntegerSet($aArray, 5); $this->assertTrue(is_array($aArray)); $this->assertEqual(count($aArray), 1); $this->assertEqual($aArray[5], 10); // Test 4 $aArray = array(); $aArray[5] = 'string'; MAX_Delivery_log_ensureIntegerSet($aArray, 5); $this->assertTrue(is_array($aArray)); $this->assertEqual(count($aArray), 1); $this->assertEqual($aArray[5], 0); }