diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 1bf209cf8b..3e49324c9a 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -51,6 +51,10 @@ New Features * Added support for writing to a fail2ban compatible log file on unsuccessful login attempts. + * Replaced advertiser and website statistics with a new account statistics + screen for administrator users. + + Bug Fixes --------- diff --git a/lib/OA/Admin/Menu/config.php b/lib/OA/Admin/Menu/config.php index e17e298c23..fd34610952 100644 --- a/lib/OA/Admin/Menu/config.php +++ b/lib/OA/Admin/Menu/config.php @@ -26,7 +26,10 @@ function _buildNavigation($accountType) } // Note: The stats screens haven't been updated to use the new menuing names... - $oMenu->add(new OA_Admin_Menu_Section("2", 'Stats', "stats.php?entity=global&breakdown=history", false, "statistics")); + $oMenu->add(new OA_Admin_Menu_Section("2", 'Stats', "stats.php?entity=global&breakdown=agency", false, "statistics")); + $oMenu->addTo("2", new OA_Admin_Menu_Section("2.9", 'GlobalAgency', "stats.php?entity=global&breakdown=agency", false, "statistics/agencies")); + $oMenu->addTo("2.9", new OA_Admin_Menu_Section("2.9.1", 'AgencyHistory', "stats.php?entity=agency&breakdown=history&agencyid={agencyid}", false, "statistics/agencyHistory")); + $oMenu->addTo("2.9.1", new OA_Admin_Menu_Section("2.9.1.1", 'DailyStats', "stats.php?entity=agency&breakdown=daily&agencyid={agencyid}&day={day}", false, "statistics/agencyHistory/daily")); $oMenu->addTo("2", new OA_Admin_Menu_Section("2.2", 'GlobalHistory', "stats.php?entity=global&breakdown=history", false, "statistics/global")); $oMenu->addTo("2.2", new OA_Admin_Menu_Section("2.2.1", 'DailyStats', "stats.php?entity=global&breakdown=daily&day={day}", false, "statistics/global/daily")); $oMenu->addTo("2", new OA_Admin_Menu_Section("report-index", 'AdvancedReports', "report-index.php", false, "statistics")); diff --git a/lib/OA/Admin/Statistics/Common.php b/lib/OA/Admin/Statistics/Common.php index f789a9bee1..5698bc2b0e 100644 --- a/lib/OA/Admin/Statistics/Common.php +++ b/lib/OA/Admin/Statistics/Common.php @@ -589,7 +589,7 @@ public function _pluginSort($a, $b) * @access private * @param string $type One of "advertiser", "publisher", "placement", * "ad", "zone". - * @param ingeger $default Optional default value. + * @param integer|null $default Optional default value. * @return integer The appropriate ID field. */ public function _getId($type, $default = null) @@ -628,6 +628,12 @@ public function _getId($type, $default = null) } else { return (int) MAX_getValue('zoneid', $default); } + } elseif ($type == 'agency') { + if (is_null($default)) { + return (int) MAX_getValue('agencyid', ''); + } else { + return (int) MAX_getValue('agencyid', $default); + } } } diff --git a/lib/OA/Admin/Statistics/Delivery/CommonEntity.php b/lib/OA/Admin/Statistics/Delivery/CommonEntity.php index fdd82481d1..3573c38a46 100644 --- a/lib/OA/Admin/Statistics/Delivery/CommonEntity.php +++ b/lib/OA/Admin/Statistics/Delivery/CommonEntity.php @@ -54,6 +54,7 @@ abstract class OA_Admin_Statistics_Delivery_CommonEntity extends OA_Admin_Statis 'b' => 'stats.php?entity=banner&breakdown=history', 'p' => 'stats.php?entity=affiliate&breakdown=history', 'z' => 'stats.php?entity=zone&breakdown=history', + 'g' => 'stats.php?entity=agency&breakdown=history', ]; /** @@ -240,6 +241,7 @@ public function prepareData($aParams) } $this->data = [ + 'agency_id' => [], 'advertiser_id' => [], 'placement_id' => [], 'ad_id' => [], @@ -303,6 +305,9 @@ public function prepareData($aParams) } } } + if (in_array('agency_id', $aggregates)) { + $this->childrendata['agency_id'] = Admin_DA::fromCache('getAgencies', $aParams); + } foreach ($aRows as $row) { foreach ($aggregates as $agg) { @@ -354,59 +359,52 @@ public function mergeData($aParams, $key) } /** - * Get advertiser stats + * Get agency stats * * @param array Query parameters * @param int Tree level * @param string Expand GET parameter, used only when called from other get methods - * @return Entities array + * @return array Entities array */ - public function getAdvertisers($aParams, $level, $expand = '') + public function getAgencies($aParams) { - $aParams['include'] = ['advertiser_id', 'placement_id']; - $aParams['exclude'] = ['zone_id']; + $aParams['include'] = ['agency_id']; + $aParams['exclude'] = ['advertiser_id', 'zone_id', 'ad_id', 'placement_id']; $this->prepareData($aParams); $period_preset = MAX_getStoredValue('period_preset', 'today'); - $aAdvertisers = $this->mergeData($aParams, 'advertiser_id'); + $aAgencies = $this->mergeData($aParams, 'agency_id'); MAX_sortArray( - $aAdvertisers, - ($this->listOrderField == 'id' ? 'advertiser_id' : $this->listOrderField), + $aAgencies, + ($this->listOrderField == 'id' ? 'agency_id' : $this->listOrderField), $this->listOrderDirection == 'up', ); $aEntitiesData = []; - foreach ($aAdvertisers as $advertiserId => $advertiser) { - $advertiser['active'] = $this->_hasActiveStats($advertiser); + foreach ($aAgencies as $agencyId => $agency) { + $agency['active'] = $this->_hasActiveStats($agency); - $this->_summarizeStats($advertiser); + $this->_summarizeStats($agency); - if ($this->startLevel > $level || !$this->hideInactive || $advertiser['active']) { - $advertiser['prefix'] = 'a'; - $advertiser['id'] = $advertiserId; - $advertiser['linkparams'] = "clientid={$advertiserId}&"; + if (!$this->hideInactive || $agency['active']) { + $agency['prefix'] = 'g'; + $agency['id'] = $agencyId; + $agency['linkparams'] = "agencyid={$agencyId}&"; if (is_array($aParams) && $aParams !== []) { foreach ($aParams as $key => $value) { if ($key != "include" && $key != "exclude") { - $advertiser['linkparams'] .= $key . "=" . $value . "&"; + $agency['linkparams'] .= $key . "=" . $value . "&"; } } } else { - $advertiser['linkparams'] .= "&"; + $agency['linkparams'] .= "&"; } - $advertiser['linkparams'] .= "period_preset={$period_preset}&period_start=" . MAX_getStoredValue('period_start', date('Y-m-d')) - . "&period_end=" . MAX_getStoredValue('period_end', date('Y-m-d')); - - $advertiser['conversionslink'] = "stats.php?entity=conversions&clientid={$advertiserId}"; - $advertiser['expanded'] = MAX_isExpanded($advertiserId, $expand, $this->aNodes, $advertiser['prefix']); - $advertiser['icon'] = MAX_getEntityIcon('advertiser', $advertiser['active'], $advertiser['type']); + $agency['linkparams'] .= "period_preset={$period_preset}&period_start=" . MAX_getStoredValue('period_start', date('Y-m-d')) + . "&period_end=" . MAX_getStoredValue('period_end', date('Y-m-d')); - if ($advertiser['expanded'] || $this->startLevel > $level) { - $aParams2 = $aParams + ['advertiser_id' => $advertiserId]; - $advertiser['subentities'] = $this->getCampaigns($aParams2, $level + 1, $expand); - } + $agency['icon'] = MAX_getEntityIcon('agency', $agency['active']); - $aEntitiesData[] = $advertiser; - } elseif ($this->startLevel == $level) { + $aEntitiesData[] = $agency; + } else { $this->hiddenEntities++; } } @@ -420,7 +418,7 @@ public function getAdvertisers($aParams, $level, $expand = '') * @param array Query parameters * @param int Tree level * @param string Expand GET parameter, used only when called from other get methods - * @return Entities array + * @return array Entities array */ public function getCampaigns($aParams, $level, $expand = '') { @@ -467,7 +465,7 @@ public function getCampaigns($aParams, $level, $expand = '') $campaign['linkparams'] .= "&"; } $campaign['linkparams'] .= "period_preset={$period_preset}&period_start=" . MAX_getStoredValue('period_start', date('Y-m-d')) - . "&period_end=" . MAX_getStoredValue('period_end', date('Y-m-d')); + . "&period_end=" . MAX_getStoredValue('period_end', date('Y-m-d')); $campaign['expanded'] = MAX_isExpanded($campaignId, $expand, $this->aNodes, $campaign['prefix']); $campaign['icon'] = MAX_getEntityIcon('placement', $campaign['active'], $campaign['type']); @@ -495,6 +493,67 @@ public function getCampaigns($aParams, $level, $expand = '') return $aEntitiesData; } + /** + * Get advertiser stats + * + * @param array Query parameters + * @param int Tree level + * @param string Expand GET parameter, used only when called from other get methods + * @return array Entities array + */ + public function getAdvertisers($aParams, $level, $expand = '') + { + $aParams['include'] = ['advertiser_id', 'placement_id']; + $aParams['exclude'] = ['zone_id']; + $this->prepareData($aParams); + $period_preset = MAX_getStoredValue('period_preset', 'today'); + $aAdvertisers = $this->mergeData($aParams, 'advertiser_id'); + MAX_sortArray( + $aAdvertisers, + ($this->listOrderField == 'id' ? 'advertiser_id' : $this->listOrderField), + $this->listOrderDirection == 'up', + ); + + $aEntitiesData = []; + foreach ($aAdvertisers as $advertiserId => $advertiser) { + $advertiser['active'] = $this->_hasActiveStats($advertiser); + + $this->_summarizeStats($advertiser); + + if ($this->startLevel > $level || !$this->hideInactive || $advertiser['active']) { + $advertiser['prefix'] = 'a'; + $advertiser['id'] = $advertiserId; + $advertiser['linkparams'] = "clientid={$advertiserId}&"; + if (is_array($aParams) && $aParams !== []) { + foreach ($aParams as $key => $value) { + if ($key != "include" && $key != "exclude") { + $advertiser['linkparams'] .= $key . "=" . $value . "&"; + } + } + } else { + $advertiser['linkparams'] .= "&"; + } + $advertiser['linkparams'] .= "period_preset={$period_preset}&period_start=" . MAX_getStoredValue('period_start', date('Y-m-d')) + . "&period_end=" . MAX_getStoredValue('period_end', date('Y-m-d')); + + $advertiser['conversionslink'] = "stats.php?entity=conversions&clientid={$advertiserId}"; + $advertiser['expanded'] = MAX_isExpanded($advertiserId, $expand, $this->aNodes, $advertiser['prefix']); + $advertiser['icon'] = MAX_getEntityIcon('advertiser', $advertiser['active'], $advertiser['type']); + + if ($advertiser['expanded'] || $this->startLevel > $level) { + $aParams2 = $aParams + ['advertiser_id' => $advertiserId]; + $advertiser['subentities'] = $this->getCampaigns($aParams2, $level + 1, $expand); + } + + $aEntitiesData[] = $advertiser; + } elseif ($this->startLevel == $level) { + $this->hiddenEntities++; + } + } + + return $aEntitiesData; + } + /** * Returns the HTML used to display the help icon triggering the tooltip * @param $id ID of the html div to show on hover @@ -511,7 +570,7 @@ private function getHtmlHelpLink($id) * @param array Query parameters * @param int Tree level * @param string Expand GET parameter, used only when called from other get methods - * @return Entities array + * @return array Entities array */ public function getBanners($aParams, $level, $expand = '') { @@ -574,7 +633,7 @@ public function getBanners($aParams, $level, $expand = '') * @param array Query parameters * @param int Tree level * @param string Expand GET parameter, used only when called from other get methods - * @return Entities array + * @return array Entities array */ public function getPublishers($aParams, $level, $expand = '') { @@ -634,7 +693,7 @@ public function getPublishers($aParams, $level, $expand = '') * @param array Query parameters * @param int Tree level * @param string Expand GET parameter, used only when called from other get methods - * @return Entities array + * @return array Entities array */ public function getZones($aParams, $level, $expand) { diff --git a/lib/OA/Admin/Statistics/Delivery/Controller/AgencyDaily.php b/lib/OA/Admin/Statistics/Delivery/Controller/AgencyDaily.php new file mode 100644 index 0000000000..815efa2b72 --- /dev/null +++ b/lib/OA/Admin/Statistics/Delivery/Controller/AgencyDaily.php @@ -0,0 +1,90 @@ + Accounts -> Daily Statistics + * + * @package OpenXAdmin + * @subpackage StatisticsDelivery + */ +class OA_Admin_Statistics_Delivery_Controller_AgencyDaily extends OA_Admin_Statistics_Delivery_CommonCrossHistory +{ + /** + * The final "child" implementation of the PHP5-style constructor. + * + * @param array $aParams An array of parameters. The array should + * be indexed by the name of object variables, + * with the values that those variables should + * be set to. For example, the parameter: + * $aParams = array('foo' => 'bar') + * would result in $this->foo = bar. + */ + public function __construct($aParams) + { + // Set this page's entity/breakdown values + $this->entity = 'agency'; + $this->breakdown = 'daily'; + + // Use the OA_Admin_Statistics_Daily helper class + $this->useDailyClass = true; + + parent::__construct($aParams); + } + + /** + * The final "child" implementation of the parental abstract method. + * + * @see OA_Admin_Statistics_Common::start() + */ + public function start() + { + // Get parameters + $agencyId = $this->_getId('agency'); + + // Security check + OA_Permission::enforceAccount(OA_ACCOUNT_ADMIN); + + // Add standard page parameters + $this->aPageParams = ['agencyid' => $agencyId]; + + // Load $_GET parameters + $this->_loadParams(); + + // Load the period preset and stats breakdown parameters + $this->_loadPeriodPresetParam(); + $this->_loadStatsBreakdownParam(); + + // HTML Framework + $this->pageId = '2.9.1.1'; + $this->aPageSections = [$this->pageId]; + + // Add breadcrumbs + $this->_addBreadcrumbs('agency', $agencyId); + + // Add shortcuts + $this->_addShortcut( + $GLOBALS['strAgencyProperties'], + 'agency-edit.php?agencyid=' . $agencyId, + 'iconAgency', + ); + + // Prepare the data for display by output() method + $aParams = [ + 'agency_id' => $agencyId, + ]; + $this->prepare($aParams); + } +} diff --git a/lib/OA/Admin/Statistics/Delivery/Controller/AgencyHistory.php b/lib/OA/Admin/Statistics/Delivery/Controller/AgencyHistory.php new file mode 100644 index 0000000000..8cba2251f5 --- /dev/null +++ b/lib/OA/Admin/Statistics/Delivery/Controller/AgencyHistory.php @@ -0,0 +1,92 @@ + Accounts + * + * @package OpenXAdmin + * @subpackage StatisticsDelivery + */ +class OA_Admin_Statistics_Delivery_Controller_AgencyHistory extends OA_Admin_Statistics_Delivery_CommonHistory +{ + /** + * The final "child" implementation of the PHP5-style constructor. + * + * @param array $aParams An array of parameters. The array should + * be indexed by the name of object variables, + * with the values that those variables should + * be set to. For example, the parameter: + * $aParams = array('foo' => 'bar') + * would result in $this->foo = bar. + */ + public function __construct($aParams) + { + // Set this page's entity/breakdown values + $this->entity = 'agency'; + $this->breakdown = 'history'; + + // This page uses the day span selector element + $this->showDaySpanSelector = true; + + parent::__construct($aParams); + } + + /** + * The final "child" implementation of the parental abstract method. + * + * @see OA_Admin_Statistics_Common::start() + */ + public function start() + { + // Get parameters + $agencyId = $this->_getId('agency'); + + // Security check + OA_Permission::enforceAccount(OA_ACCOUNT_ADMIN); + + // Add standard page parameters + $this->aPageParams = [ + 'agencyid' => $agencyId, + ]; + + // Load the period preset and stats breakdown parameters + $this->_loadPeriodPresetParam(); + $this->_loadStatsBreakdownParam(); + + // Load $_GET parameters + $this->_loadParams(); + + // HTML Framework + $this->pageId = '2.9.1'; + $this->aPageSections = [$this->pageId]; + + // Add breadcrumbs + $this->_addBreadcrumbs('agency', $agencyId); + + // Add shortcuts + $this->_addShortcut( + $GLOBALS['strAgencyProperties'], + 'agency-edit.php?agencyid=' . $agencyId, + 'iconAgency', + ); + + // Prepare the data for display by output() method + $aParams = [ + 'agency_id' => $agencyId, + ]; + $this->prepare($aParams, 'stats.php'); + } +} diff --git a/lib/OA/Admin/Statistics/Delivery/Controller/GlobalAgency.php b/lib/OA/Admin/Statistics/Delivery/Controller/GlobalAgency.php new file mode 100644 index 0000000000..c458c717c2 --- /dev/null +++ b/lib/OA/Admin/Statistics/Delivery/Controller/GlobalAgency.php @@ -0,0 +1,100 @@ + Accounts + * + * @package OpenXAdmin + * @subpackage StatisticsDelivery + */ +class OA_Admin_Statistics_Delivery_Controller_GlobalAgency extends OA_Admin_Statistics_Delivery_CommonEntity +{ + /** + * The final "child" implementation of the PHP5-style constructor. + * + * @param array $aParams An array of parameters. The array should + * be indexed by the name of object variables, + * with the values that those variables should + * be set to. For example, the parameter: + * $aParams = array('foo' => 'bar') + * would result in $this->foo = bar. + */ + public function __construct($aParams) + { + // Set this page's entity/breakdown values + $this->entity = 'global'; + $this->breakdown = 'agency'; + + // This page uses the day span selector element + $this->showDaySpanSelector = true; + + parent::__construct($aParams); + } + + /** + * The final "child" implementation of the parental abstract method. + * + * @see OA_Admin_Statistics_Common::start() + */ + public function start() + { + // Get the preferences + $aPref = $GLOBALS['_MAX']['PREF']; + + // Security check + OA_Permission::enforceAccount(OA_ACCOUNT_ADMIN); + + // HTML Framework + $this->pageId = '2.9'; + $this->aPageSections = ['2.4', '2.9']; + + $this->hideInactive = MAX_getStoredValue('hideinactive', ($aPref['ui_hide_inactive'] == true), null, true); + $this->showHideInactive = true; + + $this->startLevel = MAX_getStoredValue('startlevel', 0, null, true); + + // Init nodes + $this->aNodes = MAX_getStoredArray('nodes', []); + $expand = MAX_getValue('expand', ''); + $collapse = MAX_getValue('collapse'); + + // Adjust which nodes are opened closed... + MAX_adjustNodes($this->aNodes, $expand, $collapse); + + $aParams = $this->coreParams; + + // Load the period preset and stats breakdown parameters + $this->_loadPeriodPresetParam(); + $this->_loadStatsBreakdownParam(); + + $this->_loadParams(); + + $this->aEntitiesData = $this->getAgencies($aParams); + + // Summarise the values into the totals array, & format + $this->_summariseTotalsAndFormat($this->aEntitiesData); + + // Location params + $this->aPageParams['period_preset'] = MAX_getStoredValue('period_preset', 'today'); + $this->aPageParams['statsBreakdown'] = htmlspecialchars(MAX_getStoredValue('statsBreakdown', 'day')); + $this->aPageParams['period_start'] = htmlspecialchars(MAX_getStoredValue('period_start', date('Y-m-d'))); + $this->aPageParams['period_end'] = htmlspecialchars(MAX_getStoredValue('period_end', date('Y-m-d'))); + $this->_loadParams(); + + // Save preferences + $this->aPagePrefs['hideinactive'] = $this->hideInactive; + } +} diff --git a/lib/OA/Admin/Statistics/Fields/Delivery.php b/lib/OA/Admin/Statistics/Fields/Delivery.php index b960820d74..3177a8c563 100644 --- a/lib/OA/Admin/Statistics/Fields/Delivery.php +++ b/lib/OA/Admin/Statistics/Fields/Delivery.php @@ -391,8 +391,8 @@ public function mergeConversions(&$aRows, $method, $aParams, $emptyRow) $aFields[] = "CONCAT(diac.ad_id, '_', diac.zone_id) AS pkey"; } elseif (!isset($aParams['exclude']['ad_id'])) { $aFields[] = "diac.ad_id AS pkey"; - } else { - $aFields[] = "diac.zone_id AS pkey"; + } elseif (!isset($aParams['exclude']['zone_id'])) { + $aFields[] = "(0) AS pkey"; } } else { $aParams['exclude']['ad_id'] = true; @@ -441,14 +441,20 @@ public function mergeConversions(&$aRows, $method, $aParams, $emptyRow) " AND '" . $oEndDate->format('%Y-%m-%d %H:%M:%S') . "'"; } - if (!empty($aParams['agency_id'])) { + if (!empty($aParams['agency_id']) || isset($aParams['include']['agency_id'])) { $aFrom['b'] = "JOIN {$conf['table']['prefix']}{$conf['table']['banners']} b ON (b.bannerid = diac.ad_id)"; $aFrom['m'] = "JOIN {$conf['table']['prefix']}{$conf['table']['campaigns']} m ON (m.campaignid = b.campaignid)"; $aFrom['c'] = "JOIN {$conf['table']['prefix']}{$conf['table']['clients']} c ON (c.clientid = m.clientid)"; - $aFrom['z'] = "LEFT JOIN {$conf['table']['prefix']}{$conf['table']['zones']} z ON (z.zoneid = diac.zone_id)"; - $aFrom['p'] = "LEFT JOIN {$conf['table']['prefix']}{$conf['table']['affiliates']} p ON (p.affiliateid = z.affiliateid AND p.agencyid = '{$aParams['agency_id']}')"; - $aWhere[] = "c.agencyid = '{$aParams['agency_id']}'"; + if (!empty($aParams['agency_id'])) { + $aFrom['z'] = "LEFT JOIN {$conf['table']['prefix']}{$conf['table']['zones']} z ON (z.zoneid = diac.zone_id)"; + $aFrom['p'] = "LEFT JOIN {$conf['table']['prefix']}{$conf['table']['affiliates']} p ON (p.affiliateid = z.affiliateid AND p.agencyid = '{$aParams['agency_id']}')"; + + $aWhere[] = "c.agencyid = '{$aParams['agency_id']}'"; + } else { + $aFields[] = "c.agencyid AS agency_id"; + $aGroupBy[] = "agency_id"; + } } if (!empty($aParams['advertiser_id']) || isset($aParams['include']['advertiser_id'])) { $aFrom['b'] = "JOIN {$conf['table']['prefix']}{$conf['table']['banners']} b ON (b.bannerid = diac.ad_id)"; diff --git a/lib/OA/Admin/Statistics/tests/unit/Factory.admin.test.php b/lib/OA/Admin/Statistics/tests/unit/Factory.admin.test.php index 37fedd134e..c2dfc24e78 100644 --- a/lib/OA/Admin/Statistics/tests/unit/Factory.admin.test.php +++ b/lib/OA/Admin/Statistics/tests/unit/Factory.admin.test.php @@ -45,6 +45,8 @@ class Test_OA_Admin_Statistics_Factory extends UnitTestCase 'affiliate-history' => 'OA_Admin_Statistics_Delivery_Controller_AffiliateHistory', 'affiliate-zones' => 'OA_Admin_Statistics_Delivery_Controller_AffiliateZones', + 'agency-history' => 'OA_Admin_Statistics_Delivery_Controller_AgencyHistory', + 'banner-affiliates' => 'OA_Admin_Statistics_Delivery_Controller_BannerAffiliates', 'banner-affiliate-history' => 'OA_Admin_Statistics_Delivery_Controller_BannerAffiliateHistory', //'banner-daily' => 'OA_Admin_Statistics_Delivery_Controller_BannerDaily', @@ -60,6 +62,7 @@ class Test_OA_Admin_Statistics_Factory extends UnitTestCase 'global-advertiser' => 'OA_Admin_Statistics_Delivery_Controller_GlobalAdvertiser', 'global-affiliates' => 'OA_Admin_Statistics_Delivery_Controller_GlobalAffiliates', + 'global-agency' => 'OA_Admin_Statistics_Delivery_Controller_GlobalAgency', //'global-daily' => 'OA_Admin_Statistics_Delivery_Controller_GlobalDaily', 'global-history' => 'OA_Admin_Statistics_Delivery_Controller_GlobalHistory', diff --git a/lib/max/SqlBuilder.php b/lib/max/SqlBuilder.php index 82a1a8aa84..e66bcd9a41 100644 --- a/lib/max/SqlBuilder.php +++ b/lib/max/SqlBuilder.php @@ -131,6 +131,9 @@ public static function _getColumns($entity, $aParams, $allFields) case 'stats_by_entity': if (isset($aParams['include']) && is_array($aParams['include'])) { + if (in_array('agency_id', $aParams['include'])) { + $aColumns += ['g.agencyid' => 'agency_id']; + } if (in_array('advertiser_id', $aParams['include'])) { $aColumns += ['m.clientid' => 'advertiser_id']; } @@ -166,6 +169,7 @@ public static function _getColumns($entity, $aParams, $allFields) 'placement_id' => 'd.campaignid', 'advertiser_id' => 'm.clientid', 'publisher_id' => 'z.affiliateid', + 'agency_id' => 'g.agencyid', ]; $aColumns[strtr(self::sqlKeyConcat($aParams['include']), $tr)] = 'pkey'; } else { @@ -593,6 +597,14 @@ public static function _getTables($entity, $aParams, $includeStats = false) $aTables += [$conf['table']['prefix'] . $conf['table']['data_summary_ad_hourly'] => 's']; } + if (in_array('agency_id', $aParams['include'] ?? [])) { + $aTables += [ + $conf['table']['prefix'] . $conf['table']['agency'] => 'g', + $conf['table']['prefix'] . $conf['table']['affiliates'] => 'p', + $conf['table']['prefix'] . $conf['table']['zones'] => 'z', + ]; + } + if (!empty($aParams['agency_id'])) { if (!in_array('ad_id', $aParams['exclude'] ?? [])) { $aTables += [ diff --git a/lib/max/language/en/default.lang.php b/lib/max/language/en/default.lang.php index 4e9a7bcb59..1e22d81777 100644 --- a/lib/max/language/en/default.lang.php +++ b/lib/max/language/en/default.lang.php @@ -991,6 +991,7 @@ // Agency $GLOBALS['strAgencyManagement'] = "Account Management"; +$GLOBALS['strGlobalAgency'] = 'Accounts'; $GLOBALS['strAgency'] = "Account"; $GLOBALS['strAddAgency'] = "Add new account"; $GLOBALS['strAddAgency_Key'] = "Add new account"; diff --git a/lib/max/other/html.php b/lib/max/other/html.php index 018f36de98..12bb31c188 100644 --- a/lib/max/other/html.php +++ b/lib/max/other/html.php @@ -37,12 +37,13 @@ function MAX_buildName($id, $name) return htmlspecialchars($name); } -function MAX_getEntityIcon($entity, $active = true, $type = '', $marketAdvertiserid = '') +function MAX_getEntityIcon($entity, $active = true, $type = '') { include_once MAX_PATH . '/www/admin/lib-zones.inc.php'; $icon = ''; switch ($entity) { + case 'agency': case 'advertiser': $icon = $active ? 'images/icon-advertiser.gif' : 'images/icon-advertiser-d.gif'; break; @@ -67,8 +68,7 @@ function MAX_getEntityIcon($entity, $active = true, $type = '', $marketAdvertise case 'zone': switch ($type) { - case MAX_ZoneMarketMigrated: $icon = 'images/icon-advertiser-openx.png'; - break; + default: case phpAds_ZoneBanner: $icon = 'images/icon-zone.gif'; break; case phpAds_ZoneInterstitial: $icon = 'images/icon-interstitial.gif'; @@ -81,8 +81,6 @@ function MAX_getEntityIcon($entity, $active = true, $type = '', $marketAdvertise break; case MAX_ZoneClick: $icon = 'images/icon-zone-click.gif'; break; - default: $icon = 'images/icon-zone.gif'; - break; } break; } diff --git a/www/admin/assets/css/icons.css b/www/admin/assets/css/icons.css index 15aa087f18..2450ce80d1 100644 --- a/www/admin/assets/css/icons.css +++ b/www/admin/assets/css/icons.css @@ -20,9 +20,6 @@ div.breadcrumb .inlineIcon { .iconAdvertiser { background-image: url("../images/icon-advertiser.png"); } -.iconAdvertiserSystem { - background-image: url("../images/icon-advertiser-openx.png"); -} .iconAdvertiserLarge { background-image: url("../images/icon-advertiser-large.png"); } @@ -41,12 +38,6 @@ div.breadcrumb .inlineIcon { .iconCampaign { background-image: url("../images/icon-campaign.png"); } -.iconCampaignSystem { - background-image: url("../images/icon-campaign-openx.png"); -} -.iconCampaignSystemLarge { - background-image: url("../images/icon-campaign-openx-large.png"); -} .iconCampaignDisabled { background-image: url("../images/icon-campaign-disabled.png"); } @@ -62,12 +53,6 @@ div.breadcrumb .inlineIcon { .iconCampaignAddLarge { background-image: url("../images/icon-campaign-add-large.png"); } -.iconCampaignSystemAdd { - background-image: url("../images/icon-campaign-openx-add.png"); -} -.iconCampaignSystemAddLarge { - background-image: url("../images/icon-campaign-openx-add-large.png"); -} .iconCampaignDuplicate { background-image: url("../images/icon-campaign-duplicate.png"); } @@ -83,12 +68,6 @@ div.breadcrumb .inlineIcon { .iconCampaignsLarge { background-image: url("../images/icon-campaigns-large.png"); } -.iconCampaignsSystem { - background-image: url("../images/icon-campaigns-openx.png"); -} -.iconCampaignsSystemLarge { - background-image: url("../images/icon-campaigns-openx-large.png"); -} .iconTracker { background-image: url("../images/icon-tracker.png"); } diff --git a/www/admin/assets/images/icon-campaign-openx-add-large.png b/www/admin/assets/images/icon-campaign-openx-add-large.png deleted file mode 100644 index 55bf526391..0000000000 Binary files a/www/admin/assets/images/icon-campaign-openx-add-large.png and /dev/null differ diff --git a/www/admin/assets/images/icon-campaign-openx-add.png b/www/admin/assets/images/icon-campaign-openx-add.png deleted file mode 100644 index c3bbd0a5f8..0000000000 Binary files a/www/admin/assets/images/icon-campaign-openx-add.png and /dev/null differ diff --git a/www/admin/assets/images/icon-campaign-openx-large.png b/www/admin/assets/images/icon-campaign-openx-large.png deleted file mode 100644 index e36e58fe5e..0000000000 Binary files a/www/admin/assets/images/icon-campaign-openx-large.png and /dev/null differ diff --git a/www/admin/assets/images/icon-campaign-openx.png b/www/admin/assets/images/icon-campaign-openx.png deleted file mode 100644 index 15858e2144..0000000000 Binary files a/www/admin/assets/images/icon-campaign-openx.png and /dev/null differ