-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathadmin.php
99 lines (77 loc) · 2.74 KB
/
admin.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
/**
* DokuWiki Plugin autologoff (Admin Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author Andreas Gohr <[email protected]>
*/
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
class admin_plugin_autologoff extends DokuWiki_Admin_Plugin {
/** @var helper_plugin_autologoff */
private $helper;
public function __construct(){
$this->helper = $this->loadHelper('autologoff', false);
}
/**
* @return int sort number in admin menu
*/
public function getMenuSort() {
return 500;
}
/**
* @return bool true if only access for superuser, false is for superusers and moderators
*/
public function forAdminOnly() {
return false;
}
/**
* Should carry out any processing required by the plugin.
*/
public function handle() {
if(isset($_REQUEST['remove']) && checkSecurityToken()){
$this->helper->remove_entry($_REQUEST['remove']);
}
if(isset($_REQUEST['usergroup']) && checkSecurityToken()){
$this->helper->add_entry($_REQUEST['usergroup'], $_REQUEST['time']);
}
}
/**
* Render HTML output, e.g. helpful text and a form
*/
public function html() {
echo $this->locale_xhtml('intro');
$config = $this->helper->load_config();
echo '<form action="'.script().'" method="post">';
echo '<input type="hidden" name="do" value="admin" />';
echo '<input type="hidden" name="page" value="autologoff" />';
echo '<input type="hidden" name="sectok" value="'.getSecurityToken().'" />';
echo '<table class="inline">';
echo '<tr>';
echo '<th>'.$this->getLang('usergroup').'</th>';
echo '<th>'.$this->getLang('time').'</th>';
echo '<th></th>';
echo '</tr>';
foreach($config as $usergroup => $time){
$url = wl('',array(
'do' => 'admin',
'page' => 'autologoff',
'remove' => $usergroup,
'sectok' => getSecurityToken()
));
echo '<tr>';
echo '<td>'.hsc($usergroup).'</td>';
echo '<td>'.hsc($time).'</td>';
echo '<td><a href="'.$url.'">'.$this->getLang('remove').'</a></td>';
echo '</tr>';
}
echo '<tr>';
echo '<td><input type="text" name="usergroup" class="edit" /></td>';
echo '<td><input type="text" name="time" class="edit" /></td>';
echo '<td><input type="submit" class="button" value="'.$this->getLang('save').'" /></td>';
echo '</tr>';
echo '</table>';
echo '</form>';
}
}
// vim:ts=4:sw=4:et: