phpBB

Code Changes

File: includes/mcp/mcp_forum.php

  Unmodified   Added   Modified   Removed
Line 34Line 34

// merge_topic is the quickmod action, merge_topics is the mcp_forum action, and merge_select is the mcp_topic action
$merge_select = ($action == 'merge_select' || $action == 'merge_topic' || $action == 'merge_topics') ? true : false;


// merge_topic is the quickmod action, merge_topics is the mcp_forum action, and merge_select is the mcp_topic action
$merge_select = ($action == 'merge_select' || $action == 'merge_topic' || $action == 'merge_topics') ? true : false;


if ($merge_select)
{
// Fixes a "bug" that makes forum_view use the same ordering as topic_view
$request->overwrite('sk', null);
$request->overwrite('sd', null);
$request->overwrite('sk', null, \phpbb\request\request_interface::POST);
$request->overwrite('sd', null, \phpbb\request\request_interface::POST);
}

 

$forum_id = $forum_info['forum_id'];


$forum_id = $forum_info['forum_id'];

	$start				= request_var('start', 0);
$topic_id_list = request_var('topic_id_list', array(0));
$post_id_list = request_var('post_id_list', array(0));
$source_topic_ids = array(request_var('t', 0));
$to_topic_id = request_var('to_topic_id', 0);

	$start				= $request->variable('start', 0);
$topic_id_list = $request->variable('topic_id_list', array(0));
$post_id_list = $request->variable('post_id_list', array(0));
$source_topic_ids = array($request->variable('t', 0));
$to_topic_id = $request->variable('to_topic_id', 0);


$url_extra = '';
$url_extra .= ($forum_id) ? "&f=$forum_id" : '';


$url_extra = '';
$url_extra .= ($forum_id) ? "&f=$forum_id" : '';

Line 63Line 54
	switch ($action)
{
case 'resync':

	switch ($action)
{
case 'resync':

			$topic_ids = request_var('topic_id_list', array(0));

			$topic_ids = $request->variable('topic_id_list', array(0));

			mcp_resync_topics($topic_ids);
break;


			mcp_resync_topics($topic_ids);
break;


Line 77Line 68
		break;
}


		break;
}


 
	/**
* Get some data in order to execute other actions.
*
* @event core.mcp_forum_view_before
* @var string action The action
* @var array forum_info Array with forum infos
* @var int start Start value
* @var array topic_id_list Array of topics ids
* @var array post_id_list Array of posts ids
* @var array source_topic_ids Array of source topics ids
* @var int to_topic_id Array of destination topics ids
* @since 3.1.6-RC1
*/
$vars = array(
'action',
'forum_info',
'start',
'topic_id_list',
'post_id_list',
'source_topic_ids',
'to_topic_id',
);
extract($phpbb_dispatcher->trigger_event('core.mcp_forum_view_before', compact($vars)));

/* @var $pagination \phpbb\pagination */

	$pagination = $phpbb_container->get('pagination');

$selected_ids = '';

	$pagination = $phpbb_container->get('pagination');

$selected_ids = '';

Line 130Line 146
		'S_CAN_SYNC'			=> $auth->acl_get('m_', $forum_id),
'S_CAN_APPROVE' => $auth->acl_get('m_approve', $forum_id),
'S_MERGE_SELECT' => ($merge_select) ? true : false,

		'S_CAN_SYNC'			=> $auth->acl_get('m_', $forum_id),
'S_CAN_APPROVE' => $auth->acl_get('m_approve', $forum_id),
'S_MERGE_SELECT' => ($merge_select) ? true : false,

		'S_CAN_MAKE_NORMAL'		=> $auth->acl_gets('f_sticky', 'f_announce', $forum_id),

		'S_CAN_MAKE_NORMAL'		=> $auth->acl_gets('f_sticky', 'f_announce', 'f_announce_global', $forum_id),

		'S_CAN_MAKE_STICKY'		=> $auth->acl_get('f_sticky', $forum_id),
