From 7aa7595ba5e3608d38292db7f2e03b5549494f24 Mon Sep 17 00:00:00 2001 From: benakamoorthi Date: Fri, 1 Feb 2013 05:24:58 +0000 Subject: Refs #3680, added message w/ last time auto updater was run to GeoIP settings page. git-svn-id: http://dev.piwik.org/svn/trunk@7832 59fd770c-687e-43c8-a1e3-f5a4ff64c105 --- plugins/UserCountry/Controller.php | 6 ++++++ plugins/UserCountry/GeoIPAutoUpdater.php | 15 +++++++++++++++ plugins/UserCountry/templates/updaterSetup.tpl | 9 ++++++++- 3 files changed, 29 insertions(+), 1 deletion(-) (limited to 'plugins/UserCountry') diff --git a/plugins/UserCountry/Controller.php b/plugins/UserCountry/Controller.php index 38fc6e94ff..cef3a3051a 100644 --- a/plugins/UserCountry/Controller.php +++ b/plugins/UserCountry/Controller.php @@ -162,6 +162,12 @@ class Piwik_UserCountry_Controller extends Piwik_Controller_Admin $view->geoIPUpdatePeriod = Piwik_UserCountry_GeoIPAutoUpdater::getSchedulePeriod(); $view->geoLiteUrl = Piwik_UserCountry_LocationProvider_GeoIp::GEO_LITE_URL; + + $lastRunTime = Piwik_UserCountry_GeoIPAutoUpdater::getLastRunTime(); + if ($lastRunTime !== false) + { + $view->lastTimeUpdaterRun = ''.$lastRunTime->toString().''; + } } /** diff --git a/plugins/UserCountry/GeoIPAutoUpdater.php b/plugins/UserCountry/GeoIPAutoUpdater.php index 3d2ebc53c4..2bfbbde0e2 100755 --- a/plugins/UserCountry/GeoIPAutoUpdater.php +++ b/plugins/UserCountry/GeoIPAutoUpdater.php @@ -24,6 +24,8 @@ class Piwik_UserCountry_GeoIPAutoUpdater const ISP_URL_OPTION_NAME = 'geoip.isp_db_url'; const ORG_URL_OPTION_NAME = 'geoip.org_db_url'; + const LAST_RUN_TIME_OPTION_NAME = 'geoip.updater_last_run_time'; + private static $urlOptions = array( 'loc' => self::LOC_URL_OPTION_NAME, 'isp' => self::ISP_URL_OPTION_NAME, @@ -46,6 +48,8 @@ class Piwik_UserCountry_GeoIPAutoUpdater { try { + Piwik_SetOption(self::LAST_RUN_TIME_OPTION_NAME, Piwik_Date::factory('today')->getTimestamp()); + $locUrl = Piwik_GetOption(self::LOC_URL_OPTION_NAME); if (!empty($locUrl)) { @@ -494,4 +498,15 @@ class Piwik_UserCountry_GeoIPAutoUpdater { self::$unzipPhpError = array($errno, $errstr, $errfile, $errline); } + + /** + * Returns the time the auto updater was last run. + * + * @return Piwik_Date|false + */ + public static function getLastRunTime() + { + $timestamp = Piwik_GetOption(self::LAST_RUN_TIME_OPTION_NAME); + return $timestamp === false ? false : Piwik_Date::factory((int)$timestamp); + } } diff --git a/plugins/UserCountry/templates/updaterSetup.tpl b/plugins/UserCountry/templates/updaterSetup.tpl index 4cb2342af4..11d498a9b5 100755 --- a/plugins/UserCountry/templates/updaterSetup.tpl +++ b/plugins/UserCountry/templates/updaterSetup.tpl @@ -38,7 +38,14 @@ -   + + {if !empty($lastTimeUpdaterRun)} + {capture assign=lastTimeRunNote} + {'UserCountry_UpdaterWasLastRun'|translate:$lastTimeUpdaterRun} + {/capture} + {$lastTimeRunNote|inlineHelp} + {/if} +

-- cgit v1.2.3