/** * @param OA_Admin_Menu_Section $oSection */ public function check($oSection) { // this checker is called 6 times, not sure why, but we cache the lookup in a static variable static $cache = array(); if (isset($cache[$oSection->getId()])) { return $cache[$oSection->getId()]; } $enabled = false; require_once MAX_PATH . '/www/admin/plugins/videoReport/stats-api.php'; $vast = new OX_Video_Report(); phpAds_registerGlobal('clientid', 'campaignid', 'bannerid', 'zoneid'); global $clientid, $campaignid, $bannerid, $zoneid, $affiliateid; // echo "<pre>";debug_print_backtrace(); switch ($oSection->getId()) { case 'stats-vast-advertiser': $enabled = $vast->doesAdvertiserHaveVast((int) $clientid); break; case 'stats-vast-campaign': $enabled = $vast->doesCampaignHaveVast((int) $campaignid); break; case 'stats-vast-banner': $enabled = $vast->doesBannerHaveVast((int) $bannerid); break; case 'stats-vast-zone': $enabled = $vast->isZoneVast((int) $zoneid); break; case 'stats-vast-website': $enabled = $vast->doesWebsiteHaveVast((int) $affiliateid); break; case 'players-vast': return true; break; case 'zone-invocation': if (!empty($zoneid) && $vast->isZoneVast((int) $zoneid)) { $oSection->setNameKey('Video Invocation Code'); $oSection->setLink('plugins/videoReport/zone-invocation-code.php?zoneid=' . (int) $zoneid . '&affiliateid=' . (int) $affiliateid); } $enabled = true; break; } $cache[$oSection->getId()] = $enabled; return $enabled; }
// Period preset in calendar $today = date('Y-m-d'); $yesterday = date('Y-m-d', strtotime('1 day ago')); $sevenDaysAgo = date('Y-m-d', strtotime('7 days ago')); $thirtyDaysAgo = date('Y-m-d', strtotime('30 days ago')); $availableDateRanges = array('Today' => array($today, $today), 'Yesterday' => array($yesterday, $yesterday), 'Last 7 days' => array($sevenDaysAgo, $today), 'Last 30 days' => array($thirtyDaysAgo, $today)); if (empty($startDate) || empty($endDate)) { $defaultDateRange = 'Last 7 days'; $startDate = $availableDateRanges[$defaultDateRange][0]; $endDate = $availableDateRanges[$defaultDateRange][1]; } if (($selectedDateRangeName = array_search(array($startDate, $endDate), $availableDateRanges)) === false) { $selectedDateRangeName = "{$startDate} - {$endDate}"; } // BUILDING REPORT $videoReport = new OX_Video_Report(); $dataTable = $videoReport->getVastStatistics($entity, $entityId, $dimension, $startDate, $endDate); $columns = $videoReport->getColumnsIdToNameInOrder($availableDimensions[$dimension]); $summaryRow = $videoReport->getSummaryRowFromDataTable($dataTable); if (!empty($exportCsv)) { require_once "stats-export-csv.php"; exit; } $graphMetricsToPlot = OX_Video_Report::$graphMetricsToPlot; $graphEventsIdToName = $graphValues = array(); foreach ($graphMetricsToPlot as $eventId) { $value = 0; if (isset($summaryRow[$eventId])) { $value = $summaryRow[$eventId]; } $graphValues[$eventId] = $value;
/** Testing & QA ============ 1 - Data Generator You can use the data generator to generate data directly in the stats_vast table. At the beginning of "/openx/www/admin/plugins/videoReport/stats-debug.php" you will find the related code. Note that you can customize the range of banner and zone id to generate. 2 - Data checks Calling the API for all entities and all combination of "View As" ; look and set $outputAllCallGetStatistics to true in "/openx/www/admin/plugins/videoReport/stats-debug.php" NOTE: To trigger the data generator or the data check, you just have to visit any of the "Video Report" tabs, in the Statistics section. Don't try and access stats-debug.php directly in your browser as it will fail. */ $videoReport = new OX_Video_Report(); // Generate fake stats? // Note: you can generate for any campaign and banner; However if you generate stats for a non-vast banner // and then try to access the UI for reporting of this non-vast banner, the "access check" will fail and // the error "Menu system error: Manager::stats-vast-campaign not found for the current user" will be displayed. $generateFakeStatistics = false; if ($generateFakeStatistics) { $bannerIds = range($minBannerId = 1, $maxBannerId = 3, $step = 1); $zoneIds = range($minZoneId = 4, $maxZoneId = 5, $step = 1); $pastDays = 17; echo "generating fake data for " . count($bannerIds) . " banners and " . count($zoneIds) . " zones for the last " . $pastDays . " days...<br>"; flush(); foreach ($bannerIds as $bannerId) { foreach ($zoneIds as $zoneId) { $videoReport->generateFakeVastStatistics($pastDays, $bannerId, $zoneId); }