'S_CAN_MAKE_ANNOUNCE' => $auth->acl_get('f_announce', $forum_id),

		'S_CAN_MAKE_STICKY'		=> $auth->acl_get('f_sticky', $forum_id),
'S_CAN_MAKE_ANNOUNCE' => $auth->acl_get('f_announce', $forum_id),

 
		'S_CAN_MAKE_ANNOUNCE_GLOBAL'	=> $auth->acl_get('f_announce_global', $forum_id),


'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
'U_VIEW_FORUM_LOGS' => ($auth->acl_gets('a_', 'm_', $forum_id) && $module->loaded('logs')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=logs&mode=forum_logs&f=' . $forum_id) : '',


'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
'U_VIEW_FORUM_LOGS' => ($auth->acl_gets('a_', 'm_', $forum_id) && $module->loaded('logs')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=logs&mode=forum_logs&f=' . $forum_id) : '',

Line 157Line 174
		$read_tracking_join = $read_tracking_select = '';
}


		$read_tracking_join = $read_tracking_select = '';
}


 
	/* @var $phpbb_content_visibility \phpbb\content_visibility */

	$phpbb_content_visibility = $phpbb_container->get('content.visibility');

$sql = 'SELECT t.topic_id

	$phpbb_content_visibility = $phpbb_container->get('content.visibility');

$sql = 'SELECT t.topic_id

Line 165Line 183
			AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.') . "
$limit_time_sql
ORDER BY t.topic_type DESC, $sort_order_sql";

			AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.') . "
$limit_time_sql
ORDER BY t.topic_type DESC, $sort_order_sql";

 

/**
* Modify SQL query before MCP forum view topic list is queried
*
* @event core.mcp_view_forum_modify_sql
* @var string sql SQL query for forum view topic list
* @var int forum_id ID of the forum
* @var string limit_time_sql SQL query part for limit time
* @var string sort_order_sql SQL query part for sort order
* @var int topics_per_page Number of topics per page
* @var int start Start value
* @since 3.1.2-RC1
*/
$vars = array('sql', 'forum_id', 'limit_time_sql', 'sort_order_sql', 'topics_per_page', 'start');
extract($phpbb_dispatcher->trigger_event('core.mcp_view_forum_modify_sql', compact($vars)));


	$result = $db->sql_query_limit($sql, $topics_per_page, $start);

$topic_list = $topic_tracking_info = array();


	$result = $db->sql_query_limit($sql, $topics_per_page, $start);

$topic_list = $topic_tracking_info = array();


	while ($row = $db->sql_fetchrow($result))

	while ($row_ary = $db->sql_fetchrow($result))

	{

	{

		$topic_list[] = $row['topic_id'];

		$topic_list[] = $row_ary['topic_id'];

	}
$db->sql_freeresult($result);


	}
$db->sql_freeresult($result);


Line 180Line 214
		WHERE " . $db->sql_in_set('t.topic_id', $topic_list, false, true);

$result = $db->sql_query($sql);

		WHERE " . $db->sql_in_set('t.topic_id', $topic_list, false, true);

$result = $db->sql_query($sql);

	while ($row = $db->sql_fetchrow($result))

	while ($row_ary = $db->sql_fetchrow($result))

	{

	{

		$topic_rows[$row['topic_id']] = $row;

		$topic_rows[$row_ary['topic_id']] = $row_ary;

	}
$db->sql_freeresult($result);


	}
$db->sql_freeresult($result);


Line 207Line 241

