From 5827ba0b8aa706e4201a3dc654b3c2cf141f6dd2 Mon Sep 17 00:00:00 2001 From: Guillaume Turri Date: Sat, 18 Dec 2010 10:27:49 +0100 Subject: Popularity plugin displays the last time the data was sent --- lib/plugins/popularity/helper.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'lib/plugins/popularity/helper.php') diff --git a/lib/plugins/popularity/helper.php b/lib/plugins/popularity/helper.php index 00a359cbd..629d0bd67 100644 --- a/lib/plugins/popularity/helper.php +++ b/lib/plugins/popularity/helper.php @@ -13,7 +13,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin { /** * Name of the file which determine if the the autosubmit is enabled, - * and when it was submited for the las time + * and when it was submited for the last time */ var $autosubmitFile; @@ -22,10 +22,19 @@ class helper_plugin_popularity extends Dokuwiki_Plugin { */ var $autosubmitErrorFile; + /** + * Name of the file which determine when the popularity data was manually + * submitted for the last time + * (If this file doesn't exist, the data has never been sent) + */ + var $popularityLastSubmitFile; + + function helper_plugin_popularity(){ global $conf; $this->autosubmitFile = $conf['cachedir'].'/autosubmit.txt'; $this->autosubmitErrorFile = $conf['cachedir'].'/autosubmitError.txt'; + $this->popularityLastSubmitFile = $conf['cachedir'].'/lastSubmitTime.txt'; } function getMethods(){ @@ -48,6 +57,12 @@ class helper_plugin_popularity extends Dokuwiki_Plugin { 'params' => array(), 'return' => array('data' => 'string') ); + $result[] = array( + 'name' => 'lastSentTime', + 'desc' => 'Compute the last time popularity data was sent', + 'params' => 'array()', + 'return' => array('data' => 'int') + ); return $result; } @@ -75,6 +90,16 @@ class helper_plugin_popularity extends Dokuwiki_Plugin { return $error; } + /** + * Compute the last time the data was sent. If it has never been sent, we return 0. + */ + function lastSentTime(){ + $manualSubmission = @filemtime($this->popularityLastSubmitFile); + $autoSubmission = @filemtime($this->autosubmitFile); + + return max((int) $manualSubmission, (int) $autoSubmission); + } + /** * Gather all information * @return The popularity data as a string -- cgit v1.2.3