aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/posting.php
diff options
context:
space:
mode:
authorstevendegroote <stevendegroote@gmail.com>2019-09-17 23:15:54 +0200
committerstevendegroote <stevendegroote@gmail.com>2019-09-17 23:15:54 +0200
commitf8967fec78d826ea8d9ca34f65966ff8a7674b47 (patch)
treef9c5f408e7764ec6343e084e7fc6d62d07e3400f /phpBB/posting.php
parentce93b224107a65b43253c36812b636321eb55a78 (diff)
parent4db585a4cb2e5359074a82ef088574609155294b (diff)
downloadforums-f8967fec78d826ea8d9ca34f65966ff8a7674b47.tar
forums-f8967fec78d826ea8d9ca34f65966ff8a7674b47.tar.gz
forums-f8967fec78d826ea8d9ca34f65966ff8a7674b47.tar.bz2
forums-f8967fec78d826ea8d9ca34f65966ff8a7674b47.tar.xz
forums-f8967fec78d826ea8d9ca34f65966ff8a7674b47.zip
Merge branch '3.2.x' into ticket/16159
Diffstat (limited to 'phpBB/posting.php')
-rw-r--r--phpBB/posting.php137
1 files changed, 88 insertions, 49 deletions
diff --git a/phpBB/posting.php b/phpBB/posting.php
index 02bf1c1d07..5089448483 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -33,7 +33,6 @@ $post_id = $request->variable('p', 0);
$topic_id = $request->variable('t', 0);
$forum_id = $request->variable('f', 0);
$draft_id = $request->variable('d', 0);
-$lastclick = $request->variable('lastclick', 0);
$preview = (isset($_POST['preview'])) ? true : false;
$save = (isset($_POST['save'])) ? true : false;
@@ -68,7 +67,6 @@ $current_time = time();
* @var int topic_id ID of the topic
* @var int forum_id ID of the forum
* @var int draft_id ID of the draft
-* @var int lastclick Timestamp of when the form was last loaded
* @var bool submit Whether or not the form has been submitted
* @var bool preview Whether or not the post is being previewed
* @var bool save Whether or not a draft is being saved
@@ -85,13 +83,13 @@ $current_time = time();
* language keys.
* @since 3.1.0-a1
* @changed 3.1.2-RC1 Removed 'delete' var as it does not exist
+* @changed 3.2.4-RC1 Remove unused 'lastclick' var
*/
$vars = array(
'post_id',
'topic_id',
'forum_id',
'draft_id',
- 'lastclick',
'submit',
'preview',
'save',
@@ -224,6 +222,25 @@ if (!$post_data)
trigger_error(($mode == 'post' || $mode == 'bump' || $mode == 'reply') ? 'NO_TOPIC' : 'NO_POST');
}
+/**
+* This event allows you to bypass reply/quote test of an unapproved post.
+*
+* @event core.posting_modify_row_data
+* @var array post_data All post data from database
+* @var string mode What action to take if the form has been submitted
+* post|reply|quote|edit|delete|bump|smilies|popup
+* @var int topic_id ID of the topic
+* @var int forum_id ID of the forum
+* @since 3.2.8-RC1
+*/
+$vars = array(
+ 'post_data',
+ 'mode',
+ 'topic_id',
+ 'forum_id',
+);
+extract($phpbb_dispatcher->trigger_event('core.posting_modify_row_data', compact($vars)));
+
// Not able to reply to unapproved posts/topics
// TODO: add more descriptive language key
if ($auth->acl_get('m_approve', $forum_id) && ((($mode == 'reply' || $mode == 'bump') && $post_data['topic_visibility'] != ITEM_APPROVED) || ($mode == 'quote' && $post_data['post_visibility'] != ITEM_APPROVED)))
@@ -354,7 +371,6 @@ switch ($mode)
* @var int topic_id ID of the topic
* @var int forum_id ID of the forum
* @var int draft_id ID of the draft
-* @var int lastclick Timestamp of when the form was last loaded
* @var bool submit Whether or not the form has been submitted
* @var bool preview Whether or not the post is being previewed
* @var bool save Whether or not a draft is being saved
@@ -370,13 +386,13 @@ switch ($mode)
* @var array post_data All post data from database
* @since 3.1.3-RC1
* @changed 3.1.10-RC1 Added post_data
+* @changed 3.2.4-RC1 Remove unused 'lastclick' var
*/
$vars = array(
'post_id',
'topic_id',
'forum_id',
'draft_id',
- 'lastclick',
'submit',
'preview',
'save',
@@ -581,7 +597,7 @@ if ($mode == 'edit')
);
}
-$orig_poll_options_size = sizeof($post_data['poll_options']);
+$orig_poll_options_size = count($post_data['poll_options']);
$message_parser = new parse_message();
/* @var $plupload \phpbb\plupload\plupload */
@@ -600,6 +616,20 @@ if (isset($post_data['post_text']))
// Set some default variables
$uninit = array('post_attachment' => 0, 'poster_id' => $user->data['user_id'], 'enable_magic_url' => 0, 'topic_status' => 0, 'topic_type' => POST_NORMAL, 'post_subject' => '', 'topic_title' => '', 'post_time' => 0, 'post_edit_reason' => '', 'notify_set' => 0);
+/**
+* This event allows you to modify the default variables for post_data, and unset them in post_data if needed
+*
+* @event core.posting_modify_default_variables
+* @var array post_data Array with post data
+* @var array uninit Array with default vars to put into post_data, if they aren't there
+* @since 3.2.5-RC1
+*/
+$vars = array(
+ 'post_data',
+ 'uninit',
+);
+extract($phpbb_dispatcher->trigger_event('core.posting_modify_default_variables', compact($vars)));
+
foreach ($uninit as $var_name => $default_value)
{
if (!isset($post_data[$var_name]))
@@ -835,6 +865,7 @@ if ($load && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $post_
load_drafts($topic_id, $forum_id);
}
+/** @var \phpbb\textformatter\utils_interface $bbcode_utils */
$bbcode_utils = $phpbb_container->get('text_formatter.utils');
if ($submit || $preview || $refresh)
@@ -884,7 +915,7 @@ if ($submit || $preview || $refresh)
}
// Delete Poll
- if ($poll_delete && $mode == 'edit' && sizeof($post_data['poll_options']) &&
+ if ($poll_delete && $mode == 'edit' && count($post_data['poll_options']) &&
((!$post_data['poll_last_vote'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id)))
{
if ($submit && check_form_key('posting'))
@@ -1034,7 +1065,7 @@ if ($submit || $preview || $refresh)
// Parse message
if ($update_message)
{
- if (sizeof($message_parser->warn_msg))
+ if (count($message_parser->warn_msg))
{
$error[] = implode('<br />', $message_parser->warn_msg);
$message_parser->warn_msg = array();
@@ -1046,7 +1077,7 @@ if ($submit || $preview || $refresh)
}
// On a refresh we do not care about message parsing errors
- if (sizeof($message_parser->warn_msg) && $refresh && !$preview)
+ if (count($message_parser->warn_msg) && $refresh && !$preview)
{
$message_parser->warn_msg = array();
}
@@ -1268,7 +1299,7 @@ if ($submit || $preview || $refresh)
}
}
- if (sizeof($message_parser->warn_msg))
+ if (count($message_parser->warn_msg))
{
$error[] = implode('<br />', $message_parser->warn_msg);
}
@@ -1313,7 +1344,7 @@ if ($submit || $preview || $refresh)
extract($phpbb_dispatcher->trigger_event('core.posting_modify_submission_errors', compact($vars)));
// Store message, sync counters
- if (!sizeof($error) && $submit)
+ if (!count($error) && $submit)
{
if ($submit)
{
@@ -1510,7 +1541,7 @@ if ($submit || $preview || $refresh)
}
// Preview
-if (!sizeof($error) && $preview)
+if (!count($error) && $preview)
{
$post_data['post_time'] = ($mode == 'edit') ? $post_data['post_time'] : $current_time;
@@ -1552,7 +1583,7 @@ if (!sizeof($error) && $preview)
}
$template->assign_vars(array(
- 'S_HAS_POLL_OPTIONS' => (sizeof($post_data['poll_options'])),
+ 'S_HAS_POLL_OPTIONS' => (count($post_data['poll_options'])),
'S_IS_MULTI_CHOICE' => ($post_data['poll_max_options'] > 1) ? true : false,
'POLL_QUESTION' => $parse_poll->message,
@@ -1581,7 +1612,7 @@ if (!sizeof($error) && $preview)
}
// Attachment Preview
- if (sizeof($message_parser->attachment_data))
+ if (count($message_parser->attachment_data))
{
$template->assign_var('S_HAS_ATTACHMENTS', true);
@@ -1599,7 +1630,7 @@ if (!sizeof($error) && $preview)
unset($attachment_data);
}
- if (!sizeof($error))
+ if (!count($error))
{
$template->assign_vars(array(
'PREVIEW_SUBJECT' => $preview_subject,
@@ -1622,7 +1653,7 @@ if ($generate_quote && $config['max_quote_depth'] > 0)
}
// Decode text for message display
-$post_data['bbcode_uid'] = ($mode == 'quote' && !$preview && !$refresh && !sizeof($error)) ? $post_data['bbcode_uid'] : $message_parser->bbcode_uid;
+$post_data['bbcode_uid'] = ($mode == 'quote' && !$preview && !$refresh && !count($error)) ? $post_data['bbcode_uid'] : $message_parser->bbcode_uid;
$message_parser->decode_message($post_data['bbcode_uid']);
if ($generate_quote)
@@ -1630,47 +1661,56 @@ if ($generate_quote)
// Remove attachment bbcode tags from the quoted message to avoid mixing with the new post attachments if any
$message_parser->message = preg_replace('#\[attachment=([0-9]+)\](.*?)\[\/attachment\]#uis', '\\2', $message_parser->message);
- if ($config['allow_bbcode'])
- {
- $message_parser->message = $bbcode_utils->generate_quote(
- censor_text($message_parser->message),
- array(
- 'author' => $post_data['quote_username'],
- 'post_id' => $post_data['post_id'],
- 'time' => $post_data['post_time'],
- 'user_id' => $post_data['poster_id'],
- )
- );
- $message_parser->message .= "\n\n";
- }
- else
- {
- $offset = 0;
- $quote_string = "&gt; ";
- $message = censor_text(trim($message_parser->message));
- // see if we are nesting. It's easily tricked but should work for one level of nesting
- if (strpos($message, "&gt;") !== false)
- {
- $offset = 10;
- }
- $message = utf8_wordwrap($message, 75 + $offset, "\n");
+ $quote_attributes = array(
+ 'author' => $post_data['quote_username'],
+ 'post_id' => $post_data['post_id'],
+ 'time' => $post_data['post_time'],
+ 'user_id' => $post_data['poster_id'],
+ );
- $message = $quote_string . $message;
- $message = str_replace("\n", "\n" . $quote_string, $message);
- $message_parser->message = $post_data['quote_username'] . " " . $user->lang['WROTE'] . ":\n" . $message . "\n";
- }
+ /**
+ * This event allows you to modify the quote attributes of the post being quoted
+ *
+ * @event core.posting_modify_quote_attributes
+ * @var array quote_attributes Array with quote attributes
+ * @var array post_data Array with post data
+ * @since 3.2.6-RC1
+ */
+ $vars = array(
+ 'quote_attributes',
+ 'post_data',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.posting_modify_quote_attributes', compact($vars)));
+
+ /** @var \phpbb\language\language $language */
+ $language = $phpbb_container->get('language');
+ phpbb_format_quote($language, $message_parser, $bbcode_utils, $bbcode_status, $quote_attributes);
}
if (($mode == 'reply' || $mode == 'quote') && !$submit && !$preview && !$refresh)
{
$post_data['post_subject'] = ((strpos($post_data['post_subject'], 'Re: ') !== 0) ? 'Re: ' : '') . censor_text($post_data['post_subject']);
+
+ $post_subject = $post_data['post_subject'];
+
+ /**
+ * This event allows you to modify the post subject of the post being quoted
+ *
+ * @event core.posting_modify_post_subject
+ * @var string post_subject String with the post subject already censored.
+ * @since 3.2.8-RC1
+ */
+ $vars = array('post_subject');
+ extract($phpbb_dispatcher->trigger_event('core.posting_modify_post_subject', compact($vars)));
+
+ $post_data['post_subject'] = $post_subject;
}
$attachment_data = $message_parser->attachment_data;
$filename_data = $message_parser->filename_data;
$post_data['post_text'] = $message_parser->message;
-if (sizeof($post_data['poll_options']) || (isset($post_data['poll_title']) && !$bbcode_utils->is_empty($post_data['poll_title'])))
+if (count($post_data['poll_options']) || (isset($post_data['poll_title']) && !$bbcode_utils->is_empty($post_data['poll_title'])))
{
$message_parser->message = $post_data['poll_title'];
$message_parser->bbcode_uid = $post_data['bbcode_uid'];
@@ -1762,7 +1802,6 @@ if ($config['enable_post_confirm'] && !$user->data['is_registered'] && (isset($c
}
$s_hidden_fields = ($mode == 'reply' || $mode == 'quote') ? '<input type="hidden" name="topic_cur_post_id" value="' . $post_data['topic_last_post_id'] . '" />' : '';
-$s_hidden_fields .= '<input type="hidden" name="lastclick" value="' . $current_time . '" />';
$s_hidden_fields .= ($draft_id || isset($_REQUEST['draft_loaded'])) ? '<input type="hidden" name="draft_loaded" value="' . $request->variable('draft_loaded', $draft_id) . '" />' : '';
if ($mode == 'edit')
@@ -1795,7 +1834,7 @@ $page_data = array(
'FORUM_NAME' => $post_data['forum_name'],
'FORUM_DESC' => ($post_data['forum_desc']) ? generate_text_for_display($post_data['forum_desc'], $post_data['forum_desc_uid'], $post_data['forum_desc_bitfield'], $post_data['forum_desc_options']) : '',
'TOPIC_TITLE' => censor_text($post_data['topic_title']),
- 'MODERATORS' => (sizeof($moderators)) ? implode($user->lang['COMMA_SEPARATOR'], $moderators[$forum_id]) : '',
+ 'MODERATORS' => (count($moderators)) ? implode($user->lang['COMMA_SEPARATOR'], $moderators[$forum_id]) : '',
'USERNAME' => ((!$preview && $mode != 'quote') || $preview) ? $post_data['username'] : '',
'SUBJECT' => $post_data['post_subject'],
'MESSAGE' => $post_data['post_text'],
@@ -1807,7 +1846,7 @@ $page_data = array(
'MAX_FONT_SIZE' => (int) $config['max_post_font_size'],
'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['POST']),
'POST_DATE' => ($post_data['post_time']) ? $user->format_date($post_data['post_time']) : '',
- 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
+ 'ERROR' => (count($error)) ? implode('<br />', $error) : '',
'TOPIC_TIME_LIMIT' => (int) $post_data['topic_time_limit'],
'EDIT_REASON' => $request->variable('edit_reason', '', true),
'SHOW_PANEL' => $request->variable('show_panel', ''),
@@ -1867,7 +1906,7 @@ if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_
$page_data = array_merge($page_data, array(
'S_SHOW_POLL_BOX' => true,
'S_POLL_VOTE_CHANGE' => ($auth->acl_get('f_votechg', $forum_id) && $auth->acl_get('f_vote', $forum_id)),
- 'S_POLL_DELETE' => ($mode == 'edit' && sizeof($post_data['poll_options']) && ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))),
+ 'S_POLL_DELETE' => ($mode == 'edit' && count($post_data['poll_options']) && ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))),
'S_POLL_DELETE_CHECKED' => (!empty($poll_delete)) ? true : false,
'L_POLL_OPTIONS_EXPLAIN' => $user->lang('POLL_OPTIONS_' . (($mode == 'edit') ? 'EDIT_' : '') . 'EXPLAIN', (int) $config['max_poll_options']),