Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
poll_option
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 get_columns
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 get_records_by_range_query
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
 save_record
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3*
4* This file is part of the phpBB Forum Software package.
5*
6* @copyright (c) phpBB Limited <https://www.phpbb.com>
7* @license GNU General Public License, version 2 (GPL-2.0)
8*
9* For full copyright and license information, please see
10* the docs/CREDITS.txt file.
11*
12*/
13
14namespace phpbb\textreparser\plugins;
15
16class poll_option extends \phpbb\textreparser\row_based_plugin
17{
18    /**
19    * {@inheritdoc}
20    */
21    public function get_columns()
22    {
23        return [
24            'id'   => 'topic_id',
25            'text' => 'poll_option_text',
26        ];
27    }
28
29    /**
30    * {@inheritdoc}
31    */
32    protected function get_records_by_range_query($min_id, $max_id)
33    {
34        $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
35            FROM ' . POLL_OPTIONS_TABLE . ' o, ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
36            WHERE o.topic_id BETWEEN ' . $min_id . ' AND ' . $max_id .'
37                AND t.topic_id = o.topic_id
38                AND p.post_id = t.topic_first_post_id';
39
40        return $sql;
41    }
42
43    /**
44    * {@inheritdoc}
45    */
46    protected function save_record(array $record)
47    {
48        $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . "
49            SET poll_option_text = '" . $this->db->sql_escape($record['text']) . "'
50            WHERE topic_id = " . $record['topic_id'] . '
51                AND poll_option_id = ' . $record['poll_option_id'];
52        $this->db->sql_query($sql);
53    }
54}