Ejemplo n.º 1
0
/**
 * Check to see if this impression contains the valid channel.
 *
 * @param string $limitation The channel limitation
 * @param string $op The operator (either '==' or '=~', or '!~')
 * @param array $aParams An array of additional parameters to be checked
 * @return boolean Whether this impression's channel passes this limitation's test.
 */
function MAX_checkSite_Channel($limitation, $op, $aParams = array())
{
    if (empty($limitation)) {
        return true;
    }
    if (!isset($GLOBALS['_MAX']['FILES']['aIncludedPlugins'])) {
        $GLOBALS['_MAX']['FILES']['aIncludedPlugins'] = array();
    }
    if (isset($GLOBALS['_MAX']['channel_results'][$limitation][$op])) {
        return $GLOBALS['_MAX']['channel_results'][$limitation][$op];
    }
    $aLimitations = MAX_cacheGetChannelLimitations($limitation);
    $aConf = $GLOBALS['_MAX']['CONF'];
    // Include required deliveryLimitation files...
    if (strlen($aLimitations['acl_plugins'])) {
        $acl_plugins = explode(',', $aLimitations['acl_plugins']);
        foreach ($acl_plugins as $acl_plugin) {
            list($extension, $package, $name) = explode(':', $acl_plugin);
            $pluginName = MAX_PATH . $aConf['pluginPaths']['plugins'] . "{$extension}/{$package}/{$name}.delivery.php";
            if (!isset($GLOBALS['_MAX']['FILES']['aIncludedPlugins'][$pluginName]) && file_exists($pluginName)) {
                require $pluginName;
                $GLOBALS['_MAX']['FILES']['aIncludedPlugins'][$pluginName] = true;
            }
        }
    }
    $result = true;
    // Set to true in case of error in eval
    if (!empty($aLimitations['compiledlimitation'])) {
        @eval('$result = (' . $aLimitations['compiledlimitation'] . ');');
    }
    // Store the channel result for later use.
    $GLOBALS['_MAX']['channels'][$result][] = array('limitation' => $limitation, 'op' => $op);
    $GLOBALS['_MAX']['channel_results'][$limitation][$op] = $result;
    return $result;
}
 /**
  * Method tests invalidateChannelCache method
  */
 function test_invalidateChannelCache()
 {
     $cachedData = MAX_cacheGetChannelLimitations($this->_aIds['channel'][0]);
     // Change channel data
     $doChannel = OA_Dal::factoryDO('channel');
     $doChannel->get($this->_aIds['channel'][0]);
     $doChannel->acl_plugins = 'new value';
     $doChannel->update();
     // Expect no changes in cache
     $this->assertEqual(MAX_cacheGetChannelLimitations($this->_aIds['channel'][0]), $cachedData);
     $this->oDeliveryCacheManager->invalidateChannelCache($this->_aIds['channel'][0]);
     // Now expect changes in cache
     $this->assertNotEqual(MAX_cacheGetChannelLimitations($this->_aIds['channel'][0]), $cachedData);
 }
 /**
  * Creates all possible delivert cache files
  *
  * @param array $aIds array of DB Ids returned by _createTestData
  * @see _createTestData
  */
 function _createTestCacheFiles($aIds)
 {
     // Create cache files not related to DB Objects
     MAX_cacheGetAccountTZs();
     MAX_cacheCheckIfMaintenanceShouldRun();
     MAX_cacheGetGoogleJavaScript();
     // Create cache files for banners and images
     foreach ($aIds['banners'] as $bannerId) {
         MAX_cacheGetAd($bannerId);
     }
     foreach ($aIds['images'] as $filename) {
         MAX_cacheGetCreative($filename);
     }
     // Create cache files for zones
     foreach ($aIds['zones'] as $zoneId) {
         MAX_cacheGetZoneLinkedAds($zoneId);
         MAX_cacheGetZoneInfo($zoneId);
     }
     // Create cache files for websites
     foreach ($aIds['affiliates'] as $affiliateid) {
         OA_cacheGetPublisherZones($affiliateid);
     }
     // Create cache files for trackers
     foreach ($aIds['trackers'] as $trackerid) {
         MAX_cacheGetTracker($trackerid);
         MAX_cacheGetTrackerVariables($trackerid);
     }
     // Create cache files for channels
     foreach ($aIds['channel'] as $channelid) {
         MAX_cacheGetChannelLimitations($channelid);
     }
     // cache files for direct-selection are not created
     // due to problems with invalidating MAX_cacheGetLinkedAds
 }
 /**
  * Method tests invalidateGetChannelLimitationsCache method
  */
 function test_invalidateGetChannelLimitationsCache()
 {
     $aIds = $this->_createTestData();
     $this->_createTestCacheFiles($aIds);
     $cachedData = MAX_cacheGetChannelLimitations($aIds['channel'][0]);
     // Change channel data
     $doChannel = OA_Dal::factoryDO('channel');
     $doChannel->get($aIds['channel'][0]);
     $doChannel->acl_plugins = 'new value';
     $doChannel->update();
     // Expect no changes in cache
     $this->assertEqual(MAX_cacheGetChannelLimitations($aIds['channel'][0]), $cachedData);
     $this->oDeliveryCacheCommon->invalidateGetChannelLimitationsCache($aIds['channel'][0]);
     // Now expect changes in cache
     $this->assertNotEqual(MAX_cacheGetChannelLimitations($aIds['channel'][0]), $cachedData);
 }