From 986af43f37342953bff548630aa33904c21234f4 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 1 May 2015 08:47:01 +0200 Subject: [ticket/13803] Added plugins PHPBB3-13803 --- phpBB/phpbb/textreparser/plugins/poll_option.php | 50 ++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 phpBB/phpbb/textreparser/plugins/poll_option.php (limited to 'phpBB/phpbb/textreparser/plugins/poll_option.php') diff --git a/phpBB/phpbb/textreparser/plugins/poll_option.php b/phpBB/phpbb/textreparser/plugins/poll_option.php new file mode 100644 index 0000000000..f074f1866d --- /dev/null +++ b/phpBB/phpbb/textreparser/plugins/poll_option.php @@ -0,0 +1,50 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\textreparser\plugins; + +class poll_option extends \phpbb\textreparser\row_based_plugin +{ + /** + * {@inheritdoc} + */ + protected function get_columns() + { + return array( + 'id' => 'poll_option_id', + 'text' => 'poll_option_text', + ); + } + + /** + * {@inheritdoc} + */ + protected function get_records_query($min_id, $max_id) + { + $sql = 'SELECT o.poll_option_id AS id, o.poll_option_text AS text, p.bbcode_uid + FROM ' . POLL_OPTIONS_TABLE . ' o, ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p + WHERE o.poll_option_id BETWEEN ' . $min_id . ' AND ' . $max_id .' + AND t.topic_id = o.topic_id + AND p.post_id = t.topic_first_post_id'; + + return $sql; + } + + /** + * {@inheritdoc} + */ + protected function get_table_name() + { + return POLL_OPTIONS_TABLE; + } +} -- cgit v1.2.1 From 459f1d4c1f26658c70d29ac7c4e3f3389a973a59 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 1 May 2015 20:05:15 +0200 Subject: [ticket/13803] Refactored test PHPBB3-13803 --- phpBB/phpbb/textreparser/plugins/poll_option.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/textreparser/plugins/poll_option.php') diff --git a/phpBB/phpbb/textreparser/plugins/poll_option.php b/phpBB/phpbb/textreparser/plugins/poll_option.php index f074f1866d..cc28599737 100644 --- a/phpBB/phpbb/textreparser/plugins/poll_option.php +++ b/phpBB/phpbb/textreparser/plugins/poll_option.php @@ -18,7 +18,7 @@ class poll_option extends \phpbb\textreparser\row_based_plugin /** * {@inheritdoc} */ - protected function get_columns() + public function get_columns() { return array( 'id' => 'poll_option_id', @@ -43,7 +43,7 @@ class poll_option extends \phpbb\textreparser\row_based_plugin /** * {@inheritdoc} */ - protected function get_table_name() + public function get_table_name() { return POLL_OPTIONS_TABLE; } -- cgit v1.2.1 From 3827a131ae11dcd3adf852f80ff4d85e7a7d470b Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 9 May 2015 20:12:30 +0200 Subject: [ticket/13803] Rewrote the poll_option plugin As it turns out, poll_option_id is not a primary key. PHPBB3-13803 --- phpBB/phpbb/textreparser/plugins/poll_option.php | 48 ++++++++++++++++++------ 1 file changed, 36 insertions(+), 12 deletions(-) (limited to 'phpBB/phpbb/textreparser/plugins/poll_option.php') diff --git a/phpBB/phpbb/textreparser/plugins/poll_option.php b/phpBB/phpbb/textreparser/plugins/poll_option.php index cc28599737..3249e21694 100644 --- a/phpBB/phpbb/textreparser/plugins/poll_option.php +++ b/phpBB/phpbb/textreparser/plugins/poll_option.php @@ -13,38 +13,62 @@ namespace phpbb\textreparser\plugins; -class poll_option extends \phpbb\textreparser\row_based_plugin +class poll_option extends \phpbb\textreparser\base { + /** + * @var \phpbb\db\driver\driver_interface + */ + protected $db; + + /** + * Constructor + * + * @param \phpbb\db\driver\driver_interface $db Database connection + */ + public function __construct(\phpbb\db\driver\driver_interface $db) + { + $this->db = $db; + } + /** * {@inheritdoc} */ - public function get_columns() + public function get_max_id() { - return array( - 'id' => 'poll_option_id', - 'text' => 'poll_option_text', - ); + $sql = 'SELECT MAX(topic_id) AS max_id FROM ' . POLL_OPTIONS_TABLE; + $result = $this->db->sql_query($sql); + $max_id = (int) $this->db->sql_fetchfield('max_id'); + $this->db->sql_freeresult($result); + + return $max_id; } /** * {@inheritdoc} */ - protected function get_records_query($min_id, $max_id) + protected function get_records($min_id, $max_id) { - $sql = 'SELECT o.poll_option_id AS id, o.poll_option_text AS text, p.bbcode_uid + $sql = 'SELECT o.topic_id, o.poll_option_id, o.poll_option_text AS text, p.bbcode_uid FROM ' . POLL_OPTIONS_TABLE . ' o, ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p - WHERE o.poll_option_id BETWEEN ' . $min_id . ' AND ' . $max_id .' + WHERE o.topic_id BETWEEN ' . $min_id . ' AND ' . $max_id .' AND t.topic_id = o.topic_id AND p.post_id = t.topic_first_post_id'; + $result = $this->db->sql_query($sql); + $records = $this->db->sql_fetchrowset($result); + $this->db->sql_freeresult($result); - return $sql; + return $records; } /** * {@inheritdoc} */ - public function get_table_name() + protected function save_record(array $record) { - return POLL_OPTIONS_TABLE; + $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . " + SET poll_option_text = '" . $this->db->sql_escape($record['text']) . "' + WHERE topic_id = " . $record['topic_id'] . ' + AND poll_option_id = ' . $record['poll_option_id']; + $this->db->sql_query($sql); } } -- cgit v1.2.1 From 75eb283f8d7a7afcd3945d0d28bd0f58aa4f0cd6 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 19 May 2015 09:48:29 +0200 Subject: [ticket/13803] Renamed methods PHPBB3-13803 --- phpBB/phpbb/textreparser/plugins/poll_option.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/textreparser/plugins/poll_option.php') diff --git a/phpBB/phpbb/textreparser/plugins/poll_option.php b/phpBB/phpbb/textreparser/plugins/poll_option.php index 3249e21694..7b803146c4 100644 --- a/phpBB/phpbb/textreparser/plugins/poll_option.php +++ b/phpBB/phpbb/textreparser/plugins/poll_option.php @@ -46,7 +46,7 @@ class poll_option extends \phpbb\textreparser\base /** * {@inheritdoc} */ - protected function get_records($min_id, $max_id) + protected function get_records_by_range($min_id, $max_id) { $sql = 'SELECT o.topic_id, o.poll_option_id, o.poll_option_text AS text, p.bbcode_uid FROM ' . POLL_OPTIONS_TABLE . ' o, ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p -- cgit v1.2.1 From a44711e57478c6f9d1fa38582deae72cad240560 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 6 Jul 2015 19:17:40 +0200 Subject: [ticket/13990] Reparse markup inside of forum rules/description PHPBB3-13990 --- phpBB/phpbb/textreparser/plugins/poll_option.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/textreparser/plugins/poll_option.php') diff --git a/phpBB/phpbb/textreparser/plugins/poll_option.php b/phpBB/phpbb/textreparser/plugins/poll_option.php index 7b803146c4..44cacfae62 100644 --- a/phpBB/phpbb/textreparser/plugins/poll_option.php +++ b/phpBB/phpbb/textreparser/plugins/poll_option.php @@ -48,7 +48,7 @@ class poll_option extends \phpbb\textreparser\base */ protected function get_records_by_range($min_id, $max_id) { - $sql = 'SELECT o.topic_id, o.poll_option_id, o.poll_option_text AS text, p.bbcode_uid + $sql = 'SELECT o.topic_id, o.poll_option_id, o.poll_option_text AS text, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.bbcode_uid FROM ' . POLL_OPTIONS_TABLE . ' o, ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p WHERE o.topic_id BETWEEN ' . $min_id . ' AND ' . $max_id .' AND t.topic_id = o.topic_id -- cgit v1.2.1