1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* PayPal Donation extension for the phpBB Forum Software package. |
5
|
|
|
* |
6
|
|
|
* @copyright (c) 2015-2024 Skouat |
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0) |
8
|
|
|
* |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace skouat\ppde\acp; |
12
|
|
|
|
13
|
|
|
class ppde_module |
14
|
|
|
{ |
15
|
|
|
public $u_action; |
16
|
|
|
public $page_title; |
17
|
|
|
public $tpl_name; |
18
|
|
|
private $module_config; |
19
|
|
|
private $module_info; |
20
|
|
|
|
21
|
|
|
public function __construct() |
22
|
|
|
{ |
23
|
|
|
$this->module_config = [ |
24
|
|
|
'currency' => ['lang_key_prefix' => 'PPDE_DC', 'id_prefix_name' => 'currency'], |
25
|
|
|
'donation_pages' => ['lang_key_prefix' => 'PPDE_DP', 'id_prefix_name' => 'page'], |
26
|
|
|
'overview' => ['lang_key_prefix' => 'PPDE'], |
27
|
|
|
'paypal_features' => ['lang_key_prefix' => 'PPDE_PAYPAL_FEATURES'], |
28
|
|
|
'settings' => ['lang_key_prefix' => 'PPDE_SETTINGS'], |
29
|
|
|
'transactions' => ['lang_key_prefix' => 'PPDE_DT', 'id_prefix_name' => 'transaction'],]; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param string $id |
34
|
|
|
* @param string $mode |
35
|
|
|
* |
36
|
|
|
* @return void |
37
|
|
|
* @throws \Exception |
38
|
|
|
*/ |
39
|
|
|
public function main($id, $mode) |
|
|
|
|
40
|
|
|
{ |
41
|
|
|
global $phpbb_container; |
42
|
|
|
|
43
|
|
|
/** @type \phpbb\request\request $request Request object */ |
44
|
|
|
$request = $phpbb_container->get('request'); |
45
|
|
|
/** @type \phpbb\language\language $language Language object */ |
46
|
|
|
$language = $phpbb_container->get('language'); |
47
|
|
|
|
48
|
|
|
if (!isset($this->module_config[$mode])) |
49
|
|
|
{ |
50
|
|
|
trigger_error('NO_MODE', E_USER_ERROR); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$this->module_info = $this->module_config[$mode]; |
54
|
|
|
|
55
|
|
|
$language->add_lang('acp_' . $mode, 'skouat/ppde'); |
56
|
|
|
|
57
|
|
|
/** @type \skouat\ppde\controller\admin\admin_main $controller */ |
58
|
|
|
$controller = $phpbb_container->get('skouat.ppde.controller.admin.' . $mode); |
59
|
|
|
$controller->set_page_url($this->u_action); |
60
|
|
|
$controller->set_module_info($this->module_info, $mode); |
61
|
|
|
|
62
|
|
|
$this->set_page_title_and_template($mode); |
63
|
|
|
if (in_array($mode, ['currency', 'donation_pages', 'transactions'])) |
64
|
|
|
{ |
65
|
|
|
$this->handle_item_actions($controller, $request); |
66
|
|
|
} |
67
|
|
|
elseif ($mode === 'overview') |
68
|
|
|
{ |
69
|
|
|
$action = $request->variable('action', ''); |
70
|
|
|
/** @type \skouat\ppde\controller\admin\overview_controller $controller */ |
71
|
|
|
$controller->display_overview($action); |
72
|
|
|
} |
73
|
|
|
else |
74
|
|
|
{ |
75
|
|
|
/** @type \skouat\ppde\controller\admin\settings_controller|\skouat\ppde\controller\admin\paypal_features_controller $controller */ |
76
|
|
|
$controller->display_settings(); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
private function set_page_title_and_template($mode): void |
81
|
|
|
{ |
82
|
|
|
$this->page_title = 'PPDE_ACP_' . strtoupper($mode); |
83
|
|
|
$this->tpl_name = 'ppde_' . strtolower($mode); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @param \skouat\ppde\controller\admin\admin_main $controller |
88
|
|
|
* @param \phpbb\request\request $request |
89
|
|
|
*/ |
90
|
|
|
private function handle_item_actions($controller, $request): void |
91
|
|
|
{ |
92
|
|
|
$action = $request->variable('action', ''); |
93
|
|
|
$id_prefix_name = $this->module_info['id_prefix_name']; |
94
|
|
|
$item_id = $request->variable($id_prefix_name . '_id', 0); |
95
|
|
|
$module_id = $request->variable('i', ''); |
96
|
|
|
$mode = $request->variable('mode', ''); |
97
|
|
|
|
98
|
|
|
$controller->set_item_id($item_id); |
99
|
|
|
$controller->set_hidden_fields($module_id, $mode, $action); |
100
|
|
|
$controller->main(); |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.