forked from solewniczak/dokuwiki-plugin-randompage2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.php
37 lines (27 loc) · 895 Bytes
/
action.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
/**
*
* @author Szymon Olewniczak
*/
if(!defined('DOKU_INC')) die();
class action_plugin_randompage2 extends DokuWiki_Action_Plugin {
public function register(Doku_Event_Handler $controller) {
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'do_randompage');
}
public function do_randompage(Doku_Event $event, $param) {
if($event->data !== 'randompage') return;
$event->preventDefault();
$this->action_randompage($event, $args);
}
function action_randompage(Doku_Event $event, $args) {
global $conf;
$dir = $conf['savedir'];
$pages = file($dir.'/index/page.idx');
shuffle($pages);
foreach ($pages as $page) {
if (auth_quickaclcheck($page)) {
header('Location: '.wl($page,'',true));
}
}
}
}