1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* PayPal Donation extension for the phpBB Forum Software package. |
5
|
|
|
* |
6
|
|
|
* @copyright (c) 2015 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
|
|
|
/** @var string */ |
16
|
|
|
public $u_action; |
17
|
|
|
/** @var string */ |
18
|
|
|
public $page_title; |
19
|
|
|
/** @var string */ |
20
|
|
|
public $tpl_name; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @param string $id |
24
|
|
|
* @param string $mode |
25
|
|
|
*/ |
26
|
|
|
public function main($id, $mode) |
27
|
|
|
{ |
28
|
|
|
global $phpbb_container, $request; |
29
|
|
|
|
30
|
|
|
// Requests |
31
|
|
|
$action = $request->variable('action', ''); |
32
|
|
|
$page_id = $request->variable('page_id', 0); |
33
|
|
|
$currency_id = $request->variable('currency_id', 0); |
34
|
|
|
|
35
|
|
|
switch ($mode) |
36
|
|
|
{ |
37
|
|
|
case 'overview': |
38
|
|
|
case 'settings': |
39
|
|
|
case 'transactions': |
40
|
|
|
// Get an instance of the admin controller |
41
|
|
|
/** @type \skouat\ppde\controller\admin_main $admin_controller */ |
42
|
|
|
$admin_controller = $phpbb_container->get('skouat.ppde.controller.admin.' . $mode); |
43
|
|
|
|
44
|
|
|
// Make the $u_action url available in the admin overview controller |
45
|
|
|
$admin_controller->set_page_url($this->u_action); |
46
|
|
|
|
47
|
|
|
// Set the page title for our ACP page |
48
|
|
|
$this->page_title = 'PPDE_ACP_' . strtoupper($mode); |
49
|
|
|
|
50
|
|
|
// Load a template from adm/style for our ACP page |
51
|
|
|
$this->tpl_name = 'ppde_' . strtolower($mode); |
52
|
|
|
|
53
|
|
|
switch ($mode) |
54
|
|
|
{ |
55
|
|
|
case 'overview': |
56
|
|
|
// Load the display overview handle in the admin controller |
57
|
|
|
/** @type \skouat\ppde\controller\admin_overview_controller $admin_controller */ |
58
|
|
|
$admin_controller->display_overview($action); |
59
|
|
|
break; |
60
|
|
|
case 'settings': |
61
|
|
|
// Load the display options handle in the admin controller |
62
|
|
|
/** @type \skouat\ppde\controller\admin_settings_controller $admin_controller */ |
63
|
|
|
$admin_controller->display_settings(); |
64
|
|
|
break; |
65
|
|
|
case 'transactions': |
66
|
|
|
// Load the display transactions log handle in the admin controller |
67
|
|
|
/** @type \skouat\ppde\controller\admin_transactions_controller $admin_controller */ |
68
|
|
|
$admin_controller->display_transactions($id, $mode, $action); |
69
|
|
|
} |
70
|
|
|
break; |
71
|
|
|
case 'donation_pages': |
72
|
|
|
// Get an instance of the admin controller and the entity |
73
|
|
|
/** @type \skouat\ppde\controller\admin_donation_pages_controller $admin_donation_pages_controller */ |
74
|
|
|
$admin_donation_pages_controller = $phpbb_container->get('skouat.ppde.controller.admin.donation_pages'); |
75
|
|
|
/** @type \skouat\ppde\entity\donation_pages $donation_pages_entity */ |
76
|
|
|
$donation_pages_entity = $phpbb_container->get('skouat.ppde.entity.donation_pages'); |
77
|
|
|
|
78
|
|
|
// Make the $u_action url available in controller and entity |
79
|
|
|
$admin_donation_pages_controller->set_page_url($this->u_action); |
80
|
|
|
$donation_pages_entity->set_page_url($this->u_action); |
81
|
|
|
|
82
|
|
|
// Load a template from adm/style for our ACP page |
83
|
|
|
$this->tpl_name = 'ppde_donation_pages'; |
84
|
|
|
|
85
|
|
|
// Set the page title for our ACP page |
86
|
|
|
$this->page_title = 'PPDE_ACP_DONATION_PAGES'; |
87
|
|
|
|
88
|
|
|
// Perform any actions submitted by the user |
89
|
|
|
switch ($action) |
90
|
|
|
{ |
91
|
|
|
case 'add': |
92
|
|
|
// Set the page title for our ACP page |
93
|
|
|
$this->page_title = 'PPDE_DP_CONFIG'; |
94
|
|
|
|
95
|
|
|
// Load the add donation page handle in the admin controller |
96
|
|
|
$admin_donation_pages_controller->add_donation_page(); |
97
|
|
|
|
98
|
|
|
// Return to stop execution of this script |
99
|
|
|
return; |
100
|
|
|
case 'edit': |
101
|
|
|
// Set the page title for our ACP page |
102
|
|
|
$this->page_title = 'PPDE_DP_CONFIG'; |
103
|
|
|
|
104
|
|
|
// Load the edit donation page handle in the admin controller |
105
|
|
|
$admin_donation_pages_controller->edit_donation_page($page_id); |
106
|
|
|
|
107
|
|
|
// Return to stop execution of this script |
108
|
|
|
return; |
109
|
|
|
case 'delete': |
110
|
|
|
// Delete a donation page |
111
|
|
|
$admin_donation_pages_controller->delete_donation_page($page_id); |
112
|
|
|
break; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
// Display module main page |
116
|
|
|
$admin_donation_pages_controller->display_donation_pages(); |
117
|
|
|
break; |
118
|
|
|
case 'currency': |
119
|
|
|
// Get an instance of the admin controller and the entity |
120
|
|
|
/** @type \skouat\ppde\controller\admin_currency_controller $admin_currency_controller */ |
121
|
|
|
$admin_currency_controller = $phpbb_container->get('skouat.ppde.controller.admin.currency'); |
122
|
|
|
/** @type \skouat\ppde\entity\currency $currency_entity */ |
123
|
|
|
$currency_entity = $phpbb_container->get('skouat.ppde.entity.currency'); |
124
|
|
|
|
125
|
|
|
// Make the $u_action url available in controller and entity |
126
|
|
|
$admin_currency_controller->set_page_url($this->u_action); |
127
|
|
|
$currency_entity->set_page_url($this->u_action); |
128
|
|
|
|
129
|
|
|
// Load a template from adm/style for our ACP page |
130
|
|
|
$this->tpl_name = 'ppde_currency'; |
131
|
|
|
|
132
|
|
|
// Set the page title for our ACP page |
133
|
|
|
$this->page_title = 'PPDE_ACP_CURRENCY'; |
134
|
|
|
|
135
|
|
|
// Perform any actions submitted by the user |
136
|
|
|
switch ($action) |
137
|
|
|
{ |
138
|
|
|
case 'add': |
139
|
|
|
// Set the page title for our ACP page |
140
|
|
|
$this->page_title = 'PPDE_DC_CONFIG'; |
141
|
|
|
|
142
|
|
|
// Load the add currency handle in the admin controller |
143
|
|
|
$admin_currency_controller->add_currency(); |
144
|
|
|
|
145
|
|
|
// Return to stop execution of this script |
146
|
|
|
return; |
147
|
|
|
case 'edit': |
148
|
|
|
// Set the page title for our ACP page |
149
|
|
|
$this->page_title = 'PPDE_DC_CONFIG'; |
150
|
|
|
|
151
|
|
|
// Load the edit donation pages handle in the admin controller |
152
|
|
|
$admin_currency_controller->edit_currency($currency_id); |
153
|
|
|
|
154
|
|
|
// Return to stop execution of this script |
155
|
|
|
return; |
156
|
|
|
case 'move_down': |
157
|
|
|
case 'move_up': |
158
|
|
|
// Move a currency |
159
|
|
|
$admin_currency_controller->move_currency($currency_id, $action); |
160
|
|
|
break; |
161
|
|
|
case 'enable': |
162
|
|
|
case 'disable': |
163
|
|
|
// Enable/disable a currency |
164
|
|
|
$admin_currency_controller->enable_currency($currency_id, $action); |
165
|
|
|
break; |
166
|
|
|
case 'delete': |
167
|
|
|
// Delete a donation page |
168
|
|
|
$admin_currency_controller->delete_currency($currency_id); |
169
|
|
|
break; |
170
|
|
|
} |
171
|
|
|
// Display module main page |
172
|
|
|
$admin_currency_controller->display_currency(); |
173
|
|
|
break; |
174
|
|
|
default: |
175
|
|
|
trigger_error('NO_MODE', E_USER_ERROR); |
176
|
|
|
break; |
177
|
|
|
} |
178
|
|
|
} |
179
|
|
|
} |
180
|
|
|
|