1 | <?php |
||
20 | class acp_manager |
||
21 | { |
||
22 | /** @var driver_interface */ |
||
23 | protected $db; |
||
24 | |||
25 | /** @var request */ |
||
26 | protected $request; |
||
27 | |||
28 | /** @var user */ |
||
29 | protected $user; |
||
30 | |||
31 | /** |
||
32 | * Constructor |
||
33 | * |
||
34 | * @param driver_interface $db |
||
35 | * @param request $request |
||
36 | * @param user $user |
||
37 | * @access public |
||
38 | */ |
||
39 | 34 | public function __construct(driver_interface $db, request $request, user $user) |
|
45 | |||
46 | /** |
||
47 | * Update BBCode order fields in the db on move up/down |
||
48 | * |
||
49 | * @param string $action The action move_up|move_down |
||
50 | * @access public |
||
51 | */ |
||
52 | 10 | public function move($action) |
|
75 | |||
76 | /** |
||
77 | * Update BBCode order fields in the db on drag_drop |
||
78 | * |
||
79 | * @access public |
||
80 | */ |
||
81 | 3 | public function drag_drop() |
|
108 | |||
109 | /** |
||
110 | * Retrieve the maximum value from the bbcode_order field stored in the db |
||
111 | * |
||
112 | * @return int The maximum order |
||
113 | * @access public |
||
114 | */ |
||
115 | 1 | public function get_max_bbcode_order() |
|
119 | |||
120 | /** |
||
121 | * Get the bbcode_group data from the posted form |
||
122 | * |
||
123 | * @return string The usergroup id numbers, comma delimited, or empty |
||
124 | * @access public |
||
125 | */ |
||
126 | 3 | public function get_bbcode_group_form_data() |
|
133 | |||
134 | /** |
||
135 | * Get the bbcode_group data from the database |
||
136 | * |
||
137 | * @param int $bbcode_id Custom BBCode id |
||
138 | * @return array Custom BBCode user group ids |
||
139 | * @access public |
||
140 | */ |
||
141 | 6 | public function get_bbcode_group_data($bbcode_id) |
|
152 | |||
153 | /** |
||
154 | * Get the bbcode_group data from the database, |
||
155 | * for every BBCode that has groups assigned |
||
156 | * |
||
157 | * @return array Custom BBCode user group ids for each BBCode, by name |
||
158 | * @access public |
||
159 | */ |
||
160 | 1 | public function get_bbcode_groups_data() |
|
175 | |||
176 | /** |
||
177 | * Generate a select box containing user groups |
||
178 | * |
||
179 | * @param array $select_id The user groups to mark as selected |
||
180 | * @return string HTML markup of user groups select box for the form |
||
181 | * @access public |
||
182 | */ |
||
183 | 5 | public function bbcode_group_select_options(array $select_id = array()) |
|
202 | |||
203 | /** |
||
204 | * Resynchronize the Custom BBCodes order field |
||
205 | * (Originally based on Custom BBCode Sorting MOD by RMcGirr83) |
||
206 | * |
||
207 | * @access public |
||
208 | */ |
||
209 | 14 | public function resynchronize_bbcode_order() |
|
230 | |||
231 | /** |
||
232 | * Get the bbcode_order value for a bbcode |
||
233 | * |
||
234 | * @param int $bbcode_id ID of the bbcode |
||
235 | * @return int The bbcode's order |
||
236 | * @access protected |
||
237 | */ |
||
238 | 9 | protected function get_bbcode_order($bbcode_id) |
|
249 | |||
250 | /** |
||
251 | * Update the bbcode orders for bbcodes moved up/down |
||
252 | * |
||
253 | * @param int $bbcode_order Value of the bbcode order |
||
254 | * @param string $action The action move_up|move_down |
||
255 | * @return mixed Number of the affected rows by the last query |
||
256 | * false if no query has been run before |
||
257 | * @access protected |
||
258 | */ |
||
259 | 7 | protected function update_bbcode_orders($bbcode_order, $action) |
|
275 | |||
276 | /** |
||
277 | * Build SQL query to update a bbcode order value |
||
278 | * |
||
279 | * @param int $bbcode_id ID of the bbcode |
||
280 | * @param int $bbcode_order Value of the bbcode order |
||
281 | * @return string The SQL query to run |
||
282 | * @access protected |
||
283 | */ |
||
284 | 8 | protected function update_bbcode_order($bbcode_id, $bbcode_order) |
|
290 | |||
291 | /** |
||
292 | * Retrieve the maximum value in a column from the bbcodes table |
||
293 | * |
||
294 | * @param string $column Name of the column (bbcode_id|bbcode_order) |
||
295 | * @return int The maximum value in the column |
||
296 | * @access protected |
||
297 | */ |
||
298 | 3 | protected function get_max_column_value($column) |
|
308 | |||
309 | /** |
||
310 | * Send a JSON response |
||
311 | * |
||
312 | * @param bool $content The content of the JSON response (true|false) |
||
313 | * @access protected |
||
314 | */ |
||
315 | 9 | protected function send_json_response($content) |
|
325 | } |
||
326 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.