[Piwik-svn] r496 - in trunk: modules plugins/Home
svnmaster at piwik.org
svnmaster at piwik.org
Thu May 29 04:30:53 CEST 2008
Author: matt
Date: 2008-05-29 04:30:52 +0200 (Thu, 29 May 2008)
New Revision: 496
Modified:
trunk/modules/Date.php
trunk/plugins/Home/Controller.php
Log:
- fix #174: The first day piwik has been installed, date should default to "today" instead of yesterday.
Thanks Christian for the patch
Modified: trunk/modules/Date.php
===================================================================
--- trunk/modules/Date.php 2008-05-29 01:58:19 UTC (rev 495)
+++ trunk/modules/Date.php 2008-05-29 02:30:52 UTC (rev 496)
@@ -290,6 +290,16 @@
}
return 1;
}
+
+ /**
+ * Returns true if current date is today
+ *
+ * @return bool
+ */
+ public function isToday()
+ {
+ return $this->get('Y-m-d') === date('Y-m-d', time());
+ }
/**
* Returns a date object set to today midnight
@@ -300,7 +310,8 @@
{
$date = new Piwik_Date(date("Y-m-d 00:00:00"));
return $date;
- }
+ }
+
/**
* Returns a date object set to yesterday midnight
* @return Piwik_Date
Modified: trunk/plugins/Home/Controller.php
===================================================================
--- trunk/plugins/Home/Controller.php 2008-05-29 01:58:19 UTC (rev 495)
+++ trunk/plugins/Home/Controller.php 2008-05-29 02:30:52 UTC (rev 496)
@@ -28,9 +28,17 @@
{
$sitesId = Piwik_SitesManager_API::getSitesIdWithAtLeastViewAccess();
if(!empty($sitesId))
- {
- $defaultDate = Zend_Registry::get('config')->General->default_day;
- $firstSiteId = $sitesId[0];
+ {
+ $firstSiteId = $sitesId[0];
+ $firstSite = new Piwik_Site($firstSiteId);
+ if ($firstSite->getCreationDate()->isToday())
+ {
+ $defaultDate = 'today';
+ }
+ else
+ {
+ $defaultDate = Zend_Registry::get('config')->General->default_day;
+ }
header("Location:index.php?module=Home&action=index&idSite=$firstSiteId&period=day&date=$defaultDate");
}
else
More information about the Piwik-svn
mailing list