Пример #1
0
 /**
  * Handle all necessary operations when new agency is created
  *
  * @see DB_DataObject::insert()
  */
 function insert()
 {
     // Create account first
     $result = $this->createAccount(OA_ACCOUNT_MANAGER, $this->name);
     if (!$result) {
         return $result;
     }
     // Store data to create a user
     if (!empty($this->username) && !empty($this->password)) {
         $aUser = array('contact_name' => $this->contact, 'email_address' => $this->email, 'username' => $this->username, 'password' => $this->password, 'default_account_id' => $this->account_id);
     }
     $agencyid = parent::insert();
     if (!$agencyid) {
         return $agencyid;
     }
     // Create user if needed
     // Is this even required anymore?
     if (!empty($aUser)) {
         $this->createUser($aUser);
     }
     // Execute any components which have registered at the afterAgencyCreate hook
     $aPlugins = OX_Component::getListOfRegisteredComponentsForHook('afterAgencyCreate');
     foreach ($aPlugins as $i => $id) {
         if ($obj = OX_Component::factoryByComponentIdentifier($id)) {
             $obj->afterAgencyCreate($agencyid);
         }
     }
     return $agencyid;
 }
Пример #2
0
 /**
  * The constructor method.
  */
 function OA_Maintenance_Priority_AdServer()
 {
     $this->aComponents = OX_Component::getListOfRegisteredComponentsForHook('addMaintenancePriorityTask');
     // addMaintenancePriorityTask hook
     if (!empty($this->aComponents) && is_array($this->aComponents)) {
         foreach ($this->aComponents as $componentId) {
             if ($obj = OX_Component::factoryByComponentIdentifier($componentId)) {
                 $obj->beforeMpe();
             }
         }
     }
     // Create the task runner object, for running the MPE tasks
     $this->oTaskRunner = new OA_Task_Runner();
     // Add a task to update the zone impression forecasts
     $oForecastZoneImpressions = new OA_Maintenance_Priority_AdServer_Task_ForecastZoneImpressions();
     $this->oTaskRunner->addTask($oForecastZoneImpressions);
     // Add tasks to get the required ad impressions
     $oGetRequiredAdImpressionsLifetime = new OA_Maintenance_Priority_AdServer_Task_GetRequiredAdImpressionsLifetime();
     $this->oTaskRunner->addTask($oGetRequiredAdImpressionsLifetime);
     $oGetRequiredAdImpressionsDaily = new OA_Maintenance_Priority_AdServer_Task_GetRequiredAdImpressionsDaily();
     $this->oTaskRunner->addTask($oGetRequiredAdImpressionsDaily);
     // Add a task to allocate the ad impressions to zones
     $oAllocateZoneImpressions = new OA_Maintenance_Priority_AdServer_Task_AllocateZoneImpressions();
     $this->oTaskRunner->addTask($oAllocateZoneImpressions);
     // Add a task to compensate & save the priority values
     $oPriorityCompensation = new OA_Maintenance_Priority_AdServer_Task_PriorityCompensation();
     $this->oTaskRunner->addTask($oPriorityCompensation);
     // Add a task to update priority values for eCPM Contract campaigns
     $oPriorityEcpmContract = new OA_Maintenance_Priority_AdServer_Task_ECPMforContract();
     $this->oTaskRunner->addTask($oPriorityEcpmContract);
     // Add a task to update priority values for eCPM Remnant campaigns
     $oPriorityEcpmRemnant = new OA_Maintenance_Priority_AdServer_Task_ECPMforRemnant();
     $this->oTaskRunner->addTask($oPriorityEcpmRemnant);
     // addMaintenancePriorityTask hook
     if (!empty($this->aComponents) && is_array($this->aComponents)) {
         foreach ($this->aComponents as $componentId) {
             if ($obj = OX_Component::factoryByComponentIdentifier($componentId)) {
                 $this->oTaskRunner->addTask($obj->addMaintenancePriorityTask(), $obj->getExistingClassName(), $obj->getOrder());
             }
         }
     }
 }
