phpBB

Code Changes

File: posting.php

  Unmodified   Added   Modified   Removed
Line 84Line 84
*							NOTE: Should be actual language strings, NOT
* language keys.
* @since 3.1.0-a1

*							NOTE: Should be actual language strings, NOT
* language keys.
* @since 3.1.0-a1

* @change 3.1.2-RC1			Removed 'delete' var as it does not exist

* @changed 3.1.2-RC1			Removed 'delete' var as it does not exist

*/
$vars = array(
'post_id',

*/
$vars = array(
'post_id',

Line 339Line 339
			// Fall back to soft_delete if we have no permissions to delete posts but to soft delete them
$is_authed = true;
$mode = 'soft_delete';

			// Fall back to soft_delete if we have no permissions to delete posts but to soft delete them
$is_authed = true;
$mode = 'soft_delete';

		}
else if (!$is_authed)
{
// Display the same error message for softdelete we use for delete
$mode = 'delete';

 
		}
break;
}

		}
break;
}

Line 371Line 366
*							NOTE: Should be actual language strings, NOT
* language keys.
* @var bool is_authed Does the user have the required permissions?

*							NOTE: Should be actual language strings, NOT
* language keys.
* @var bool is_authed Does the user have the required permissions?

 
* @var	array	post_data	All post data from database

* @since 3.1.3-RC1

* @since 3.1.3-RC1

 
* @changed 3.1.10-RC1 Added post_data

*/
$vars = array(
'post_id',

*/
$vars = array(
'post_id',

Line 387Line 384
	'mode',
'error',
'is_authed',

	'mode',
'error',
'is_authed',

 
	'post_data',

);
extract($phpbb_dispatcher->trigger_event('core.modify_posting_auth', compact($vars)));


);
extract($phpbb_dispatcher->trigger_event('core.modify_posting_auth', compact($vars)));


if (!$is_authed)

if (!$is_authed || !empty($error))

{

{

	$check_auth = ($mode == 'quote') ? 'reply' : $mode;

	$check_auth = ($mode == 'quote') ? 'reply' : (($mode == 'soft_delete') ? 'delete' : $mode);


if ($user->data['is_registered'])
{


if ($user->data['is_registered'])
{

		trigger_error('USER_CANNOT_' . strtoupper($check_auth));

		trigger_error(empty($error) ? 'USER_CANNOT_' . strtoupper($check_auth) : implode('<br/>', $error));

	}
$message = $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)];


	}
$message = $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)];


Line 481Line 479
	}

$delete_reason = $request->variable('delete_reason', '', true);

	}

$delete_reason = $request->variable('delete_reason', '', true);

	phpbb_handle_post_delete($forum_id, $topic_id, $post_id, $post_data, ($mode == 'soft_delete'), $delete_reason);

	phpbb_handle_post_delete($forum_id, $topic_id, $post_id, $post_data, ($mode == 'soft_delete' && !$request->is_set_post('delete_permanent')), $delete_reason);

	return;
}


	return;
}


Line 599Line 597
		WHERE post_msg_id = $post_id
AND in_message = 0
AND is_orphan = 0

		WHERE post_msg_id = $post_id
AND in_message = 0
AND is_orphan = 0

		ORDER BY filetime DESC";

		ORDER BY attach_id DESC";

	$result = $db->sql_query($sql);
$message_parser->attachment_data = array_merge($message_parser->attachment_data, $db->sql_fetchrowset($result));
$db->sql_freeresult($result);

	$result = $db->sql_query($sql);
$message_parser->attachment_data = array_merge($message_parser->attachment_data, $db->sql_fetchrowset($result));
$db->sql_freeresult($result);

Line 622Line 620
	$post_data['enable_smilies']	= ($config['allow_smilies'] && $user->optionget('smilies')) ? true : false;
$post_data['enable_bbcode'] = ($config['allow_bbcode'] && $user->optionget('bbcode')) ? true : false;
$post_data['enable_urls'] = true;

	$post_data['enable_smilies']	= ($config['allow_smilies'] && $user->optionget('smilies')) ? true : false;
$post_data['enable_bbcode'] = ($config['allow_bbcode'] && $user->optionget('bbcode')) ? true : false;
$post_data['enable_urls'] = true;

 
}

if ($mode == 'post')
{
$post_data['topic_status'] = ($request->is_set_post('lock_topic') && $auth->acl_gets('m_lock', 'f_user_lock', $forum_id)) ? ITEM_LOCKED : ITEM_UNLOCKED;

}

