-
Notifications
You must be signed in to change notification settings - Fork 4
/
action.php
36 lines (27 loc) · 884 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
<?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();
global $conf;
$dir = $conf['indexdir'];
$pages = file($dir.'/page.idx');
shuffle($pages);
foreach ($pages as $page) {
$page = trim($page);
if(!page_exists($page)) continue;
if(isHiddenPage($page)) continue;
if (auth_quickaclcheck($page)) {
send_redirect(wl($page, '', true, '&'));
}
}
}
}