Пример #3
0
 function test_getListOfRegisteredComponentsForHook()
 {
     $GLOBALS['_MAX']['CONF']['pluginPaths']['packages'] = '/lib/OX/Plugin/tests/data/plugins/etc/';
     $GLOBALS['_MAX']['CONF']['pluginPaths']['admin'] = '/lib/OX/Plugin/tests/data/www/admin/plugins/';
     $GLOBALS['_MAX']['CONF']['plugins'] = array('testPluginPackage' => 1);
     $GLOBALS['_MAX']['CONF']['pluginGroupComponents'] = array('testPlugin' => 1);
     require_once LIB_PATH . '/Extension/ExtensionCommon.php';
     //generate test cache
     $oExtension = new OX_Extension_Common();
     $oExtension->cacheComponentHooks();
     $aHooks = OX_Component::getListOfRegisteredComponentsForHook('duringTest');
     $this->assertIsA($aHooks, 'array');
     $this->assertEqual(count($aHooks), 1);
     $this->assertEqual($aHooks[0], 'admin:testPlugin:testPlugin');
     //remove cache
     unset($GLOBALS['_MAX']['ComponentHooks']);
     $oCache = new OA_Cache('Plugins', 'ComponentHooks');
     $oCache->setFileNameProtection(false);
     $oCache->clear();
     //should auto regenerate cache
     $aHooks = OX_Component::getListOfRegisteredComponentsForHook('duringTest');
     $this->assertIsA($aHooks, 'array');
     $this->assertEqual(count($aHooks), 1);
     $this->assertEqual($aHooks[0], 'admin:testPlugin:testPlugin');
     //cache file should be regenerated
     $aAllHooks = $oCache->load();
     $this->assertEqual($aHooks, $aAllHooks['duringTest']);
     TestEnv::restoreConfig();
     $oCache->clear();
 }
 public function finishAction()
 {
     $oWizard = new OX_Admin_UI_Install_Wizard($this->getInstallStatus());
     $this->setCurrentStepIfReachable($oWizard, 'finish');
     $oUpgrader = $this->getUpgrader();
     $isUpgrade = $this->getInstallStatus()->isUpgrade();
     //finalize - mark OpenX as installed, clear files etc.
     $this->finalizeInstallation();
     $oStorage = OX_Admin_UI_Install_InstallUtils::getSessionStorage();
     //collect only job statuses with errors
     $aJobStatuses = $oStorage->get('aJobStatuses');
     $aStatuses = array();
     if ($aJobStatuses) {
         foreach ($aJobStatuses as $jobId => $aJobStatus) {
             //check session for job statuses
             if (!empty($aJobStatus['errors'])) {
                 $aStatuses[$jobId] = $aJobStatus;
             }
         }
     }
     $oRequest = $this->getRequest();
     if ($oRequest->isPost()) {
         $this->resetInstaller();
         global $installerIsUpgrade;
         $installerIsUpgrade = $isUpgrade;
         // Execute any components which have registered at the afterLogin hook
         $aPlugins = OX_Component::getListOfRegisteredComponentsForHook('afterLogin');
         foreach ($aPlugins as $i => $id) {
             if ($obj = OX_Component::factoryByComponentIdentifier($id)) {
                 $obj->afterLogin();
             }
         }
         require_once LIB_PATH . '/Admin/Redirect.php';
         OX_Admin_Redirect::redirect('advertiser-index.php');
     }
     $logPath = str_replace('/', DIRECTORY_SEPARATOR, $oUpgrader->getLogFileName());
     $this->setModelProperty('logPath', $logPath);
     $this->setModelProperty('oWizard', $oWizard);
     $this->setModelProperty('aStatuses', $aStatuses);
     $this->setModelProperty('isUpgrade', $isUpgrade);
 }