$post_data['enable_magic_url'] = $post_data['drafts'] = false;

}

$post_data['enable_magic_url'] = $post_data['drafts'] = false;

Line 933Line 936
	*				is posting a new topic or editing a post)
* @var bool refresh Whether or not to retain previously submitted data
* @var object message_parser The message parser object

	*				is posting a new topic or editing a post)
* @var bool refresh Whether or not to retain previously submitted data
* @var object message_parser The message parser object

 
	* @var	array	error		Array of errors

	* @since 3.1.2-RC1

	* @since 3.1.2-RC1

 
	* @changed 3.1.11-RC1 Added error

	*/
$vars = array(
'post_data',

	*/
$vars = array(
'post_data',

Line 948Line 953
		'cancel',
'refresh',
'message_parser',

		'cancel',
'refresh',
'message_parser',

 
		'error',

	);
extract($phpbb_dispatcher->trigger_event('core.posting_modify_message_text', compact($vars)));


	);
extract($phpbb_dispatcher->trigger_event('core.posting_modify_message_text', compact($vars)));


Line 1022Line 1028
		$message_parser->bbcode_bitfield = $post_data['bbcode_bitfield'];
}


		$message_parser->bbcode_bitfield = $post_data['bbcode_bitfield'];
}


	if ($mode != 'edit' && !$preview && !$refresh && $config['flood_interval'] && !$auth->acl_get('f_ignoreflood', $forum_id))


	$ignore_flood = $auth->acl_get('u_ignoreflood') ? true : $auth->acl_get('f_ignoreflood', $forum_id);
if ($mode != 'edit' && !$preview && !$refresh && $config['flood_interval'] && !$ignore_flood)

	{
// Flood check
$last_post_time = 0;

	{
// Flood check
$last_post_time = 0;

Line 1053Line 1060

// Validate username
if (($post_data['username'] && !$user->data['is_registered']) || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS && $post_data['username'] && $post_data['post_username'] && $post_data['post_username'] != $post_data['username']))


// Validate username
if (($post_data['username'] && !$user->data['is_registered']) || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS && $post_data['username'] && $post_data['post_username'] && $post_data['post_username'] != $post_data['username']))

 
	{
if (!function_exists('validate_username'))

	{
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);

	{
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);

 
		}


$user->add_lang('ucp');



$user->add_lang('ucp');


Line 1252Line 1262
	* @var	array	error		Any error strings; a non-empty array aborts form submission.
* NOTE: Should be actual language strings, NOT language keys.
* @since 3.1.0-RC5

	* @var	array	error		Any error strings; a non-empty array aborts form submission.
* NOTE: Should be actual language strings, NOT language keys.
* @since 3.1.0-RC5

	* @change 3.1.5-RC1 Added poll array to the event

	* @changed 3.1.5-RC1 Added poll array to the event

	*/
