phpBB

Code Changes

File: posting.php

  Unmodified   Added   Modified   Removed
Line 35Line 35
$draft_id	= request_var('d', 0);
$lastclick = request_var('lastclick', 0);


$draft_id	= request_var('d', 0);
$lastclick = request_var('lastclick', 0);


$submit		= (isset($_POST['post'])) ? true : false;

 
$preview	= (isset($_POST['preview'])) ? true : false;
$save = (isset($_POST['save'])) ? true : false;
$load = (isset($_POST['load'])) ? true : false;

$preview	= (isset($_POST['preview'])) ? true : false;
$save = (isset($_POST['save'])) ? true : false;
$load = (isset($_POST['load'])) ? true : false;

Line 43Line 42
$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);

$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', '');

// If the user is not allowed to delete the post, we try to soft delete it, so we overwrite the mode here.

$mode		= request_var('mode', '');

// If the user is not allowed to delete the post, we try to soft delete it, so we overwrite the mode here.

Line 73Line 73
* @var	bool	preview		Whether or not the post is being previewed
* @var bool save Whether or not a draft is being saved
* @var bool load Whether or not a draft is being loaded

* @var	bool	preview		Whether or not the post is being previewed
* @var bool save Whether or not a draft is being saved
* @var bool load Whether or not a draft is being loaded

* @var	bool	delete		Whether or not the post is being deleted

 
* @var	bool	cancel		Whether or not to cancel the form (returns to
* viewtopic or viewforum depending on if the user
* is posting a new topic or editing a post)

* @var	bool	cancel		Whether or not to cancel the form (returns to
* viewtopic or viewforum depending on if the user
* is posting a new topic or editing a post)

Line 85Line 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

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

*/
$vars = array(
'post_id',

*/
$vars = array(
'post_id',

Line 96Line 96
	'preview',
'save',
'load',

	'preview',
'save',
'load',

	'delete',

 
	'cancel',
'refresh',
'mode',

	'cancel',
'refresh',
'mode',

Line 331Line 330
		{
$is_authed = true;
}

		{
$is_authed = true;
}

	break;



// no break;


case 'soft_delete':


case 'soft_delete':

		if ($user->data['is_registered'] && $phpbb_content_visibility->can_soft_delete($forum_id, $post_data['poster_id'], $post_data['post_edit_locked']))

		if (!$is_authed && $user->data['is_registered'] && $phpbb_content_visibility->can_soft_delete($forum_id, $post_data['poster_id'], $post_data['post_edit_locked']))

		{

		{

 
			// Fall back to soft_delete if we have no permissions to delete posts but to soft delete them

			$is_authed = true;

			$is_authed = true;

		}
else
{
// Display the same error message for softdelete we use for delete
$mode = 'delete';

			$mode = 'soft_delete';





		}
break;
}

		}
break;
}

 
/**
* This event allows you to do extra auth checks and verify if the user
* has the required permissions
*
* Extensions should only change the error and is_authed variables.
*
* @event core.modify_posting_auth
* @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 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
* @var bool load Whether or not a draft is being loaded
* @var bool refresh Whether or not to retain previously submitted data
* @var string mode What action to take if the form has been submitted
* post|reply|quote|edit|delete|bump|smilies|popup
* @var array error Any error strings; a non-empty array aborts
* form submission.
* 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
* @changed 3.1.10-RC1 Added post_data
*/
$vars = array(
'post_id',
'topic_id',
'forum_id',
'draft_id',
'lastclick',
'submit',
'preview',
'save',
'load',
'refresh',
'mode',
'error',
'is_authed',
'post_data',
);
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 437Line 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 555Line 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 578Line 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 869Line 916

// Parse Attachments - before checksum is calculated
$message_parser->parse_attachments('fileupload', $mode, $forum_id, $submit, $preview, $refresh);


// Parse Attachments - before checksum is calculated
$message_parser->parse_attachments('fileupload', $mode, $forum_id, $submit, $preview, $refresh);

 

/**
* This event allows you to modify message text before parsing
*
* @event core.posting_modify_message_text
* @var array post_data Array with post data
* @var string mode What action to take if the form is submitted
* post|reply|quote|edit|delete|bump|smilies|popup
* @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 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 load Whether or not a draft is being loaded
* @var bool cancel Whether or not to cancel the form (returns to
* viewtopic or viewforum depending on if the user
* 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
* @changed 3.1.11-RC1 Added error
*/
$vars = array(
'post_data',
'mode',
'post_id',
'topic_id',
'forum_id',
'submit',
'preview',
'save',
'load',
'cancel',
'refresh',
'message_parser',
'error',
);
extract($phpbb_dispatcher->trigger_event('core.posting_modify_message_text', compact($vars)));


// Grab md5 'checksum' of new message
$message_md5 = md5($message_parser->message);


// Grab md5 'checksum' of new message
$message_md5 = md5($message_parser->message);

Line 941Line 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 972Line 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 1125Line 1216
			break;
}


			break;
}


		if (!$auth->acl_get($auth_option, $forum_id))

		if ($auth_option != '' && !$auth->acl_get($auth_option, $forum_id))

		{
// There is a special case where a user edits his post whereby the topic type got changed by an admin/mod.
// Another case would be a mod not having sticky permissions for example but edit permissions.

		{
// There is a special case where a user edits his post whereby the topic type got changed by an admin/mod.
// Another case would be a mod not having sticky permissions for example but edit permissions.

Line 1160Line 1251
	*
* @event core.posting_modify_submission_errors
* @var array post_data Array with post data

	*
* @event core.posting_modify_submission_errors
* @var array post_data Array with post data

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

Line 1170Line 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

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

	*/
$vars = array(
'post_data',

	*/
$vars = array(
'post_data',

 
		'poll',

		'mode',
'page_title',
'post_id',

		'mode',
'page_title',
'post_id',

Line 1241Line 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 1256Line 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 1290Line 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 1307Line 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 1332Line 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 1350Line 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 1439Line 1527
			'L_MAX_VOTES'		=> $user->lang('MAX_OPTIONS_SELECT', (int) $post_data['poll_max_options']),
));


			'L_MAX_VOTES'		=> $user->lang('MAX_OPTIONS_SELECT', (int) $post_data['poll_max_options']),
));


		$parse_poll->message = implode("\n", $post_data['poll_options']);




		$preview_poll_options = array();