Пример #5
0
 /**
  * The method to run the Maintenance Statistics Engine process.
  *
  * @static
  */
 function run()
 {
     OA::switchLogIdent('maintenance');
     // Get the configuration
     $aConf = $GLOBALS['_MAX']['CONF'];
     // Log the start of the process
     OA::debug('Running Maintenance Statistics Engine', PEAR_LOG_INFO);
     // Set longer time out, and ignore user abort
     if (!ini_get('safe_mode')) {
         @set_time_limit($aConf['maintenance']['timeLimitScripts']);
         @ignore_user_abort(true);
     }
     // Run the following code as the "Maintenance" user
     OA_Permission::switchToSystemProcessUser('Maintenance');
     // Ensure the the current time is registered with the OA_ServiceLocator
     $oServiceLocator =& OA_ServiceLocator::instance();
     $oDate =& $oServiceLocator->get('now');
     if (!$oDate) {
         // Record the current time, and register with the OA_ServiceLocator
         $oDate = new Date();
         $oServiceLocator->register('now', $oDate);
     }
     $this->aComponents = OX_Component::getListOfRegisteredComponentsForHook('addMaintenanceStatisticsTask');
     // addMaintenanceStatisticsTask hook
     if (!empty($this->aComponents) && is_array($this->aComponents)) {
         foreach ($this->aComponents as $componentId) {
             if ($obj = OX_Component::factoryByComponentIdentifier($componentId)) {
                 $obj->beforeMse();
             }
         }
     }
     // Initialise the task runner object, for storing/running the tasks
     $this->oTaskRunner = new OA_Task_Runner();
     // Register this object as the controlling class for the process,
     // so that tasks run by the task runner can locate this class to
     // update the report, etc.
     $oServiceLocator =& OA_ServiceLocator::instance();
     $oServiceLocator->register('Maintenance_Statistics_Controller', $this);
     // Create and register an instance of the OA_Dal_Maintenance_Statistics DAL
     // class for the following tasks to use
     if (!$oServiceLocator->get('OX_Dal_Maintenance_Statistics')) {
         $oFactory = new OX_Dal_Maintenance_Statistics_Factory();
         $oDal = $oFactory->factory();
         $oServiceLocator->register('OX_Dal_Maintenance_Statistics', $oDal);
     }
     // Add the task to set the update requirements
     $oSetUpdateRequirements = new OX_Maintenance_Statistics_Task_SetUpdateRequirements();
     $this->oTaskRunner->addTask($oSetUpdateRequirements);
     // Add the task to migrate the bucket data into the statistics tables
     $oSummariseIntermediate = new OX_Maintenance_Statistics_Task_MigrateBucketData();
     $this->oTaskRunner->addTask($oSummariseIntermediate);
     // Add the task to handle the de-duplication and rejection of empty conversions
     $oDeDuplicateConversions = new OX_Maintenance_Statistics_Task_DeDuplicateConversions();
     $this->oTaskRunner->addTask($oDeDuplicateConversions);
     // Add the task to handle the updating of "intermediate" statistics with
     // conversion information, as a legacy issue until all code obtains
     // conversion data from the standard conversion statistics tables
     $oManageConversions = new OX_Maintenance_Statistics_Task_ManageConversions();
     $this->oTaskRunner->addTask($oManageConversions);
     // Add the task to summarise the intermediate statistics into final form
     $oSummariseFinal = new OX_Maintenance_Statistics_Task_SummariseFinal();
     $this->oTaskRunner->addTask($oSummariseFinal);
     // Add the task to log the completion of the task
     $oLogCompletion = new OX_Maintenance_Statistics_Task_LogCompletion();
     $this->oTaskRunner->addTask($oLogCompletion);
     // Add the task to manage (enable/disable) campaigns
     $oManageCampaigns = new OX_Maintenance_Statistics_Task_ManageCampaigns();
     $this->oTaskRunner->addTask($oManageCampaigns);
     // addMaintenanceStatisticsTask hook
     if (!empty($this->aComponents) && is_array($this->aComponents)) {
         foreach ($this->aComponents as $componentId) {
             if ($obj = OX_Component::factoryByComponentIdentifier($componentId)) {
                 $this->oTaskRunner->addTask($obj->addMaintenanceStatisticsTask(), $obj->getExistingClassName(), $obj->getOrder());
             }
         }
     }
     // Run the MSE process tasks
     $this->oTaskRunner->runTasks();
     // addMaintenanceStatisticsTask hook
     if (!empty($this->aComponents) && is_array($this->aComponents)) {
         foreach ($this->aComponents as $componentId) {
             if ($obj = OX_Component::factoryByComponentIdentifier($componentId)) {
                 $obj->afterMse();
             }
         }
     }
     // Return to the "normal" user
     OA_Permission::switchToSystemProcessUser();
     // Log the end of the process
     OA::debug('Maintenance Statistics Engine Completed (Started at ' . $oDate->format('%Y-%m-%d %H:%M:%S') . ' ' . $oDate->tz->getShortName() . ')', PEAR_LOG_INFO);
     OA::switchLogIdent();
 }
