phpBB

Code Changes

File: includes/functions_posting.php

  Unmodified   Added   Modified   Removed
Line 119Line 119

foreach ($smilies as $row)
{


foreach ($smilies as $row)
{

 
			/**
* Modify smiley root path before populating smiley list
*
* @event core.generate_smilies_before
* @var string root_path root_path for smilies
* @since 3.1.11-RC1
*/
$vars = array('root_path');
extract($phpbb_dispatcher->trigger_event('core.generate_smilies_before', compact($vars)));

			$template->assign_block_vars('smiley', array(
'SMILEY_CODE' => $row['code'],
'A_SMILEY_CODE' => addslashes($row['code']),

			$template->assign_block_vars('smiley', array(
'SMILEY_CODE' => $row['code'],
'A_SMILEY_CODE' => addslashes($row['code']),

Line 310Line 319
			{
$template->assign_block_vars('topic_icon', array(
'ICON_ID' => $id,

			{
$template->assign_block_vars('topic_icon', array(
'ICON_ID' => $id,

 
					'ICON_NAME'		=> $data['img'],

					'ICON_IMG'		=> $root_path . $config['icons_path'] . '/' . $data['img'],
'ICON_WIDTH' => $data['width'],
'ICON_HEIGHT' => $data['height'],

					'ICON_IMG'		=> $root_path . $config['icons_path'] . '/' . $data['img'],
'ICON_WIDTH' => $data['width'],
'ICON_HEIGHT' => $data['height'],

Line 701Line 711

$used_imagick = false;



$used_imagick = false;


	// Only use imagemagick if defined and the passthru function not disabled

	// Only use ImageMagick if defined and the passthru function not disabled

	if ($config['img_imagick'] && function_exists('passthru'))
{
if (substr($config['img_imagick'], -1) !== '/')

	if ($config['img_imagick'] && function_exists('passthru'))
{
if (substr($config['img_imagick'], -1) !== '/')

Line 1036Line 1046
*/
function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id = 0, $show_quote_button = true)
{

*/
function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id = 0, $show_quote_button = true)
{

	global $user, $auth, $db, $template, $bbcode, $cache;
global $config, $phpbb_root_path, $phpEx, $phpbb_container;

	global $user, $auth, $db, $template, $cache;
global $config, $phpbb_root_path, $phpEx, $phpbb_container, $phpbb_dispatcher;


$phpbb_content_visibility = $phpbb_container->get('content.visibility');
$sql_sort = ($mode == 'post_review') ? 'ASC' : 'DESC';


$phpbb_content_visibility = $phpbb_container->get('content.visibility');
$sql_sort = ($mode == 'post_review') ? 'ASC' : 'DESC';

Line 1073Line 1083
	}

$sql_ary = array(

	}

$sql_ary = array(

		'SELECT'	=> 'u.username, u.user_id, u.user_colour, p.*, z.friend, z.foe',

		'SELECT'	=> 'u.username, u.user_id, u.user_colour, p.*, z.friend, z.foe, uu.username as post_delete_username, uu.user_colour as post_delete_user_colour',


'FROM' => array(
USERS_TABLE => 'u',


'FROM' => array(
USERS_TABLE => 'u',

Line 1084Line 1094
			array(
'FROM' => array(ZEBRA_TABLE => 'z'),
'ON' => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id',

			array(
'FROM' => array(ZEBRA_TABLE => 'z'),
'ON' => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id',

 
			),
array(
'FROM' => array(USERS_TABLE => 'uu'),
'ON' => 'uu.user_id = p.post_delete_user',

			),
),


			),
),


Line 1094Line 1108
	$sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query($sql);


	$sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query($sql);


	$bbcode_bitfield = '';

 
	$rowset = array();
$has_attachments = false;
while ($row = $db->sql_fetchrow($result))
{
$rowset[$row['post_id']] = $row;

	$rowset = array();
$has_attachments = false;
while ($row = $db->sql_fetchrow($result))
{
$rowset[$row['post_id']] = $row;

		$bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);

 

if ($row['post_attachment'])
{


if ($row['post_attachment'])
{

Line 1108Line 1120
		}
}
$db->sql_freeresult($result);

		}
}
$db->sql_freeresult($result);


// Instantiate BBCode class
if (!isset($bbcode) && $bbcode_bitfield !== '')
{
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
}

 

// Grab extensions
$extensions = $attachments = array();


// Grab extensions
$extensions = $attachments = array();

Line 1136Line 1141
		}
$db->sql_freeresult($result);
}

		}
$db->sql_freeresult($result);
}

 

/**
* Event to modify the posts list for topic reviews
*
* @event core.topic_review_modify_post_list
* @var array attachments Array with the post attachments data
* @var int cur_post_id Post offset ID
* @var int forum_id The topic's forum ID
* @var string mode The topic review mode
* @var array post_list Array with the post IDs
* @var array rowset Array with the posts data
* @var bool show_quote_button Flag indicating if the quote button should be displayed
* @var int topic_id The topic ID that is being reviewed
* @since 3.1.9-RC1
*/
$vars = array(
'attachments',
'cur_post_id',
'forum_id',
'mode',
'post_list',
'rowset',
'show_quote_button',
'topic_id',
);
extract($phpbb_dispatcher->trigger_event('core.topic_review_modify_post_list', compact($vars)));


for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
{


for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
{

Line 1176Line 1207
		$post_anchor = ($mode == 'post_review') ? 'ppr' . $row['post_id'] : 'pr' . $row['post_id'];
$u_show_post = append_sid($phpbb_root_path . 'viewtopic.' . $phpEx, "f=$forum_id&amp;t=$topic_id&amp;p={$row['post_id']}&amp;view=show#p{$row['post_id']}");


		$post_anchor = ($mode == 'post_review') ? 'ppr' . $row['post_id'] : 'pr' . $row['post_id'];
$u_show_post = append_sid($phpbb_root_path . 'viewtopic.' . $phpEx, "f=$forum_id&amp;t=$topic_id&amp;p={$row['post_id']}&amp;view=show#p{$row['post_id']}");


		$template->assign_block_vars($mode . '_row', array(


























		$l_deleted_message = '';
if ($row['post_visibility'] == ITEM_DELETED)
{
$display_postername = get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']);

// User having deleted the post also being the post author?
if (!$row['post_delete_user'] || $row['post_delete_user'] == $poster_id)
{
$display_username = $display_postername;
}
else
{
$display_username = get_username_string('full', $row['post_delete_user'], $row['post_delete_username'], $row['post_delete_user_colour']);
}

if ($row['post_delete_reason'])
{
$l_deleted_message = $user->lang('POST_DELETED_BY_REASON', $display_postername, $display_username, $user->format_date($row['post_delete_time'], false, true), $row['post_delete_reason']);
}
else
{
$l_deleted_message = $user->lang('POST_DELETED_BY', $display_postername, $display_username, $user->format_date($row['post_delete_time'], false, true));
}
}

$post_row = array(

			'POST_AUTHOR_FULL'		=> get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'POST_AUTHOR_COLOUR' => get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'POST_AUTHOR' => get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),

			'POST_AUTHOR_FULL'		=> get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'POST_AUTHOR_COLOUR' => get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'POST_AUTHOR' => get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),

Line 1186Line 1242
			'S_FRIEND'			=> ($row['friend']) ? true : false,
'S_IGNORE_POST' => ($row['foe']) ? true : false,
'L_IGNORE_POST' => ($row['foe']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), "<a href=\"{$u_show_post}\" onclick=\"phpbb.toggleDisplay('{$post_anchor}', 1); return false;\">", '</a>') : '',

			'S_FRIEND'			=> ($row['friend']) ? true : false,
'S_IGNORE_POST' => ($row['foe']) ? true : false,
'L_IGNORE_POST' => ($row['foe']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), "<a href=\"{$u_show_post}\" onclick=\"phpbb.toggleDisplay('{$post_anchor}', 1); return false;\">", '</a>') : '',

 
			'S_POST_DELETED'	=> ($row['post_visibility'] == ITEM_DELETED) ? true : false,
'L_DELETE_POST' => $l_deleted_message,


'POST_SUBJECT' => $post_subject,
'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['POST']),


'POST_SUBJECT' => $post_subject,
'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['POST']),

Line 1195Line 1253
			'POST_ID'			=> $row['post_id'],
'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . '#p' . $row['post_id'],
'U_MCP_DETAILS' => ($auth->acl_get('m_info', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=post_details&amp;f=' . $forum_id . '&amp;p=' . $row['post_id'], true, $user->session_id) : '',

			'POST_ID'			=> $row['post_id'],
'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . '#p' . $row['post_id'],
'U_MCP_DETAILS' => ($auth->acl_get('m_info', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=post_details&amp;f=' . $forum_id . '&amp;p=' . $row['post_id'], true, $user->session_id) : '',

			'POSTER_QUOTE'		=> ($show_quote_button && $auth->acl_get('f_reply', $forum_id)) ? addslashes(get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username'])) : '')

			'POSTER_QUOTE'		=> ($show_quote_button && $auth->acl_get('f_reply', $forum_id)) ? addslashes(get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username'])) : '',

		);

		);

 

$current_row_number = $i;

/**
* Event to modify the template data block for topic reviews
*
* @event core.topic_review_modify_row
* @var string mode The review mode
* @var int topic_id The topic that is being reviewed
* @var int forum_id The topic's forum
* @var int cur_post_id Post offset id
* @var int current_row_number Number of the current row being iterated
* @var array post_row Template block array of the current post
* @var array row Array with original post and user data
* @since 3.1.4-RC1
*/
$vars = array(
'mode',
'topic_id',
'forum_id',
'cur_post_id',
'current_row_number',
'post_row',
'row',
);
extract($phpbb_dispatcher->trigger_event('core.topic_review_modify_row', compact($vars)));

$template->assign_block_vars($mode . '_row', $post_row);


// Display not already displayed Attachments for this post, we already parsed them. ;)
if (!empty($attachments[$row['post_id']]))


// Display not already displayed Attachments for this post, we already parsed them. ;)
if (!empty($attachments[$row['post_id']]))

Line 1229Line 1315
*/
function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $softdelete_reason = '')
{

*/
function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $softdelete_reason = '')
{

	global $db, $user, $auth, $phpbb_container;

	global $db, $user, $auth, $phpbb_container, $phpbb_dispatcher;

	global $config, $phpEx, $phpbb_root_path;

// Specify our post mode

	global $config, $phpEx, $phpbb_root_path;

// Specify our post mode

Line 1479Line 1565
	{
sync('topic_reported', 'topic_id', array($topic_id));
}

	{
sync('topic_reported', 'topic_id', array($topic_id));
}

 

/**
* This event is used for performing actions directly after a post or topic
* has been deleted.
*
* @event core.delete_post_after
* @var int forum_id Post forum ID
* @var int topic_id Post topic ID
* @var int post_id Post ID
* @var array data Post data
* @var bool is_soft Soft delete flag
* @var string softdelete_reason Soft delete reason
* @var string post_mode delete_topic, delete_first_post, delete_last_post or delete
* @var mixed next_post_id Next post ID in the topic (post ID or false)
*
* @since 3.1.11-RC1
*/
$vars = array(
'forum_id',
'topic_id',
'post_id',
'data',
'is_soft',
'softdelete_reason',
'post_mode',
'next_post_id',
);
extract($phpbb_dispatcher->trigger_event('core.delete_post_after', compact($vars)));


return $next_post_id;
}


return $next_post_id;
}

Line 1523Line 1637
		return false;
}


		return false;
}


 
	if (!empty($data['post_time']))
{
$current_time = $data['post_time'];
}
else
{

	$current_time = time();

	$current_time = time();

 
	}


if ($mode == 'post')
{


if ($mode == 'post')
{

Line 1582Line 1703
				$post_visibility = ITEM_REAPPROVE;
break;
}

				$post_visibility = ITEM_REAPPROVE;
break;
}

 
	}
else if (isset($data['post_visibility']) && $data['post_visibility'] !== false)
{
$post_visibility = $data['post_visibility'];

	}

// MODs/Extensions are able to force any visibility on posts

	}

// MODs/Extensions are able to force any visibility on posts

Line 1719Line 1844
				'topic_type'				=> $topic_type,
'topic_time_limit' => ($topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE) ? ($data['topic_time_limit'] * 86400) : 0,
'topic_attachment' => (!empty($data['attachment_data'])) ? 1 : 0,

				'topic_type'				=> $topic_type,
'topic_time_limit' => ($topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE) ? ($data['topic_time_limit'] * 86400) : 0,
'topic_attachment' => (!empty($data['attachment_data'])) ? 1 : 0,

 
				'topic_status'				=> (isset($data['topic_status'])) ? $data['topic_status'] : ITEM_UNLOCKED,

			);

if (isset($poll['poll_options']) && !empty($poll['poll_options']))

			);

if (isset($poll['poll_options']) && !empty($poll['poll_options']))

Line 2190Line 2316
		}

$error = false;

		}

$error = false;

		$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);

		$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);


if ($error)
{


if ($error)
{

Line 2375Line 2501

$params = $add_anchor = '';



$params = $add_anchor = '';


	if ($post_visibility == ITEM_APPROVED)



	if ($post_visibility == ITEM_APPROVED ||
($auth->acl_get('m_softdelete', $data['forum_id']) && $post_visibility == ITEM_DELETED) ||
($auth->acl_get('m_approve', $data['forum_id']) && in_array($post_visibility, array(ITEM_UNAPPROVED, ITEM_REAPPROVE))))

	{
$params .= '&amp;t=' . $data['topic_id'];


	{
$params .= '&amp;t=' . $data['topic_id'];


Line 2414Line 2542
	* @var	string	url					The "Return to topic" URL
*
* @since 3.1.0-a3

	* @var	string	url					The "Return to topic" URL
*
* @since 3.1.0-a3

	* @change 3.1.0-RC3 Added vars mode, subject, username, topic_type,

	* @changed 3.1.0-RC3 Added vars mode, subject, username, topic_type,

	*		poll, update_message, update_search_index
*/
$vars = array(

	*		poll, update_message, update_search_index
*/
$vars = array(

Line 2563Line 2691

/**
* Do the various checks required for removing posts as well as removing it


/**
* Do the various checks required for removing posts as well as removing it

 
*
* @param int $forum_id The id of the forum
* @param int $topic_id The id of the topic
* @param int $post_id The id of the post
* @param array $post_data Array with the post data
* @param bool $is_soft The flag indicating whether it is the soft delete mode
* @param string $delete_reason Description for the post deletion reason
*
* @return null

*/
function phpbb_handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_soft = false, $delete_reason = '')
{
global $user, $auth, $config, $request;

*/
function phpbb_handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_soft = false, $delete_reason = '')
{
global $user, $auth, $config, $request;

	global $phpbb_root_path, $phpEx;

	global $phpbb_root_path, $phpEx, $phpbb_dispatcher;





 
	$force_delete_allowed = $force_softdelete_allowed = false;

	$perm_check = ($is_soft) ? 'softdelete' : 'delete';

	$perm_check = ($is_soft) ? 'softdelete' : 'delete';

 

/**
* This event allows to modify the conditions for the post deletion
*
* @event core.handle_post_delete_conditions
* @var int forum_id The id of the forum
* @var int topic_id The id of the topic
* @var int post_id The id of the post
* @var array post_data Array with the post data
* @var bool is_soft The flag indicating whether it is the soft delete mode
* @var string delete_reason Description for the post deletion reason
* @var bool force_delete_allowed Allow the user to delete the post (all permissions and conditions are ignored)
* @var bool force_softdelete_allowed Allow the user to softdelete the post (all permissions and conditions are ignored)
* @var string perm_check The deletion mode softdelete|delete
* @since 3.1.11-RC1
*/
$vars = array(
'forum_id',
'topic_id',
'post_id',
'post_data',
'is_soft',
'delete_reason',
'force_delete_allowed',
'force_softdelete_allowed',
'perm_check',
);
extract($phpbb_dispatcher->trigger_event('core.handle_post_delete_conditions', compact($vars)));


// If moderator removing post or user itself removing post, present a confirmation screen


// If moderator removing post or user itself removing post, present a confirmation screen

	if ($auth->acl_get("m_$perm_check", $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get("f_$perm_check", $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time'])))

	if ($force_delete_allowed || ($is_soft && $force_softdelete_allowed) || $auth->acl_get("m_$perm_check", $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get("f_$perm_check", $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time'])))

	{
$s_hidden_fields = array(
'p' => $post_id,

	{
$s_hidden_fields = array(
'p' => $post_id,

Line 2629Line 2795
		}
else
{

		}
else
{

			global $user, $template, $request;

			global $template;





			$can_delete = $auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id));
$can_softdelete = $auth->acl_get('m_softdelete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_softdelete', $forum_id));

			$can_delete = $force_delete_allowed || ($auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id)));
$can_softdelete = $force_softdelete_allowed || ($auth->acl_get('m_softdelete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_softdelete', $forum_id)));


$template->assign_vars(array(
'S_SOFTDELETED' => $post_data['post_visibility'] == ITEM_DELETED,


$template->assign_vars(array(
'S_SOFTDELETED' => $post_data['post_visibility'] == ITEM_DELETED,