-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathaction.php
More file actions
executable file
·45 lines (39 loc) · 1.21 KB
/
action.php
File metadata and controls
executable file
·45 lines (39 loc) · 1.21 KB
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
<?php
use dokuwiki\Extension\ActionPlugin;
use dokuwiki\Extension\Event;
use dokuwiki\Extension\EventHandler;
use dokuwiki\plugin\virtualgroup\VirtualGroups;
/**
* DokuWiki Plugin virtualgroup (Action Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
*/
class action_plugin_virtualgroup extends ActionPlugin
{
/** @inheritdoc */
public function register(EventHandler $controller)
{
$controller->register_hook('DOKUWIKI_INIT_DONE', 'BEFORE', $this, 'start');
}
/**
* Add the virtual groups to the current user
*
* @param Event $event DOKUWIKI_INIT_DONE
* @return void
*/
public function start(Event $event)
{
global $USERINFO;
global $INFO;
global $INPUT;
$user = $INPUT->server->str('REMOTE_USER');
if (!$user) return;
$virtualgroups = (new VirtualGroups())->getUserGroups($user);
if (!$virtualgroups) return;
if (!isset($USERINFO['grps'])) $USERINFO['grps'] = [];
$grps = array_unique(array_merge($USERINFO['grps'], $virtualgroups));
$USERINFO['grps'] = $grps;
$_SESSION[DOKU_COOKIE]['auth']['info']['grps'] = $grps;
$INFO = pageinfo();
}
}