forked from cosmocode/virtualgroup
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.php
More file actions
executable file
·75 lines (62 loc) · 1.93 KB
/
action.php
File metadata and controls
executable file
·75 lines (62 loc) · 1.93 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
if(!defined('DOKU_INC')) die();
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once DOKU_PLUGIN.'action.php';
class action_plugin_virtualgroupjo extends DokuWiki_Action_Plugin {
var $users;
function getInfo(){
return confToHash(dirname(__FILE__).'/plugin.info.txt');
}
function register(Doku_Event_Handler $controller) {
$controller->register_hook('DOKUWIKI_INIT_DONE', 'BEFORE', $this,'start');
}
function start(&$event, $param) {
global $USERINFO;
global $auth;
global $INFO;
if (!$_SERVER['REMOTE_USER']) {
return;
}
$this->_load();
if (!isset($this->users[$_SERVER['REMOTE_USER']])) {
return;
}
if (!isset($USERINFO['grps'])) {
$USERINFO['grps'] = array();
}
$grps = array_unique(array_merge($USERINFO['grps'],$this->users[$_SERVER['REMOTE_USER']]));
$USERINFO['grps'] = $grps;
$_SESSION[DOKU_COOKIE]['auth']['info']['grps'] = $grps;
$INFO = pageinfo();
}
/**
* load the users -> group connection
*/
function _load() {
global $conf;
// determine the path to the data
$userFile = DOKU_INC . $conf['savedir'] . '/virtualgrp.php';
// if there is no file we hava no data ;-)
if (!is_file($userFile)) {
$this->users = array();
return;
}
// read the file
$content = file_get_contents($userFile);
// if its empty we have no data also
if (empty($content)) {
$this->users = array();
return;
}
$users = unserialize($content);
// check for invalid data
if ($users === FALSE) {
$this->users = array();
@unlink($userFile);
return;
}
// place the users array
$this->users = $users;
}
}
?>