aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/posting.php
diff options
context:
space:
mode:
authorMaat <maat-pub@mageia.biz>2020-05-08 21:52:11 +0200
committerMaat <maat-pub@mageia.biz>2020-05-08 21:52:11 +0200
commit8ea437e30605e0f66b5220bf904a61d7c1d11ddd (patch)
treee0db2bb4a012d5b06a633160b19f62f4868ecd28 /phpBB/posting.php
parent36bc1870f21fac04736a1049c1d5b8e127d729f4 (diff)
parent2fdd46b36431ae0f58bb2e78e42553168db9a0ff (diff)
downloadforums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.gz
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.bz2
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.xz
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.zip
Merge remote-tracking branch 'upstream/prep-release-3.2.9'
Diffstat (limited to 'phpBB/posting.php')
-rw-r--r--phpBB/posting.php302
1 files changed, 202 insertions, 100 deletions
diff --git a/phpBB/posting.php b/phpBB/posting.php
index 35c1f84fa3..57b52320a3 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -29,11 +29,10 @@ $auth->acl($user->data);
// Grab only parameters needed here
-$post_id = request_var('p', 0);
-$topic_id = request_var('t', 0);
-$forum_id = request_var('f', 0);
-$draft_id = request_var('d', 0);
-$lastclick = request_var('lastclick', 0);
+$post_id = $request->variable('p', 0);
+$topic_id = $request->variable('t', 0);
+$forum_id = $request->variable('f', 0);
+$draft_id = $request->variable('d', 0);
$preview = (isset($_POST['preview'])) ? true : false;
$save = (isset($_POST['save'])) ? true : false;
@@ -43,7 +42,7 @@ $cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false;
$refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) || $save || $load || $preview);
$submit = $request->is_set_post('post') && !$refresh && !$preview;
-$mode = request_var('mode', '');
+$mode = $request->variable('mode', '');
// If the user is not allowed to delete the post, we try to soft delete it, so we overwrite the mode here.
if ($mode == 'delete' && (($confirm && !$request->is_set_post('delete_permanent')) || !$auth->acl_gets('f_delete', 'm_delete', $forum_id)))
@@ -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',
@@ -104,7 +102,7 @@ $vars = array(
extract($phpbb_dispatcher->trigger_event('core.modify_posting_parameters', compact($vars)));
// Was cancel pressed? If so then redirect to the appropriate page
-if ($cancel || ($current_time - $lastclick < 2 && $submit))
+if ($cancel)
{
$f = ($forum_id) ? 'f=' . $forum_id . '&amp;' : '';
$redirect = ($post_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $f . 'p=' . $post_id) . '#p' . $post_id : (($topic_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $f . 't=' . $topic_id) : (($forum_id) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) : append_sid("{$phpbb_root_path}index.$phpEx")));
@@ -116,6 +114,7 @@ if (in_array($mode, array('post', 'reply', 'quote', 'edit', 'delete')) && !$foru
trigger_error('NO_FORUM');
}
+/* @var $phpbb_content_visibility \phpbb\content_visibility */
$phpbb_content_visibility = $phpbb_container->get('content.visibility');
// We need to know some basic information in all cases before we do anything.
@@ -223,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)))
@@ -238,12 +256,6 @@ if ($mode == 'popup')
$user->setup(array('posting', 'mcp', 'viewtopic'), $post_data['forum_style']);
-if ($config['enable_post_confirm'] && !$user->data['is_registered'])
-{
- $captcha = $phpbb_container->get('captcha.factory')->get_instance($config['captcha_plugin']);
- $captcha->init(CONFIRM_POST);
-}
-
// Use post_row values in favor of submitted ones...
$forum_id = (!empty($post_data['forum_id'])) ? (int) $post_data['forum_id'] : (int) $forum_id;
$topic_id = (!empty($post_data['topic_id'])) ? (int) $post_data['topic_id'] : (int) $topic_id;
@@ -353,7 +365,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
@@ -369,13 +380,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',
@@ -410,6 +421,12 @@ if (!$is_authed || !empty($error))
login_box('', $message);
}
+if ($config['enable_post_confirm'] && !$user->data['is_registered'])
+{
+ $captcha = $phpbb_container->get('captcha.factory')->get_instance($config['captcha_plugin']);
+ $captcha->init(CONFIRM_POST);
+}
+
// Is the user able to post within this forum?
if ($post_data['forum_type'] != FORUM_POST && in_array($mode, array('post', 'bump', 'quote', 'reply')))
{
@@ -487,7 +504,7 @@ if ($mode == 'delete' || $mode == 'soft_delete')
if ($mode == 'bump')
{
if ($bump_time = bump_topic_allowed($forum_id, $post_data['topic_bumped'], $post_data['topic_last_post_time'], $post_data['topic_poster'], $post_data['topic_last_poster_id'])
- && check_link_hash(request_var('hash', ''), "topic_{$post_data['topic_id']}"))
+ && check_link_hash($request->variable('hash', ''), "topic_{$post_data['topic_id']}"))
{
$meta_url = phpbb_bump_topic($forum_id, $topic_id, $post_data, $current_time);
meta_refresh(3, $meta_url);
@@ -546,6 +563,27 @@ if ($post_data['poll_start'])
$db->sql_freeresult($result);
}
+/**
+* This event allows you to modify the post data before parsing
+*
+* @event core.posting_modify_post_data
+* @var int forum_id ID of the forum
+* @var string mode What action to take if the form has been submitted
+* post|reply|quote|edit|delete|bump|smilies|popup
+* @var array post_data Array with post data
+* @var int post_id ID of the post
+* @var int topic_id ID of the topic
+* @since 3.2.2-RC1
+*/
+$vars = array(
+ 'forum_id',
+ 'mode',
+ 'post_data',
+ 'post_id',
+ 'topic_id',
+);
+extract($phpbb_dispatcher->trigger_event('core.posting_modify_post_data', compact($vars)));
+
if ($mode == 'edit')
{
$original_poll_data = array(
@@ -559,13 +597,15 @@ 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 */
$plupload = $phpbb_container->get('plupload');
+
+/* @var $mimetype_guesser \phpbb\mimetype\guesser */
$mimetype_guesser = $phpbb_container->get('mimetype.guesser');
$message_parser->set_plupload($plupload);
-$message_parser->set_mimetype_guesser($mimetype_guesser);
if (isset($post_data['post_text']))
{
@@ -576,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]))
@@ -678,21 +732,24 @@ $quote_status = true;
// Save Draft
if ($save && $user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote'))
{
- $subject = utf8_normalize_nfc(request_var('subject', '', true));
+ $subject = $request->variable('subject', '', true);
$subject = (!$subject && $mode != 'post') ? $post_data['topic_title'] : $subject;
- $message = utf8_normalize_nfc(request_var('message', '', true));
+ $message = $request->variable('message', '', true);
if ($subject && $message)
{
if (confirm_box(true))
{
+ $message_parser->message = $message;
+ $message_parser->parse($post_data['enable_bbcode'], ($config['allow_post_links']) ? $post_data['enable_urls'] : false, $post_data['enable_smilies'], $img_status, $flash_status, $quote_status, $config['allow_post_links']);
+
$sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
'user_id' => (int) $user->data['user_id'],
'topic_id' => (int) $topic_id,
'forum_id' => (int) $forum_id,
'save_time' => (int) $current_time,
'draft_subject' => (string) $subject,
- 'draft_message' => (string) $message)
+ 'draft_message' => (string) $message_parser->message)
);
$db->sql_query($sql);
@@ -750,11 +807,11 @@ if ($save && $user->data['is_registered'] && $auth->acl_get('u_savedrafts') && (
if (is_bool($default))
{
// Use the string representation
- $hidden_fields[$name] = request_var($name, '');
+ $hidden_fields[$name] = $request->variable($name, '');
}
else
{
- $hidden_fields[$name] = request_var($name, $default);
+ $hidden_fields[$name] = $request->variable($name, $default);
}
}
@@ -808,23 +865,25 @@ 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)
{
- $post_data['topic_cur_post_id'] = request_var('topic_cur_post_id', 0);
- $post_data['post_subject'] = utf8_normalize_nfc(request_var('subject', '', true));
- $message_parser->message = utf8_normalize_nfc(request_var('message', '', true));
+ $post_data['topic_cur_post_id'] = $request->variable('topic_cur_post_id', 0);
+ $post_data['post_subject'] = $request->variable('subject', '', true);
+ $message_parser->message = $request->variable('message', '', true);
- $post_data['username'] = utf8_normalize_nfc(request_var('username', $post_data['username'], true));
- $post_data['post_edit_reason'] = ($request->variable('edit_reason', false, false, \phpbb\request\request_interface::POST) && $mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? utf8_normalize_nfc(request_var('edit_reason', '', true)) : '';
+ $post_data['username'] = $request->variable('username', $post_data['username'], true);
+ $post_data['post_edit_reason'] = ($request->variable('edit_reason', false, false, \phpbb\request\request_interface::POST) && $mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? $request->variable('edit_reason', '', true) : '';
$post_data['orig_topic_type'] = $post_data['topic_type'];
- $post_data['topic_type'] = request_var('topic_type', (($mode != 'post') ? (int) $post_data['topic_type'] : POST_NORMAL));
- $post_data['topic_time_limit'] = request_var('topic_time_limit', (($mode != 'post') ? (int) $post_data['topic_time_limit'] : 0));
+ $post_data['topic_type'] = $request->variable('topic_type', (($mode != 'post') ? (int) $post_data['topic_type'] : POST_NORMAL));
+ $post_data['topic_time_limit'] = $request->variable('topic_time_limit', (($mode != 'post') ? (int) $post_data['topic_time_limit'] : 0));
if ($post_data['enable_icons'] && $auth->acl_get('f_icons', $forum_id))
{
- $post_data['icon_id'] = request_var('icon', (int) $post_data['icon_id']);
+ $post_data['icon_id'] = $request->variable('icon', (int) $post_data['icon_id']);
}
$post_data['enable_bbcode'] = (!$bbcode_status || isset($_POST['disable_bbcode'])) ? false : true;
@@ -856,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'))
@@ -889,10 +948,10 @@ if ($submit || $preview || $refresh)
}
else
{
- $post_data['poll_title'] = utf8_normalize_nfc(request_var('poll_title', '', true));
- $post_data['poll_length'] = request_var('poll_length', 0);
- $post_data['poll_option_text'] = utf8_normalize_nfc(request_var('poll_option_text', '', true));
- $post_data['poll_max_options'] = request_var('poll_max_options', 1);
+ $post_data['poll_title'] = $request->variable('poll_title', '', true);
+ $post_data['poll_length'] = $request->variable('poll_length', 0);
+ $post_data['poll_option_text'] = $request->variable('poll_option_text', '', true);
+ $post_data['poll_max_options'] = $request->variable('poll_max_options', 1);
$post_data['poll_vote_change'] = ($auth->acl_get('f_votechg', $forum_id) && $auth->acl_get('f_vote', $forum_id) && isset($_POST['poll_vote_change'])) ? 1 : 0;
}
@@ -915,7 +974,10 @@ if ($submit || $preview || $refresh)
}
// Parse Attachments - before checksum is calculated
- $message_parser->parse_attachments('fileupload', $mode, $forum_id, $submit, $preview, $refresh);
+ if ($message_parser->check_attachment_form_token($language, $request, 'posting'))
+ {
+ $message_parser->parse_attachments('fileupload', $mode, $forum_id, $submit, $preview, $refresh);
+ }
/**
* This event allows you to modify message text before parsing
@@ -964,8 +1026,8 @@ if ($submit || $preview || $refresh)
// Notify and show user the changed post
if ($mode == 'edit' && $post_data['forum_flags'] & FORUM_FLAG_POST_REVIEW)
{
- $edit_post_message_checksum = request_var('edit_post_message_checksum', '');
- $edit_post_subject_checksum = request_var('edit_post_subject_checksum', '');
+ $edit_post_message_checksum = $request->variable('edit_post_message_checksum', '');
+ $edit_post_subject_checksum = $request->variable('edit_post_subject_checksum', '');
// $post_data['post_checksum'] is the checksum of the post submitted in the meantime
// $message_md5 is the checksum of the post we're about to submit
@@ -1006,7 +1068,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();
@@ -1018,7 +1080,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();
}
@@ -1083,9 +1145,9 @@ if ($submit || $preview || $refresh)
if ($config['enable_post_confirm'] && !$user->data['is_registered'] && in_array($mode, array('quote', 'post', 'reply')))
{
$captcha_data = array(
- 'message' => utf8_normalize_nfc(request_var('message', '', true)),
- 'subject' => utf8_normalize_nfc(request_var('subject', '', true)),
- 'username' => utf8_normalize_nfc(request_var('username', '', true)),
+ 'message' => $request->variable('message', '', true),
+ 'subject' => $request->variable('subject', '', true),
+ 'username' => $request->variable('username', '', true),
);
$vc_response = $captcha->validate($captcha_data);
if ($vc_response)
@@ -1119,12 +1181,27 @@ if ($submit || $preview || $refresh)
$error[] = $user->lang['EMPTY_SUBJECT'];
}
- // Check for out-of-bounds characters that are currently
- // not supported by utf8_bin in MySQL
- if (preg_match_all('/[\x{10000}-\x{10FFFF}]/u', $post_data['post_subject'], $matches))
+ /**
+ * Replace Emojis and other 4bit UTF-8 chars not allowed by MySQL to UCR/NCR.
+ * Using their Numeric Character Reference's Hexadecimal notation.
+ * Check the permissions for posting Emojis first.
+ */
+ if ($auth->acl_get('u_emoji'))
{
- $character_list = implode('<br />', $matches[0]);
- $error[] = $user->lang('UNSUPPORTED_CHARACTERS_SUBJECT', $character_list);
+ $post_data['post_subject'] = utf8_encode_ucr($post_data['post_subject']);
+ }
+ else
+ {
+ /**
+ * Check for out-of-bounds characters that are currently
+ * not supported by utf8_bin in MySQL
+ */
+ if (preg_match_all('/[\x{10000}-\x{10FFFF}]/u', $post_data['post_subject'], $matches))
+ {
+ $character_list = implode('<br>', $matches[0]);
+
+ $error[] = $user->lang('UNSUPPORTED_CHARACTERS_SUBJECT', $character_list);
+ }
}
$post_data['poll_last_vote'] = (isset($post_data['poll_last_vote'])) ? $post_data['poll_last_vote'] : 0;
@@ -1176,10 +1253,15 @@ if ($submit || $preview || $refresh)
$post_data['poll_title'] = '';
$post_data['poll_start'] = $post_data['poll_length'] = $post_data['poll_max_options'] = $post_data['poll_last_vote'] = $post_data['poll_vote_change'] = 0;
}
- else if (!$auth->acl_get('f_poll', $forum_id) && ($mode == 'edit') && ($post_id == $post_data['topic_first_post_id']) && ($original_poll_data['poll_title'] != ''))
+ else if (!$auth->acl_get('f_poll', $forum_id) && ($mode == 'edit') && ($post_id == $post_data['topic_first_post_id']) && !$bbcode_utils->is_empty($original_poll_data['poll_title']))
{
// We have a poll but the editing user is not permitted to create/edit it.
// So we just keep the original poll-data.
+ // Decode the poll title and options text fisrt.
+ $original_poll_data['poll_title'] = $bbcode_utils->unparse($original_poll_data['poll_title']);
+ $original_poll_data['poll_option_text'] = $bbcode_utils->unparse($original_poll_data['poll_option_text']);
+ $original_poll_data['poll_options'] = explode("\n", $original_poll_data['poll_option_text']);
+
$poll = array_merge($original_poll_data, array(
'enable_bbcode' => $post_data['enable_bbcode'],
'enable_urls' => $post_data['enable_urls'],
@@ -1203,6 +1285,9 @@ if ($submit || $preview || $refresh)
switch ($post_data['topic_type'])
{
case POST_GLOBAL:
+ $auth_option = 'f_announce_global';
+ break;
+
case POST_ANNOUNCE:
$auth_option = 'f_announce';
break;
@@ -1232,7 +1317,7 @@ if ($submit || $preview || $refresh)
}
}
- if (sizeof($message_parser->warn_msg))
+ if (count($message_parser->warn_msg))
{
$error[] = implode('<br />', $message_parser->warn_msg);
}
@@ -1254,7 +1339,6 @@ if ($submit || $preview || $refresh)
* @var array poll Array with poll data from post (must be used instead of the post_data equivalent)
* @var string mode What action to take if the form is submitted
* post|reply|quote|edit|delete|bump|smilies|popup
- * @var string page_title Title of the mode page
* @var int post_id ID of the post
* @var int topic_id ID of the topic
* @var int forum_id ID of the forum
@@ -1263,12 +1347,12 @@ if ($submit || $preview || $refresh)
* NOTE: Should be actual language strings, NOT language keys.
* @since 3.1.0-RC5
* @changed 3.1.5-RC1 Added poll array to the event
+ * @changed 3.2.0-a1 Removed undefined page_title
*/
$vars = array(
'post_data',
'poll',
'mode',
- 'page_title',
'post_id',
'topic_id',
'forum_id',
@@ -1278,7 +1362,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)
{
@@ -1305,7 +1389,11 @@ if ($submit || $preview || $refresh)
$user_lock = ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $post_data['topic_poster']) ? 'USER_' : '';
- add_log('mod', $forum_id, $topic_id, 'LOG_' . $user_lock . (($change_topic_status == ITEM_LOCKED) ? 'LOCK' : 'UNLOCK'), $post_data['topic_title']);
+ $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_' . $user_lock . (($change_topic_status == ITEM_LOCKED) ? 'LOCK' : 'UNLOCK'), false, array(
+ 'forum_id' => $forum_id,
+ 'topic_id' => $topic_id,
+ $post_data['topic_title']
+ ));
}
// Lock/Unlock Post Edit
@@ -1377,7 +1465,6 @@ if ($submit || $preview || $refresh)
* @var array data Array with post data going to be stored in the database
* @var string mode What action to take if the form is submitted
* post|reply|quote|edit|delete
- * @var string page_title Title of the mode page
* @var int post_id ID of the post
* @var int topic_id ID of the topic
* @var int forum_id ID of the forum
@@ -1387,13 +1474,13 @@ if ($submit || $preview || $refresh)
* NOTE: Should be actual language strings, NOT language keys.
* @since 3.1.0-RC5
* @changed 3.1.6-RC1 remove submit and error from event Submit and Error are checked previously prior to running event
+ * @change 3.2.0-a1 Removed undefined page_title
*/
$vars = array(
'post_data',
'poll',
'data',
'mode',
- 'page_title',
'post_id',
'topic_id',
'forum_id',
@@ -1415,7 +1502,6 @@ if ($submit || $preview || $refresh)
* @var array data Array with post data going to be stored in the database
* @var string mode What action to take if the form is submitted
* post|reply|quote|edit|delete
- * @var string page_title Title of the mode page
* @var int post_id ID of the post
* @var int topic_id ID of the topic
* @var int forum_id ID of the forum
@@ -1426,13 +1512,13 @@ if ($submit || $preview || $refresh)
* NOTE: Should be actual language strings, NOT language keys.
* @since 3.1.0-RC5
* @changed 3.1.6-RC1 remove submit and error from event Submit and Error are checked previously prior to running event
+ * @change 3.2.0-a1 Removed undefined page_title
*/
$vars = array(
'post_data',
'poll',
'data',
'mode',
- 'page_title',
'post_id',
'topic_id',
'forum_id',
@@ -1473,7 +1559,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;
@@ -1486,14 +1572,11 @@ if (!sizeof($error) && $preview)
// Signature
if ($post_data['enable_sig'] && $config['allow_sig'] && $preview_signature && $auth->acl_get('f_sigs', $forum_id))
{
- $parse_sig = new parse_message($preview_signature);
- $parse_sig->bbcode_uid = $preview_signature_uid;
- $parse_sig->bbcode_bitfield = $preview_signature_bitfield;
-
- // Not sure about parameters for bbcode/smilies/urls... in signatures
- $parse_sig->format_display($config['allow_sig_bbcode'], $config['allow_sig_links'], $config['allow_sig_smilies']);
- $preview_signature = $parse_sig->message;
- unset($parse_sig);
+ $flags = ($config['allow_sig_bbcode']) ? OPTION_FLAG_BBCODE : 0;
+ $flags |= ($config['allow_sig_links']) ? OPTION_FLAG_LINKS : 0;
+ $flags |= ($config['allow_sig_smilies']) ? OPTION_FLAG_SMILIES : 0;
+
+ $preview_signature = generate_text_for_display($preview_signature, $preview_signature_uid, $preview_signature_bitfield, $flags, false);
}
else
{
@@ -1518,7 +1601,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,
@@ -1547,7 +1630,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);
@@ -1565,7 +1648,7 @@ if (!sizeof($error) && $preview)
unset($attachment_data);
}
- if (!sizeof($error))
+ if (!count($error))
{
$template->assign_vars(array(
'PREVIEW_SUBJECT' => $preview_subject,
@@ -1588,7 +1671,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)
@@ -1596,38 +1679,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 = '[quote=&quot;' . $post_data['quote_username'] . '&quot;]' . censor_text(trim($message_parser->message)) . "[/quote]\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']) || !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'];
@@ -1719,8 +1820,7 @@ 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_var('draft_loaded', $draft_id) . '" />' : '';
+$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')
{
@@ -1739,6 +1839,8 @@ if (isset($captcha) && $captcha->is_solved() !== false)
$form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !$config['allow_attachments'] || !$auth->acl_get('u_attach') || !$auth->acl_get('f_attach', $forum_id)) ? '' : ' enctype="multipart/form-data"';
add_form_key('posting');
+/** @var \phpbb\controller\helper $controller_helper */
+$controller_helper = $phpbb_container->get('controller.helper');
// Build array of variables for main posting page
$page_data = array(
@@ -1750,11 +1852,11 @@ $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'],
- 'BBCODE_STATUS' => ($bbcode_status) ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>'),
+ 'BBCODE_STATUS' => $user->lang(($bbcode_status ? 'BBCODE_IS_ON' : 'BBCODE_IS_OFF'), '<a href="' . $controller_helper->route('phpbb_help_bbcode_controller') . '">', '</a>'),
'IMG_STATUS' => ($img_status) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
'FLASH_STATUS' => ($flash_status) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'],
'SMILIES_STATUS' => ($smilies_status) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
@@ -1762,7 +1864,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', ''),
@@ -1822,7 +1924,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']),