本文整理汇总了PHP中OA_Dal::factoryDAL方法的典型用法代码示例。如果您正苦于以下问题:PHP OA_Dal::factoryDAL方法的具体用法?PHP OA_Dal::factoryDAL怎么用?PHP OA_Dal::factoryDAL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OA_Dal
的用法示例。
在下文中一共展示了OA_Dal::factoryDAL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforePageHeader
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;
}
}
}
示例2: setUp
function setUp()
{
$this->dalData_intermediate_ad = OA_Dal::factoryDAL('data_intermediate_ad');
$rsDal = $this->dalData_intermediate_ad->getDeliveredByCampaign(123);
$aDelivered = $rsDal->toArray();
foreach ($aDelivered as $delivered) {
$this->assertNull($delivered);
}
$this->aIds = TestEnv::loadData('data_intermediate_ad_001');
}
示例3: testFactoryDAL
/**
* Test that method returns correct object when DataObject exists and false otherwise.
*
* @TODO Add PEAR_Error expectations to simpletest in order to catch them
*/
function testFactoryDAL()
{
// Test when object exists
$dalBanners = OA_Dal::factoryDAL('banners');
$this->assertIsA($dalBanners, 'MAX_Dal_Admin_Banners');
// Test when object doesn't exist
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$dalBanners = OA_Dal::factoryDAL('foo' . rand());
PEAR::staticPopErrorHandling();
$this->assertFalse($dalBanners);
}
示例4: delete
function delete($useWhere = false, $cascade = true, $parentid = null)
{
// Find acls which use this channels
$dalAcls = OA_Dal::factoryDAL('acls');
$rsChannel = $dalAcls->getAclsByDataValueType($this->channelid, 'Site:Channel');
$rsChannel->reset();
while ($rsChannel->next()) {
// Get the IDs of the banner that's using this channel
$bannerId = $rsChannel->get('bannerid');
// Get the remaining channels the banner will use, if any
$aChannelIds = explode(',', $rsChannel->get('data'));
$aChannelIds = array_diff($aChannelIds, array($this->channelid));
// Prepare to update the banner's limitations in the "acls" table
$doAcls = DB_DataObject::factory('acls');
$doAcls->init();
$doAcls->bannerid = $bannerId;
$doAcls->executionorder = $rsChannel->get('executionorder');
if (!empty($aChannelIds)) {
$doAcls->data = implode(',', $aChannelIds);
$doAcls->update();
} else {
$doAcls->delete();
}
// Re-compile the banner's limitations
$aAcls = array();
$doAcls = DB_DataObject::factory('acls');
$doAcls->init();
$doAcls->bannerid = $bannerId;
$doAcls->orderBy('executionorder');
$doAcls->find();
while ($doAcls->fetch()) {
$aData = $doAcls->toArray();
$deliveryLimitationPlugin = OX_Component::factoryByComponentIdentifier('deliveryLimitations:' . $aData['type']);
if ($deliveryLimitationPlugin) {
$deliveryLimitationPlugin->init($aData);
if ($deliveryLimitationPlugin->isAllowed($page)) {
$aAcls[$aData['executionorder']] = $aData;
}
}
}
$sLimitation = MAX_AclGetCompiled($aAcls, $page);
// TODO: it should be done inside plugins instead, there is no need to slash the data
$sLimitation = !get_magic_quotes_runtime() ? stripslashes($sLimitation) : $sLimitation;
$doBanners = OA_Dal::factoryDO('banners');
$doBanners->bannerid = $bannerId;
$doBanners->find();
$doBanners->fetch();
$doBanners->acl_plugins = MAX_AclGetPlugins($aAcls);
$doBanners->acls_updated = OA::getNow();
$doBanners->compiledlimitation = $sLimitation;
$doBanners->update();
}
return parent::delete($useWhere, $cascade, $parentid);
}
示例5: createTemplateWithModel
public static function createTemplateWithModel($panel, $single = true)
{
$agencyId = OA_Permission::getAgencyId();
$oDalZones = OA_Dal::factoryDAL('zones');
$infix = $single ? '' : '-' . $panel;
phpAds_registerGlobalUnslashed('action', 'campaignid', 'clientid', "text{$infix}", "page{$infix}");
$campaignId = $GLOBALS['campaignid'];
$text = $GLOBALS["text{$infix}"];
$linked = $panel == 'linked';
$showStats = empty($GLOBALS['_MAX']['CONF']['ui']['zoneLinkingStatistics']) ? false : true;
$websites = $oDalZones->getWebsitesAndZonesList($agencyId, $campaignId, $linked, $text);
$matchingZones = 0;
foreach ($websites as $aWebsite) {
$matchingZones += count($aWebsite['zones']);
}
$aZonesCounts = array('all' => $oDalZones->countZones($agencyId, null, $campaignId, $linked), 'matching' => $matchingZones);
$pagerFileName = 'campaign-zone-zones.php';
$pagerParams = array('clientid' => $GLOBALS['clientid'], 'campaignid' => $GLOBALS['campaignid'], 'status' => $panel, 'text' => $text);
$currentPage = null;
if (!$single) {
$currentPage = $GLOBALS["page{$infix}"];
}
$oTpl = new OA_Admin_Template('campaign-zone-zones.html');
$oPager = OX_buildPager($websites, self::WEBSITES_PER_PAGE, true, 'websites', 2, $currentPage, $pagerFileName, $pagerParams);
$oTopPager = OX_buildPager($websites, self::WEBSITES_PER_PAGE, false, 'websites', 2, $currentPage, $pagerFileName, $pagerParams);
list($itemsFrom, $itemsTo) = $oPager->getOffsetByPageId();
$websites = array_slice($websites, $itemsFrom - 1, self::WEBSITES_PER_PAGE, true);
// Add statistics for the displayed zones if required
if ($showStats) {
$oDalZones->mergeStatistics($websites, $campaignId);
}
// Count how many zone are displayed
$showingCount = 0;
foreach ($websites as $website) {
$showingCount += count($website['zones']);
}
$aZonesCounts['showing'] = $showingCount;
$oTpl->assign('pager', $oPager);
$oTpl->assign('topPager', $oTopPager);
$oTpl->assign('websites', $websites);
$oTpl->assign('zonescounts', $aZonesCounts);
$oTpl->assign('text', $text);
$oTpl->assign('status', $panel);
$oTpl->assign('page', $oTopPager->getCurrentPageID());
$oTpl->assign('showStats', $showStats);
$oTpl->assign('colspan', $showStats ? 6 : 3);
return $oTpl;
}
示例6: createTemplateWithModel
public static function createTemplateWithModel($panel, $single = true)
{
$agencyId = OA_Permission::getAgencyId();
$oDalZones = OA_Dal::factoryDAL('zones');
$infix = $single ? '' : '-' . $panel;
phpAds_registerGlobalUnslashed('action', 'campaignid', 'clientid', "category{$infix}", "category{$infix}-text", "text{$infix}", "page{$infix}");
$campaignId = $GLOBALS['campaignid'];
$category = $GLOBALS["category{$infix}"];
$categoryText = $GLOBALS["category{$infix}-text"];
$text = $GLOBALS["text{$infix}"];
$linked = $panel == 'linked';
$websites = $oDalZones->getWebsitesAndZonesListByCategory($agencyId, $category, $campaignId, $linked, $text);
$pagerFileName = 'campaign-zone-zones.php';
$pagerParams = array('clientid' => $GLOBALS['clientid'], 'campaignid' => $GLOBALS['campaignid'], 'status' => $panel, 'category' => $category, 'category-text' => $categoryText, 'text' => $text);
$currentPage = null;
if (!$single) {
$currentPage = $GLOBALS["page{$infix}"];
}
$oTpl = new OA_Admin_Template('campaign-zone-zones.html');
$oPager = OX_buildPager($websites, self::WEBSITES_PER_PAGE, true, 'websites', 2, $currentPage, $pagerFileName, $pagerParams);
$oTopPager = OX_buildPager($websites, self::WEBSITES_PER_PAGE, false, 'websites', 2, $currentPage, $pagerFileName, $pagerParams);
list($itemsFrom, $itemsTo) = $oPager->getOffsetByPageId();
$websites = array_slice($websites, $itemsFrom - 1, self::WEBSITES_PER_PAGE, true);
$aZonesCounts = array('all' => $oDalZones->countZones($agencyId, null, $campaignId, $linked), 'matching' => $oDalZones->countZones($agencyId, $category, $campaignId, $linked, $text));
$showingCount = 0;
// TODO: currently we're calculating the number in PHP code. Once
// MAX_Dal_Admin_Zones::countZones() supports the limit parameter, we can remove
// the code below and use the dal.
foreach ($websites as $website) {
$showingCount += count($website['zones']);
}
$aZonesCounts['showing'] = $showingCount;
$oTpl->assign('pager', $oPager);
$oTpl->assign('topPager', $oTopPager);
$oTpl->assign('websites', $websites);
$oTpl->assign('zonescounts', $aZonesCounts);
$oTpl->assign('category', $categoryText);
$oTpl->assign('text', $text);
$oTpl->assign('status', $panel);
$oTpl->assign('page', $oTopPager->getCurrentPageID());
return $oTpl;
}
示例7: processCampaignForm
/**
* Processes submit values of campaign form
*
* @param OA_Admin_UI_Component_Form $form form to process
* @return An array of Pear::Error objects if any
*/
function processCampaignForm($form, &$oComponent = null)
{
$aFields = $form->exportValues();
if (!empty($aFields['start'])) {
$oDate = new Date(date('Y-m-d 00:00:00', strtotime($aFields['start'])));
$oDate->toUTC();
$activate = $oDate->getDate();
} else {
$oDate = new Date(date('Y-m-d 00:00:00'));
$oDate->toUTC();
$activate = $oDate->getDate();
}
if (!empty($aFields['end'])) {
$oDate = new Date(date('Y-m-d 23:59:59', strtotime($aFields['end'])));
$oDate->toUTC();
$expire = $oDate->getDate();
} else {
$expire = null;
}
if (empty($aFields['campaignid'])) {
// The form is submitting a new campaign, so, the ID is not set;
// set the ID to the string "null" so that the table auto_increment
// or sequence will be used when the campaign is created
$aFields['campaignid'] = "null";
} else {
// The form is submitting a campaign modification; need to test
// if any of the banners in the campaign are linked to an email zone,
// and if so, if the link(s) would still be valid if the change(s)
// to the campaign were made...
$dalCampaigns = OA_Dal::factoryDAL('campaigns');
$aCurrentLinkedEmalZoneIds = $dalCampaigns->getLinkedEmailZoneIds($aFields['campaignid']);
if (PEAR::isError($aCurrentLinkedEmalZoneIds)) {
OX::disableErrorHandling();
$errors[] = PEAR::raiseError($GLOBALS['strErrorDBPlain']);
OX::enableErrorHandling();
}
$errors = array();
foreach ($aCurrentLinkedEmalZoneIds as $zoneId) {
$thisLink = Admin_DA::_checkEmailZoneAdAssoc($zoneId, $aFields['campaignid'], $activate, $expire);
if (PEAR::isError($thisLink)) {
$errors[] = $thisLink;
break;
}
}
}
//correct and check revenue and ecpm
correctAdnCheckNumericFormField($aFields, $errors, 'revenue', $GLOBALS['strErrorEditingCampaignRevenue']);
correctAdnCheckNumericFormField($aFields, $errors, 'ecpm', $GLOBALS['strErrorEditingCampaignECPM']);
if (empty($errors)) {
//check booked limits values
// If this is a remnant, ecpm or exclusive campaign with an expiry date, set the target's to unlimited
if (!empty($expire) && ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_REMNANT || $aFields['campaign_type'] == OX_CAMPAIGN_TYPE_ECPM || $aFields['campaign_type'] == OX_CAMPAIGN_TYPE_CONTRACT_EXCLUSIVE)) {
$aFields['impressions'] = $aFields['clicks'] = $aFields['conversions'] = -1;
} else {
if (!empty($aFields['impr_unlimited']) && $aFields['impr_unlimited'] == 't') {
$aFields['impressions'] = -1;
} else {
if (empty($aFields['impressions']) || $aFields['impressions'] == '-') {
$aFields['impressions'] = 0;
}
}
if (!empty($aFields['click_unlimited']) && $aFields['click_unlimited'] == 't') {
$aFields['clicks'] = -1;
} else {
if (empty($aFields['clicks']) || $aFields['clicks'] == '-') {
$aFields['clicks'] = 0;
}
}
if (!empty($aFields['conv_unlimited']) && $aFields['conv_unlimited'] == 't') {
$aFields['conversions'] = -1;
} else {
if (empty($aFields['conversions']) || $aFields['conversions'] == '-') {
$aFields['conversions'] = 0;
}
}
}
//pricing model - reset fields not applicable to model to 0,
//note that in new flow MAX_FINANCE_CPA allows all limits to be set
if ($aFields['revenue_type'] == MAX_FINANCE_CPM) {
$aFields['clicks'] = -1;
$aFields['conversions'] = -1;
} else {
if ($aFields['revenue_type'] == MAX_FINANCE_CPC) {
$aFields['conversions'] = -1;
} else {
if ($aFields['revenue_type'] == MAX_FINANCE_MT) {
$aFields['impressions'] = -1;
$aFields['clicks'] = -1;
$aFields['conversions'] = -1;
}
}
}
//check type and set priority
if ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_REMNANT) {
//.........这里部分代码省略.........
示例8: test_invalidateZonesLinkingCache
/**
* Method tests invalidateZonesLinkingCache method
*/
function test_invalidateZonesLinkingCache()
{
$cachedData[0] = MAX_cacheGetZoneLinkedAds($this->_aIds['zones'][0]);
$cachedData[1] = MAX_cacheGetZoneLinkedAds($this->_aIds['zones'][1]);
$aZonesIds = array($this->_aIds['zones'][0], $this->_aIds['zones'][1]);
// Unlink zones from campaign
$dalZones = OA_Dal::factoryDAL('zones');
$dalZones->unlinkZonesFromCampaign($aZonesIds, $this->_aIds['campaigns'][0]);
// Expect no changes in cache
$this->assertEqual(MAX_cacheGetZoneLinkedAds($this->_aIds['zones'][0]), $cachedData[0]);
$this->assertEqual(MAX_cacheGetZoneLinkedAds($this->_aIds['zones'][1]), $cachedData[1]);
$this->oDeliveryCacheManager->invalidateZonesLinkingCache($aZonesIds);
// Now expect changes in cache
$this->assertNotEqual(MAX_cacheGetZoneLinkedAds($this->_aIds['zones'][0]), $cachedData[0]);
$this->assertNotEqual(MAX_cacheGetZoneLinkedAds($this->_aIds['zones'][1]), $cachedData[1]);
}
示例9: phpAds_SessionDataStore
/*-------------------------------------------------------*/
/* Store preferences */
/*-------------------------------------------------------*/
$session['prefs']['inventory_entities'][OA_Permission::getEntityId()]['clientid'] = $clientid;
phpAds_SessionDataStore();
/*-------------------------------------------------------*/
/* HTML framework */
/*-------------------------------------------------------*/
if (!isset($variables)) {
if (isset($session['prefs']['tracker-variables.php']['variables']) && $session['prefs']['tracker-variables.php']['trackerid'] == $trackerid) {
$variables = $session['prefs']['tracker-variables.php']['variables'];
}
}
if (!empty($trackerid)) {
// Get publisher list
$dalAffiliates = OA_Dal::factoryDAL('affiliates');
$rsAffiliates = $dalAffiliates->getPublishersByTracker($trackerid);
$rsAffiliates->find();
$publishers = array();
while ($rsAffiliates->fetch() && ($row = $rsAffiliates->toArray())) {
$publishers[$row['affiliateid']] = strip_tags(phpAds_BuildAffiliateName($row['affiliateid'], $row['name']));
}
if (!isset($variablemethod)) {
// get variable method
$doTrackers = OA_Dal::factoryDO('trackers');
if ($doTrackers->get($trackerid)) {
$variablemethod = $doTrackers->variablemethod;
}
}
if (!isset($variables)) {
// get variables from db
示例10: phpAds_registerGlobalUnslashed
| Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+---------------------------------------------------------------------------+
$Id: campaign-zone-link.php 37157 2009-05-28 12:31:10Z andrew.hill $
*/
// Require the initialisation file
require_once '../../init.php';
// Required files
require_once MAX_PATH . '/www/admin/config.php';
/*-------------------------------------------------------*/
/* Main code */
/*-------------------------------------------------------*/
require_once MAX_PATH . '/lib/OA/Admin/Template.php';
require_once MAX_PATH . '/lib/OA/Admin/UI/CampaignZoneLink.php';
phpAds_registerGlobalUnslashed('action', 'campaignid', 'allSelected', 'category-linked', 'category-available', 'text-linked', 'text-available');
$agencyId = OA_Permission::getAgencyId();
$oDalZones = OA_Dal::factoryDAL('zones');
$action = $GLOBALS["action"];
$campaignId = $GLOBALS['campaignid'];
OA_Permission::enforceAccount(OA_ACCOUNT_MANAGER);
OA_Permission::enforceAccessToObject('campaigns', $campaignid);
$aZonesIds = array();
$aZonesIdsHash = array();
foreach ($_REQUEST['ids'] as $zone) {
if (substr($zone, 0, 1) == 'z') {
$aZonesIds[] = substr($zone, 1);
$aZonesIdsHash[substr($zone, 1)] = "x";
}
}
// If we're requested to link all matching zones, we need to determine the ids to link
// Ideally, there should be a DAL method to that directly. Note that we're replacing
// only the $aZonesIds array here, and keeping $aZonesIdsHash populated based on the
示例11: setUp
function setUp()
{
$this->dalBanners = OA_Dal::factoryDAL('banners');
}
示例12: logout
/**
* Cleans up the session and carry on any additional tasks required to logout the user
*
*/
function logout()
{
phpAds_SessionDataDestroy();
$dalAgency = OA_Dal::factoryDAL('agency');
header("Location: " . $dalAgency->getLogoutUrl(OA_Permission::getAgencyId()));
exit;
}
示例13: setUp
function setUp()
{
$this->dalChannel = OA_Dal::factoryDAL('channel');
}
示例14: while
$rsChannel->find();
$allChannelsValid = true;
while ($rsChannel->fetch() && ($row = $rsChannel->toArray())) {
if (!MAX_AclValidate('channel-acl.php', array('channelid' => $row['channelid']))) {
$allChannelsValid = false;
$affiliateName = !empty($row['affiliatename']) ? $row['affiliatename'] : $strUntitled;
echo "<a href='channel-acl.php?affiliateid={$row['affiliateid']}&channelid={$row['channelid']}'>{$row['name']}</a><br />";
}
}
if ($allChannelsValid) {
echo $strChannelCompiledLimitationsValid;
}
phpAds_showBreak();
echo "<strong>{$strBanners}:</strong>";
phpAds_ShowBreak();
$dalBanners = OA_Dal::factoryDAL('banners');
$rsBanners = $dalBanners->getBannersCampaignsClients();
$rsBanners->find();
$allBannersValid = true;
while ($rsBanners->fetch() && ($row = $rsBanners->toArray())) {
if (!MAX_AclValidate('banner-acl.php', array('bannerid' => $row['bannerid']))) {
$allBannersValid = false;
$bannerName = !empty($row['description']) ? $row['description'] : $strUntitled;
$campaignName = !empty($row['campaignname']) ? $row['campaignname'] : $strUntitled;
$clientName = !empty($row['clientname']) ? $row['clientname'] : $strUntitled;
echo "{$clientName} -> {$campaignName} -> <a href='banner-acl.php?clientid={$row['clientid']}&campaignid={$row['campaignid']}&bannerid={$row['bannerid']}'>{$bannerName}</a><br />";
}
}
if ($allBannersValid) {
echo $strBannerCompiledLimitationsValid;
}
示例15: sendCampaignImpendingExpiryEmail
/**
* @param $oDate
* @param $campaignId
* @return int Number of emails sent
*/
function sendCampaignImpendingExpiryEmail($oDate, $campaignId)
{
$aConf = $GLOBALS['_MAX']['CONF'];
global $date_format;
$oPreference = new OA_Preferences();
if (!isset($this->aAdminCache)) {
// Get admin account ID
$adminAccountId = OA_Dal_ApplicationVariables::get('admin_account_id');
// Get admin prefs
$adminPrefsNames = $this->_createPrefsListPerAccount(OA_ACCOUNT_ADMIN);
$aAdminPrefs = $oPreference->loadAccountPreferences($adminAccountId, $adminPrefsNames, OA_ACCOUNT_ADMIN);
// Get admin users
$aAdminUsers = $this->getAdminUsersLinkedToAccount();
// Store admin cache
$this->aAdminCache = array($aAdminPrefs, $aAdminUsers);
} else {
// Retrieve admin cache
list($aAdminPrefs, $aAdminUsers) = $this->aAdminCache;
}
$aPreviousOIDates = OX_OperationInterval::convertDateToPreviousOperationIntervalStartAndEndDates($oDate);
$aPreviousOIDates = OX_OperationInterval::convertDateToPreviousOperationIntervalStartAndEndDates($aPreviousOIDates['start']);
$doCampaigns = OA_Dal::staticGetDO('campaigns', $campaignId);
if (!$doCampaigns) {
return 0;
}
$aCampaign = $doCampaigns->toArray();
if (!isset($this->aClientCache[$aCampaign['clientid']])) {
$doClients = OA_Dal::staticGetDO('clients', $aCampaign['clientid']);
// Add advertiser linked users
$aLinkedUsers['advertiser'] = $this->getUsersLinkedToAccount('clients', $aCampaign['clientid']);
// Add advertiser prefs
$advertiserPrefsNames = $this->_createPrefsListPerAccount(OA_ACCOUNT_ADVERTISER);
$aPrefs['advertiser'] = $oPreference->loadAccountPreferences($doClients->account_id, $advertiserPrefsNames, OA_ACCOUNT_ADVERTISER);
if (!isset($aAgencyCache[$doClients->agencyid])) {
// Add manager linked users
$doAgency = OA_Dal::staticGetDO('agency', $doClients->agencyid);
$aLinkedUsers['manager'] = $this->getUsersLinkedToAccount('agency', $doClients->agencyid);
// Add manager preferences
$managerPrefsNames = $this->_createPrefsListPerAccount(OA_ACCOUNT_MANAGER);
$aPrefs['manager'] = $oPreference->loadAccountPreferences($doAgency->account_id, $managerPrefsNames, OA_ACCOUNT_MANAGER);
// Get agency "From" details
$aAgencyFromDetails = $this->_getAgencyFromDetails($doAgency->agencyid);
// Store in the agency cache
$this->aAgencyCache = array($doClients->agencyid => array($aLinkedUsers['manager'], $aPrefs['manager'], $aAgencyFromDetails));
} else {
// Retrieve agency cache
list($aLinkedUsers['manager'], $aPrefs['manager'], $aAgencyFromDetails) = $this->aAgencyCache[$doClients->agencyid];
}
// Add admin linked users and preferences
$aLinkedUsers['admin'] = $aAdminUsers;
$aPrefs['admin'] = $aAdminPrefs;
// Create a linked user 'special' for the advertiser that will take the admin preferences for advertiser
$aLinkedUsers['special']['advertiser'] = $doClients->toArray();
$aLinkedUsers['special']['advertiser']['contact_name'] = $aLinkedUsers['special']['advertiser']['contact'];
$aLinkedUsers['special']['advertiser']['email_address'] = $aLinkedUsers['special']['advertiser']['email'];
$aLinkedUsers['special']['advertiser']['language'] = '';
$aLinkedUsers['special']['advertiser']['user_id'] = 0;
// Check that every user is not going to receive more than one email if they
// are linked to more than one account
$aLinkedUsers = $this->_deleteDuplicatedUser($aLinkedUsers);
// Create the linked special user preferences from the admin preferences
// the special user is the client that doesn't have preferences in the database
$aPrefs['special'] = $aPrefs['admin'];
$aPrefs['special']['warn_email_special'] = $aPrefs['special']['warn_email_advertiser'];
$aPrefs['special']['warn_email_special_day_limit'] = $aPrefs['special']['warn_email_advertiser_day_limit'];
$aPrefs['special']['warn_email_special_impression_limit'] = $aPrefs['special']['warn_email_advertiser_impression_limit'];
// Store in the client cache
$this->aClientCache = array($aCampaign['clientid'] => array($aLinkedUsers, $aPrefs, $aAgencyFromDetails));
} else {
// Retrieve client cache
list($aLinkedUsers, $aPrefs, $aAgencyFromDetails) = $this->aClientCache[$aCampaign['clientid']];
}
$copiesSent = 0;
foreach ($aLinkedUsers as $accountType => $aUsers) {
if ($accountType == 'special' || $accountType == 'advertiser') {
// Get the agency details and use them for emailing advertisers
$aFromDetails = $aAgencyFromDetails;
} else {
// Use the Admin details
$aFromDetails = '';
}
if ($aPrefs[$accountType]['warn_email_' . $accountType]) {
// Does the account type want warnings when the impressions are low?
if ($aPrefs[$accountType]['warn_email_' . $accountType . '_impression_limit'] > 0 && $aCampaign['views'] > 0) {
// Test to see if the placements impressions remaining are less than the limit
$dalCampaigns = OA_Dal::factoryDAL('campaigns');
$remainingImpressions = $dalCampaigns->getAdImpressionsLeft($aCampaign['campaignid']);
if ($remainingImpressions < $aPrefs[$accountType]['warn_email_' . $accountType . '_impression_limit']) {
// Yes, the placement will expire soon! But did the placement just reach
// the point where it is about to expire, or did it happen a while ago?
$previousRemainingImpressions = $dalCampaigns->getAdImpressionsLeft($aCampaign['campaignid'], $aPreviousOIDates['end']);
if ($previousRemainingImpressions >= $aPrefs[$accountType]['warn_email_' . $accountType . '_impression_limit']) {
// Yes! This is the operation interval that the boundary
// was crossed to the point where it's about to expire,
// so send that email, baby!
//.........这里部分代码省略.........