Ejemplo n.º 1
0
 /**
  * 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;
 }
 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 callOnPlugins() method.
  *
  * @TODO Deal with class name case changes.
  */
 function testCallOnPlugins()
 {
     // Set the error handling class' handleErrors() method as
     // the error handler for PHP for this test.
     $oTestErrorHandler = new TestErrorHandler();
     PEAR::pushErrorHandling(PEAR_ERROR_CALLBACK, array(&$oTestErrorHandler, 'handleErrors'));
     // Test with a non-array parameter for the plugins
     $aPlugins = 'bar';
     $result = MAX_Plugin::callOnPlugins($aPlugins, 'foo');
     $this->assertEqual(count($oTestErrorHandler->aErrors), 1);
     $this->assertEqual($oTestErrorHandler->aErrors[0]->message, 'Bad argument: Not an array of plugins.');
     $this->assertFalse($result);
     $oTestErrorHandler->reset();
     // Test with an array of non-plugins
     $aPlugins = array('bar');
     $result = MAX_Plugin::callOnPlugins($aPlugins, 'foo');
     $this->assertEqual(count($oTestErrorHandler->aErrors), 1);
     $this->assertEqual($oTestErrorHandler->aErrors[0]->message, 'Bad argument: Not an array of plugins.');
     $this->assertFalse($result);
     $oTestErrorHandler->reset();
     // Prepare an array of plugins
     $aPlugins = MAX_Plugin::getPlugins('reports', 'standard', true, 0);
     // Test with a bad method
     $result = MAX_Plugin::callOnPlugins($aPlugins, 'foo');
     $this->assertEqual(count($oTestErrorHandler->aErrors), 1);
     $this->assertEqual($oTestErrorHandler->aErrors[0]->message, "Method 'foo()' not defined in class 'Plugins_Reports_Standard_AdvertisingAnalysisReport'.");
     $this->assertFalse($result);
     $oTestErrorHandler->reset();
     // Unset the error handler
     PEAR::popErrorHandling();
     // Test with a real method, no parameters
     $result = MAX_Plugin::callOnPlugins($aPlugins, 'getDefaults');
     foreach ($aPlugins as $key => $oPlugin) {
         if (is_a($oPlugin, 'Plugins_Reports_Standard_LiveCampaignDeliveryReport')) {
             $this->assertTrue(is_array($result[$key]));
             $this->assertEqual(count($result[$key]), 2);
         } else {
             $this->assertTrue(is_array($result[$key]));
             $this->assertEqual(count($result[$key]), 3);
         }
     }
     // Test with a real method, with parameters
     $result = MAX_Plugin::callOnPlugins($aPlugins, 'useReportWriter', array('foo'));
     foreach ($aPlugins as $key => $oPlugin) {
         $this->assertNull($result[$key]);
     }
 }