aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/textreparser
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb/textreparser')
-rw-r--r--phpBB/phpbb/textreparser/base.php52
-rw-r--r--phpBB/phpbb/textreparser/plugins/forum_description.php1
-rw-r--r--phpBB/phpbb/textreparser/plugins/forum_rules.php1
-rw-r--r--phpBB/phpbb/textreparser/plugins/group_description.php1
-rw-r--r--phpBB/phpbb/textreparser/plugins/poll_option.php2
-rw-r--r--phpBB/phpbb/textreparser/plugins/poll_title.php2
6 files changed, 47 insertions, 12 deletions
diff --git a/phpBB/phpbb/textreparser/base.php b/phpBB/phpbb/textreparser/base.php
index 87a4268d0d..3e5ee248a1 100644
--- a/phpBB/phpbb/textreparser/base.php
+++ b/phpBB/phpbb/textreparser/base.php
@@ -16,6 +16,11 @@ namespace phpbb\textreparser;
abstract class base implements reparser_interface
{
/**
+ * @var bool Whether to save changes to the database
+ */
+ protected $save_changes = true;
+
+ /**
* {@inheritdoc}
*/
abstract public function get_max_id();
@@ -47,11 +52,22 @@ abstract class base implements reparser_interface
{
if (!isset($record['enable_bbcode'], $record['enable_smilies'], $record['enable_magic_url']))
{
- $record += array(
- 'enable_bbcode' => $this->guess_bbcodes($record),
- 'enable_smilies' => $this->guess_smilies($record),
- 'enable_magic_url' => $this->guess_magic_url($record),
- );
+ if (isset($record['options']))
+ {
+ $record += array(
+ 'enable_bbcode' => (bool) ($record['options'] & OPTION_FLAG_BBCODE),
+ 'enable_smilies' => (bool) ($record['options'] & OPTION_FLAG_SMILIES),
+ 'enable_magic_url' => (bool) ($record['options'] & OPTION_FLAG_LINKS),
+ );
+ }
+ else
+ {
+ $record += array(
+ 'enable_bbcode' => $this->guess_bbcodes($record),
+ 'enable_smilies' => $this->guess_smilies($record),
+ 'enable_magic_url' => $this->guess_magic_url($record),
+ );
+ }
}
// Those BBCodes are disabled based on context and user permissions and that value is never
@@ -74,6 +90,22 @@ abstract class base implements reparser_interface
}
/**
+ * Disable saving changes to the database
+ */
+ public function disable_save()
+ {
+ $this->save_changes = false;
+ }
+
+ /**
+ * Enable saving changes to the database
+ */
+ public function enable_save()
+ {
+ $this->save_changes = true;
+ }
+
+ /**
* Guess whether given BBCode is in use in given record
*
* @param array $record
@@ -92,7 +124,7 @@ abstract class base implements reparser_interface
}
}
- if (substr($record['text'], 0, 2) == '<r')
+ if (substr($record['text'], 0, 2) === '<r')
{
// Look for the closing tag inside of a e element, in an element of the same name, e.g.
// <e>[/url]</e></URL>
@@ -124,7 +156,7 @@ abstract class base implements reparser_interface
}
}
- if (substr($record['text'], 0, 2) == '<r')
+ if (substr($record['text'], 0, 2) === '<r')
{
// Look for a closing tag inside of an e element
return (bool) preg_match('(<e>\\[/\\w+\\]</e>)', $match);
@@ -170,7 +202,7 @@ abstract class base implements reparser_interface
/**
* Reparse given record
*
- * @param array $record Associative array containing the record's data
+ * @param array $record Associative array containing the record's data
*/
protected function reparse_record(array $record)
{
@@ -201,8 +233,8 @@ abstract class base implements reparser_interface
$unparsed['enable_url_bbcode']
);
- // Save the new text if it has changed
- if ($text !== $record['text'])
+ // Save the new text if it has changed and it's not a dry run
+ if ($text !== $record['text'] && $this->save_changes)
{
$record['text'] = $text;
$this->save_record($record);
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