|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * |
| 4 | + * @package phpBB Extension - Browser Update |
| 5 | + * @author Darrell Dudics (a.k.a HoLyCoW, a.k.a HoLyCoWzOrZ) me@holycowzorz.com |
| 6 | + * @copyright (c) 2015 Darrell Dudics |
| 7 | + * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | + * |
| 9 | + */ |
| 10 | + |
| 11 | +namespace holycow\browserupdate\acp; |
| 12 | + |
| 13 | +class browserupdate_module |
| 14 | +{ |
| 15 | + /** @var \phpbb\config\config */ |
| 16 | + protected $config; |
| 17 | + |
| 18 | + /** @var \phpbb\config\db_text */ |
| 19 | + protected $config_text; |
| 20 | + |
| 21 | + /** @var \phpbb\db\driver\driver_interface */ |
| 22 | + protected $db; |
| 23 | + |
| 24 | + /** @var \phpbb\log\log */ |
| 25 | + protected $log; |
| 26 | + |
| 27 | + /** @var \phpbb\request\request */ |
| 28 | + protected $request; |
| 29 | + |
| 30 | + /** @var \phpbb\template\template */ |
| 31 | + protected $template; |
| 32 | + |
| 33 | + /** @var \phpbb\user */ |
| 34 | + protected $user; |
| 35 | + |
| 36 | + /** @var ContainerInterface */ |
| 37 | + protected $phpbb_container; |
| 38 | + |
| 39 | + /** @var string */ |
| 40 | + protected $phpbb_root_path; |
| 41 | + |
| 42 | + /** @var string */ |
| 43 | + protected $php_ext; |
| 44 | + |
| 45 | + /** @var string */ |
| 46 | + public $u_action; |
| 47 | + |
| 48 | + function main($id, $mode) |
| 49 | + { |
| 50 | + global $config, $db, $request, $template, $user, $phpbb_root_path, $phpEx, $phpbb_container; |
| 51 | + |
| 52 | + $this->config = $config; |
| 53 | + $this->config_text = $phpbb_container->get('config_text'); |
| 54 | + $this->db = $db; |
| 55 | + $this->log = $phpbb_container->get('log'); |
| 56 | + $this->request = $request; |
| 57 | + $this->template = $template; |
| 58 | + $this->user = $user; |
| 59 | + $this->phpbb_root_path = $phpbb_root_path; |
| 60 | + $this->php_ext = $phpEx; |
| 61 | + |
| 62 | + // Add the board announcements ACP lang file |
| 63 | + $this->user->add_lang_ext('holycow/browserupdate', 'browserupdate_acp'); |
| 64 | + |
| 65 | + // Load a template from adm/style for our ACP page |
| 66 | + $this->tpl_name = 'browserupdate'; |
| 67 | + |
| 68 | + // Set the page title for our ACP page |
| 69 | + $this->page_title = $this->user->lang('ACP_BROWSERUPDATE_SETTINGS'); |
| 70 | + |
| 71 | + // Define the name of the form for use as a form key |
| 72 | + $form_name = 'holycow/browserupdate'; |
| 73 | + add_form_key($form_name); |
| 74 | + |
| 75 | + if ($this->request->is_set_post('submit')) |
| 76 | + { |
| 77 | + // Test if form key is valid |
| 78 | + if (!check_form_key($form_name)) |
| 79 | + { |
| 80 | + trigger_error($this->user->lang('FORM_INVALID')); |
| 81 | + } |
| 82 | + |
| 83 | + $browserupdate_reminder = $this->request->variable('browserupdate_reminder', ''); |
| 84 | + $browserupdate_reminder_closed = $this->request->variable('browserupdate_reminder_closed', ''); |
| 85 | + $browserupdate_new_window = $this->request->variable('browserupdate_new_window', 1); |
| 86 | + |
| 87 | + $this->config->set('browserupdate_reminder', $browserupdate_reminder); |
| 88 | + $this->config->set('browserupdate_reminder_closed', $browserupdate_reminder_closed); |
| 89 | + $this->config->set('browserupdate_new_window', $browserupdate_new_window); |
| 90 | + |
| 91 | + // Log the updated settings |
| 92 | + $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'ACP_BROWSERUPDATE_UPDATE_LOG'); |
| 93 | + |
| 94 | + trigger_error($this->user->lang('BROWSERUPDATE_SETTINGS_SAVED') . adm_back_link($this->u_action)); |
| 95 | + } |
| 96 | + |
| 97 | + $this->template->assign_vars(array( |
| 98 | + 'BROWSERUPDATE_REMINDER' => $this->config['browserupdate_reminder'], |
| 99 | + 'BROWSERUPDATE_REMINDER_CLOSED' => $this->config['browserupdate_reminder_closed'], |
| 100 | + 'BROWSERUPDATE_NEW_WINDOW' => (isset($browserupdate_new_window)) ? $browserupdate_new_window : $this->config['browserupdate_new_window'], |
| 101 | + |
| 102 | + 'U_ACTION' => $this->u_action |
| 103 | + )); |
| 104 | + } |
| 105 | +} |
0 commit comments