-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.php
68 lines (58 loc) · 1.94 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
* DokuWiki Plugin submgr (Action Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author Andreas Gohr <dokuwiki@cosmocode.de>
*/
class action_plugin_submgr extends DokuWiki_Action_Plugin
{
/**
* Registers a callback function for a given event
*
* @param Doku_Event_Handler $controller DokuWiki's event controller object
* @return void
*/
public function register(Doku_Event_Handler $controller)
{
$controller->register_hook('AUTH_USER_CHANGE', 'BEFORE', $this, 'handle_auth_user_change');
if ($this->getConf('applyonlogin')) {
$controller->register_hook('AUTH_LOGIN_CHECK', 'AFTER', $this, 'handle_login');
}
}
/**
* Apply rules on a newly created user
*
* @param Doku_Event $event event object by reference
* @param mixed $param not used
* @return void
* @throws Exception
*/
public function handle_auth_user_change(Doku_Event $event, $param)
{
if ($event->data['type'] != 'create') return;
/** @var helper_plugin_submgr $hlp */
$hlp = plugin_load('helper', 'submgr');
$hlp->runRules($event->data['params'][0], $event->data['params'][4]);
}
/**
* Apply rules on a successful user login (only once per session)
*
* @param Doku_Event $event event object by reference
* @param mixed $param not used
* @return void
* @throws Exception
*/
public function handle_login(Doku_Event $event, $param)
{
global $INPUT;
if (!$event->result) return;
if (isset($_SESSION[DOKU_COOKIE]['submgr'])) return;
if (!$INPUT->server->str('REMOTE_USER')) return;
global $USERINFO;
/** @var helper_plugin_submgr $hlp */
$hlp = plugin_load('helper', 'submgr');
$hlp->runRules($INPUT->server->str('REMOTE_USER'), $USERINFO['grps']);
$_SESSION[DOKU_COOKIE]['submgr'] = 1;
}
}