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/textreparser/plugins/user_signature.php | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 phpBB/phpbb/textreparser/plugins/user_signature.php (limited to 'phpBB/phpbb/textreparser/plugins/user_signature.php') 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/user_signature.php') 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/user_signature.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/textreparser/plugins/user_signature.php') 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/user_signature.php') 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 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/user_signature.php | 8 -------- 1 file changed, 8 deletions(-) (limited to 'phpBB/phpbb/textreparser/plugins/user_signature.php') 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