1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* Auto Groups extension for the phpBB Forum Software package. |
5
|
|
|
* |
6
|
|
|
* @copyright (c) 2014 phpBB Limited <https://www.phpbb.com> |
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0) |
8
|
|
|
* |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace phpbb\autogroups\acp; |
12
|
|
|
|
13
|
|
|
class autogroups_module |
14
|
|
|
{ |
15
|
|
|
public $page_title; |
16
|
|
|
public $tpl_name; |
17
|
|
|
public $u_action; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Main ACP module |
21
|
|
|
* |
22
|
|
|
* @param int $id |
23
|
|
|
* @param string $mode |
24
|
|
|
* @throws \Exception |
25
|
|
|
*/ |
26
|
|
|
public function main($id, $mode) |
|
|
|
|
27
|
|
|
{ |
28
|
|
|
global $phpbb_container; |
29
|
|
|
|
30
|
|
|
/** @var \phpbb\language\language $language */ |
31
|
|
|
$language = $phpbb_container->get('language'); |
32
|
|
|
|
33
|
|
|
/** @var \phpbb\request\request $request */ |
34
|
|
|
$request = $phpbb_container->get('request'); |
35
|
|
|
|
36
|
|
|
// Add the auto groups ACP lang file |
37
|
|
|
$language->add_lang('autogroups_acp', 'phpbb/autogroups'); |
38
|
|
|
|
39
|
|
|
// Get an instance of the admin controller |
40
|
|
|
$admin_controller = $phpbb_container->get('phpbb.autogroups.admin_controller'); |
41
|
|
|
|
42
|
|
|
// Requests |
43
|
|
|
$action = $request->variable('action', ''); |
44
|
|
|
$autogroups_id = $request->variable('autogroups_id', 0); |
45
|
|
|
|
46
|
|
|
// Make the $u_action url available in the admin controller |
47
|
|
|
$admin_controller->set_page_url($this->u_action); |
48
|
|
|
|
49
|
|
|
// Load a template from adm/style for our ACP auto groups |
50
|
|
|
$this->tpl_name = 'manage_autogroups'; |
51
|
|
|
|
52
|
|
|
// Set the page title for our ACP auto groups |
53
|
|
|
$this->page_title = 'ACP_AUTOGROUPS_MANAGE'; |
54
|
|
|
|
55
|
|
|
// Quick-submit settings from the general options form |
56
|
|
|
if ($request->is_set_post('generalsubmit')) |
57
|
|
|
{ |
58
|
|
|
$admin_controller->submit_autogroups_options(); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
// Perform any actions submitted by the user |
62
|
|
|
switch ($action) |
63
|
|
|
{ |
64
|
|
|
case 'add': |
65
|
|
|
case 'edit': |
66
|
|
|
// Set the page title for our ACP auto groups |
67
|
|
|
$this->page_title = strtoupper("ACP_AUTOGROUPS_$action"); |
68
|
|
|
|
69
|
|
|
// Load the save auto group handle in the admin controller |
70
|
|
|
$admin_controller->save_autogroup_rule($autogroups_id); |
71
|
|
|
|
72
|
|
|
// Return to stop execution of this script |
73
|
|
|
return; |
74
|
|
|
break; |
|
|
|
|
75
|
|
|
|
76
|
|
|
case 'sync': |
77
|
|
|
// Resync applies an auto group check against all users |
78
|
|
|
$admin_controller->resync_autogroup_rule($autogroups_id); |
79
|
|
|
break; |
80
|
|
|
|
81
|
|
|
case 'delete': |
82
|
|
|
// Use a confirm box routine when deleting an auto group rule |
83
|
|
|
if (confirm_box(true)) |
|
|
|
|
84
|
|
|
{ |
85
|
|
|
// Delete auto group rule on confirmation from the user |
86
|
|
|
$admin_controller->delete_autogroup_rule($autogroups_id); |
87
|
|
|
} |
88
|
|
|
else |
89
|
|
|
{ |
90
|
|
|
// Request confirmation from the user to delete the auto group rule |
91
|
|
|
confirm_box(false, $language->lang('ACP_AUTOGROUPS_DELETE_CONFIRM'), build_hidden_fields(array( |
|
|
|
|
92
|
|
|
'autogroups_id' => $autogroups_id, |
93
|
|
|
'mode' => $mode, |
94
|
|
|
'action' => $action, |
95
|
|
|
))); |
96
|
|
|
} |
97
|
|
|
break; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
// Display auto group rules |
101
|
|
|
$admin_controller->display_autogroups(); |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.