foreach ($topic_list as $topic_id)
{


foreach ($topic_list as $topic_id)
{

		$topic_title = '';

		$row_ary = &$topic_rows[$topic_id];





		$row = &$topic_rows[$topic_id];

		$replies = $phpbb_content_visibility->get_count('topic_posts', $row_ary, $forum_id) - 1;





		$replies = $phpbb_content_visibility->get_count('topic_posts', $row, $forum_id) - 1;

if ($row['topic_status'] == ITEM_MOVED)

		if ($row_ary['topic_status'] == ITEM_MOVED)



		{
$unread_topic = false;
}
else
{

		{
$unread_topic = false;
}
else
{

			$unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;

			$unread_topic = (isset($topic_tracking_info[$topic_id]) && $row_ary['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;

		}

// Get folder img, topic status/type related information
$folder_img = $folder_alt = $topic_type = '';

		}

// Get folder img, topic status/type related information
$folder_img = $folder_alt = $topic_type = '';

		topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);

		topic_status($row_ary, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);





		$topic_title = censor_text($row['topic_title']);

		$topic_title = censor_text($row_ary['topic_title']);





		$topic_unapproved = (($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE)  && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false;
$posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false;
$topic_deleted = $row['topic_visibility'] == ITEM_DELETED;
$u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? $url . '&i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . '&t=' . $row['topic_id'] : '';

		$topic_unapproved = (($row_ary['topic_visibility'] == ITEM_UNAPPROVED || $row_ary['topic_visibility'] == ITEM_REAPPROVE)  && $auth->acl_get('m_approve', $row_ary['forum_id'])) ? true : false;
$posts_unapproved = ($row_ary['topic_visibility'] == ITEM_APPROVED && $row_ary['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row_ary['forum_id'])) ? true : false;
$topic_deleted = $row_ary['topic_visibility'] == ITEM_DELETED;
$u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? $url . '&i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . '&t=' . $row_ary['topic_id'] : '';

		$u_mcp_queue = (!$u_mcp_queue && $topic_deleted) ? $url . '&i=queue&mode=deleted_topics&t=' . $topic_id : $u_mcp_queue;

$topic_row = array(

		$u_mcp_queue = (!$u_mcp_queue && $topic_deleted) ? $url . '&i=queue&mode=deleted_topics&t=' . $topic_id : $u_mcp_queue;

$topic_row = array(

			'ATTACH_ICON_IMG'		=> ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',

			'ATTACH_ICON_IMG'		=> ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row_ary['forum_id']) && $row_ary['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',

			'TOPIC_IMG_STYLE'		=> $folder_img,
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),

			'TOPIC_IMG_STYLE'		=> $folder_img,
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),

			'TOPIC_ICON_IMG'		=> (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '',
'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '',
'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '',

			'TOPIC_ICON_IMG'		=> (!empty($icons[$row_ary['icon_id']])) ? $icons[$row_ary['icon_id']]['img'] : '',
'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row_ary['icon_id']])) ? $icons[$row_ary['icon_id']]['width'] : '',
'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row_ary['icon_id']])) ? $icons[$row_ary['icon_id']]['height'] : '',

			'UNAPPROVED_IMG'		=> ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '',

			'UNAPPROVED_IMG'		=> ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '',

			'DELETED_IMG'			=> ($topic_deleted) ? $user->img('icon_topic_deleted', 'POSTS_DELETED') : '',

			'DELETED_IMG'			=> ($topic_deleted) ? $user->img('icon_topic_deleted', 'TOPIC_DELETED') : '',





			'TOPIC_AUTHOR'				=> get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),

			'TOPIC_AUTHOR'				=> get_username_string('username', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']),
'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']),
'TOPIC_AUTHOR_FULL' => get_username_string('full', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']),
'U_TOPIC_AUTHOR' => get_username_string('profile', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']),





			'LAST_POST_AUTHOR'			=> get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),

			'LAST_POST_AUTHOR'			=> get_username_string('username', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']),
'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']),
'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']),
'U_LAST_POST_AUTHOR' => get_username_string('profile', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']),


'TOPIC_TYPE' => $topic_type,
'TOPIC_TITLE' => $topic_title,


'TOPIC_TYPE' => $topic_type,
'TOPIC_TITLE' => $topic_title,

			'REPLIES'			=> $phpbb_content_visibility->get_count('topic_posts', $row, $row['forum_id']) - 1,
'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']),
'FIRST_POST_TIME' => $user->format_date($row['topic_time']),
'LAST_POST_SUBJECT' => $row['topic_last_post_subject'],
'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']),

			'REPLIES'			=> $phpbb_content_visibility->get_count('topic_posts', $row_ary, $row_ary['forum_id']) - 1,
