1<?php
2/**
3  *  @author Myron Turner
4  *  @email turnermm02@shaw.ca
5  *  action plugin completes processing of news data
6 */
7
8if(!defined('DOKU_INC')) die();
9if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
10require_once DOKU_PLUGIN.'action.php';
11
12
13class action_plugin_news extends DokuWiki_Action_Plugin {
14    var $helper;
15
16    /**
17     * Register its handlers with the DokuWiki's event controller
18     */
19    function register(Doku_Event_Handler $controller) {
20        $controller->register_hook('DOKUWIKI_DONE', 'BEFORE', $this,
21                                   'process_feed');
22    }
23
24	function action_plugin_news() {
25	    global $newsUpdated;
26		$this->helper = $this->loadHelper('news', true);
27    }
28
29
30    /**
31        check permissions and send page to be processed
32     */
33    function process_feed(&$event, $param) {
34	    global $ID,$INFO;
35
36        $perm = $this->helper->has_permission();
37        if($perm == 2 && $INFO['perm'] != 1) {       //INFO['perm'] = 1 when logging out
38            msg($this->getLang('no_permission'));
39            return;
40        }
41        if($this->helper->pageUpdated() ) {
42            $metafile = $this->helper->getMetaFN('wasupdated','.meta') ;
43			io_saveFile($metafile,time() . "\n" . $ID ."\n");
44			$this->helper->saveFeedData($ID);
45		}
46    }
47}
48