mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-01 14:30:32 +02:00
[ticket/13803] Added tests, fixed param order in generate_text_for_storage()
PHPBB3-13803
This commit is contained in:
@@ -63,8 +63,8 @@ abstract class base implements reparser_interface
|
||||
$bitfield,
|
||||
$flags,
|
||||
$unparsed['enable_bbcode'],
|
||||
$unparsed['enable_smilies'],
|
||||
$unparsed['enable_magic_url']
|
||||
$unparsed['enable_magic_url'],
|
||||
$unparsed['enable_smilies']
|
||||
);
|
||||
|
||||
// Save the new text if it has changed
|
||||
|
@@ -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',
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -44,6 +44,29 @@ abstract class row_based_plugin extends base
|
||||
*/
|
||||
abstract protected function get_table_name();
|
||||
|
||||
/**
|
||||
* Add fields to given row, if applicable
|
||||
*
|
||||
* The enable_* fields are not always saved to the database. Sometimes we need to guess their
|
||||
* original value based on the text content or possibly other fields
|
||||
*
|
||||
* @param array $row Original row
|
||||
* @return array Complete row
|
||||
*/
|
||||
protected function add_missing_fields(array $row)
|
||||
{
|
||||
if (!isset($row['enable_bbcode'], $row['enable_smilies'], $row['enable_magic_url']))
|
||||
{
|
||||
$row += array(
|
||||
'enable_bbcode' => !empty($row['bbcode_uid']),
|
||||
'enable_smilies' => (strpos($row['text'], '<!-- s') !== false),
|
||||
'enable_magic_url' => (strpos($row['text'], '<!-- m -->') !== false),
|
||||
);
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -67,16 +90,7 @@ abstract class row_based_plugin extends base
|
||||
$result = $this->db->sql_query($this->get_records_query($min_id, $max_id));
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
if (!isset($row['enable_bbcode'], $row['enable_smilies'], $row['enable_magic_url']))
|
||||
{
|
||||
// Those fields are not saved to the database, we need to guess their original value
|
||||
$row += array(
|
||||
'enable_bbcode' => !empty($row['bbcode_uid']),
|
||||
'enable_smilies' => (strpos($row['text'], '<!-- s') !== false),
|
||||
'enable_magic_url' => (strpos($row['text'], '<!-- m -->') !== false)
|
||||
);
|
||||
}
|
||||
$records[] = $row;
|
||||
$records[] = $this->add_missing_fields($row);
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
|
Reference in New Issue
Block a user