From 98dab4ed0f74debd59be76792d51bb231444e709 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 26 Nov 2013 13:03:45 +0100 Subject: [PATCH] [use/request_class] Use request class in links module --- config/modules.yml | 1 + modules/links.php | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/config/modules.yml b/config/modules.yml index 4ceac076..99ce47cc 100644 --- a/config/modules.yml +++ b/config/modules.yml @@ -145,6 +145,7 @@ services: arguments: - @config - @dbal.conn + - @request - @template - %core.root_path% - %core.php_ext% diff --git a/modules/links.php b/modules/links.php index 2ce08532..ead19f0a 100644 --- a/modules/links.php +++ b/modules/links.php @@ -59,6 +59,9 @@ class links extends module_base /** @var \phpbb\db\driver */ protected $db; + /** @var \phpbb\request\request */ + protected $request; + /** @var \phpbb\template */ protected $template; @@ -76,15 +79,17 @@ class links extends module_base * * @param \phpbb\config\config $config phpBB config * @param \phpbb\db\driver $db phpBB db driver + * @param \phpbb\request\request $request phpBB request * @param \phpbb\template $template phpBB template * @param string $phpEx php file extension * @param string $phpbb_root_path phpBB root path * @param \phpbb\user $user phpBB user object */ - public function __construct($config, $db, $template, $phpbb_root_path, $phpEx, $user) + public function __construct($config, $db, $request, $template, $phpbb_root_path, $phpEx, $user) { $this->config = $config; $this->db = $db; + $this->request = $request; $this->template = $template; $this->php_ext = $phpEx; $this->phpbb_root_path = $phpbb_root_path; @@ -227,10 +232,10 @@ class links extends module_base */ public function manage_links($value, $key, $module_id) { - $action = request_var('action', ''); - $action = (isset($_POST['add'])) ? 'add' : $action; - $action = (isset($_POST['save'])) ? 'save' : $action; - $link_id = request_var('id', 99999999); // 0 will trigger unwanted behavior, therefore we set a number we should never reach + $action = $this->request->variable('action', ''); + $action = ($this->request->is_set_post('add')) ? 'add' : $action; + $action = ($this->request->is_set_post('save')) ? 'save' : $action; + $link_id = $this->request->variable('id', 99999999); // 0 will trigger unwanted behavior, therefore we set a number we should never reach $portal_config = obtain_portal_config(); $links = array(); @@ -248,11 +253,11 @@ class links extends module_base trigger_error($this->user->lang['FORM_INVALID']. adm_back_link($u_action), E_USER_WARNING); } - $link_title = utf8_normalize_nfc(request_var('link_title', ' ', true)); - $link_type = request_var('link_type', 2); // default to B3_LINK_EXT, no categories in Links block - $link_url = utf8_normalize_nfc(request_var('link_url', ' ', true)); + $link_title = $this->request->variable('link_title', ' ', true); + $link_type = $this->request->variable('link_type', 2); // default to B3_LINK_EXT, no categories in Links block + $link_url = $this->request->variable('link_url', ' ', true); $link_url = str_replace('&', '&', $link_url); - $link_permission = request_var('permission-setting-link', array(0 => '')); + $link_permission = $this->request->variable('permission-setting-link', array(0 => '')); $groups_ary = array(); // get groups and check if the selected groups actually exist