diff --git a/core/Config.php b/core/Config.php index a37dd19e52a6043c60c1bfa93c8b386c5b80a236..dfade336737746fe93240286e67131d50864c80f 100644 --- a/core/Config.php +++ b/core/Config.php @@ -135,8 +135,6 @@ class Config $this->configCache['Plugins'] = $this->configGlobal['Plugins']; $this->configCache['Plugins']['Plugins'][] = 'DevicesDetection'; } - - $this->configCache['disable_merged_assets'] = 1; } /** diff --git a/plugins/UserCountryMap/Controller.php b/plugins/UserCountryMap/Controller.php index 8b868c406e44fd1bf744da8972b655249dd8dd8e..6a75075e62d411975bea181835369d18dbd580bc 100644 --- a/plugins/UserCountryMap/Controller.php +++ b/plugins/UserCountryMap/Controller.php @@ -185,7 +185,8 @@ class Controller extends \Piwik\Controller 'removeOldVisits' => Common::getRequestVar('removeOldVisits', true, 'int'), 'showFooterMessage' => Common::getRequestVar('showFooterMessage', true, 'int'), 'showDateTime' => Common::getRequestVar('showDateTime', true, 'int'), - 'doNotRefreshVisits' => Common::getRequestVar('doNotRefreshVisits', false, 'int') + 'doNotRefreshVisits' => Common::getRequestVar('doNotRefreshVisits', false, 'int'), + 'enableAnimation' => Common::getRequestVar('enableAnimation', true, 'int') ); if ($fetch) { diff --git a/plugins/UserCountryMap/javascripts/realtime-map.js b/plugins/UserCountryMap/javascripts/realtime-map.js index 805b30e73b717c00e0ac638c16e641b8ec58f4eb..f42a7aadef48c31e4e69ae85c4af3ac2b667380e 100644 --- a/plugins/UserCountryMap/javascripts/realtime-map.js +++ b/plugins/UserCountryMap/javascripts/realtime-map.js @@ -81,6 +81,7 @@ changeVisitAlpha = typeof config.changeVisitAlpha === 'undefined' ? true : config.changeVisitAlpha, removeOldVisits = typeof config.removeOldVisits === 'undefined' ? true : config.removeOldVisits, doNotRefreshVisits = typeof config.doNotRefreshVisits === 'undefined' ? false : config.doNotRefreshVisits, + enableAnimation = typeof config.enableAnimation === 'undefined' ? true : config.enableAnimation, width = main.width(), lastTimestamp = -1, lastVisits = [], @@ -177,8 +178,9 @@ * from the map */ function age(r) { - var now = new Date().getTime() / 1000; - var o = (r.lastActionTimestamp - oldest) / (now - oldest); + var nowSecs = Math.floor(now); + var o = (r.lastActionTimestamp - oldest) / (nowSecs - oldest); + o = Math.floor(o * 100) / 100; // normalize age for testing purposes return Math.min(1, Math.max(0, o)); } @@ -435,14 +437,16 @@ visitSymbols.layout().render(); - $.each(newSymbols, function (i, s) { - if (i > 10) return false; + if (!enableAnimation) { + $.each(newSymbols, function (i, s) { + if (i > 10) return false; - s.path.hide(); // hide new symbol at first - var t = setTimeout(function () { animateSymbol(s); }, - 1000 * (s.data.lastActionTimestamp - now) + config.liveRefreshAfterMs); - symbolFadeInTimer.push(t); - }); + s.path.hide(); // hide new symbol at first + var t = setTimeout(function () { animateSymbol(s); }, + 1000 * (s.data.lastActionTimestamp - now) + config.liveRefreshAfterMs); + symbolFadeInTimer.push(t); + }); + } lastTimestamp = report[0].lastActionTimestamp; diff --git a/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php b/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php index c5a2bc0dbef3af97f82937f944550502cdafabaf..7cc320e154bd79e570bdf0dca00f579ed13d6ca7 100644 --- a/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php +++ b/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php @@ -11,6 +11,7 @@ use Piwik\Plugins\Annotations\API as APIAnnotations; use Piwik\Plugins\Goals\API as APIGoals; use Piwik\Plugins\SegmentEditor\API as APISegmentEditor; use Piwik\WidgetsList; +use Piwik\Date; require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php'; @@ -27,6 +28,7 @@ class Test_Piwik_Fixture_ManySitesImportedLogsWithXssAttempts extends Test_Piwik $this->setupDashboards(); $this->setupXssSegment(); $this->addAnnotations(); + $this->trackVisitsForRealtimeMap(); } public function setUpWebsitesAndGoals() @@ -47,13 +49,13 @@ class Test_Piwik_Fixture_ManySitesImportedLogsWithXssAttempts extends Test_Piwik $dashboardColumnCount = 3; $dashboardCount = 3; + $layout = array(); + for ($j = 0; $j != $dashboardColumnCount; ++$j) { + $layout[] = array(); + } + $dashboards = array(); for ($i = 0; $i != $dashboardCount; ++$i) { - $layout = array(); - for ($j = 0; $j != $dashboardColumnCount; ++$j) { - $layout[] = array(); - } - $dashboards[] = $layout; } @@ -61,9 +63,10 @@ class Test_Piwik_Fixture_ManySitesImportedLogsWithXssAttempts extends Test_Piwik $_GET['idSite'] = $this->idSite; // collect widgets to add to the layout + $allWidgets = WidgetsList::get(); $groupedWidgets = array(); $dashboard = 0; - foreach (WidgetsList::get() as $category => $widgets) { + foreach ($allWidgets as $category => $widgets) { foreach ($widgets as $widget) { if ($widget['uniqueId'] == 'widgetSEOgetRank' || $widget['uniqueId'] == 'widgetReferrersgetKeywordsForPage' @@ -90,13 +93,32 @@ class Test_Piwik_Fixture_ManySitesImportedLogsWithXssAttempts extends Test_Piwik $dashboards[$dashboardIndex][$column][] = $widget; } } - + foreach ($dashboards as $id => $layout) { $_GET['name'] = self::makeXssContent('dashboard name' . $id); $_GET['layout'] = Common::json_encode($layout); $_GET['idDashboard'] = $id + 1; FrontController::getInstance()->fetchDispatch('Dashboard', 'saveLayout'); } + + // create empty dashboard + $widget = reset($allWidgets[Piwik_Translate('UserSettings_VisitorSettings')]); + $dashboard = array( + array( + array( + 'uniqueId' => $widget['uniqueId'], + 'parameters' => $widget['parameters'] + ) + ), + array(), + array() + ); + + $_GET['name'] = 'D4'; + $_GET['layout'] = Common::json_encode($dashboard); + $_GET['idDashboard'] = 4; + $_GET['idSite'] = 2; + FrontController::getInstance()->fetchDispatch('Dashboard', 'saveLayout'); $_GET = $oldGet; } @@ -116,6 +138,47 @@ class Test_Piwik_Fixture_ManySitesImportedLogsWithXssAttempts extends Test_Piwik $this->idSite, '2012-08-08', self::makeXssContent("annotation"), $starred = 0); APIAnnotations::getInstance()->add($this->idSite, '2012-08-10', "Note 3", $starred = 1); } + + public function trackVisitsForRealtimeMap() + { + $dateTime = Date::factory('now')->addHour(-1.25)->getDatetime(); + $idSite = 2; + + $t = self::getTracker($idSite, Date::factory($dateTime)->addHour(-3)->getDatetime(), $defaultInit = true, $useLocal = true); + $t->setTokenAuth(self::getTokenAuth()); + $t->setUrl('http://example.org/index1.htm'); + self::checkResponse($t->doTrackPageView('incredible title!')); + + $t = self::getTracker($idSite, $dateTime, $defaultInit = true, $useLocal = true); + $t->setTokenAuth(self::getTokenAuth()); + $t->setUrl('http://example.org/index1.htm'); + $t->setCountry('jp'); + $t->setRegion("40"); + $t->setCity('Tokyo'); + $t->setLatitude(35.70); + $t->setLongitude(139.71); + self::checkResponse($t->doTrackPageView('incredible title!')); + + $t = self::getTracker($idSite, Date::factory($dateTime)->addHour(0.5)->getDatetime(), $defaultInit = true, $useLocal = true); + $t->setTokenAuth(self::getTokenAuth()); + $t->setUrl('http://example.org/index2.htm'); + $t->setCountry('ca'); + $t->setRegion("QC"); + $t->setCity('Montreal'); + $t->setLatitude(45.52); + $t->setLongitude(-73.58); + self::checkResponse($t->doTrackPageView('incredible title!')); + + $t = self::getTracker($idSite, Date::factory($dateTime)->addHour(1)->getDatetime(), $defaultInit = true, $useLocal = true); + $t->setTokenAuth(self::getTokenAuth()); + $t->setUrl('http://example.org/index3.htm'); + $t->setCountry('br'); + $t->setRegion("27"); + $t->setCity('Sao Paolo'); + $t->setLatitude(-23.55); + $t->setLongitude(-46.64); + self::checkResponse($t->doTrackPageView('incredible title!')); + } // NOTE: since API_Request does sanitization, API methods do not. when calling them, we must // sometimes do sanitization ourselves. diff --git a/tests/PHPUnit/UI b/tests/PHPUnit/UI index 9df5e46640e21a43250ab6360a632e74a41dce0c..a0ce6d5951d0a968ad7e216bb17eb2e380c95d36 160000 --- a/tests/PHPUnit/UI +++ b/tests/PHPUnit/UI @@ -1 +1 @@ -Subproject commit 9df5e46640e21a43250ab6360a632e74a41dce0c +Subproject commit a0ce6d5951d0a968ad7e216bb17eb2e380c95d36