From 3e287f888a28872f6da716275790ad612e7a588e Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Tue, 21 Nov 2017 11:32:40 +0100 Subject: [PATCH] add group switch --- .../controllers/admin/d3_usersonline_statistic.php | 11 ++++++++++- .../modules/d3/d3usersonline/models/d3usersonline.php | 11 ++++++++--- .../views/admin/tpl/d3_usersonline_statistic.tpl | 8 +++++++- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/copy_this/modules/d3/d3usersonline/controllers/admin/d3_usersonline_statistic.php b/copy_this/modules/d3/d3usersonline/controllers/admin/d3_usersonline_statistic.php index e39df09..3c14f46 100644 --- a/copy_this/modules/d3/d3usersonline/controllers/admin/d3_usersonline_statistic.php +++ b/copy_this/modules/d3/d3usersonline/controllers/admin/d3_usersonline_statistic.php @@ -21,6 +21,15 @@ class d3_usersonline_statistic extends d3_cfg_mod_main protected $_sMenuSubItemTitle = 'd3mxusersonline_analysis'; + public $blGroupByClass = false; + + public function render() + { + $this->blGroupByClass = oxRegistry::getConfig()->getRequestParameter('groupbyclass') == 'true'; + $this->addTplParam('blGroupByClass', $this->blGroupByClass); + return parent::render(); + } + /** * @return array */ @@ -29,7 +38,7 @@ class d3_usersonline_statistic extends d3_cfg_mod_main /** @var d3usersonline $oUsersOnline */ $oUsersOnline = oxNew('d3usersonline'); $oUsersOnline->clearOldItems($this->_iExpTime); - return $oUsersOnline->getUserCount(); + return $oUsersOnline->getUserCount($this->blGroupByClass); } public function getControllerTitle($sControllerIdent) diff --git a/copy_this/modules/d3/d3usersonline/models/d3usersonline.php b/copy_this/modules/d3/d3usersonline/models/d3usersonline.php index 65f9dce..531209f 100644 --- a/copy_this/modules/d3/d3usersonline/models/d3usersonline.php +++ b/copy_this/modules/d3/d3usersonline/models/d3usersonline.php @@ -66,12 +66,17 @@ class d3usersonline extends oxbase /** * @return array */ - public function getUserCount() + public function getUserCount($blGroupByClass = false) { startProfile(__METHOD__); - $sSelect = "select count(oxid) AS counter, oxclass, oxpage from ". - $this->getViewName()." GROUP BY oxclass, oxpage ORDER BY counter desc"; + if ($blGroupByClass) { + $sSelect = "SELECT count(oxid) AS counter, oxclass FROM " . + $this->getViewName() . " GROUP BY oxclass ORDER BY counter DESC"; + } else { + $sSelect = "select count(oxid) AS counter, oxclass, oxpage from ". + $this->getViewName()." GROUP BY oxclass, oxpage ORDER BY counter desc"; + } $aRecords = oxDb::getDb(oxDb::FETCH_MODE_ASSOC)->getAll($sSelect); $iAllCounter = 0; diff --git a/copy_this/modules/d3/d3usersonline/views/admin/tpl/d3_usersonline_statistic.tpl b/copy_this/modules/d3/d3usersonline/views/admin/tpl/d3_usersonline_statistic.tpl index 9ceffeb..4b0b8ad 100644 --- a/copy_this/modules/d3/d3usersonline/views/admin/tpl/d3_usersonline_statistic.tpl +++ b/copy_this/modules/d3/d3usersonline/views/admin/tpl/d3_usersonline_statistic.tpl @@ -39,6 +39,10 @@