foreach ($post_data['poll_options'] as $poll_option)
{
$parse_poll->message = $poll_option;

		$parse_poll->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies']);

		$parse_poll->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies']);

		$preview_poll_options = explode('<br />', $parse_poll->message);


			$preview_poll_options[] = $parse_poll->message;
}

		unset($parse_poll);

foreach ($preview_poll_options as $key => $option)

		unset($parse_poll);

foreach ($preview_poll_options as $key => $option)

Line 1483Line 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 1640Line 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 1658Line 1764
	'POST_DATE'				=> ($post_data['post_time']) ? $user->format_date($post_data['post_time']) : '',
'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
'TOPIC_TIME_LIMIT' => (int) $post_data['topic_time_limit'],

	'POST_DATE'				=> ($post_data['post_time']) ? $user->format_date($post_data['post_time']) : '',
'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
'TOPIC_TIME_LIMIT' => (int) $post_data['topic_time_limit'],

	'EDIT_REASON'			=> $request->variable('edit_reason', ''),

	'EDIT_REASON'			=> $request->variable('edit_reason', '', true),

	'SHOW_PANEL'			=> $request->variable('show_panel', ''),
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"),
'U_VIEW_TOPIC' => ($mode != 'post') ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id") : '',

	'SHOW_PANEL'			=> $request->variable('show_panel', ''),
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"),
'U_VIEW_TOPIC' => ($mode != 'post') ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id") : '',

Line 1680Line 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 1705Line 1811
	'S_ATTACH_DATA'			=> json_encode($message_parser->attachment_data),
'S_IN_POSTING' => true,
);

	'S_ATTACH_DATA'			=> json_encode($message_parser->attachment_data),
'S_IN_POSTING' => true,
);

 

// Build custom bbcodes array
display_custom_bbcodes();

// Poll entry
if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/))
&& $auth->acl_get('f_poll', $forum_id))
{
$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_CHECKED' => (!empty($poll_delete)) ? true : false,

'L_POLL_OPTIONS_EXPLAIN' => $user->lang('POLL_OPTIONS_' . (($mode == 'edit') ? 'EDIT_' : '') . 'EXPLAIN', (int) $config['max_poll_options']),

'VOTE_CHANGE_CHECKED' => (!empty($post_data['poll_vote_change'])) ? ' checked="checked"' : '',
'POLL_TITLE' => (isset($post_data['poll_title'])) ? $post_data['poll_title'] : '',
'POLL_OPTIONS' => (!empty($post_data['poll_options'])) ? implode("\n", $post_data['poll_options']) : '',
'POLL_MAX_OPTIONS' => (isset($post_data['poll_max_options'])) ? (int) $post_data['poll_max_options'] : 1,
'POLL_LENGTH' => $post_data['poll_length'],
)
);
}


/**
* This event allows you to modify template variables for the posting screen


/**
* This event allows you to modify template variables for the posting screen

Line 1723Line 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 load Whether or not a draft is being 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
* @var bool load Whether or not a draft is being loaded

* @var	bool	delete		Whether or not the post is being deleted

 
* @var	bool	cancel		Whether or not to cancel the form (returns to
* viewtopic or viewforum depending on if the user
* is posting a new topic or editing a post)

* @var	bool	cancel		Whether or not to cancel the form (returns to
* viewtopic or viewforum depending on if the user
* is posting a new topic or editing a post)

Line 1740Line 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

 
* @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 1757Line 1890
	'post_id',
'topic_id',
'forum_id',

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

 
	'draft_id',

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

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

	'delete',

 
	'cancel',
'refresh',
'error',

	'cancel',
'refresh',
'error',

Line 1772Line 1905

// Start assigning vars for main posting page ...
$template->assign_vars($page_data);


// Start assigning vars for main posting page ...
$template->assign_vars($page_data);


// Build custom bbcodes array
display_custom_bbcodes();

// Poll entry
if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/))
&& $auth->acl_get('f_poll', $forum_id))
{
$template->assign_vars(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_CHECKED' => (!empty($poll_delete)) ? true : false,

'L_POLL_OPTIONS_EXPLAIN' => $user->lang('POLL_OPTIONS_' . (($mode == 'edit') ? 'EDIT_' : '') . 'EXPLAIN', (int) $config['max_poll_options']),

'VOTE_CHANGE_CHECKED' => (!empty($post_data['poll_vote_change'])) ? ' checked="checked"' : '',
'POLL_TITLE' => (isset($post_data['poll_title'])) ? $post_data['poll_title'] : '',
'POLL_OPTIONS' => (!empty($post_data['poll_options'])) ? implode("\n", $post_data['poll_options']) : '',
'POLL_MAX_OPTIONS' => (isset($post_data['poll_max_options'])) ? (int) $post_data['poll_max_options'] : 1,
'POLL_LENGTH' => $post_data['poll_length'])
);
}

 

// Show attachment box for adding attachments if true
$allowed = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && $config['allow_attachments'] && $form_enctype);


// Show attachment box for adding attachments if true
$allowed = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && $config['allow_attachments'] && $form_enctype);