'LAST_POST_TIME' => $user->format_date($row_ary['topic_last_post_time']),
'FIRST_POST_TIME' => $user->format_date($row_ary['topic_time']),
'LAST_POST_SUBJECT' => $row_ary['topic_last_post_subject'],
'LAST_VIEW_TIME' => $user->format_date($row_ary['topic_last_view_time']),





			'S_TOPIC_REPORTED'		=> (!empty($row['topic_reported']) && empty($row['topic_moved_id']) && $auth->acl_get('m_report', $row['forum_id'])) ? true : false,

			'S_TOPIC_REPORTED'		=> (!empty($row_ary['topic_reported']) && empty($row_ary['topic_moved_id']) && $auth->acl_get('m_report', $row_ary['forum_id'])) ? true : false,

			'S_TOPIC_UNAPPROVED'	=> $topic_unapproved,
'S_POSTS_UNAPPROVED' => $posts_unapproved,
'S_TOPIC_DELETED' => $topic_deleted,
'S_UNREAD_TOPIC' => $unread_topic,
);


			'S_TOPIC_UNAPPROVED'	=> $topic_unapproved,
'S_POSTS_UNAPPROVED' => $posts_unapproved,
'S_TOPIC_DELETED' => $topic_deleted,
'S_UNREAD_TOPIC' => $unread_topic,
);


		if ($row['topic_status'] == ITEM_MOVED)

		if ($row_ary['topic_status'] == ITEM_MOVED)

		{
$topic_row = array_merge($topic_row, array(

		{
$topic_row = array_merge($topic_row, array(

				'U_VIEW_TOPIC'		=> append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_moved_id']}"),
'U_DELETE_TOPIC' => ($auth->acl_get('m_delete', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&f=$forum_id&topic_id_list[]={$row['topic_id']}&mode=forum_view&action=delete_topic") : '',

				'U_VIEW_TOPIC'		=> append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row_ary['topic_moved_id']}"),
'U_DELETE_TOPIC' => ($auth->acl_get('m_delete', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&f=$forum_id&topic_id_list[]={$row_ary['topic_id']}&mode=forum_view&action=delete_topic") : '',

				'S_MOVED_TOPIC'		=> true,

				'S_MOVED_TOPIC'		=> true,

				'TOPIC_ID'			=> $row['topic_moved_id'],

				'TOPIC_ID'			=> $row_ary['topic_moved_id'],

			));
}
else
{
if ($action == 'merge_topic' || $action == 'merge_topics')
{

			));
}
else
{
if ($action == 'merge_topic' || $action == 'merge_topics')
{

				$u_select_topic = $url . "&i=$id&mode=forum_view&action=$action&to_topic_id=" . $row['topic_id'] . $selected_ids;

				$u_select_topic = $url . "&i=$id&mode=forum_view&action=$action&to_topic_id=" . $row_ary['topic_id'] . $selected_ids;

			}
else
{

			}
else
{

				$u_select_topic = $url . "&i=$id&mode=topic_view&action=merge&to_topic_id=" . $row['topic_id'] . $selected_ids;

				$u_select_topic = $url . "&i=$id&mode=topic_view&action=merge&to_topic_id=" . $row_ary['topic_id'] . $selected_ids;

			}
$topic_row = array_merge($topic_row, array(

			}
$topic_row = array_merge($topic_row, array(

				'U_VIEW_TOPIC'		=> append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&f=$forum_id&t={$row['topic_id']}&mode=topic_view"),

				'U_VIEW_TOPIC'		=> append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&f=$forum_id&t={$row_ary['topic_id']}&mode=topic_view"),





				'S_SELECT_TOPIC'	=> ($merge_select && !in_array($row['topic_id'], $source_topic_ids)) ? true : false,

				'S_SELECT_TOPIC'	=> ($merge_select && !in_array($row_ary['topic_id'], $source_topic_ids)) ? true : false,

				'U_SELECT_TOPIC'	=> $u_select_topic,
'U_MCP_QUEUE' => $u_mcp_queue,

				'U_SELECT_TOPIC'	=> $u_select_topic,
'U_MCP_QUEUE' => $u_mcp_queue,

				'U_MCP_REPORT'		=> ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=topic_view&t=' . $row['topic_id'] . '&action=reports') : '',
'TOPIC_ID' => $row['topic_id'],
'S_TOPIC_CHECKED' => ($topic_id_list && in_array($row['topic_id'], $topic_id_list)) ? true : false,

				'U_MCP_REPORT'		=> ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=topic_view&t=' . $row_ary['topic_id'] . '&action=reports') : '',
'TOPIC_ID' => $row_ary['topic_id'],
'S_TOPIC_CHECKED' => ($topic_id_list && in_array($row_ary['topic_id'], $topic_id_list)) ? true : false,

			));
}


			));
}


 
		$row = $row_ary;

		/**
* Modify the topic data before it is assigned to the template in MCP
*
* @event core.mcp_view_forum_modify_topicrow

		/**
* Modify the topic data before it is assigned to the template in MCP
*
* @event core.mcp_view_forum_modify_topicrow

		* @var	array	row			Array with topic data

		* @var	array	row		Array with topic data

		* @var	array	topic_row	Template array with topic data
* @since 3.1.0-a1
*/
$vars = array('row', 'topic_row');
extract($phpbb_dispatcher->trigger_event('core.mcp_view_forum_modify_topicrow', compact($vars)));

		* @var	array	topic_row	Template array with topic data
* @since 3.1.0-a1
*/
$vars = array('row', 'topic_row');
extract($phpbb_dispatcher->trigger_event('core.mcp_view_forum_modify_topicrow', compact($vars)));

 
		$row_ary = $row;
unset($row);


$template->assign_block_vars('topicrow', $topic_row);
}


$template->assign_block_vars('topicrow', $topic_row);
}

Line 321Line 356
*/
function mcp_resync_topics($topic_ids)
{

*/
function mcp_resync_topics($topic_ids)
{

	global $auth, $db, $template, $phpEx, $user, $phpbb_root_path;

	global $db, $user, $phpbb_log, $request;


if (!sizeof($topic_ids))
{


if (!sizeof($topic_ids))
{

Line 346Line 381
	// Log this action
while ($row = $db->sql_fetchrow($result))
{

	// Log this action
while ($row = $db->sql_fetchrow($result))
{

		add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_TOPIC_RESYNC', $row['topic_title']);





		$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_TOPIC_RESYNC', false, array(
'forum_id' => $row['forum_id'],
'topic_id' => $row['topic_id'],
$row['topic_title']
));

	}
$db->sql_freeresult($result);

$msg = (sizeof($topic_ids) == 1) ? $user->lang['TOPIC_RESYNC_SUCCESS'] : $user->lang['TOPICS_RESYNC_SUCCESS'];


	}
$db->sql_freeresult($result);

$msg = (sizeof($topic_ids) == 1) ? $user->lang['TOPIC_RESYNC_SUCCESS'] : $user->lang['TOPICS_RESYNC_SUCCESS'];


	$redirect = request_var('redirect', $user->data['session_page']);

	$redirect = $request->variable('redirect', $user->data['session_page']);


meta_refresh(3, $redirect);
trigger_error($msg . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));


meta_refresh(3, $redirect);
trigger_error($msg . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));

Line 365Line 404
*/
function merge_topics($forum_id, $topic_ids, $to_topic_id)
{

*/
function merge_topics($forum_id, $topic_ids, $to_topic_id)
{

	global $db, $template, $user, $phpEx, $phpbb_root_path, $auth;

	global $db, $template, $user, $phpEx, $phpbb_root_path, $phpbb_log, $request, $phpbb_dispatcher;


if (!sizeof($topic_ids))
{


if (!sizeof($topic_ids))
{

Line 380Line 419

$sync_topics = array_merge($topic_ids, array($to_topic_id));



$sync_topics = array_merge($topic_ids, array($to_topic_id));


	$topic_data = phpbb_get_topic_data($sync_topics, 'm_merge');

	$all_topic_data = phpbb_get_topic_data($sync_topics, 'm_merge');





	if (!sizeof($topic_data) || empty($topic_data[$to_topic_id]))

	if (!sizeof($all_topic_data) || empty($all_topic_data[$to_topic_id]))

	{
$template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
return;
}

$sync_forums = array();

	{
$template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
return;
}

$sync_forums = array();

	foreach ($topic_data as $data)


	$topic_views = 0;
foreach ($all_topic_data as $data)

	{
$sync_forums[$data['forum_id']] = $data['forum_id'];

	{
$sync_forums[$data['forum_id']] = $data['forum_id'];

 
		$topic_views = max($topic_views, $data['topic_views']);

	}


	}


	$topic_data = $topic_data[$to_topic_id];

	$to_topic_data = $all_topic_data[$to_topic_id];





	$post_id_list	= request_var('post_id_list', array(0));
$start = request_var('start', 0);

	$post_id_list	= $request->variable('post_id_list', array(0));
$start = $request->variable('start', 0);


if (!sizeof($post_id_list) && sizeof($topic_ids))
{


if (!sizeof($post_id_list) && sizeof($topic_ids))
{

Line 425Line 466
		return;
}


		return;
}


	$redirect = request_var('redirect', build_url(array('quickmod')));

	$redirect = $request->variable('redirect', "{$phpbb_root_path}mcp.$phpEx?f=$forum_id&amp;i=main&amp;mode=forum_view");


$s_hidden_fields = build_hidden_fields(array(
'i' => 'main',


$s_hidden_fields = build_hidden_fields(array(
'i' => 'main',

Line 438Line 479
		'redirect'		=> $redirect,
'topic_id_list' => $topic_ids)
);

		'redirect'		=> $redirect,
'topic_id_list' => $topic_ids)
);

	$success_msg = $return_link = '';

	$return_link = '';


if (confirm_box(true))
{


if (confirm_box(true))
{

		$to_forum_id = $topic_data['forum_id'];

		$to_forum_id = $to_topic_data['forum_id'];


move_posts($post_id_list, $to_topic_id, false);


move_posts($post_id_list, $to_topic_id, false);

		add_log('mod', $to_forum_id, $to_topic_id, 'LOG_MERGE', $topic_data['topic_title']);













$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_MERGE', false, array(
'forum_id' => $to_forum_id,
'topic_id' => $to_topic_id,
$to_topic_data['topic_title']
));

// Update topic views count
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_views = ' . $topic_views . '
WHERE topic_id = ' . $to_topic_id;
$db->sql_query($sql);


// Message and return links
$success_msg = 'POSTS_MERGED_SUCCESS';


// Message and return links
$success_msg = 'POSTS_MERGED_SUCCESS';

Line 469Line 521

// Link to the new topic
$return_link .= (($return_link) ? '<br /><br />' : '') . sprintf($user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_forum_id . '&amp;t=' . $to_topic_id) . '">', '</a>');


// Link to the new topic
$return_link .= (($return_link) ? '<br /><br />' : '') . sprintf($user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_forum_id . '&amp;t=' . $to_topic_id) . '">', '</a>');

		$redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&amp;t=$to_topic_id");

		$redirect = $request->variable('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&amp;t=$to_topic_id");

		$redirect = reapply_sid($redirect);

		$redirect = reapply_sid($redirect);

 

/**
* Perform additional actions after merging topics.
*
* @event core.mcp_forum_merge_topics_after
* @var array all_topic_data The data from all topics involved in the merge
* @var int to_topic_id The ID of the topic into which the rest are merged
* @since 3.1.11-RC1
*/
$vars = array(
'all_topic_data',
'to_topic_id',
);
extract($phpbb_dispatcher->trigger_event('core.mcp_forum_merge_topics_after', compact($vars)));


meta_refresh(3, $redirect);
trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link);


meta_refresh(3, $redirect);
trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link);