require_once MAX_PATH . '/lib/pear/Date.php'; require_once MAX_PATH . '/lib/max/other/html.php'; require_once MAX_PATH . '/lib/OX/Admin/UI/ViewHooks.php'; phpAds_registerGlobalUnslashed('hideinactive', 'listorder', 'orderdirection'); // Security check OA_Permission::enforceAccount(OA_ACCOUNT_MANAGER, OA_ACCOUNT_ADVERTISER); if (!empty($clientid) && !OA_Permission::hasAccessToObject('clients', $clientid, OA_Permission::OPERATION_VIEW)) { //check if can see given advertiser $page = basename($_SERVER['SCRIPT_NAME']); OX_Admin_Redirect::redirect($page); } /*-------------------------------------------------------*/ /* Init data */ /*-------------------------------------------------------*/ //get advertisers and set the current one $aAdvertisers = getAdvertiserMap(); if (empty($clientid)) { //if it's empty if ($session['prefs']['inventory_entities'][OA_Permission::getEntityId()]['clientid']) { //try previous one from session $sessionClientId = $session['prefs']['inventory_entities'][OA_Permission::getEntityId()]['clientid']; if (isset($aAdvertisers[$sessionClientId])) { //check if 'id' from session was not removed $clientid = $sessionClientId; } } if (empty($clientid)) { //was empty, is still empty - just pick one, no need for redirect $ids = array_keys($aAdvertisers); $clientid = !empty($ids) ? $ids[0] : -1; //if no advertisers set to non-existent id
function buildHeaderModel($aEntities) { global $phpAds_TextDirection; $aConf = $GLOBALS['_MAX']['CONF']; $advertiserId = $aEntities['clientid']; $campaignId = $aEntities['campaignid']; $agencyId = OA_Permission::getAgencyId(); $entityString = _getEntityString($aEntities); $aOtherEntities = $aEntities; unset($aOtherEntities['campaignid']); $otherEntityString = _getEntityString($aOtherEntities); $advertiser = phpAds_getClientDetails($advertiserId); $advertiserName = $advertiser['clientname']; $campaignDetails = Admin_DA::getPlacement($campaignId); $campaignName = $campaignDetails['name']; if (!OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER)) { $campaignEditUrl = "campaign-edit.php?clientid={$advertiserId}&campaignid={$campaignId}"; } $builder = new OA_Admin_UI_Model_InventoryPageHeaderModelBuilder(); $oHeaderModel = $builder->buildEntityHeader(array(array('name' => $advertiserName, 'url' => '', 'id' => $advertiserId, 'entities' => getAdvertiserMap($agencyId), 'htmlName' => 'clientid'), array('name' => $campaignName, 'url' => $campaignEditUrl, 'id' => $campaignId, 'entities' => getCampaignMap($advertiserId), 'htmlName' => 'campaignid'), array('name' => '')), 'banners', 'list'); return $oHeaderModel; }