diff options
Diffstat (limited to 'phpBB/includes/mcp/mcp_forum.php')
| -rw-r--r-- | phpBB/includes/mcp/mcp_forum.php | 79 | 
1 files changed, 46 insertions, 33 deletions
diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index 04e0e70f1d..d0d13aaf13 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -2,9 +2,8 @@  /**  *  * @package mcp -* @version $Id$  * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2  *  */ @@ -23,6 +22,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info)  {  	global $template, $db, $user, $auth, $cache, $module;  	global $phpEx, $phpbb_root_path, $config; +	global $request, $phpbb_dispatcher, $phpbb_container;  	$user->add_lang(array('viewtopic', 'viewforum')); @@ -34,7 +34,10 @@ function mcp_forum_view($id, $mode, $action, $forum_info)  	if ($merge_select)  	{  		// Fixes a "bug" that makes forum_view use the same ordering as topic_view -		unset($_POST['sk'], $_POST['sd'], $_REQUEST['sk'], $_REQUEST['sd']); +		$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']; @@ -95,9 +98,12 @@ function mcp_forum_view($id, $mode, $action, $forum_info)  	$sort_by_sql = $sort_order_sql = array();  	mcp_sorting('viewforum', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id); -	$forum_topics = ($total == -1) ? $forum_info['forum_topics'] : $total; +	$forum_topics = ($total == -1) ? $forum_info['forum_topics_approved'] : $total;  	$limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : ''; +	$base_url = $url . "&i=$id&action=$action&mode=$mode&sd=$sort_dir&sk=$sort_key&st=$sort_days" . (($merge_select) ? $selected_ids : ''); +	phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $forum_topics, $topics_per_page, $start); +  	$template->assign_vars(array(  		'ACTION'				=> $action,  		'FORUM_NAME'			=> $forum_info['forum_name'], @@ -110,6 +116,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info)  		'S_CAN_REPORT'			=> $auth->acl_get('m_report', $forum_id),  		'S_CAN_DELETE'			=> $auth->acl_get('m_delete', $forum_id), +		'S_CAN_RESTORE'			=> $auth->acl_get('m_approve', $forum_id),  		'S_CAN_MERGE'			=> $auth->acl_get('m_merge', $forum_id),  		'S_CAN_MOVE'			=> $auth->acl_get('m_move', $forum_id),  		'S_CAN_FORK'			=> $auth->acl_get('m_', $forum_id), @@ -126,9 +133,8 @@ function mcp_forum_view($id, $mode, $action, $forum_info)  		'S_MCP_ACTION'			=> $url . "&i=$id&forum_action=$action&mode=$mode&start=$start" . (($merge_select) ? $selected_ids : ''), -		'PAGINATION'			=> generate_pagination($url . "&i=$id&action=$action&mode=$mode&sd=$sort_dir&sk=$sort_key&st=$sort_days" . (($merge_select) ? $selected_ids : ''), $forum_topics, $topics_per_page, $start), -		'PAGE_NUMBER'			=> on_page($forum_topics, $topics_per_page, $start), -		'TOTAL_TOPICS'			=> ($forum_topics == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $forum_topics), +		'PAGE_NUMBER'			=> phpbb_on_page($template, $user, $base_url, $forum_topics, $topics_per_page, $start), +		'TOTAL_TOPICS'			=> $user->lang('VIEW_FORUM_TOPICS', (int) $forum_topics),  	));  	// Grab icons @@ -146,10 +152,12 @@ function mcp_forum_view($id, $mode, $action, $forum_info)  		$read_tracking_join = $read_tracking_select = '';  	} -	$sql = "SELECT t.topic_id -		FROM " . TOPICS_TABLE . " t -		WHERE t.forum_id IN($forum_id, 0) -			" . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1') . " +	$phpbb_content_visibility = $phpbb_container->get('content.visibility'); + +	$sql = 'SELECT t.topic_id +		FROM ' . TOPICS_TABLE . ' t +		WHERE t.forum_id = ' . $forum_id . ' +			AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.') . "  			$limit_time_sql  		ORDER BY t.topic_type DESC, $sort_order_sql";  	$result = $db->sql_query_limit($sql, $topics_per_page, $start); @@ -184,11 +192,11 @@ function mcp_forum_view($id, $mode, $action, $forum_info)  	{  		if ($config['load_db_lastread'])  		{ -			$topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time']), array()); +			$topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time']));  		}  		else  		{ -			$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list, array()); +			$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list);  		}  	} @@ -198,7 +206,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info)  		$row = &$topic_rows[$topic_id]; -		$replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies']; +		$replies = $phpbb_content_visibility->get_count('topic_posts', $row, $forum_id) - 1;  		if ($row['topic_status'] == ITEM_MOVED)  		{ @@ -215,18 +223,21 @@ function mcp_forum_view($id, $mode, $action, $forum_info)  		$topic_title = censor_text($row['topic_title']); -		$topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false; -		$posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false; +		$topic_unapproved = ($row['topic_visibility'] == ITEM_UNAPPROVED  && $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'] : ''; +		$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']) : '', +			'TOPIC_IMG_STYLE'		=> $folder_img,  			'TOPIC_FOLDER_IMG'		=> $user->img($folder_img, $folder_alt), -			'TOPIC_FOLDER_IMG_SRC'	=> $user->img($folder_img, $folder_alt, false, '', 'src'),  			'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'] : '',  			'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') : '',  			'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']), @@ -240,7 +251,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info)  			'TOPIC_TYPE'		=> $topic_type,  			'TOPIC_TITLE'		=> $topic_title, -			'REPLIES'			=> ($auth->acl_get('m_approve', $row['forum_id'])) ? $row['topic_replies_real'] : $row['topic_replies'], +			'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'], @@ -249,6 +260,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info)  			'S_TOPIC_REPORTED'		=> (!empty($row['topic_reported']) && empty($row['topic_moved_id']) && $auth->acl_get('m_report', $row['forum_id'])) ? true : false,  			'S_TOPIC_UNAPPROVED'	=> $topic_unapproved,  			'S_POSTS_UNAPPROVED'	=> $posts_unapproved, +			'S_TOPIC_DELETED'		=> $topic_deleted,  			'S_UNREAD_TOPIC'		=> $unread_topic,  		); @@ -283,6 +295,17 @@ function mcp_forum_view($id, $mode, $action, $forum_info)  			));  		} +		/** +		* 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	topic_row	Template array with topic data +		* @since 3.1-A1 +		*/ +		$vars = array('row', 'topic_row'); +		extract($phpbb_dispatcher->trigger_event('core.mcp_view_forum_modify_topicrow', compact($vars))); +  		$template->assign_block_vars('topicrow', $topic_row);  	}  	unset($topic_rows); @@ -427,24 +450,14 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id)  		// 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 . '&t=' . $to_topic_id) . '">', '</a>'); -	} -	else -	{ -		confirm_box(false, 'MERGE_TOPICS', $s_hidden_fields); -	} +		$redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id"); +		$redirect = reapply_sid($redirect); -	$redirect = request_var('redirect', "index.$phpEx"); -	$redirect = reapply_sid($redirect); - -	if (!$success_msg) -	{ -		return; +		meta_refresh(3, $redirect); +		trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link);  	}  	else  	{ -		meta_refresh(3, append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$to_forum_id&t=$to_topic_id")); -		trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link); +		confirm_box(false, 'MERGE_TOPICS', $s_hidden_fields);  	}  } - -?>
\ No newline at end of file  | 
