public function beforePageHeader(OX_Admin_UI_Event_EventContext $oEventContext)
 {
     $pageId = $oEventContext->data['pageId'];
     $pageData = $oEventContext->data['pageData'];
     $oHeaderModel = $oEventContext->data['headerModel'];
     $agencyId = $pageData['agencyid'];
     $campaignId = $pageData['campaignid'];
     $advertiserId = $pageData['clientid'];
     $oEntityHelper = $this->oMarkedTextAdvertiserComponent->getEntityHelper();
     if (OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER)) {
         switch ($pageId) {
             case 'campaign-banners':
                 $oDalZones = OA_Dal::factoryDAL('zones');
                 $linkedWebsites = $oDalZones->getWebsitesAndZonesListByCategory($agencyId, null, $campaignId, true);
                 $arraylinkedWebsitesKeys = array_keys($linkedWebsites);
                 $linkedWebsitesKey = $arraylinkedWebsitesKeys[0];
                 $arraylinkedZonesKeys = array_keys($linkedWebsites[$linkedWebsitesKey]['zones']);
                 $zoneId = $arraylinkedZonesKeys[0];
                 $aZone = Admin_DA::getZone($zoneId);
                 if ($aZone['type'] == 3) {
                     if (OA_Permission::hasAccessToObject('clients', $clientid) && OA_Permission::hasAccessToObject('campaigns', $campaignid)) {
                         OX_Admin_Redirect::redirect('plugins/' . $this->oMarkedTextAdvertiserComponent->group . "/oxMarkedTextAdvertiser-index.php?campaignid={$campaignId}&clientid={$advertiserId}");
                     }
                 }
                 break;
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Tests the timestamps are updated correctly.
  * 
  * Test 1: Tests the current timestamp is inserted for a new image.
  * Test 2: Tests the timestamp is updated when an image is updated.
  *
  */
 function testUpdate()
 {
     // Test 1
     // Get the start time of the test
     $start = time();
     sleep(1);
     // Insert an image
     $doImages = OA_Dal::factoryDO('images');
     $doImages->filename = 'foo.jpg';
     $doImages->contents = '';
     DataGenerator::generateOne($doImages);
     // Get the image out of the DB
     $doImages = OA_Dal::staticGetDO('images', 'filename', 'foo.jpg');
     // Check the timestamp is > time at start of test and <= current time
     // Deal with MySQL 4.0 timestamps
     if (preg_match('/^(\\d\\d\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)$/', $doImages->t_stamp, $m)) {
         $doImages->t_stamp = "{$m[1]}-{$m[2]}-{$m[3]} {$m[4]}:{$m[5]}:{$m[6]}";
     }
     $actual = strtotime($doImages->t_stamp);
     $this->assertTrue($actual > $start && $actual <= time());
     // Test 2
     // Update the image
     $doImages->contents = '1';
     sleep(1);
     $doImages->update();
     // Get the image out of the DB
     $doImages = OA_Dal::staticGetDO('images', 'filename', 'foo.jpg');
     $oldTime = $actual;
     // Deal with MySQL 4.0 timestamps
     if (preg_match('/^(\\d\\d\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)$/', $doImages->t_stamp, $m)) {
         $doImages->t_stamp = "{$m[1]}-{$m[2]}-{$m[3]} {$m[4]}:{$m[5]}:{$m[6]}";
     }
     $actual = strtotime($doImages->t_stamp);
     $this->assertTrue($actual > $oldTime && $actual <= time());
 }
 function testGetPublishersByTracker()
 {
     $campaignId = 1;
     // Add a couple of campaign_trackers
     $doCampaignsTrackers = OA_Dal::factoryDO('campaigns_trackers');
     $doCampaignsTrackers->campaignid = $campaignId;
     $doCampaignsTrackers->trackerid = 1;
     $aCampaignTrackerId = DataGenerator::generate($doCampaignsTrackers, 2);
     $doBanners = OA_Dal::factoryDO('banners');
     $doBanners->campaignid = $campaignId;
     $doBanners->acls_updated = '2007-04-03 18:39:45';
     $bannerId = DataGenerator::generateOne($doBanners, true);
     // Add a couple of affiliates
     $aAffiliateId = DataGenerator::generate('affiliates', 2);
     $doZones = OA_Dal::factoryDO('zones');
     $doZones->affiliateid = $aAffiliateId[0];
     $zoneId = DataGenerator::generateOne($doZones);
     $doAddZoneAssoc = OA_Dal::factoryDO('ad_zone_assoc');
     $doAddZoneAssoc->zone_id = $zoneId;
     $doAddZoneAssoc->ad_id = $BannerId;
     $adZoneAssocId = DataGenerator::generateOne($doAddZoneAssoc);
     // Test the correct number of rows is returned.
     $expectedRows = 1;
     $rsAffiliates = $this->dalAffiliates->getPublishersByTracker($aCampaignTrackerId[0]);
     $rsAffiliates->find();
     $actualRows = $rsAffiliates->getRowCount();
     $this->assertEqual($actualRows, $expectedRows);
 }
Ejemplo n.º 4
0
 /**
  * Class constructor
  *
  * @param string $accountId If null, the current account ID is used
  * @param string $accountType If null, the current account type is used
  * @return OA_Central_M2M
  */
 function OA_Central_M2M($accountId = null)
 {
     parent::OA_Central_Common();
     $currentId = OA_Permission::getAccountId();
     if (is_null($accountId)) {
         $this->accountId = $currentId;
     } else {
         $this->accountId = $accountId;
     }
     if ($this->accountId == $currentId) {
         $this->accountType = OA_Permission::getAccountType();
     } else {
         $doAccounts = OA_Dal::factoryDO('accounts');
         $doAccounts->account_id = $this->accountId;
         $doAccounts->find();
         if ($doAccounts->fetch()) {
             $this->accountType = $doAccounts->account_type;
         } else {
             Max::raiseError('Unexisting account ID', null, PEAR_ERROR_DIE);
         }
     }
     if ($this->accountType == OA_ACCOUNT_ADMIN) {
         $this->accountId = 0;
     }
 }
Ejemplo n.º 5
0
/**
 * This function iterates over the table fields, and either gathers data which would be changed, or changes the data
 *
 * @param array $aTableFields
 * @return array
 */
function _iterateTableFields($aTableFields, $execute = false)
{
    $aChanged = array();
    $encTo = !empty($_POST['encTo']) ? $_POST['encTo'] : 'UTF-8';
    $encFrom = !empty($_POST['encFrom']) ? $_POST['encFrom'] : 'UTF-8';
    foreach ($aTableFields as $table => $tableData) {
        $doTable = OA_Dal::factoryDO($table);
        $doTable->find();
        while ($doTable->fetch()) {
            $changed = false;
            foreach ($tableData['fields'] as $field) {
                $converted = MAX_commonConvertEncoding($doTable->{$field}, $encTo, $encFrom);
                if ($converted === $doTable->{$field}) {
                    continue;
                }
                $id = array();
                foreach ($tableData['idfields'] as $idField) {
                    $id[$idField] = $doTable->{$idField};
                }
                if ($execute && !in_array(implode('.', $id), $_POST['aExecute'][$table][$field])) {
                    continue;
                }
                $aChanged[$table][$field][] = array('from' => $doTable->{$field}, 'to' => $converted, 'id' => $id);
                $doTable->{$field} = $converted;
                $changed = true;
            }
            if ($changed && $execute) {
                $doTable->update();
            }
        }
    }
    return $aChanged;
}
Ejemplo n.º 6
0
 function &staticGetApi($createDefaultManager = true)
 {
     $oApi =& $GLOBALS['_STATIC']['staticGetApi'];
     if (empty($oApi)) {
         $doAccounts = OA_Dal::factoryDO('accounts');
         $doAccounts->account_type = OA_ACCOUNT_ADMIN;
         $adminAccountId = DataGenerator::generateOne($doAccounts);
         if ($createDefaultManager) {
             $doAgency = OA_Dal::factoryDO('agency');
             $doAgency->name = 'Default Manager';
             $agencyId = DataGenerator::generateOne($doAgency);
             $doAgency = OA_Dal::staticGetDO('agency', $agencyId);
             $managerAccountId = $doAgency->account_id;
         }
         $doUsers = OA_Dal::factoryDO('users');
         $doUsers->username = '******' . md5(uniqid('', true));
         $doUsers->password = md5('secret');
         $doUsers->default_account_id = $createDefaultManager ? $managerAccountId : $adminAccountId;
         $userId = DataGenerator::generateOne($doUsers);
         $doAUA = OA_Dal::factoryDO('account_user_assoc');
         $doAUA->account_id = $adminAccountId;
         $doAUA->user_id = $userId;
         DataGenerator::generateOne($doAUA);
         $oApi = new Mocked_OA_Api_Xmlrpc($doUsers->username, 'secret');
     }
     return $oApi;
 }
Ejemplo n.º 7
0
 function testUpdateWhereOne()
 {
     $this->initTables(array('campaigns', 'trackers'));
     $doCampaigns = OA_Dal::factoryDO('campaigns');
     $doCampaigns->campaignname = 'First';
     $doCampaigns->views = 10;
     $campaignId1 = DataGenerator::generateOne($doCampaigns);
     $doCampaigns = OA_Dal::factoryDO('campaigns');
     $doCampaigns->campaignname = 'Third';
     $doCampaigns->views = 30;
     $campaignId2 = DataGenerator::generateOne($doCampaigns);
     $doCampaigns = OA_Dal::factoryDO('campaigns');
     $doCampaigns->campaignname = 'Fifth';
     $doCampaigns->views = 50;
     $campaignId3 = DataGenerator::generateOne($doCampaigns);
     $cUpdated = OA_DB_Sql::updateWhereOne('campaigns', 'campaignid', $campaignId2, array('campaignname' => 'Second', 'views' => 20));
     $this->assertEqual(1, $cUpdated);
     $doCampaigns = OA_Dal::staticGetDO('campaigns', $campaignId2);
     $this->assertEqual('Second', $doCampaigns->campaignname);
     $this->assertEqual(20, $doCampaigns->views);
     $doCampaigns = OA_Dal::staticGetDO('campaigns', $campaignId1);
     $this->assertEqual('First', $doCampaigns->campaignname);
     $this->assertEqual('10', $doCampaigns->views);
     $aConf = $GLOBALS['_MAX']['CONF'];
     $this->oaTable->dropTable($aConf['table']['prefix'] . 'campaigns');
     $this->oaTable->dropTable($aConf['table']['prefix'] . 'trackers');
 }
 function defaultData()
 {
     $oManager = new OX_Plugin_ComponentGroupManager();
     if (!array_key_exists('testPlugin', $GLOBALS['_MAX']['CONF']['pluginGroupComponents'])) {
         $oManager->disableComponentGroup('testPlugin');
     }
     $this->oManager->enableComponentGroup('testPlugin');
     $oTestPluginTable = OA_Dal::factoryDO('testplugin_table');
     if (!$oTestPluginTable) {
         OA::debug('Failed to instantiate DataObject for testplugin_table');
         return false;
     }
     $oTestPluginTable->myplugin_desc = 'Hello World';
     $aSettings[0]['data'] = $oTestPluginTable->insert();
     $aSettings[0]['section'] = 'myPlugin';
     $aSettings[0]['key'] = 'english';
     $oTestPluginTable->myplugin_desc = 'Hola Mundo';
     $aSettings[1]['data'] = $oTestPluginTable->insert();
     $aSettings[1]['section'] = 'myPlugin';
     $aSettings[1]['key'] = 'spanish';
     $oTestPluginTable->myplugin_desc = 'Look Simon, you\'re just making it up now';
     $aSettings[2]['data'] = $oTestPluginTable->insert();
     $aSettings[2]['section'] = 'myPlugin';
     $aSettings[2]['key'] = 'russian';
     $oManager->_registerSettings($aSettings);
     $oManager->disableComponentGroup('testPlugin');
     return true;
 }
Ejemplo n.º 9
0
function processBanners($commit = false)
{
    $doBanners = OA_Dal::factoryDO('banners');
    if (OA_INSTALLATION_STATUS === OA_INSTALLATION_STATUS_INSTALLED && OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
        $doBanners->addReferenceFilter('agency', $agencyId = OA_Permission::getEntityId());
    }
    $doBanners->find();
    $different = 0;
    $same = 0;
    $errors = array();
    while ($doBanners->fetch()) {
        // Rebuild filename
        if ($doBanners->storagetype == 'sql' || $doBanners->storagetype == 'web') {
            $doBanners->imageurl = '';
        }
        $GLOBALS['_MAX']['bannerrebuild']['errors'] = false;
        if ($commit) {
            $doBannersClone = clone $doBanners;
            $doBannersClone->update();
            $newCache = $doBannersClone->htmlcache;
        } else {
            $newCache = phpAds_getBannerCache($doBanners->toArray());
        }
        if (empty($GLOBALS['_MAX']['bannerrebuild']['errors'])) {
            if ($doBanners->htmlcache != $newCache && $doBanners->storagetype == 'html') {
                $different++;
            } else {
                $same++;
            }
        } else {
            $errors[] = $doBanners->toArray();
        }
    }
    return array('errors' => $errors, 'different' => $different, 'same' => $same);
}
 function testExecute()
 {
     Mock::generatePartial('OA_UpgradeLogger', $mockLogger = 'OA_UpgradeLogger' . rand(), array('logOnly', 'logError', 'log'));
     $oLogger = new $mockLogger($this);
     $oLogger->setReturnValue('logOnly', true);
     $oLogger->setReturnValue('logError', true);
     $oLogger->setReturnValue('log', true);
     Mock::generatePartial('OA_Upgrade', $mockUpgrade = 'OA_Upgrade' . rand(), array('addPostUpgradeTask'));
     $mockUpgrade = new $mockUpgrade($this);
     $mockUpgrade->setReturnValue('addPostUpgradeTask', true);
     $mockUpgrade->oLogger = $oLogger;
     $mockUpgrade->oDBUpgrader = new OA_DB_Upgrade($oLogger);
     $mockUpgrade->oDBUpgrader->oTable =& $this->oaTable;
     // Run the upgrade
     $postscript = new OA_UpgradePostscript_2_7_30_beta_rc5();
     $ret = $postscript->execute(array(&$mockUpgrade));
     $this->assertTrue($ret);
     // Get the preference that we have inserted
     $doPreferences = OA_Dal::factoryDO('preferences');
     $doPreferences->preference_name = 'campaign_ecpm_enabled';
     $doPreferences->account_type = 'MANAGER';
     $doPreferences->find();
     $numberPreferences = $doPreferences->getRowCount();
     $this->assertEqual(1, $numberPreferences);
 }
Ejemplo n.º 11
0
 /**
  * A mathod to quickly check the data in the database for the date
  * range given, to ensure that the range being tested & corrected
  * seems reasonable.
  *
  * @param Date $oStartDate The start date/time of the range to test & correct.
  * @param Date $oEndDate   The end date/time of the range to test & correct.
  * @return boolean True if the date range seems okay, false otherwise.
  */
 function checkRangeData($oStartDate, $oEndDate)
 {
     // Test that there are no rows in the data_intermediate_ad table where the
     // operation interval value does not match that in the configuration file
     $doData_intermediate_ad = OA_Dal::factoryDO('data_intermediate_ad');
     $doData_intermediate_ad->whereAdd('date_time >= ' . $this->oDbh->quote($oStartDate->format('%Y-%m-%d %H:%M:%S'), 'timestamp'));
     $doData_intermediate_ad->whereAdd('date_time <= ' . $this->oDbh->quote($oEndDate->format('%Y-%m-%d %H:%M:%S'), 'timestamp'));
     $doData_intermediate_ad->whereAdd('operation_interval != ' . $this->oDbh->quote(OX_OperationInterval::getOperationInterval(), 'integer'));
     $doData_intermediate_ad->find();
     $rows = $doData_intermediate_ad->getRowCount();
     if ($rows > 0) {
         $message = "\n    Detected at least one row in the data_intermediate_ad table with operation interval != " . OX_OperationInterval::getOperationInterval() . ".\n";
         echo $message;
         return false;
     }
     // Test that all of the date/time values in the data_summary_ad_hourly
     // table align with the start of operation intervals
     $doData_summary_ad_hourly = OA_Dal::factoryDO('data_summary_ad_hourly');
     $doData_summary_ad_hourly->selectAdd();
     $doData_summary_ad_hourly->selectAdd('DISTINCT date_time');
     $doData_summary_ad_hourly->whereAdd('date_time >= ' . $this->oDbh->quote($oStartDate->format('%Y-%m-%d %H:%M:%S'), 'timestamp'));
     $doData_summary_ad_hourly->whereAdd('date_time <= ' . $this->oDbh->quote($oEndDate->format('%Y-%m-%d %H:%M:%S'), 'timestamp'));
     $doData_summary_ad_hourly->find();
     while ($doData_summary_ad_hourly->fetch()) {
         $oDate = new Date($doData_summary_ad_hourly->date_time);
         $result = OX_OperationInterval::checkDateIsStartDate($oDate);
         if (!$result) {
             $message = "\n    Detected at least one row in the data_summary_ad_hourly table with date_time value not on the hour start interval.\n";
             echo $message;
             return false;
         }
     }
     return true;
 }
 function addAdZoneAssoc($adId, $zoneId, $priority)
 {
     $doAd_zone_assoc = OA_Dal::factoryDO('ad_zone_assoc');
     $doAd_zone_assoc->ad_id = $adId;
     $doAd_zone_assoc->zone_id = $zoneId;
     $doAd_zone_assoc->priority = $priority;
     DataGenerator::generateOne($doAd_zone_assoc);
 }
Ejemplo n.º 13
0
 /**
  * A method to retrieve a list of all advertiser names. Can be limited to
  * just return the advertisers that are "owned" by an agency.
  *
  * @param string  $listorder      The column name to sort the agency names by. One of "name" or "id".
  * @param string  $orderdirection The sort oder for the sort column. One of "up" or "down".
  * @param integer $agencyId       Optional. The agency ID to limit results to.
  * @return array
  *
  * @todo Consider removing order options (or making them optional)
  */
 function getAllAdvertisers($listorder, $orderdirection, $agencyId = null)
 {
     $doClients = OA_Dal::factoryDO('clients');
     if (!empty($agencyId) && is_numeric($agencyId)) {
         $doClients->agencyid = $agencyId;
     }
     $doClients->addListOrderBy($listorder, $orderdirection);
     return $doClients->getAll(array('clientname', 'an_adnetwork_id'), $indexWitkPk = true, $flatten = false);
 }
Ejemplo n.º 14
0
 private function idExists($tableName, $id)
 {
     $doObject = OA_Dal::factoryDO($tableName);
     if (empty($id) || !($object = $doObject->get($id))) {
         return false;
     } else {
         return true;
     }
 }
 protected function getEntity($entityTable, $entityId)
 {
     $do = OA_Dal::factoryDO($entityTable);
     $aEntity = null;
     if ($do->get($entityId)) {
         $aEntity = $do->toArray();
     }
     return $aEntity;
 }
Ejemplo n.º 16
0
 function testDuplicate()
 {
     // Insert a tracker with some default data.
     $doTrackers = OA_Dal::factoryDO('trackers');
     $doTrackers->trackername = 'foo';
     $doTrackers->clientid = 1;
     $doTrackers->clickwindow = 3600;
     $doTrackers->status = 4;
     $doTrackers->type = 1;
     $trackerId = DataGenerator::generateOne($doTrackers, true);
     // Insert a variable for the tracker
     $doVariables = OA_Dal::factoryDO('variables');
     $doVariables->trackerid = $trackerId;
     $doVariables->name = 'bar';
     $variableId = DataGenerator::generateOne($doVariables);
     // Link the tracker to a campaign
     $doCampaignTrackers = OA_Dal::factoryDO('campaigns_trackers');
     $doCampaignTrackers->campaignid = 1;
     $doCampaignTrackers->trackerid = $trackerId;
     $campaignTrackerId = DataGenerator::generateOne($doCampaignTrackers);
     // Duplicate the tracker
     $doTrackers = OA_Dal::staticGetDO('trackers', $trackerId);
     $newTrackerId = $doTrackers->duplicate();
     $this->assertNotEmpty($newTrackerId);
     // Get the two trackers
     $doNewTrackers = OA_Dal::staticGetDO('trackers', $newTrackerId);
     $this->assertTrue($doNewTrackers);
     $doTrackers = OA_Dal::staticGetDO('trackers', $trackerId);
     $this->assertTrue($doTrackers);
     // Assert the trackers are not equal, excluding the primary key
     $this->assertNotEqualDataObjects($this->stripKeys($doTrackers), $this->stripKeys($doNewTrackers));
     // Assert the only difference in the trackers is their description
     $doTrackers->trackername = $doNewTrackers->trackername = null;
     $this->assertEqualDataObjects($this->stripKeys($doTrackers), $this->stripKeys($doNewTrackers));
     // Get the two variables
     $doNewVariables = OA_Dal::staticGetDO('variables', 'trackerid', $newTrackerId);
     $this->assertTrue($doNewVariables);
     $doVariables = OA_Dal::staticGetDO('variables', $variableId);
     $this->assertTrue($doVariables);
     // Assert the variables are not equal, excluding the primary key
     $this->assertNotEqualDataObjects($this->stripKeys($doVariables), $this->stripKeys($doNewVariables));
     // Assert the only difference in the variables is the trackers they are attached to
     $doVariables->trackerid = $doNewVariables->trackerid = null;
     $this->assertEqualDataObjects($this->stripKeys($doVariables), $this->stripKeys($doNewVariables));
     // Get the two campaign tracker links
     $doNewCampaignTrackers = OA_Dal::staticGetDO('campaigns_trackers', 'trackerid', $newTrackerId);
     $this->assertTrue($doNewCampaignTrackers);
     $doCampaignTrackers = OA_Dal::staticGetDO('campaigns_trackers', $campaignTrackerId);
     $this->assertTrue($doCampaignTrackers);
     // Assert the campaign trackers are not equal, excluding the primary key
     $this->assertNotEqualDataObjects($this->stripKeys($doCampaignTrackers), $this->stripKeys($doNewCampaignTrackers));
     // Assert the only difference in the campaign trackers is the trackers they are attached to
     $doCampaignTrackers->trackerid = $doNewCampaignTrackers->trackerid = null;
     $this->assertEqualDataObjects($this->stripKeys($doCampaignTrackers), $this->stripKeys($doNewCampaignTrackers));
     DataGenerator::cleanUp(array('campaigns', 'campaigns_trackers', 'trackers', 'variables'));
 }
 function getAgencyDetails($agencyId = null)
 {
     if (is_null($agencyId)) {
         $agencyId = OA_Permission::getAgencyId();
     }
     $doAgency =& OA_Dal::factoryDO('agency');
     $doAgency->get($agencyId);
     $aResult = $doAgency->toArray();
     return $aResult;
 }
 public function processCampaignForm(&$aFields)
 {
     $aConf = $GLOBALS['_MAX']['CONF'];
     $oExt_market_campaign_pref = OA_Dal::factoryDO('ext_market_campaign_pref');
     $oExt_market_campaign_pref->updateCampaignStatus($aFields['campaignid'], $aFields['mkt_is_enabled'] == 't', $aFields['floor_price']);
     // invalidate campaign-market delivery cache
     if (!function_exists('OX_cacheInvalidateGetCampaignMarketInfo')) {
         require_once MAX_PATH . $aConf['pluginPaths']['plugins'] . 'deliveryAdRender/oxMarkedTextAdvertiserDelivery/oxMarkedTextAdvertiserDelivery.delivery.php';
     }
     OX_cacheInvalidateGetCampaignMarketInfo($aFields['campaignid']);
 }
Ejemplo n.º 19
0
function OA_HeaderNavigation()
{
    global $agencyid;
    if (OA_Permission::isAccount(OA_ACCOUNT_ADMIN)) {
        phpAds_PageHeader("agency-access");
        $doAgency = OA_Dal::staticGetDO('agency', $agencyid);
        MAX_displayInventoryBreadcrumbs(array(array("name" => $doAgency->name)), "agency");
    } else {
        phpAds_PageHeader("agency-user");
    }
}
 function delete($useWhere = false, $cascadeDelete = true, $parentid = null)
 {
     // delete also all permissions linked to this account/user
     $doAccount_user_permission_assoc = OA_Dal::factoryDO('account_user_permission_assoc');
     $doAccount_user_permission_assoc->user_id = $this->user_id;
     $doAccount_user_permission_assoc->account_id = $this->account_id;
     if ($useWhere) {
         $doAccount_user_permission_assoc->_query['condition'] = $this->_query['condition'];
     }
     $doAccount_user_permission_assoc->delete($useWhere, false, $parentid);
     return parent::delete($useWhere, $cascadeDelete, $parentid);
 }
Ejemplo n.º 21
0
 /**
  * A method to retrieve a list of all advertiser names. Can be limited to
  * just return the advertisers that are "owned" by an agency.
  *
  * @param string  $listorder      The column name to sort the agency names by. One of "name" or "id".
  * @param string  $orderdirection The sort oder for the sort column. One of "up" or "down".
  * @param integer $agencyId       Optional. The agency ID to limit results to.
  * @param array $aIncludeSystemTypes an array of system types to be
  *              included apart from default advertisers
  *
  * @return array
  *
  * @todo Consider removing order options (or making them optional)
  */
 function getAllAdvertisers($listorder, $orderdirection, $agencyId = null, $aIncludeSystemTypes = array())
 {
     $aIncludeSystemTypes = array_merge(array(DataObjects_Clients::ADVERTISER_TYPE_DEFAULT), $aIncludeSystemTypes);
     $doClients = OA_Dal::factoryDO('clients');
     if (!empty($agencyId) && is_numeric($agencyId)) {
         $doClients->agencyid = $agencyId;
     }
     $doClients->whereInAdd('type', $aIncludeSystemTypes);
     $doClients->orderBy('(type=' . DataObjects_Clients::ADVERTISER_TYPE_DEFAULT . ') ASC');
     $doClients->addListOrderBy($listorder, $orderdirection);
     return $doClients->getAll(array('clientname', 'type'), $indexWitkPk = true, $flatten = false);
 }
Ejemplo n.º 22
0
 /**
  * Invalidate delivery cache files related to given zone
  *
  * @param int $zoneId Zone Id
  */
 function invalidateZoneCache($zoneId)
 {
     if (!is_numeric($zoneId)) {
         return;
     }
     $this->invalidateGetZoneInfoCache($zoneId);
     $this->invalidateZoneLinkedAdsCache($zoneId);
     $doZone = OA_Dal::factoryDO('zones');
     $doZone->get($zoneId);
     $this->invalidatePublisherZonesCache($doZone->affiliateid);
     // @todo Add invalidating direct-selection cache files
 }
 function test_registerPreferences()
 {
     $aPreferences[0] = array('name' => 'testpref', 'type' => 'text', 'label' => 'Test Pref', 'required' => '1', 'size' => 12, 'visible' => 1, 'permission' => 'ADMIN', 'value' => 'testval');
     $oPluginManager = new OX_Plugin_ComponentGroupManager();
     $oPluginManager->_registerPreferences('testPlugin', $aPreferences);
     $prefName = $name . '_' . $aPreference['name'];
     $doPreferences = OA_Dal::factoryDO('preferences');
     $doPreferences->preference_name = 'testPlugin_testpref';
     $this->assertTrue($doPreferences->find());
     $oPluginManager->_unregisterPreferences('testPlugin', $aPreferences);
     $this->assertFalse($doPreferences->find());
 }
 function _insertCampaignBanner()
 {
     $doCampaigns = OA_Dal::factoryDO('campaigns');
     $doCampaigns->priority = 1;
     $doCampaigns->status = OA_ENTITY_STATUS_RUNNING;
     $campaignId = DataGenerator::generateOne($doCampaigns);
     $doBanners = OA_Dal::factoryDO('banners');
     $doBanners->campaignid = $campaignId;
     $doBanners->status = OA_ENTITY_STATUS_RUNNING;
     $bannerId = DataGenerator::generateOne($doBanners);
     return $bannerId;
 }
 function _testImageServe($timeZone)
 {
     OA_setTimeZone($timeZone);
     $fileName = 'tz_test.gif';
     $doImages = OA_Dal::factoryDO('images');
     $doImages->filename = $fileName;
     $doImages->contents = '';
     $this->assertTrue(DataGenerator::generateOne($doImages));
     $now = time();
     $this->assertTrue($timeZone == 'UTC' || date('Z', $now), 'Time zone not correctly set');
     // Simulate delivery
     OA_setTimeZoneUTC();
     $aCreative = OA_Dal_Delivery_getCreative($fileName);
     $this->assertTrue($aCreative);
     // Serve with no If-Modified-Since header
     unset($GLOBALS['_HEADERS']);
     unset($_SERVER['HTTP_IF_MODIFIED_SINCE']);
     MAX_imageServe($aCreative, $fileName, 'gif');
     if ($this->assertEqual(count($GLOBALS['_HEADERS']), 2, 'Mismatching headers with ' . $timeZone)) {
         $this->assertPattern('/^Last-Modified: /i', $GLOBALS['_HEADERS'][0]);
         $this->assertPattern('/^Content-Type: /i', $GLOBALS['_HEADERS'][1]);
     }
     // 1-day old If-Modified-Since header
     unset($GLOBALS['_HEADERS']);
     $_SERVER['HTTP_IF_MODIFIED_SINCE'] = gmdate('D, d M Y H:i:s', $now - 86400) . ' GMT';
     MAX_imageServe($aCreative, $fileName, 'gif');
     if ($this->assertEqual(count($GLOBALS['_HEADERS']), 2, 'Mismatching headers with ' . $timeZone)) {
         $this->assertPattern('/^Last-Modified: /i', $GLOBALS['_HEADERS'][0]);
         $this->assertPattern('/^Content-Type: /i', $GLOBALS['_HEADERS'][1]);
     }
     // 1-day future If-Modified-Since header
     unset($GLOBALS['_HEADERS']);
     $_SERVER['HTTP_IF_MODIFIED_SINCE'] = gmdate('D, d M Y H:i:s', $now + 86400) . ' GMT';
     MAX_imageServe($aCreative, $fileName, 'gif');
     if ($this->assertEqual(count($GLOBALS['_HEADERS']), 1, 'Mismatching headers with ' . $timeZone)) {
         $this->assertPattern('/^HTTP\\/1.0 304/i', $GLOBALS['_HEADERS'][0]);
     }
     // 1 minute ago If-Modified-Since header
     unset($GLOBALS['_HEADERS']);
     $_SERVER['HTTP_IF_MODIFIED_SINCE'] = gmdate('D, d M Y H:i:s', $now - 60) . ' GMT';
     MAX_imageServe($aCreative, $fileName, 'gif');
     if ($this->assertEqual(count($GLOBALS['_HEADERS']), 2, 'Mismatching headers with ' . $timeZone)) {
         $this->assertPattern('/^Last-Modified: /i', $GLOBALS['_HEADERS'][0]);
         $this->assertPattern('/^Content-Type: /i', $GLOBALS['_HEADERS'][1]);
     }
     // 1 minute in future If-Modified-Since header
     unset($GLOBALS['_HEADERS']);
     $_SERVER['HTTP_IF_MODIFIED_SINCE'] = gmdate('D, d M Y H:i:s', $now + 60) . ' GMT';
     MAX_imageServe($aCreative, $fileName, 'gif');
     if ($this->assertEqual(count($GLOBALS['_HEADERS']), 1, 'Mismatching headers with ' . $timeZone)) {
         $this->assertPattern('/^HTTP\\/1.0 304/i', $GLOBALS['_HEADERS'][0]);
     }
 }
 function testAddConversion()
 {
     $day = '2007-04-04';
     $hour = 17;
     $total_basket_value = 100.0;
     $creative_id = 4;
     $zone_id = 5;
     $bannerId = $this->aIds['banners'][0];
     $dataIntermediateAdId = $this->aIds['dataIA'][0];
     $result = $this->dalData_intermediate_ad->addConversion('+', $basketValue = 12, $numItems = 4, $bannerId, $creative_id, $zone_id, $day, $hour);
     $doData_intermediate_ad = OA_Dal::staticGetDO('data_intermediate_ad', $dataIntermediateAdId);
     $this->assertEqual($doData_intermediate_ad->total_basket_value, $total_basket_value + $basketValue);
 }
 /**
  * The constructor method.
  */
 function Dal_TestOfMAX_Dal_Entities()
 {
     $this->UnitTestCase();
     $this->doBanners = OA_Dal::factoryDO('banners');
     $this->doZones = OA_Dal::factoryDO('zones');
     $this->doAcls = OA_Dal::factoryDO('acls');
     $this->doAdZone = OA_Dal::factoryDO('ad_zone_assoc');
     $this->doAgency = OA_Dal::factoryDO('agency');
     $this->doChannel = OA_Dal::factoryDO('channel');
     $this->doAclsChannel = OA_Dal::factoryDO('acls_channel');
     $this->doCampaigns = OA_Dal::factoryDO('campaigns');
     $this->doAffiliates = OA_Dal::factoryDO('affiliates');
 }
 /**
  * The constructor method.
  */
 function __construct()
 {
     parent::__construct();
     $this->doBanners = OA_Dal::factoryDO('banners');
     $this->doZones = OA_Dal::factoryDO('zones');
     $this->doAcls = OA_Dal::factoryDO('acls');
     $this->doAdZone = OA_Dal::factoryDO('ad_zone_assoc');
     $this->doAgency = OA_Dal::factoryDO('agency');
     $this->doChannel = OA_Dal::factoryDO('channel');
     $this->doAclsChannel = OA_Dal::factoryDO('acls_channel');
     $this->doCampaigns = OA_Dal::factoryDO('campaigns');
     $this->doAffiliates = OA_Dal::factoryDO('affiliates');
 }
 function test_DeliveryDB_getAdminTZ()
 {
     // Create the admin account
     $doAccounts = OA_Dal::factoryDO('accounts');
     $doAccounts->account_name = 'System Administrator';
     $doAccounts->account_type = OA_ACCOUNT_ADMIN;
     $adminAccountId = DataGenerator::generateOne($doAccounts);
     $aExpect = array('default' => 'UTC', 'aAccounts' => array(), 'adminAccountId' => 1);
     $aResult = OA_Dal_Delivery_getAccountTZs();
     $this->assertEqual($aResult, $aExpect);
     $doPreferences = OA_Dal::factoryDO('preferences');
     $doPreferences->preference_name = 'timezone';
     $preferenceId = $doPreferences->insert();
     $doAPA = OA_Dal::factoryDO('account_preference_assoc');
     $doAPA->account_id = $adminAccountId;
     $doAPA->preference_id = $preferenceId;
     $doAPA->value = '';
     $doAPA->insert();
     $aResult = OA_Dal_Delivery_getAccountTZs();
     $this->assertEqual($aResult, $aExpect);
     $doAPA = OA_Dal::factoryDO('account_preference_assoc');
     $doAPA->account_id = $adminAccountId;
     $doAPA->preference_id = $preferenceId;
     $doAPA->value = 'Europe/Rome';
     $doAPA->update();
     $aExpect = array('default' => 'Europe/Rome', 'aAccounts' => array(), 'adminAccountId' => 1);
     $aResult = OA_Dal_Delivery_getAccountTZs();
     $this->assertEqual($aResult, $aExpect);
     // Create a couple of manager accounts
     $doAccounts = OA_Dal::factoryDO('accounts');
     $doAccounts->account_name = 'Manager Account 1';
     $doAccounts->account_type = OA_ACCOUNT_MANAGER;
     $managerAccountId1 = DataGenerator::generateOne($doAccounts);
     $doAPA = OA_Dal::factoryDO('account_preference_assoc');
     $doAPA->account_id = $managerAccountId1;
     $doAPA->preference_id = $preferenceId;
     $doAPA->value = 'Europe/London';
     $doAPA->insert();
     $doAccounts = OA_Dal::factoryDO('accounts');
     $doAccounts->account_name = 'Manager Account 2';
     $doAccounts->account_type = OA_ACCOUNT_MANAGER;
     $managerAccountId2 = DataGenerator::generateOne($doAccounts);
     $doAPA = OA_Dal::factoryDO('account_preference_assoc');
     $doAPA->account_id = $managerAccountId2;
     $doAPA->preference_id = $preferenceId;
     $doAPA->value = 'CEST';
     $doAPA->insert();
     $aExpect = array('default' => 'Europe/Rome', 'aAccounts' => array($managerAccountId1 => 'Europe/London', $managerAccountId2 => 'CEST'), 'adminAccountId' => 1);
     $aResult = OA_Dal_Delivery_getAccountTZs();
     $this->assertEqual($aResult, $aExpect);
 }
Ejemplo n.º 30
0
 /**
  * Test method _relinkOrDeleteUsers
  */
 function test_relinkOrDeleteUsers()
 {
     // Insert an agency
     $doAgency = OA_Dal::factoryDO('agency');
     $agencyId = DataGenerator::generateOne($doAgency);
     $managerAccountId = DataGenerator::getReferenceId('accounts');
     $doAgency = OA_Dal::factoryDO('agency');
     $doAgency->get($agencyId);
     $managerAccountId = $doAgency->account_id;
     // Create admin account
     $doAccounts = OA_Dal::factoryDO('accounts');
     $doAccounts->account_type = OA_ACCOUNT_ADMIN;
     $adminAccountId = DataGenerator::generateOne($doAccounts);
     // Create user linked to admin account
     // Default account for this user is set to manager account
     $doUsers = OA_Dal::factoryDO('users');
     $doUsers->default_account_id = $managerAccountId;
     $doUsers->username = '******';
     $adminUserID = DataGenerator::generateOne($doUsers);
     $doAccountsUserAssoc = OA_Dal::factoryDO('account_user_assoc');
     $doAccountsUserAssoc->account_id = $adminAccountId;
     $doAccountsUserAssoc->user_id = $adminUserID;
     DataGenerator::generateOne($doAccountsUserAssoc);
     // Create manager user
     $doUsers = OA_Dal::factoryDO('users');
     $doUsers->default_account_id = $managerAccountId;
     $doUsers->username = '******';
     $managerUserID = DataGenerator::generateOne($doUsers);
     // Now delete Agency
     $doAgency = OA_Dal::factoryDO('agency');
     $doAgency->agencyid = $agencyId;
     $doAgency->onDeleteCascade = false;
     // Disable cascade delete
     $doAgency->delete();
     $doAccounts = OA_Dal::factoryDO('accounts');
     $doAccounts->get($managerAccountId);
     // Relink / Delete users here
     $doAccounts->_relinkOrDeleteUsers();
     // Test: admin user exists, linked to admin account
     $doUsers = OA_Dal::factoryDO('users');
     $doUsers->user_id = $adminUserID;
     $doUsers->find();
     $this->assertTrue($doUsers->fetch());
     $this->assertEqual($doUsers->default_account_id, $adminAccountId);
     // Test: manager users is deleted
     $doUsers = OA_Dal::factoryDO('users');
     $doUsers->user_id = $managerUserID;
     $doUsers->find();
     $this->assertFalse($doUsers->fetch());
 }