Пример #6
0
 private static function callAccessHook($entityTable, $entityId, $operationAccessType = self::OPERATION_ALL, $accountId = null, $accountType = null)
 {
     static $componentCache;
     /*
      * Normally we would expect plugins to return true or false here.
      * Problem arises if plugins create own entities which they protect
      * and what should happen when such plugin is disabled and entities remain.
      *
      * Solution used here is that plugin should return true/false only for entities
      * it's interested in and NULL for entities that it is ignoring.
      *
      * If, after asking all plugins, result is NULL, that means there's no plugin
      * active for such entity and if it's type is different from DEFAULT_SYSTEM it should
      * be protected.
      */
     $hasAccess = NULL;
     //ignore by default
     $aPlugins = OX_Component::getListOfRegisteredComponentsForHook('objectAccess');
     foreach ($aPlugins as $i => $id) {
         $obj = $componentCache[$id];
         if (!isset($obj)) {
             $obj = OX_Component::factoryByComponentIdentifier($id);
             $componentCache[$id] = $obj;
         }
         if ($obj) {
             $pluginResult = $obj->hasAccessToObject($entityTable, $entityId, $operationAccessType, $accountId, $accountType);
             /*
              * Ignore NULL responses from plugins and update has access only
              * if plugin was interested in the entity
              */
             $hasAccess = $pluginResult === NULL ? $hasAccess : $pluginResult;
             if ($hasAccess === false) {
                 //break on first plugin denying access
                 break;
             }
         }
     }
     //securing non-system entities if no plugin responsible found
     if ($hasAccess === NULL && !empty($entityId) && ('clients' == $entityTable || 'campaigns' == $entityTable || 'banners' == $entityTable)) {
         $do = OA_Dal::factoryDO($entityTable);
         $aEntity = null;
         if ($do->get($entityId)) {
             $aEntity = $do->toArray();
         }
         switch ($entityTable) {
             case 'clients':
                 $hasAccess = $aEntity['type'] == DataObjects_Clients::ADVERTISER_TYPE_DEFAULT;
                 break;
             case 'campaigns':
                 $hasAccess = $aEntity['type'] == DataObjects_Campaigns::CAMPAIGN_TYPE_DEFAULT;
                 break;
             case 'banners':
                 $hasAccess = $aEntity['ext_bannertype'] != DataObjects_Banners::BANNER_TYPE_MARKET;
                 break;
         }
     }
     return $hasAccess === NULL ? true : $hasAccess;
 }
Пример #7
0
 private static function init()
 {
     if (self::$initialized) {
         return;
     }
     //register UI listeners from plugins
     $aPlugins = OX_Component::getListOfRegisteredComponentsForHook('registerUiListeners');
     foreach ($aPlugins as $i => $id) {
         if ($obj = OX_Component::factoryByComponentIdentifier($id)) {
             if (is_callable(array($obj, 'registerUiListeners'))) {
                 $obj->registerUiListeners();
             }
         }
     }
     self::$initialized = true;
 }
Пример #8
0
/**
 * Starts or continue existing session
 *
 * @param unknown_type $checkRedirectFunc
 */
