Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/VisitTime')
-rw-r--r--plugins/VisitTime/Controller.php6
-rw-r--r--plugins/VisitTime/VisitTime.php46
2 files changed, 42 insertions, 10 deletions
diff --git a/plugins/VisitTime/Controller.php b/plugins/VisitTime/Controller.php
index 7053c9d545..b49f35452f 100644
--- a/plugins/VisitTime/Controller.php
+++ b/plugins/VisitTime/Controller.php
@@ -16,7 +16,7 @@
*/
class Piwik_VisitTime_Controller extends Piwik_Controller
{
- function index()
+ public function index()
{
$view = Piwik_View::factory('index');
$view->dataTableVisitInformationPerLocalTime = $this->getVisitInformationPerLocalTime(true);
@@ -24,7 +24,7 @@ class Piwik_VisitTime_Controller extends Piwik_Controller
echo $view->render();
}
- function getVisitInformationPerServerTime( $fetch = false)
+ public function getVisitInformationPerServerTime( $fetch = false)
{
$view = Piwik_ViewDataTable::factory( 'graphVerticalBar');
$view->init( $this->pluginName, __FUNCTION__, "VisitTime.getVisitInformationPerServerTime" );
@@ -42,7 +42,7 @@ class Piwik_VisitTime_Controller extends Piwik_Controller
return $this->renderView($view, $fetch);
}
- function getVisitInformationPerLocalTime( $fetch = false)
+ public function getVisitInformationPerLocalTime( $fetch = false)
{
$view = Piwik_ViewDataTable::factory( 'graphVerticalBar');
$view->init( $this->pluginName, __FUNCTION__, "VisitTime.getVisitInformationPerLocalTime" );
diff --git a/plugins/VisitTime/VisitTime.php b/plugins/VisitTime/VisitTime.php
index d565a3fb91..510a7f7ffd 100644
--- a/plugins/VisitTime/VisitTime.php
+++ b/plugins/VisitTime/VisitTime.php
@@ -19,11 +19,10 @@ class Piwik_VisitTime extends Piwik_Plugin
public function getInformation()
{
$info = array(
- 'name' => 'Visits Time',
- 'description' => 'Reports the Local and Server time. Server time information can be useful to schedule a maintenance on the Website.',
+ 'description' => Piwik_Translate('VisitTime_PluginDescription'),
'author' => 'Piwik',
- 'homepage' => 'http://piwik.org/',
- 'version' => '0.1',
+ 'author_homepage' => 'http://piwik.org/',
+ 'version' => Piwik_Version::VERSION,
);
return $info;
}
@@ -35,6 +34,7 @@ class Piwik_VisitTime extends Piwik_Plugin
'ArchiveProcessing_Period.compute' => 'archivePeriod',
'WidgetsList.add' => 'addWidgets',
'Menu.add' => 'addMenu',
+ 'Goals.getAvailableGoalSegments' => 'addGoalSegments',
);
return $hooks;
}
@@ -47,9 +47,20 @@ class Piwik_VisitTime extends Piwik_Plugin
function addMenu()
{
- Piwik_AddMenu('General_Visitors', 'VisitTime_SubmenuTimes', array('module' => 'VisitTime'));
+ Piwik_AddMenu('General_Visitors', 'VisitTime_SubmenuTimes', array('module' => 'VisitTime', 'action' => 'index'));
}
+ function addGoalSegments( $notification )
+ {
+ $segments =& $notification->getNotificationObject();
+ $segments[] = array(
+ 'group' => Piwik_Translate('VisitTime_ColumnServerTime'),
+ 'name' => Piwik_Translate('VisitTime_ColumnServerTime'),
+ 'module' => 'VisitTime',
+ 'action' => 'getVisitInformationPerServerTime',
+ );
+ }
+
function archivePeriod( $notification )
{
$archiveProcessing = $notification->getNotificationObject();
@@ -73,16 +84,37 @@ class Piwik_VisitTime extends Piwik_Plugin
$labelSQL = "HOUR(visitor_localtime)";
$this->interestByLocalTime = $archiveProcessing->getArrayInterestForLabel($labelSQL);
- $labelSQL = "HOUR(visit_first_action_time)";
+ $labelSQL = "HOUR(visit_last_action_time)";
$this->interestByServerTime = $archiveProcessing->getArrayInterestForLabel($labelSQL);
+ $this->interestByServerTime = $this->convertServerTimeToLocalTimezone($this->interestByServerTime, $archiveProcessing);
+ }
+
+ protected function convertServerTimeToLocalTimezone($interestByServerTime, $archiveProcessing)
+ {
+ $date = Piwik_Date::factory($archiveProcessing->getStartDatetimeUTC())->toString();
+ $timezone = $archiveProcessing->site->getTimezone();
+ $visitsByHourTz = array();
+ foreach($interestByServerTime as $hour => $stats)
+ {
+ $datetime = $date . ' '.$hour.':00:00';
+ $hourInTz = (int)Piwik_Date::factory($datetime, $timezone)->toString('H');
+ $visitsByHourTz[$hourInTz] = $stats;
+ }
+ return $visitsByHourTz;
}
protected function archiveDayAggregateGoals($archiveProcessing)
{
$query = $archiveProcessing->queryConversionsBySingleSegment("HOUR(server_time)");
+ $goalByServerTime = array();
while($row = $query->fetch())
{
- $this->interestByServerTime[$row['label']][Piwik_Archive::INDEX_GOALS][$row['idgoal']] = $archiveProcessing->getGoalRowFromQueryRow($row);
+ $goalByServerTime[$row['label']][$row['idgoal']] = $archiveProcessing->getGoalRowFromQueryRow($row);
+ }
+ $goalByServerTime = $this->convertServerTimeToLocalTimezone($goalByServerTime, $archiveProcessing);
+ foreach($goalByServerTime as $hour => $goals)
+ {
+ $this->interestByServerTime[$hour][Piwik_Archive::INDEX_GOALS] = $goals;
}
$archiveProcessing->enrichConversionsByLabelArray($this->interestByServerTime);
}