$vars = array(
'post_data',

	*/
$vars = array(
'post_data',

Line 1325Line 1335
				'enable_urls'			=> (bool) $post_data['enable_urls'],
'enable_indexing' => (bool) $post_data['enable_indexing'],
'message_md5' => (string) $message_md5,

				'enable_urls'			=> (bool) $post_data['enable_urls'],
'enable_indexing' => (bool) $post_data['enable_indexing'],
'message_md5' => (string) $message_md5,

				'post_time'				=> (isset($post_data['post_time'])) ? (int) $post_data['post_time'] : $current_time,

 
				'post_checksum'			=> (isset($post_data['post_checksum'])) ? (string) $post_data['post_checksum'] : '',
'post_edit_reason' => $post_data['post_edit_reason'],
'post_edit_user' => ($mode == 'edit') ? $user->data['user_id'] : ((isset($post_data['post_edit_user'])) ? (int) $post_data['post_edit_user'] : 0),

				'post_checksum'			=> (isset($post_data['post_checksum'])) ? (string) $post_data['post_checksum'] : '',
'post_edit_reason' => $post_data['post_edit_reason'],
'post_edit_user' => ($mode == 'edit') ? $user->data['user_id'] : ((isset($post_data['post_edit_user'])) ? (int) $post_data['post_edit_user'] : 0),

Line 1340Line 1349
				'message'				=> $message_parser->message,
'attachment_data' => $message_parser->attachment_data,
'filename_data' => $message_parser->filename_data,

				'message'				=> $message_parser->message,
'attachment_data' => $message_parser->attachment_data,
'filename_data' => $message_parser->filename_data,

 
				'topic_status'			=> $post_data['topic_status'],


'topic_visibility' => (isset($post_data['topic_visibility'])) ? $post_data['topic_visibility'] : false,
'post_visibility' => (isset($post_data['post_visibility'])) ? $post_data['post_visibility'] : false,


'topic_visibility' => (isset($post_data['topic_visibility'])) ? $post_data['topic_visibility'] : false,
'post_visibility' => (isset($post_data['post_visibility'])) ? $post_data['post_visibility'] : false,

Line 1374Line 1384
			* @var	string	post_author_name	Author name for guest posts
* @var bool update_message Boolean if the post message was changed
* @var bool update_subject Boolean if the post subject was changed

			* @var	string	post_author_name	Author name for guest posts
* @var bool update_message Boolean if the post message was changed
* @var bool update_subject Boolean if the post subject was changed

			* @var	bool	submit		Whether or not the form has been submitted
* @var array error Any error strings; a non-empty array aborts form submission.

 
			*				NOTE: Should be actual language strings, NOT language keys.
* @since 3.1.0-RC5

			*				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

			*/
$vars = array(
'post_data',

			*/
$vars = array(
'post_data',

Line 1391Line 1400
				'post_author_name',
'update_message',
'update_subject',

				'post_author_name',
'update_message',
'update_subject',

				'submit',
'error',

 
			);
extract($phpbb_dispatcher->trigger_event('core.posting_modify_submit_post_before', compact($vars)));


			);
extract($phpbb_dispatcher->trigger_event('core.posting_modify_submit_post_before', compact($vars)));


Line 1416Line 1423
			* @var	bool	update_message		Boolean if the post message was changed
* @var bool update_subject Boolean if the post subject was changed
* @var string redirect_url URL the user is going to be redirected to

			* @var	bool	update_message		Boolean if the post message was changed
* @var bool update_subject Boolean if the post subject was changed
* @var string redirect_url URL the user is going to be redirected to

			* @var	bool	submit		Whether or not the form has been submitted
* @var array error Any error strings; a non-empty array aborts form submission.

 
			*				NOTE: Should be actual language strings, NOT language keys.
* @since 3.1.0-RC5

			*				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

			*/
$vars = array(
'post_data',

			*/
$vars = array(
'post_data',

Line 1434Line 1440
				'update_message',
'update_subject',
'redirect_url',

				'update_message',
'update_subject',
'redirect_url',

				'submit',
'error',

 
			);
extract($phpbb_dispatcher->trigger_event('core.posting_modify_submit_post_after', compact($vars)));


			);
extract($phpbb_dispatcher->trigger_event('core.posting_modify_submit_post_after', compact($vars)));


Line 1571Line 1575
			'S_DISPLAY_PREVIEW'		=> !empty($preview_message),
));
}

			'S_DISPLAY_PREVIEW'		=> !empty($preview_message),
));
}

 
}

// Remove quotes that would become nested too deep before decoding the text
$generate_quote = ($mode == 'quote' && !$submit && !$preview && !$refresh);
if ($generate_quote && $config['max_quote_depth'] > 0)
{
$tmp_bbcode_uid = $message_parser->bbcode_uid;
$message_parser->bbcode_uid = $post_data['bbcode_uid'];
$message_parser->remove_nested_quotes($config['max_quote_depth'] - 1);
$message_parser->bbcode_uid = $tmp_bbcode_uid;

}

// Decode text for message display
$post_data['bbcode_uid'] = ($mode == 'quote' && !$preview && !$refresh && !sizeof($error)) ? $post_data['bbcode_uid'] : $message_parser->bbcode_uid;
$message_parser->decode_message($post_data['bbcode_uid']);


}

// Decode text for message display
$post_data['bbcode_uid'] = ($mode == 'quote' && !$preview && !$refresh && !sizeof($error)) ? $post_data['bbcode_uid'] : $message_parser->bbcode_uid;
$message_parser->decode_message($post_data['bbcode_uid']);