function OA_Start($checkRedirectFunc = null)
{
    $conf = $GLOBALS['_MAX']['CONF'];
    global $session;
    // XXX: Why not try loading session data when OpenX is not installed?
    //if ($conf['openads']['installed'])
    if (OA_INSTALLATION_STATUS == OA_INSTALLATION_STATUS_INSTALLED) {
        phpAds_SessionDataFetch();
    }
    if (!OA_Auth::isLoggedIn() || OA_Auth::suppliedCredentials()) {
        // Required files
        include_once MAX_PATH . '/lib/max/language/Loader.php';
        // Load the required language files
        Language_Loader::load('default');
        phpAds_SessionDataRegister(OA_Auth::login($checkRedirectFunc));
        $aPlugins = OX_Component::getListOfRegisteredComponentsForHook('afterLogin');
        foreach ($aPlugins as $i => $id) {
            if ($obj = OX_Component::factoryByComponentIdentifier($id)) {
                $obj->afterLogin();
            }
        }
    }
    // Overwrite certain preset preferences
    if (!empty($session['language']) && $session['language'] != $GLOBALS['pref']['language']) {
        $GLOBALS['_MAX']['CONF']['max']['language'] = $session['language'];
    }
    // Check if manual account switch has happened and migrate to new global variable
    if (isset($session['accountSwitch'])) {
        $GLOBALS['_OX']['accountSwtich'] = $session['accountSwitch'];
        unset($session['accountSwitch']);
        phpAds_SessionDataStore();
    }
}
Пример #9
0
/**
 * Starts or continue existing session
 *
 * @param unknown_type $checkRedirectFunc
 */
function OA_Start($checkRedirectFunc = null)
{
    $conf = $GLOBALS['_MAX']['CONF'];
    global $session;
    // Send no cache headers
    MAX_header('Pragma: no-cache');
    MAX_header('Cache-Control: no-cache, no-store, must-revalidate');
    MAX_header('Expires: 0');
    if (RV_INSTALLATION_STATUS == RV_INSTALLATION_STATUS_INSTALLED) {
        phpAds_SessionDataFetch();
    }
    if (!OA_Auth::isLoggedIn() || OA_Auth::suppliedCredentials()) {
        // Required files
        include_once MAX_PATH . '/lib/max/language/Loader.php';
        // Load the required language files
        Language_Loader::load('default');
        phpAds_SessionDataRegister(OA_Auth::login($checkRedirectFunc));
        $aPlugins = OX_Component::getListOfRegisteredComponentsForHook('afterLogin');
        foreach ($aPlugins as $i => $id) {
            if ($obj = OX_Component::factoryByComponentIdentifier($id)) {
                $obj->afterLogin();
            }
        }
    }
    // Overwrite certain preset preferences
    if (!empty($session['language']) && $session['language'] != $GLOBALS['pref']['language']) {
        $GLOBALS['_MAX']['CONF']['max']['language'] = $session['language'];
    }
    // Check if manual account switch has happened and migrate to new global variable
    if (isset($session['accountSwitch'])) {
        $GLOBALS['_OX']['accountSwtich'] = $session['accountSwitch'];
        unset($session['accountSwitch']);
        phpAds_SessionDataStore();
    }
}
Пример #10
0
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
if ($action == OA_UPGRADE_FINISH) {
    OA_Upgrade_Login::autoLogin();
    // Execute any components which have registered at the afterLogin hook
    $aPlugins = OX_Component::getListOfRegisteredComponentsForHook('afterLogin');
    foreach ($aPlugins as $i => $id) {
        if ($obj = OX_Component::factoryByComponentIdentifier($id)) {
            $obj->afterLogin();
        }
    }
    // Delete the cookie
    setcookie('oat', '');
    $oUpgrader->setOpenadsInstalledOn();
    if (!$oUpgrader->removeUpgradeTriggerFile()) {
        $message .= '. ' . $strRemoveUpgradeFile;
        $strInstallSuccess = '<div class="sysinfoerror">' . $strOaUpToDateCantRemove . '</div>' . $strInstallSuccess;
    }
}
if ($installStatus == OA_STATUS_OAD_NOT_INSTALLED) {
    setcookie('oat', OA_UPGRADE_INSTALL);