function testGetGeotargetingConfig() { $array1 = array('type' => 'testType'); MAX_Plugin::writePluginConfig($array1, 'testModule'); $array2 = array('key2' => 'val2'); MAX_Plugin::writePluginConfig($array2, 'testModule', 'testType'); $configMigration = new ConfigMigration(); $this->assertEqual(array_merge($array1, $array2), $configMigration->getPluginsConfigByType('testModule')); }
/** * A method for returning an array of the available geotargeting modes. * * @return array An array of strings representing the available geotargeting modes. */ function AvailableGeotargetingModes() { Language_Loader::load('default'); $plugins =& MAX_Plugin::getPlugins('geotargeting'); $modes['none'] = $GLOBALS['strNone']; $pluginModes = MAX_Plugin::callOnPlugins($plugins, 'getModuleInfo'); foreach ($pluginModes as $key => $pluginMode) { $modes[$key] = $pluginMode; } return $modes; }
/** * Returns plugin config by its module merged with specifig package * config. Package type is read from module config. * * @param string $module * @return array */ function getPluginsConfigByType($module) { if (isset($GLOBALS['_MAX']['CONF'][$module])) { // Make sure config is always read from ini file unset($GLOBALS['_MAX']['CONF'][$module]); } $conf = MAX_Plugin::getConfig($module); $aConfig = MAX_Plugin::getConfig($module, $conf['type']); if (is_array($aConfig)) { $conf = array_merge($conf, $aConfig); } return $conf; }
function _pluginExecute($params) { $conf = $GLOBALS['_MAX']['CONF']; $paramParams = $params->getParam(0); $pluginParams = unserialize($paramParams->scalarval()); // Instansiate the plugin and execute the method include_once MAX_PATH . '/lib/max/Plugin.php'; $plugin = MAX_Plugin::factory($pluginParams['module'], strtolower($conf['database']['type'])); if ($plugin) { $result = array(); $result = $plugin->{$pluginParams}['method']($pluginParams['data']); } $response = new XML_RPC_Value(serialize($result), 'base64'); return new XML_RPC_Response($response); }
/** * A method to delete cached plugin data. * * @static * @param string $module The plugin module name (i.e. /plugins/module directory). * @param string $package The plugin package name (i.e. /plugins/module/package * directory). * @param string $name Optional name of the PHP file which contains the plugin, * otherwise the plugin with the same name as the package * is assumed. * @param string $mode An optional PEAR::Cache_Lite cleaning mode. Default is * 'ingroup', to delete all cached data for the plugin. * @param array $aOptions An optional array of constructor options for * PEAR::Cache_Lite. The default values are those * obtained from {@link MAX_Plugin::prepareCacheOptions()}. * @return boolean True on success, false otherwise. */ function cleanPluginCache($module, $package, $name = null, $mode = 'ingroup', $aOptions = null) { if (is_null($name)) { $name = $package; } if (is_null($aOptions)) { $aOptions = MAX_Plugin::prepareCacheOptions($module, $package); } $oCache = new Cache_Lite($aOptions); return $oCache->clean($name, $mode); }
if ($aConversions[$conversionId]['connection_status'] == MAX_CONNECTION_STATUS_APPROVED) { // Substract conversion from "data_intermediate_ad" and from "data_summary_ad_hourly" // and remove $connectionBasketValue from total_basket_value $operation = '-'; } // If connection was changed to conversion if ($statusId == MAX_CONNECTION_STATUS_APPROVED) { // Add new conversion to "data_intermediate_ad" and from "data_summary_ad_hourly" // and add $connectionBasketValue to total_basket_value $operation = '+'; } // Pick the right table if ($aConversions[$conversionId]['connection_action'] == MAX_CONNECTION_AD_ARRIVAL) { $data_summary_table = 'data_summary_ad_arrival_hourly'; // Run serviceLocator register functions $plugins =& MAX_Plugin::getPlugins('Maintenance'); foreach ($plugins as $plugin) { if ($plugin->getHook() == MSE_PLUGIN_HOOK_AdServer_saveSummary) { $plugin->serviceLocatorRegister(); // Make sure it is the arrival plugin if ($oServiceLocator->get('financeSummaryTable') == $data_summary_table) { break; } else { $plugin->serviceLocatorRemove(); } } } } else { $plugin = null; $data_summary_table = 'data_summary_ad_hourly'; }
/** * A method to test the saving, reading and clearing of cache data. */ function testCacheMethods() { $aConf = $GLOBALS['_MAX']['CONF']; // Test reading when no data cached $result = MAX_Plugin::getCacheForPluginById('foo', 'Maintenance', 'Fake'); $this->assertFalse($result); // Test a simple write and read $aData = array('foo', 'bar'); $result = MAX_Plugin::saveCacheForPlugin($aData, 'foo', 'Maintenance', 'Fake'); $this->assertTrue($result); $result = MAX_Plugin::getCacheForPluginById('foo', 'Maintenance', 'Fake'); $this->assertTrue(is_array($result)); $this->assertEqual(count($result), 2); $this->assertEqual($result[0], 'foo'); $this->assertEqual($result[1], 'bar'); // Test a write and read when cache data has exipired, and the validity is tested $aOptions = MAX_Plugin::prepareCacheOptions('Maintenance', 'Fake', null, 0); $result = MAX_Plugin::saveCacheForPlugin($aData, 'foo', 'Maintenance', 'Fake', null, $aOptions); $this->assertTrue($result); $result = MAX_Plugin::getCacheForPluginById('foo', 'Maintenance', 'Fake', null, false, $aOptions); $this->assertFalse($result); // Re-test the read, not checking the validity $result = MAX_Plugin::getCacheForPluginById('foo', 'Maintenance', 'Fake', null, true, $aOptions); $this->assertTrue(is_array($result)); $this->assertEqual(count($result), 2); $this->assertEqual($result[0], 'foo'); $this->assertEqual($result[1], 'bar'); // Clear the cache and re-test the read MAX_Plugin::cleanPluginCache('Maintenance', 'Fake'); $result = MAX_Plugin::getCacheForPluginById('foo', 'Maintenance', 'Fake', null, true, $aOptions); $this->assertFalse($result); // Remove the created directory $this->_delDir(MAX_PATH . $aConf['pluginPaths']['var'] . '/cache/Maintenance'); }
/** * Save some data in a cache file * * @static * @param string $mode Flush cache mode : 'old', 'ingroup', 'notingroup' * * @return bool True if no problem, else false * */ function cleanCache($mode = 'ingroup') { return MAX_Plugin::cleanPluginCache($this->module, $this->package, $this->name, $mode); }