phpbb-extensions /
autogroups
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 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 $u_action; |
||
| 16 | |||
| 17 | public function main($id, $mode) |
||
| 18 | { |
||
| 19 | global $phpbb_container, $request; |
||
| 20 | |||
| 21 | /** @var \phpbb\language\language $language */ |
||
| 22 | $language = $phpbb_container->get('language'); |
||
| 23 | |||
| 24 | // Add the auto groups ACP lang file |
||
| 25 | $language->add_lang('autogroups_acp', 'phpbb/autogroups'); |
||
| 26 | |||
| 27 | // Get an instance of the admin controller |
||
| 28 | $admin_controller = $phpbb_container->get('phpbb.autogroups.admin_controller'); |
||
| 29 | |||
| 30 | // Requests |
||
| 31 | $action = $request->variable('action', ''); |
||
| 32 | $autogroups_id = $request->variable('autogroups_id', 0); |
||
| 33 | |||
| 34 | // Make the $u_action url available in the admin controller |
||
| 35 | $admin_controller->set_page_url($this->u_action); |
||
| 36 | |||
| 37 | // Load a template from adm/style for our ACP auto groups |
||
| 38 | $this->tpl_name = 'manage_autogroups'; |
||
| 39 | |||
| 40 | // Set the page title for our ACP auto groups |
||
| 41 | $this->page_title = $language->lang('ACP_AUTOGROUPS_MANAGE'); |
||
|
0 ignored issues
–
show
|
|||
| 42 | |||
| 43 | // Quick-submit settings from the general options form |
||
| 44 | if ($request->is_set_post('generalsubmit')) |
||
| 45 | { |
||
| 46 | $admin_controller->submit_autogroups_options(); |
||
| 47 | } |
||
| 48 | |||
| 49 | // Perform any actions submitted by the user |
||
| 50 | switch ($action) |
||
| 51 | { |
||
| 52 | case 'add': |
||
| 53 | case 'edit': |
||
| 54 | // Set the page title for our ACP auto groups |
||
| 55 | $this->page_title = $language->lang(strtoupper("ACP_AUTOGROUPS_$action")); |
||
| 56 | |||
| 57 | // Load the save auto group handle in the admin controller |
||
| 58 | $admin_controller->save_autogroup_rule($autogroups_id); |
||
| 59 | |||
| 60 | // Return to stop execution of this script |
||
| 61 | return; |
||
| 62 | break; |
||
| 63 | |||
| 64 | case 'sync': |
||
| 65 | // Resync applies an auto group check against all users |
||
| 66 | $admin_controller->resync_autogroup_rule($autogroups_id); |
||
| 67 | break; |
||
| 68 | |||
| 69 | case 'delete': |
||
| 70 | // Use a confirm box routine when deleting an auto group rule |
||
| 71 | if (confirm_box(true)) |
||
| 72 | { |
||
| 73 | // Delete auto group rule on confirmation from the user |
||
| 74 | $admin_controller->delete_autogroup_rule($autogroups_id); |
||
| 75 | } |
||
| 76 | else |
||
| 77 | { |
||
| 78 | // Request confirmation from the user to delete the auto group rule |
||
| 79 | confirm_box(false, $language->lang('ACP_AUTOGROUPS_DELETE_CONFIRM'), build_hidden_fields(array( |
||
| 80 | 'autogroups_id' => $autogroups_id, |
||
| 81 | 'mode' => $mode, |
||
| 82 | 'action' => $action, |
||
| 83 | ))); |
||
| 84 | } |
||
| 85 | break; |
||
| 86 | } |
||
| 87 | |||
| 88 | // Display auto group rules |
||
| 89 | $admin_controller->display_autogroups(); |
||
| 90 | } |
||
| 91 | } |
||
| 92 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: