diff options
author | ahriman <ahriman@falte.red> | 2018-12-03 19:22:25 -0500 |
---|---|---|
committer | ahriman <ahriman@falte.red> | 2018-12-03 19:22:25 -0500 |
commit | 0ae8cbf5c0b1a198b963490985b7738392ebcb97 (patch) | |
tree | b2c77ae72c6b717e2b97492065196ac5ffb2d9e2 /wiki/lib/plugins/popularity/action.php | |
parent | f57f6cc5a2d159f90168d292437dc4bd8cd7f934 (diff) | |
download | site-0ae8cbf5c0b1a198b963490985b7738392ebcb97.tar.gz |
installed dokuwiki, added to navbar, updated news
Diffstat (limited to 'wiki/lib/plugins/popularity/action.php')
-rw-r--r-- | wiki/lib/plugins/popularity/action.php | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/wiki/lib/plugins/popularity/action.php b/wiki/lib/plugins/popularity/action.php new file mode 100644 index 0000000..d5ec0f5 --- /dev/null +++ b/wiki/lib/plugins/popularity/action.php @@ -0,0 +1,60 @@ +<?php +/** + * Popularity Feedback Plugin + * + * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) + */ + +require_once(DOKU_PLUGIN.'action.php'); +require_once(DOKU_PLUGIN.'popularity/admin.php'); + +class action_plugin_popularity extends Dokuwiki_Action_Plugin { + + /** + * @var helper_plugin_popularity + */ + var $helper; + + function __construct(){ + $this->helper = $this->loadHelper('popularity', false); + } + + /** + * Register its handlers with the dokuwiki's event controller + */ + function register(Doku_Event_Handler $controller) { + $controller->register_hook('INDEXER_TASKS_RUN', 'AFTER', $this, '_autosubmit', array()); + } + + function _autosubmit(Doku_Event &$event, $param){ + //Do we have to send the data now + if ( !$this->helper->isAutosubmitEnabled() || $this->_isTooEarlyToSubmit() ){ + return; + } + + //Actually send it + $status = $this->helper->sendData( $this->helper->gatherAsString() ); + + if ( $status !== '' ){ + //If an error occured, log it + io_saveFile( $this->helper->autosubmitErrorFile, $status ); + } else { + //If the data has been sent successfully, previous log of errors are useless + @unlink($this->helper->autosubmitErrorFile); + //Update the last time we sent data + touch ( $this->helper->autosubmitFile ); + } + + $event->stopPropagation(); + $event->preventDefault(); + } + + /** + * Check if it's time to send autosubmit data + * (we should have check if autosubmit is enabled first) + */ + function _isTooEarlyToSubmit(){ + $lastSubmit = $this->helper->lastSentTime(); + return $lastSubmit + 24*60*60*30 > time(); + } +} |