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; } } }
function testGetZone() { $conf = $GLOBALS['_MAX']['CONF']; $dbh =& OA_DB::singleton(); $id = $this->newZone(); $this->assertTrue(is_int($id)); $this->assertTrue($id > 0); // Get zone record as control element $query = 'SELECT * FROM ' . $dbh->quoteIdentifier($conf['table']['prefix'] . 'zones', true) . ' WHERE zoneid = ' . $id; $aZone1 = $dbh->getRow($query); $this->assertTrue(is_array($aZone1)); // Massage results so as to be comparable with Admin_DA::getZone() Admin_DA::_switch($aZone1, 'affiliateid', 'publisher_id'); Admin_DA::_switch($aZone1, 'zonename', 'name'); Admin_DA::_switch($aZone1, 'delivery', 'type'); Admin_DA::_switch($aZone1, 'zoneid', 'zone_id'); unset($aZone1['zonetype']); unset($aZone1['updated']); $aZone1 = array_filter($aZone1, 'strlen'); $aZone2 = Admin_DA::getZone($id); /* Array ( [zone_id] => 80 [publisher_id] => 508 [name] => toufreacli [type] => 3 [description] => [width] => 0 [height] => 0 [chain] => [prepend] => [append] => [appendtype] => 0 [forceappend] => f [inventory_forecast_type] => 0 ) */ $this->assertTrue(is_array($aZone2)); $this->assertTrue(count($aZone2) > 0); $this->assertTrue(array_key_exists('zone_id', $aZone2)); $this->assertTrue(array_key_exists('publisher_id', $aZone2)); $this->assertTrue(array_key_exists('name', $aZone2)); $this->assertTrue(array_key_exists('type', $aZone2)); $this->assertTrue(array_key_exists('description', $aZone2)); $this->assertTrue(array_key_exists('width', $aZone2)); $this->assertTrue(array_key_exists('height', $aZone2)); $this->assertTrue(array_key_exists('chain', $aZone2)); $this->assertTrue(array_key_exists('prepend', $aZone2)); $this->assertTrue(array_key_exists('append', $aZone2)); $this->assertTrue(array_key_exists('appendtype', $aZone2)); $this->assertTrue(array_key_exists('forceappend', $aZone2)); $this->assertTrue(array_key_exists('inventory_forecast_type', $aZone2)); $this->assertTrue(array_key_exists('comments', $aZone2)); $this->assertTrue(array_key_exists('block', $aZone2)); $this->assertTrue(array_key_exists('capping', $aZone2)); $this->assertTrue(array_key_exists('session_capping', $aZone2)); $this->assertTrue(array_key_exists('show_capped_no_cookie', $aZone2)); $aZone2 = array_filter($aZone2, 'strlen'); $this->assertEqual($aZone1, $aZone2); }
} } else { if (!isset($aCampaigns[$campaignid])) { $page = basename($_SERVER['SCRIPT_NAME']); OX_Admin_Redirect::redirect("{$page}?clientid={$clientid}"); } } } $agencyId = OA_Permission::getAgencyId(); $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) { OX_Admin_Redirect::redirect("campaign-banners.php?clientid={$clientid}&campaignid={$campaignid}"); } $pageName = 'campaign-banners'; $tabindex = 1; $aEntities = array('clientid' => $clientid, 'campaignid' => $campaignid); $oTrans = new OX_Translation(); $oHeaderModel = buildHeaderModel($aEntities); phpAds_PageHeader('advertiser-campaigns', $oHeaderModel); if (!isset($hideinactive)) { if (isset($session['prefs']['campaign-banners.php'][$campaignid]['hideinactive'])) { $hideinactive = $session['prefs']['campaign-banners.php'][$campaignid]['hideinactive']; } else { $pref =& $GLOBALS['_MAX']['PREF']; $hideinactive = $pref['ui_hide_inactive'] == true;
function MAX_getLinkedAdParams($zoneId) { $aParams = array(); $aZone = Admin_DA::getZone($zoneId); if ($aZone['type'] == phpAds_ZoneText) { $aParams['ad_type'] = 'txt'; } else { $aParams['ad_type'] = '!txt'; if ($aZone['width'] > -1) { $aParams['ad_width'] = $aZone['width']; } if ($aZone['height'] > -1) { $aParams['ad_height'] = $aZone['height']; } } return $aParams; }
public function isZoneVast($zoneId) { $zone = Admin_DA::getZone($zoneId); return in_array($zone['type'], array(OX_ZoneVideoOverlay, OX_ZoneVideoInstream)); }
function duplicateZone($zoneId) { $aZone = Admin_DA::getZone($zoneId); return Admin_DA::_duplicateZone($aZone, true); }
/** * Processes submit values of zone form * * @param OA_Admin_UI_Component_Form $form form to process * @return An array of Pear::Error objects if any */ function processForm($form) { $aFields = $form->exportValues(); switch ($aFields['delivery']) { case phpAds_ZoneText: $aFields['width'] = $aFields['height'] = 0; break; case OX_ZoneVideoOverlay: $aFields['width'] = $aFields['height'] = -2; break; case OX_ZoneVideoInstream: $aFields['width'] = $aFields['height'] = -3; break; default: if ($aFields['sizetype'] == 'custom') { if (isset($aFields['width']) && $aFields['width'] == '*') { $aFields['width'] = -1; } if (isset($aFields['height']) && $aFields['height'] == '*') { $aFields['height'] = -1; } } else { list($aFields['width'], $aFields['height']) = explode('x', $aFields['size']); } break; } if (!is_numeric($aFields['oac_category_id']) || $aFields['oac_category_id'] <= 0) { $aFields['oac_category_id'] = 'NULL'; } if (empty($errors)) { // Edit if (!empty($aFields['zoneid'])) { // before we commit any changes to db, store whether the size has changed $aZone = Admin_DA::getZone($aFields['zoneid']); $size_changed = $aFields['width'] != $aZone['width'] || $aFields['height'] != $aZone['height'] ? true : false; $type_changed = $aFields['delivery'] != $aZone['delivery'] ? true : false; $doZones = OA_Dal::factoryDO('zones'); $doZones->zonename = $aFields['zonename']; $doZones->description = $aFields['description']; $doZones->width = $aFields['width']; $doZones->height = $aFields['height']; $doZones->comments = $aFields['comments']; $doZones->delivery = $aFields['delivery']; if ($aFields['delivery'] != phpAds_ZoneText && $aFields['delivery'] != phpAds_ZoneBanner) { $doZones->append = ''; } if ($aFields['delivery'] != phpAds_ZoneText) { $doZones->prepend = ''; } $doZones->oac_category_id = $aFields['oac_category_id']; $doZones->zoneid = $aFields['zoneid']; $doZones->update(); // Ad Networks $doPublisher = OA_Dal::factoryDO('affiliates'); $doPublisher->get($aFields['affiliateid']); $anWebsiteId = $doPublisher->as_website_id; if ($anWebsiteId) { $oAdNetworks = new OA_Central_AdNetworks(); $doZones->get($aFields['zoneid']); $oAdNetworks->updateZone($doZones, $anWebsiteId); } // Reset append codes which called this zone $doZones = OA_Dal::factoryDO('zones'); $doZones->appendtype = phpAds_ZoneAppendZone; if (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) { $doZones->addReferenceFilter('agency', OA_Permission::getEntityId()); } elseif (OA_Permission::isAccount(OA_ACCOUNT_TRAFFICKER)) { $doZones->addReferenceFilter('affiliates', OA_Permission::getEntityId()); } $doZones->find(); while ($doZones->fetch() && ($row = $doZones->toArray())) { $append = phpAds_ZoneParseAppendCode($row['append']); if ($append[0]['zoneid'] == $aFields['zoneid']) { $doZonesClone = clone $doZones; $doZonesClone->appendtype = phpAds_ZoneAppendRaw; $doZonesClone->append = ''; $doZonesClone->update(); } } if ($type_changed && $aFields['delivery'] == MAX_ZoneEmail) { // Unlink all campaigns/banners linked to this zone $aPlacementZones = Admin_DA::getPlacementZones(array('zone_id' => $aFields['zoneid']), true, 'placement_id'); if (!empty($aPlacementZones)) { foreach ($aPlacementZones as $placementId => $aPlacementZone) { Admin_DA::deletePlacementZones(array('zone_id' => $aFields['zoneid'], 'placement_id' => $placementId)); } } $aAdZones = Admin_DA::getAdZones(array('zone_id' => $aFields['zoneid']), false, 'ad_id'); if (!empty($aAdZones)) { foreach ($aAdZones as $adId => $aAdZone) { Admin_DA::deleteAdZones(array('zone_id' => $aFields['zoneid'], 'ad_id' => $adId)); } } } else { if ($size_changed) { $aZone = Admin_DA::getZone($aFields['zoneid']); // Loop through all appended banners and make sure that they still fit... $aAds = Admin_DA::getAdZones(array('zone_id' => $aFields['zoneid']), false, 'ad_id'); if (!empty($aAds)) { foreach ($aAds as $adId => $aAd) { $aAd = Admin_DA::getAd($adId); if ($aZone['type'] == phpAds_ZoneText && $aAd['type'] != 'txt' || $aAd['width'] != $aZone['width'] && $aZone['width'] > -1 || $aAd['height'] != $aZone['height'] && $aZone['height'] > -1) { Admin_DA::deleteAdZones(array('zone_id' => $aFields['zoneid'], 'ad_id' => $adId)); } } } // Check if any campaigns linked to this zone have ads that now fit. // If so, link them to the zone. $aPlacementZones = Admin_DA::getPlacementZones(array('zone_id' => $aFields['zoneid']), true); if (!empty($aPlacementZones)) { foreach ($aPlacementZones as $aPlacementZone) { // get ads in this campaign $aAds = Admin_DA::getAds(array('placement_id' => $aPlacementZone['placement_id']), true); foreach ($aAds as $adId => $aAd) { Admin_DA::addAdZone(array('zone_id' => $aFields['zoneid'], 'ad_id' => $adId)); } } } } } // Queue confirmation message $translation = new OX_Translation(); $translated_message = $translation->translate($GLOBALS['strZoneHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, "zone-edit.php?affiliateid=" . $aFields['affiliateid'] . "&zoneid=" . $aFields['zoneid']), htmlspecialchars($aFields['zonename']))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); OX_Admin_Redirect::redirect("zone-edit.php?affiliateid=" . $aFields['affiliateid'] . "&zoneid=" . $aFields['zoneid']); } else { $doZones = OA_Dal::factoryDO('zones'); $doZones->affiliateid = $aFields['affiliateid']; $doZones->zonename = $aFields['zonename']; $doZones->zonetype = phpAds_ZoneCampaign; $doZones->description = $aFields['description']; $doZones->comments = $aFields['comments']; $doZones->width = $aFields['width']; $doZones->height = $aFields['height']; $doZones->delivery = $aFields['delivery']; $doZones->oac_category_id = $aFields['oac_category_id']; // The following fields are NOT NULL but do not get values set in the form. // Should these fields be changed to NULL in the schema or should they have a default value? $doZones->category = ''; $doZones->ad_selection = ''; $doZones->chain = ''; $doZones->prepend = ''; $doZones->append = ''; $aFields['zoneid'] = $doZones->insert(); // Ad Networks $doPublisher = OA_Dal::factoryDO('affiliates'); $doPublisher->get($aFields['affiliateid']); $anWebsiteId = $doPublisher->as_website_id; if ($anWebsiteId) { $oAdNetworks = new OA_Central_AdNetworks(); $oAdNetworks->updateZone($doZones, $anWebsiteId); } // Queue confirmation message $translation = new OX_Translation(); $translated_message = $translation->translate($GLOBALS['strZoneHasBeenAdded'], array(MAX::constructURL(MAX_URL_ADMIN, 'zone-edit.php?affiliateid=' . $aFields['affiliateid'] . '&zoneid=' . $aFields['zoneid']), htmlspecialchars($aFields['zonename']))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); OX_Admin_Redirect::redirect("affiliate-zones.php?affiliateid=" . $aFields['affiliateid']); } } return $errors; }
function MAX_getLinkedAdParams($zoneId) { $aParams = array(); $aZone = Admin_DA::getZone($zoneId); if ($aZone['type'] == phpAds_ZoneText) { $aParams['ad_type'] = 'txt'; } else { $aParams['ad_type'] = '!txt'; if ($aZone['width'] != -1) { $aParams['ad_width'] = $aZone['width']; } if ($aZone['height'] != -1) { $aParams['ad_height'] = $aZone['height']; } } // Allow linking *x* banners $aParams['ad_nosize'] = true; return $aParams; }