diff options
-rw-r--r-- | lang/en.php | 1 | ||||
-rw-r--r-- | plugins/UserCountry/Controller.php | 6 | ||||
-rwxr-xr-x | plugins/UserCountry/GeoIPAutoUpdater.php | 15 | ||||
-rwxr-xr-x | plugins/UserCountry/templates/updaterSetup.tpl | 9 |
4 files changed, 30 insertions, 1 deletions
diff --git a/lang/en.php b/lang/en.php index fe972af535..a0644bbec9 100644 --- a/lang/en.php +++ b/lang/en.php @@ -1672,6 +1672,7 @@ And thank you for using Piwik!', 'UserCountry_SetupAutomaticUpdatesOfGeoIP_js' => 'Setup automatic updates of GeoIP databases', 'UserCountry_DownloadNewDatabasesEvery' => 'Update databases every', 'UserCountry_GeoLiteCityLink' => 'If you\'re using the GeoLite City database, use this link: %1$s%2$s%3$s.', + 'UserCountry_UpdaterWasLastRun' => 'The updater was last run on %s.', 'UserSettings_VisitorSettings' => 'Visitor Settings', 'UserSettings_BrowserFamilies' => 'Browser families', 'UserSettings_Browsers' => 'Browsers', 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 = '<strong><em>'.$lastRunTime->toString().'</em></strong>'; + } } /** 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 @@ <input type="radio" name="geoip-update-period" value="week" id="geoip-update-period-week" {if $geoIPUpdatePeriod eq 'week'}checked="checked"{/if}/> <label for="geoip-update-period-week">{'CoreHome_PeriodWeek'|translate}</label> </td> - <td width="164"> </td> + <td width="164"> + {if !empty($lastTimeUpdaterRun)} + {capture assign=lastTimeRunNote} + {'UserCountry_UpdaterWasLastRun'|translate:$lastTimeUpdaterRun} + {/capture} + {$lastTimeRunNote|inlineHelp} + {/if} + </td> </tr> </table> <p style="display:inline-block;vertical-align:top"> |