[use/request_class] Use request class in links module

This commit is contained in:
Marc Alexander
2013-11-26 13:03:45 +01:00
parent 5e575e2f83
commit 98dab4ed0f
2 changed files with 15 additions and 9 deletions

View File

@@ -145,6 +145,7 @@ services:
arguments: arguments:
- @config - @config
- @dbal.conn - @dbal.conn
- @request
- @template - @template
- %core.root_path% - %core.root_path%
- %core.php_ext% - %core.php_ext%

View File

@@ -59,6 +59,9 @@ class links extends module_base
/** @var \phpbb\db\driver */ /** @var \phpbb\db\driver */
protected $db; protected $db;
/** @var \phpbb\request\request */
protected $request;
/** @var \phpbb\template */ /** @var \phpbb\template */
protected $template; protected $template;
@@ -76,15 +79,17 @@ class links extends module_base
* *
* @param \phpbb\config\config $config phpBB config * @param \phpbb\config\config $config phpBB config
* @param \phpbb\db\driver $db phpBB db driver * @param \phpbb\db\driver $db phpBB db driver
* @param \phpbb\request\request $request phpBB request
* @param \phpbb\template $template phpBB template * @param \phpbb\template $template phpBB template
* @param string $phpEx php file extension * @param string $phpEx php file extension
* @param string $phpbb_root_path phpBB root path * @param string $phpbb_root_path phpBB root path
* @param \phpbb\user $user phpBB user object * @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->config = $config;
$this->db = $db; $this->db = $db;
$this->request = $request;
$this->template = $template; $this->template = $template;
$this->php_ext = $phpEx; $this->php_ext = $phpEx;
$this->phpbb_root_path = $phpbb_root_path; $this->phpbb_root_path = $phpbb_root_path;
@@ -227,10 +232,10 @@ class links extends module_base
*/ */
public function manage_links($value, $key, $module_id) public function manage_links($value, $key, $module_id)
{ {
$action = request_var('action', ''); $action = $this->request->variable('action', '');
$action = (isset($_POST['add'])) ? 'add' : $action; $action = ($this->request->is_set_post('add')) ? 'add' : $action;
$action = (isset($_POST['save'])) ? 'save' : $action; $action = ($this->request->is_set_post('save')) ? 'save' : $action;
$link_id = request_var('id', 99999999); // 0 will trigger unwanted behavior, therefore we set a number we should never reach $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(); $portal_config = obtain_portal_config();
$links = array(); $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); 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_title = $this->request->variable('link_title', ' ', true);
$link_type = request_var('link_type', 2); // default to B3_LINK_EXT, no categories in Links block $link_type = $this->request->variable('link_type', 2); // default to B3_LINK_EXT, no categories in Links block
$link_url = utf8_normalize_nfc(request_var('link_url', ' ', true)); $link_url = $this->request->variable('link_url', ' ', true);
$link_url = str_replace('&', '&', $link_url); $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(); $groups_ary = array();
// get groups and check if the selected groups actually exist // get groups and check if the selected groups actually exist