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 --- .../textreparser/plugins/admin_contact_info.php | 69 ++++++++++++++++++++++ .../textreparser/plugins/forum_description.php | 37 ++++++++++++ phpBB/phpbb/textreparser/plugins/forum_rules.php | 37 ++++++++++++ .../textreparser/plugins/group_description.php | 37 ++++++++++++ phpBB/phpbb/textreparser/plugins/pm_text.php | 40 +++++++++++++ phpBB/phpbb/textreparser/plugins/poll_option.php | 50 ++++++++++++++++ phpBB/phpbb/textreparser/plugins/poll_title.php | 50 ++++++++++++++++ phpBB/phpbb/textreparser/plugins/post_text.php | 40 +++++++++++++ .../phpbb/textreparser/plugins/user_signature.php | 37 ++++++++++++ 9 files changed, 397 insertions(+) create mode 100644 phpBB/phpbb/textreparser/plugins/admin_contact_info.php create mode 100644 phpBB/phpbb/textreparser/plugins/forum_description.php create mode 100644 phpBB/phpbb/textreparser/plugins/forum_rules.php create mode 100644 phpBB/phpbb/textreparser/plugins/group_description.php create mode 100644 phpBB/phpbb/textreparser/plugins/pm_text.php create mode 100644 phpBB/phpbb/textreparser/plugins/poll_option.php create mode 100644 phpBB/phpbb/textreparser/plugins/poll_title.php create mode 100644 phpBB/phpbb/textreparser/plugins/post_text.php create mode 100644 phpBB/phpbb/textreparser/plugins/user_signature.php (limited to 'phpBB/phpbb/textreparser/plugins') diff --git a/phpBB/phpbb/textreparser/plugins/admin_contact_info.php b/phpBB/phpbb/textreparser/plugins/admin_contact_info.php new file mode 100644 index 0000000000..e432ddea81 --- /dev/null +++ b/phpBB/phpbb/textreparser/plugins/admin_contact_info.php @@ -0,0 +1,69 @@ + +* @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 admin_contact_info extends \phpbb\textreparser\base +{ + /** + * @var \phpbb\config\db_text + */ + protected $config_text; + + /** + * Constructor + * + * @param \phpbb\config\db_text $config_text + */ + public function __construct(\phpbb\config\db_text $config_text) + { + $this->config_text = $config_text; + } + + /** + * {@inheritdoc} + */ + public function get_max_id() + { + return 1; + } + + /** + * {@inheritdoc} + */ + protected function get_records($min_id, $max_id) + { + $values = $this->config_text->get_array(array( + 'contact_admin_info', + 'contact_admin_info_uid', + 'contact_admin_info_flags', + )); + + return array(array( + 'id' => 1, + 'text' => $values['contact_admin_info'], + 'bbcode_uid' => $values['contact_admin_info_uid'], + 'enable_bbcode' => $values['contact_admin_info_flags'] & OPTION_FLAG_BBCODE, + 'enable_magic_url' => $values['contact_admin_info_flags'] & OPTION_FLAG_LINKS, + 'enable_smilies' => $values['contact_admin_info_flags'] & OPTION_FLAG_SMILIES, + )); + } + + /** + * {@inheritdoc} + */ + protected function save_record(array $record) + { + $this->config_text->set('admin_contact_info', $record['text']); + } +} diff --git a/phpBB/phpbb/textreparser/plugins/forum_description.php b/phpBB/phpbb/textreparser/plugins/forum_description.php new file mode 100644 index 0000000000..d6e95c9638 --- /dev/null +++ b/phpBB/phpbb/textreparser/plugins/forum_description.php @@ -0,0 +1,37 @@ + +* @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 forum_description extends \phpbb\textreparser\row_based_plugin +{ + /** + * {@inheritdoc} + */ + protected function get_columns() + { + return array( + 'id' => 'forum_id', + 'text' => 'forum_desc', + 'bbcode_uid' => 'forum_desc_uid', + ); + } + + /** + * {@inheritdoc} + */ + protected function get_table_name() + { + return FORUMS_TABLE; + } +} diff --git a/phpBB/phpbb/textreparser/plugins/forum_rules.php b/phpBB/phpbb/textreparser/plugins/forum_rules.php new file mode 100644 index 0000000000..36bb595cb9 --- /dev/null +++ b/phpBB/phpbb/textreparser/plugins/forum_rules.php @@ -0,0 +1,37 @@ + +* @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 forum_rules extends \phpbb\textreparser\row_based_plugin +{ + /** + * {@inheritdoc} + */ + protected function get_columns() + { + return array( + 'id' => 'forum_id', + 'text' => 'forum_rules', + 'bbcode_uid' => 'forum_rules_uid', + ); + } + + /** + * {@inheritdoc} + */ + protected function get_table_name() + { + return FORUMS_TABLE; + } +} diff --git a/phpBB/phpbb/textreparser/plugins/group_description.php b/phpBB/phpbb/textreparser/plugins/group_description.php new file mode 100644 index 0000000000..c83079827c --- /dev/null +++ b/phpBB/phpbb/textreparser/plugins/group_description.php @@ -0,0 +1,37 @@ + +* @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 group_description extends \phpbb\textreparser\row_based_plugin +{ + /** + * {@inheritdoc} + */ + protected function get_columns() + { + return array( + 'id' => 'group_id', + 'text' => 'group_desc', + 'bbcode_uid' => 'group_desc_uid', + ); + } + + /** + * {@inheritdoc} + */ + protected function get_table_name() + { + return GROUPS_TABLE; + } +} diff --git a/phpBB/phpbb/textreparser/plugins/pm_text.php b/phpBB/phpbb/textreparser/plugins/pm_text.php new file mode 100644 index 0000000000..f4d87525df --- /dev/null +++ b/phpBB/phpbb/textreparser/plugins/pm_text.php @@ -0,0 +1,40 @@ + +* @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 pm_text extends \phpbb\textreparser\row_based_plugin +{ + /** + * {@inheritdoc} + */ + protected function get_columns() + { + return array( + 'id' => 'msg_id', + 'enable_bbcode' => 'enable_bbcode', + 'enable_smilies' => 'enable_smilies', + 'enable_magic_url' => 'enable_magic_url', + 'text' => 'message_text', + 'bbcode_uid' => 'bbcode_uid', + ); + } + + /** + * {@inheritdoc} + */ + protected function get_table_name() + { + return PRIVMSGS_TABLE; + } +} 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; + } +} diff --git a/phpBB/phpbb/textreparser/plugins/poll_title.php b/phpBB/phpbb/textreparser/plugins/poll_title.php new file mode 100644 index 0000000000..e794780eba --- /dev/null +++ b/phpBB/phpbb/textreparser/plugins/poll_title.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_title extends \phpbb\textreparser\row_based_plugin +{ + /** + * {@inheritdoc} + */ + protected function get_columns() + { + return array( + 'id' => 'topic_id', + 'text' => 'poll_title', + ); + } + + /** + * {@inheritdoc} + */ + protected function get_records_query($min_id, $max_id) + { + $sql = 'SELECT t.topic_id AS id, t.poll_title AS text, p.bbcode_uid + FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p + WHERE t.topic_id BETWEEN ' . $min_id . ' AND ' . $max_id .' + AND t.poll_max_options > 0 + AND p.post_id = t.topic_first_post_id'; + + return $sql; + } + + /** + * {@inheritdoc} + */ + protected function get_table_name() + { + return TOPICS_TABLE; + } +} diff --git a/phpBB/phpbb/textreparser/plugins/post_text.php b/phpBB/phpbb/textreparser/plugins/post_text.php new file mode 100644 index 0000000000..2b16518b03 --- /dev/null +++ b/phpBB/phpbb/textreparser/plugins/post_text.php @@ -0,0 +1,40 @@ + +* @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 post_text extends \phpbb\textreparser\row_based_plugin +{ + /** + * {@inheritdoc} + */ + protected function get_columns() + { + return array( + 'id' => 'post_id', + 'enable_bbcode' => 'enable_bbcode', + 'enable_smilies' => 'enable_smilies', + 'enable_magic_url' => 'enable_magic_url', + 'text' => 'post_text', + 'bbcode_uid' => 'bbcode_uid', + ); + } + + /** + * {@inheritdoc} + */ + protected function get_table_name() + { + return POSTS_TABLE; + } +} diff --git a/phpBB/phpbb/textreparser/plugins/user_signature.php b/phpBB/phpbb/textreparser/plugins/user_signature.php new file mode 100644 index 0000000000..2beaaf98e5 --- /dev/null +++ b/phpBB/phpbb/textreparser/plugins/user_signature.php @@ -0,0 +1,37 @@ + +* @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 user_signature extends \phpbb\textreparser\row_based_plugin +{ + /** + * {@inheritdoc} + */ + protected function get_columns() + { + return array( + 'id' => 'user_id', + 'text' => 'user_sig', + 'bbcode_uid' => 'user_sig_bbcode_uid', + ); + } + + /** + * {@inheritdoc} + */ + protected function get_table_name() + { + return USERS_TABLE; + } +} -- cgit v1.2.1 From b5911281ae175340817345e63ddbfaf43abb3cec Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 1 May 2015 19:21:01 +0200 Subject: [ticket/13803] Added tests, fixed param order in generate_text_for_storage() PHPBB3-13803 --- .../phpbb/textreparser/plugins/user_signature.php | 39 ++++++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/textreparser/plugins') diff --git a/phpBB/phpbb/textreparser/plugins/user_signature.php b/phpBB/phpbb/textreparser/plugins/user_signature.php index 2beaaf98e5..7a66f39ab6 100644 --- a/phpBB/phpbb/textreparser/plugins/user_signature.php +++ b/phpBB/phpbb/textreparser/plugins/user_signature.php @@ -15,15 +15,48 @@ namespace phpbb\textreparser\plugins; class user_signature extends \phpbb\textreparser\row_based_plugin { + /** + * @var array Bit numbers used for user options + * @see \phpbb\user + */ + protected $keyoptions; + + /** + * Constructor + * + * Retrieves and saves the bit numbers used for user options + */ + public function __construct() + { + $class_vars = get_class_vars('phpbb\\user'); + $this->keyoptions = $class_vars['keyoptions']; + } + + /** + * {@inheritdoc} + */ + protected function add_missing_fields(array $row) + { + $options = $row['user_options']; + $row += array( + 'enable_bbcode' => phpbb_optionget($this->keyoptions['sig_bbcode'], $options), + 'enable_smilies' => phpbb_optionget($this->keyoptions['sig_smilies'], $options), + 'enable_magic_url' => phpbb_optionget($this->keyoptions['sig_links'], $options), + ); + + return $row; + } + /** * {@inheritdoc} */ protected function get_columns() { return array( - 'id' => 'user_id', - 'text' => 'user_sig', - 'bbcode_uid' => 'user_sig_bbcode_uid', + 'id' => 'user_id', + 'text' => 'user_sig', + 'bbcode_uid' => 'user_sig_bbcode_uid', + 'user_options' => 'user_options', ); } -- 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/forum_description.php | 4 ++-- phpBB/phpbb/textreparser/plugins/forum_rules.php | 4 ++-- phpBB/phpbb/textreparser/plugins/group_description.php | 4 ++-- phpBB/phpbb/textreparser/plugins/pm_text.php | 4 ++-- phpBB/phpbb/textreparser/plugins/poll_option.php | 4 ++-- phpBB/phpbb/textreparser/plugins/poll_title.php | 4 ++-- phpBB/phpbb/textreparser/plugins/post_text.php | 4 ++-- phpBB/phpbb/textreparser/plugins/user_signature.php | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) (limited to 'phpBB/phpbb/textreparser/plugins') diff --git a/phpBB/phpbb/textreparser/plugins/forum_description.php b/phpBB/phpbb/textreparser/plugins/forum_description.php index d6e95c9638..7798e4b20b 100644 --- a/phpBB/phpbb/textreparser/plugins/forum_description.php +++ b/phpBB/phpbb/textreparser/plugins/forum_description.php @@ -18,7 +18,7 @@ class forum_description extends \phpbb\textreparser\row_based_plugin /** * {@inheritdoc} */ - protected function get_columns() + public function get_columns() { return array( 'id' => 'forum_id', @@ -30,7 +30,7 @@ class forum_description extends \phpbb\textreparser\row_based_plugin /** * {@inheritdoc} */ - protected function get_table_name() + public function get_table_name() { return FORUMS_TABLE; } diff --git a/phpBB/phpbb/textreparser/plugins/forum_rules.php b/phpBB/phpbb/textreparser/plugins/forum_rules.php index 36bb595cb9..57c666a556 100644 --- a/phpBB/phpbb/textreparser/plugins/forum_rules.php +++ b/phpBB/phpbb/textreparser/plugins/forum_rules.php @@ -18,7 +18,7 @@ class forum_rules extends \phpbb\textreparser\row_based_plugin /** * {@inheritdoc} */ - protected function get_columns() + public function get_columns() { return array( 'id' => 'forum_id', @@ -30,7 +30,7 @@ class forum_rules extends \phpbb\textreparser\row_based_plugin /** * {@inheritdoc} */ - protected function get_table_name() + public function get_table_name() { return FORUMS_TABLE; } diff --git a/phpBB/phpbb/textreparser/plugins/group_description.php b/phpBB/phpbb/textreparser/plugins/group_description.php index c83079827c..ddd0e1d1c5 100644 --- a/phpBB/phpbb/textreparser/plugins/group_description.php +++ b/phpBB/phpbb/textreparser/plugins/group_description.php @@ -18,7 +18,7 @@ class group_description extends \phpbb\textreparser\row_based_plugin /** * {@inheritdoc} */ - protected function get_columns() + public function get_columns() { return array( 'id' => 'group_id', @@ -30,7 +30,7 @@ class group_description extends \phpbb\textreparser\row_based_plugin /** * {@inheritdoc} */ - protected function get_table_name() + public function get_table_name() { return GROUPS_TABLE; } diff --git a/phpBB/phpbb/textreparser/plugins/pm_text.php b/phpBB/phpbb/textreparser/plugins/pm_text.php index f4d87525df..4d06a2878b 100644 --- a/phpBB/phpbb/textreparser/plugins/pm_text.php +++ b/phpBB/phpbb/textreparser/plugins/pm_text.php @@ -18,7 +18,7 @@ class pm_text extends \phpbb\textreparser\row_based_plugin /** * {@inheritdoc} */ - protected function get_columns() + public function get_columns() { return array( 'id' => 'msg_id', @@ -33,7 +33,7 @@ class pm_text extends \phpbb\textreparser\row_based_plugin /** * {@inheritdoc} */ - protected function get_table_name() + public function get_table_name() { return PRIVMSGS_TABLE; } 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; } diff --git a/phpBB/phpbb/textreparser/plugins/poll_title.php b/phpBB/phpbb/textreparser/plugins/poll_title.php index e794780eba..6665d68847 100644 --- a/phpBB/phpbb/textreparser/plugins/poll_title.php +++ b/phpBB/phpbb/textreparser/plugins/poll_title.php @@ -18,7 +18,7 @@ class poll_title extends \phpbb\textreparser\row_based_plugin /** * {@inheritdoc} */ - protected function get_columns() + public function get_columns() { return array( 'id' => 'topic_id', @@ -43,7 +43,7 @@ class poll_title extends \phpbb\textreparser\row_based_plugin /** * {@inheritdoc} */ - protected function get_table_name() + public function get_table_name() { return TOPICS_TABLE; } diff --git a/phpBB/phpbb/textreparser/plugins/post_text.php b/phpBB/phpbb/textreparser/plugins/post_text.php index 2b16518b03..4a07c98cea 100644 --- a/phpBB/phpbb/textreparser/plugins/post_text.php +++ b/phpBB/phpbb/textreparser/plugins/post_text.php @@ -18,7 +18,7 @@ class post_text extends \phpbb\textreparser\row_based_plugin /** * {@inheritdoc} */ - protected function get_columns() + public function get_columns() { return array( 'id' => 'post_id', @@ -33,7 +33,7 @@ class post_text extends \phpbb\textreparser\row_based_plugin /** * {@inheritdoc} */ - protected function get_table_name() + public function get_table_name() { return POSTS_TABLE; } diff --git a/phpBB/phpbb/textreparser/plugins/user_signature.php b/phpBB/phpbb/textreparser/plugins/user_signature.php index 7a66f39ab6..db82d4089b 100644 --- a/phpBB/phpbb/textreparser/plugins/user_signature.php +++ b/phpBB/phpbb/textreparser/plugins/user_signature.php @@ -50,7 +50,7 @@ class user_signature extends \phpbb\textreparser\row_based_plugin /** * {@inheritdoc} */ - protected function get_columns() + public function get_columns() { return array( 'id' => 'user_id', @@ -63,7 +63,7 @@ class user_signature extends \phpbb\textreparser\row_based_plugin /** * {@inheritdoc} */ - protected function get_table_name() + public function get_table_name() { return USERS_TABLE; } -- cgit v1.2.1 From a870f8f8603993a2d6a2443c8ad746212071f392 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Wed, 6 May 2015 21:32:39 +0200 Subject: [ticket/13803] Added user_signature tests PHPBB3-13803 --- .../phpbb/textreparser/plugins/user_signature.php | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'phpBB/phpbb/textreparser/plugins') diff --git a/phpBB/phpbb/textreparser/plugins/user_signature.php b/phpBB/phpbb/textreparser/plugins/user_signature.php index db82d4089b..f657a45d38 100644 --- a/phpBB/phpbb/textreparser/plugins/user_signature.php +++ b/phpBB/phpbb/textreparser/plugins/user_signature.php @@ -21,22 +21,16 @@ class user_signature extends \phpbb\textreparser\row_based_plugin */ protected $keyoptions; - /** - * Constructor - * - * Retrieves and saves the bit numbers used for user options - */ - public function __construct() - { - $class_vars = get_class_vars('phpbb\\user'); - $this->keyoptions = $class_vars['keyoptions']; - } - /** * {@inheritdoc} */ protected function add_missing_fields(array $row) { + if (!isset($this->keyoptions)) + { + $this->save_keyoptions(); + } + $options = $row['user_options']; $row += array( 'enable_bbcode' => phpbb_optionget($this->keyoptions['sig_bbcode'], $options), @@ -44,7 +38,7 @@ class user_signature extends \phpbb\textreparser\row_based_plugin 'enable_magic_url' => phpbb_optionget($this->keyoptions['sig_links'], $options), ); - return $row; + return parent::add_missing_fields($row); } /** @@ -67,4 +61,13 @@ class user_signature extends \phpbb\textreparser\row_based_plugin { return USERS_TABLE; } + + /** + * Save the keyoptions var from \phpbb\user + */ + protected function save_keyoptions() + { + $class_vars = get_class_vars('phpbb\\user'); + $this->keyoptions = $class_vars['keyoptions']; + } } -- 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') 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 54b18df084b845c058426b38e7ccfeb534d04ce0 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sun, 10 May 2015 01:54:54 +0200 Subject: [ticket/13803] Added contact_admin_info tests PHPBB3-13803 --- .../textreparser/plugins/admin_contact_info.php | 69 ---------------------- .../textreparser/plugins/contact_admin_info.php | 69 ++++++++++++++++++++++ 2 files changed, 69 insertions(+), 69 deletions(-) delete mode 100644 phpBB/phpbb/textreparser/plugins/admin_contact_info.php create mode 100644 phpBB/phpbb/textreparser/plugins/contact_admin_info.php (limited to 'phpBB/phpbb/textreparser/plugins') diff --git a/phpBB/phpbb/textreparser/plugins/admin_contact_info.php b/phpBB/phpbb/textreparser/plugins/admin_contact_info.php deleted file mode 100644 index e432ddea81..0000000000 --- a/phpBB/phpbb/textreparser/plugins/admin_contact_info.php +++ /dev/null @@ -1,69 +0,0 @@ - -* @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 admin_contact_info extends \phpbb\textreparser\base -{ - /** - * @var \phpbb\config\db_text - */ - protected $config_text; - - /** - * Constructor - * - * @param \phpbb\config\db_text $config_text - */ - public function __construct(\phpbb\config\db_text $config_text) - { - $this->config_text = $config_text; - } - - /** - * {@inheritdoc} - */ - public function get_max_id() - { - return 1; - } - - /** - * {@inheritdoc} - */ - protected function get_records($min_id, $max_id) - { - $values = $this->config_text->get_array(array( - 'contact_admin_info', - 'contact_admin_info_uid', - 'contact_admin_info_flags', - )); - - return array(array( - 'id' => 1, - 'text' => $values['contact_admin_info'], - 'bbcode_uid' => $values['contact_admin_info_uid'], - 'enable_bbcode' => $values['contact_admin_info_flags'] & OPTION_FLAG_BBCODE, - 'enable_magic_url' => $values['contact_admin_info_flags'] & OPTION_FLAG_LINKS, - 'enable_smilies' => $values['contact_admin_info_flags'] & OPTION_FLAG_SMILIES, - )); - } - - /** - * {@inheritdoc} - */ - protected function save_record(array $record) - { - $this->config_text->set('admin_contact_info', $record['text']); - } -} diff --git a/phpBB/phpbb/textreparser/plugins/contact_admin_info.php b/phpBB/phpbb/textreparser/plugins/contact_admin_info.php new file mode 100644 index 0000000000..d21ef89445 --- /dev/null +++ b/phpBB/phpbb/textreparser/plugins/contact_admin_info.php @@ -0,0 +1,69 @@ + +* @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 contact_admin_info extends \phpbb\textreparser\base +{ + /** + * @var \phpbb\config\db_text + */ + protected $config_text; + + /** + * Constructor + * + * @param \phpbb\config\db_text $config_text + */ + public function __construct(\phpbb\config\db_text $config_text) + { + $this->config_text = $config_text; + } + + /** + * {@inheritdoc} + */ + public function get_max_id() + { + return 1; + } + + /** + * {@inheritdoc} + */ + protected function get_records($min_id, $max_id) + { + $values = $this->config_text->get_array(array( + 'contact_admin_info', + 'contact_admin_info_uid', + 'contact_admin_info_flags', + )); + + return array(array( + 'id' => 1, + 'text' => $values['contact_admin_info'], + 'bbcode_uid' => $values['contact_admin_info_uid'], + 'enable_bbcode' => $values['contact_admin_info_flags'] & OPTION_FLAG_BBCODE, + 'enable_magic_url' => $values['contact_admin_info_flags'] & OPTION_FLAG_LINKS, + 'enable_smilies' => $values['contact_admin_info_flags'] & OPTION_FLAG_SMILIES, + )); + } + + /** + * {@inheritdoc} + */ + protected function save_record(array $record) + { + $this->config_text->set('contact_admin_info', $record['text']); + } +} -- 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/contact_admin_info.php | 2 +- phpBB/phpbb/textreparser/plugins/poll_option.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/textreparser/plugins') diff --git a/phpBB/phpbb/textreparser/plugins/contact_admin_info.php b/phpBB/phpbb/textreparser/plugins/contact_admin_info.php index d21ef89445..8910f2256b 100644 --- a/phpBB/phpbb/textreparser/plugins/contact_admin_info.php +++ b/phpBB/phpbb/textreparser/plugins/contact_admin_info.php @@ -41,7 +41,7 @@ class contact_admin_info extends \phpbb\textreparser\base /** * {@inheritdoc} */ - protected function get_records($min_id, $max_id) + protected function get_records_by_range($min_id, $max_id) { $values = $this->config_text->get_array(array( 'contact_admin_info', 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 1bff7d1175cb92f10d9fc872c2bae05b1f955174 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 19 May 2015 11:29:52 +0200 Subject: [ticket/13803] Fixed method name PHPBB3-13803 --- phpBB/phpbb/textreparser/plugins/poll_title.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/textreparser/plugins') diff --git a/phpBB/phpbb/textreparser/plugins/poll_title.php b/phpBB/phpbb/textreparser/plugins/poll_title.php index 6665d68847..b447004527 100644 --- a/phpBB/phpbb/textreparser/plugins/poll_title.php +++ b/phpBB/phpbb/textreparser/plugins/poll_title.php @@ -29,7 +29,7 @@ class poll_title extends \phpbb\textreparser\row_based_plugin /** * {@inheritdoc} */ - protected function get_records_query($min_id, $max_id) + protected function get_records_by_range_query($min_id, $max_id) { $sql = 'SELECT t.topic_id AS id, t.poll_title AS text, p.bbcode_uid FROM ' . 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/forum_description.php | 1 + phpBB/phpbb/textreparser/plugins/forum_rules.php | 1 + phpBB/phpbb/textreparser/plugins/group_description.php | 1 + phpBB/phpbb/textreparser/plugins/poll_option.php | 2 +- phpBB/phpbb/textreparser/plugins/poll_title.php | 2 +- 5 files changed, 5 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/textreparser/plugins') diff --git a/phpBB/phpbb/textreparser/plugins/forum_description.php b/phpBB/phpbb/textreparser/plugins/forum_description.php index 7798e4b20b..0302dc3082 100644 --- a/phpBB/phpbb/textreparser/plugins/forum_description.php +++ b/phpBB/phpbb/textreparser/plugins/forum_description.php @@ -24,6 +24,7 @@ class forum_description extends \phpbb\textreparser\row_based_plugin 'id' => 'forum_id', 'text' => 'forum_desc', 'bbcode_uid' => 'forum_desc_uid', + 'options' => 'forum_desc_options', ); } diff --git a/phpBB/phpbb/textreparser/plugins/forum_rules.php b/phpBB/phpbb/textreparser/plugins/forum_rules.php index 57c666a556..ce550225f2 100644 --- a/phpBB/phpbb/textreparser/plugins/forum_rules.php +++ b/phpBB/phpbb/textreparser/plugins/forum_rules.php @@ -24,6 +24,7 @@ class forum_rules extends \phpbb\textreparser\row_based_plugin 'id' => 'forum_id', 'text' => 'forum_rules', 'bbcode_uid' => 'forum_rules_uid', + 'options' => 'forum_rules_options', ); } diff --git a/phpBB/phpbb/textreparser/plugins/group_description.php b/phpBB/phpbb/textreparser/plugins/group_description.php index ddd0e1d1c5..3346ccf25e 100644 --- a/phpBB/phpbb/textreparser/plugins/group_description.php +++ b/phpBB/phpbb/textreparser/plugins/group_description.php @@ -24,6 +24,7 @@ class group_description extends \phpbb\textreparser\row_based_plugin 'id' => 'group_id', 'text' => 'group_desc', 'bbcode_uid' => 'group_desc_uid', + 'options' => 'group_desc_options', ); } 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 diff --git a/phpBB/phpbb/textreparser/plugins/poll_title.php b/phpBB/phpbb/textreparser/plugins/poll_title.php index b447004527..038ae0c366 100644 --- a/phpBB/phpbb/textreparser/plugins/poll_title.php +++ b/phpBB/phpbb/textreparser/plugins/poll_title.php @@ -31,7 +31,7 @@ class poll_title extends \phpbb\textreparser\row_based_plugin */ protected function get_records_by_range_query($min_id, $max_id) { - $sql = 'SELECT t.topic_id AS id, t.poll_title AS text, p.bbcode_uid + $sql = 'SELECT t.topic_id AS id, t.poll_title AS text, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.bbcode_uid FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p WHERE t.topic_id BETWEEN ' . $min_id . ' AND ' . $max_id .' AND t.poll_max_options > 0 -- cgit v1.2.1 From 2016550a32168ee5fcf11bfdd367ce48fbcf88b1 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Thu, 29 Oct 2015 01:48:52 +0100 Subject: [ticket/14264] Don't use constants as return values This will prevent BC breaking in the future if we decide to get rid of constants. PHPBB3-14264 --- phpBB/phpbb/textreparser/plugins/forum_description.php | 8 -------- phpBB/phpbb/textreparser/plugins/forum_rules.php | 8 -------- phpBB/phpbb/textreparser/plugins/group_description.php | 8 -------- phpBB/phpbb/textreparser/plugins/pm_text.php | 8 -------- phpBB/phpbb/textreparser/plugins/poll_title.php | 8 -------- phpBB/phpbb/textreparser/plugins/post_text.php | 8 -------- phpBB/phpbb/textreparser/plugins/user_signature.php | 8 -------- 7 files changed, 56 deletions(-) (limited to 'phpBB/phpbb/textreparser/plugins') diff --git a/phpBB/phpbb/textreparser/plugins/forum_description.php b/phpBB/phpbb/textreparser/plugins/forum_description.php index 0302dc3082..b0f5a42452 100644 --- a/phpBB/phpbb/textreparser/plugins/forum_description.php +++ b/phpBB/phpbb/textreparser/plugins/forum_description.php @@ -27,12 +27,4 @@ class forum_description extends \phpbb\textreparser\row_based_plugin 'options' => 'forum_desc_options', ); } - - /** - * {@inheritdoc} - */ - public function get_table_name() - { - return FORUMS_TABLE; - } } diff --git a/phpBB/phpbb/textreparser/plugins/forum_rules.php b/phpBB/phpbb/textreparser/plugins/forum_rules.php index ce550225f2..d131d00707 100644 --- a/phpBB/phpbb/textreparser/plugins/forum_rules.php +++ b/phpBB/phpbb/textreparser/plugins/forum_rules.php @@ -27,12 +27,4 @@ class forum_rules extends \phpbb\textreparser\row_based_plugin 'options' => 'forum_rules_options', ); } - - /** - * {@inheritdoc} - */ - public function get_table_name() - { - return FORUMS_TABLE; - } } diff --git a/phpBB/phpbb/textreparser/plugins/group_description.php b/phpBB/phpbb/textreparser/plugins/group_description.php index 3346ccf25e..2c45c00474 100644 --- a/phpBB/phpbb/textreparser/plugins/group_description.php +++ b/phpBB/phpbb/textreparser/plugins/group_description.php @@ -27,12 +27,4 @@ class group_description extends \phpbb\textreparser\row_based_plugin 'options' => 'group_desc_options', ); } - - /** - * {@inheritdoc} - */ - public function get_table_name() - { - return GROUPS_TABLE; - } } diff --git a/phpBB/phpbb/textreparser/plugins/pm_text.php b/phpBB/phpbb/textreparser/plugins/pm_text.php index 4d06a2878b..867da624ee 100644 --- a/phpBB/phpbb/textreparser/plugins/pm_text.php +++ b/phpBB/phpbb/textreparser/plugins/pm_text.php @@ -29,12 +29,4 @@ class pm_text extends \phpbb\textreparser\row_based_plugin 'bbcode_uid' => 'bbcode_uid', ); } - - /** - * {@inheritdoc} - */ - public function get_table_name() - { - return PRIVMSGS_TABLE; - } } diff --git a/phpBB/phpbb/textreparser/plugins/poll_title.php b/phpBB/phpbb/textreparser/plugins/poll_title.php index 038ae0c366..76d30655c9 100644 --- a/phpBB/phpbb/textreparser/plugins/poll_title.php +++ b/phpBB/phpbb/textreparser/plugins/poll_title.php @@ -39,12 +39,4 @@ class poll_title extends \phpbb\textreparser\row_based_plugin return $sql; } - - /** - * {@inheritdoc} - */ - public function get_table_name() - { - return TOPICS_TABLE; - } } diff --git a/phpBB/phpbb/textreparser/plugins/post_text.php b/phpBB/phpbb/textreparser/plugins/post_text.php index 4a07c98cea..1c98e86067 100644 --- a/phpBB/phpbb/textreparser/plugins/post_text.php +++ b/phpBB/phpbb/textreparser/plugins/post_text.php @@ -29,12 +29,4 @@ class post_text extends \phpbb\textreparser\row_based_plugin 'bbcode_uid' => 'bbcode_uid', ); } - - /** - * {@inheritdoc} - */ - public function get_table_name() - { - return POSTS_TABLE; - } } diff --git a/phpBB/phpbb/textreparser/plugins/user_signature.php b/phpBB/phpbb/textreparser/plugins/user_signature.php index f657a45d38..647d3a7b14 100644 --- a/phpBB/phpbb/textreparser/plugins/user_signature.php +++ b/phpBB/phpbb/textreparser/plugins/user_signature.php @@ -54,14 +54,6 @@ class user_signature extends \phpbb\textreparser\row_based_plugin ); } - /** - * {@inheritdoc} - */ - public function get_table_name() - { - return USERS_TABLE; - } - /** * Save the keyoptions var from \phpbb\user */ -- cgit v1.2.1