[use/request_class] Use request class in poll module

This commit is contained in:
Marc Alexander
2013-11-26 12:25:23 +01:00
parent b628ba287d
commit f7ec84633d
2 changed files with 19 additions and 13 deletions

View File

@@ -184,6 +184,7 @@ services:
- @auth - @auth
- @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 poll extends module_base
/** @var \phpbb\db\driver */ /** @var \phpbb\db\driver */
protected $db; protected $db;
/** @var \phpbb\request\request */
protected $request;
/** @var php file extension */ /** @var php file extension */
protected $php_ext; protected $php_ext;
@@ -73,17 +76,19 @@ class poll extends module_base
* *
* @param \phpbb\auth\auth $auth phpBB auth service * @param \phpbb\auth\auth $auth phpBB auth service
* @param \phpbb\config\config $config phpBB config * @param \phpbb\config\config $config phpBB config
* @param \phpbb\template $template phpBB template
* @param \phpbb\db\driver $db Database driver * @param \phpbb\db\driver $db Database driver
* @param \phpbb\request\request $request phpBB request
* @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($auth, $config, $db, $template, $phpbb_root_path, $phpEx, $user) public function __construct($auth, $config, $db, $request, $template, $phpbb_root_path, $phpEx, $user)
{ {
$this->auth = $auth; $this->auth = $auth;
$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;
@@ -194,7 +199,7 @@ class poll extends module_base
public function store_selected_forums($key, $module_id) public function store_selected_forums($key, $module_id)
{ {
// Get selected forums // Get selected forums
$values = request_var($key, array(0 => '')); $values = $this->request->variable($key, array(0 => ''));
$news = implode(',', $values); $news = implode(',', $values);
@@ -220,17 +225,17 @@ class poll extends module_base
include($this->phpbb_root_path . 'includes/bbcode.' . $this->php_ext); include($this->phpbb_root_path . 'includes/bbcode.' . $this->php_ext);
} }
$view = request_var('view', ''); $view = $this->request->variable('view', '');
$update = request_var('update', false); $update = $this->request->variable('update', false);
$poll_view = request_var('polls', ''); $poll_view = $this->request->variable('polls', '');
$poll_view_ar = (strpos($poll_view, ',') !== FALSE) ? explode(',', $poll_view) : (($poll_view != '') ? array($poll_view) : array()); $poll_view_ar = (strpos($poll_view, ',') !== FALSE) ? explode(',', $poll_view) : (($poll_view != '') ? array($poll_view) : array());
if ($update && $this->config['board3_poll_allow_vote_' . $module_id]) if ($update && $this->config['board3_poll_allow_vote_' . $module_id])
{ {
$up_topic_id = request_var('t', 0); $up_topic_id = $this->request->variable('t', 0);
$up_forum_id = request_var('f', 0); $up_forum_id = $this->request->variable('f', 0);
$voted_id = request_var('vote_id', array('' => 0)); $voted_id = $this->request->variable('vote_id', array('' => 0));
$cur_voted_id = array(); $cur_voted_id = array();
if ($this->user->data['is_registered']) if ($this->user->data['is_registered'])
@@ -252,9 +257,9 @@ class poll extends module_base
// Cookie based guest tracking ... I don't like this but hum ho // Cookie based guest tracking ... I don't like this but hum ho
// it's oft requested. This relies on "nice" users who don't feel // it's oft requested. This relies on "nice" users who don't feel
// the need to delete cookies to mess with results. // the need to delete cookies to mess with results.
if (isset($_COOKIE[$this->config['cookie_name'] . '_poll_' . $up_topic_id])) if ($request->is_set($config['cookie_name'] . '_poll_' . $up_topic_id, \phpbb\request\request_interface::COOKIE))
{ {
$cur_voted_id = explode(',', request_var($this->config['cookie_name'] . '_poll_' . $up_topic_id, 0, false, true)); $cur_voted_id = explode(',', $this->request->variable($config['cookie_name'] . '_poll_' . $up_topic_id, '', true, \phpbb\request\request_interface::COOKIE));
$cur_voted_id = array_map('intval', $cur_voted_id); $cur_voted_id = array_map('intval', $cur_voted_id);
} }
} }
@@ -446,9 +451,9 @@ class poll extends module_base
// Cookie based guest tracking ... I don't like this but hum ho // Cookie based guest tracking ... I don't like this but hum ho
// it's oft requested. This relies on "nice" users who don't feel // it's oft requested. This relies on "nice" users who don't feel
// the need to delete cookies to mess with results. // the need to delete cookies to mess with results.
if (isset($_COOKIE[$this->config['cookie_name'] . '_poll_' . $topic_id])) if ($this->request->is_set($config['cookie_name'] . '_poll_' . $topic_id, \phpbb\request\request_interface::COOKIE))
{ {
$cur_voted_id = explode(',', request_var($this->config['cookie_name'] . '_poll_' . $topic_id, 0, false, true)); $cur_voted_id = explode(',', $this->request->variable($this->config['cookie_name'] . '_poll_' . $topic_id, 0, false, true));
$cur_voted_id = array_map('intval', $cur_voted_id); $cur_voted_id = array_map('intval', $cur_voted_id);
} }
} }