if ($mode == 'quote' && !$submit && !$preview && !$refresh)

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";

	if ($config['allow_bbcode'])
{
$message_parser->message = '[quote=&quot;' . $post_data['quote_username'] . '&quot;]' . censor_text(trim($message_parser->message)) . "[/quote]\n";

Line 1728Line 1745
	'L_POST_A'					=> $page_title,
'L_ICON' => ($mode == 'reply' || $mode == 'quote' || ($mode == 'edit' && $post_id != $post_data['topic_first_post_id'])) ? $user->lang['POST_ICON'] : $user->lang['TOPIC_ICON'],
'L_MESSAGE_BODY_EXPLAIN' => $user->lang('MESSAGE_BODY_EXPLAIN', (int) $config['max_post_chars']),

	'L_POST_A'					=> $page_title,
'L_ICON' => ($mode == 'reply' || $mode == 'quote' || ($mode == 'edit' && $post_id != $post_data['topic_first_post_id'])) ? $user->lang['POST_ICON'] : $user->lang['TOPIC_ICON'],
'L_MESSAGE_BODY_EXPLAIN' => $user->lang('MESSAGE_BODY_EXPLAIN', (int) $config['max_post_chars']),

 
	'L_DELETE_POST_PERMANENTLY'	=> $user->lang('DELETE_POST_PERMANENTLY', 1),


'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']) : '',


'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']) : '',

Line 1768Line 1786
	'S_SIGNATURE_CHECKED'		=> ($sig_checked) ? ' checked="checked"' : '',
'S_NOTIFY_ALLOWED' => (!$user->data['is_registered'] || ($mode == 'edit' && $user->data['user_id'] != $post_data['poster_id']) || !$config['allow_topic_notify'] || !$config['email_enable']) ? false : true,
'S_NOTIFY_CHECKED' => ($notify_checked) ? ' checked="checked"' : '',

	'S_SIGNATURE_CHECKED'		=> ($sig_checked) ? ' checked="checked"' : '',
'S_NOTIFY_ALLOWED' => (!$user->data['is_registered'] || ($mode == 'edit' && $user->data['user_id'] != $post_data['poster_id']) || !$config['allow_topic_notify'] || !$config['email_enable']) ? false : true,
'S_NOTIFY_CHECKED' => ($notify_checked) ? ' checked="checked"' : '',

	'S_LOCK_TOPIC_ALLOWED'		=> (($mode == 'edit' || $mode == 'reply' || $mode == 'quote') && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED))) ? true : false,

	'S_LOCK_TOPIC_ALLOWED'		=> (($mode == 'edit' || $mode == 'reply' || $mode == 'quote' || $mode == 'post') && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED))) ? true : false,

	'S_LOCK_TOPIC_CHECKED'		=> ($lock_topic_checked) ? ' checked="checked"' : '',
'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false,
'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '',

	'S_LOCK_TOPIC_CHECKED'		=> ($lock_topic_checked) ? ' checked="checked"' : '',
'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false,
'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '',

Line 1835Line 1853
* @var	int	post_id		ID of the post
* @var int topic_id ID of the topic
* @var int forum_id ID of the forum

* @var	int	post_id		ID of the post
* @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	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

* @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

Line 1851Line 1870
*				posting page via $template->assign_vars()
* @var object message_parser The message parser object
* @since 3.1.0-a1

*				posting page via $template->assign_vars()
* @var object message_parser The message parser object
* @since 3.1.0-a1

* @change 3.1.0-b3 Added vars post_data, moderators, mode, page_title,

* @changed 3.1.0-b3 Added vars post_data, moderators, mode, page_title,

*		s_topic_icons, form_enctype, s_action, s_hidden_fields,
* post_id, topic_id, forum_id, submit, preview, save, load,
* delete, cancel, refresh, error, page_data, message_parser

*		s_topic_icons, form_enctype, s_action, s_hidden_fields,
* post_id, topic_id, forum_id, submit, preview, save, load,
* delete, cancel, refresh, error, page_data, message_parser

* @change 3.1.2-RC1 Removed 'delete' var as it does not exist
* @change 3.1.5-RC1 Added poll variables to the page_data array


* @changed 3.1.2-RC1 Removed 'delete' var as it does not exist
* @changed 3.1.5-RC1 Added poll variables to the page_data array
* @changed 3.1.6-RC1 Added 'draft_id' var

*/
$vars = array(
'post_data',

*/
$vars = array(
'post_data',

Line 1870Line 1890
	'post_id',
'topic_id',
'forum_id',

	'post_id',
'topic_id',
'forum_id',

 
	'draft_id',

	'submit',
'preview',
'save',

	'submit',
'preview',
'save',