Ejemplo n.º 1
0
/**
* View topic in MCP
*/
function mcp_topic_view($id, $mode, $action)
{
    global $phpEx, $phpbb_root_path, $config;
    global $template, $db, $user, $auth, $cache;
    $url = append_sid("{$phpbb_root_path}mcp.{$phpEx}?" . extra_url());
    $user->add_lang('viewtopic');
    $topic_id = request_var('t', 0);
    $topic_info = get_topic_data(array($topic_id), false, true);
    if (!sizeof($topic_info)) {
        trigger_error('TOPIC_NOT_EXIST');
    }
    $topic_info = $topic_info[$topic_id];
    // Set up some vars
    $icon_id = request_var('icon', 0);
    $subject = utf8_normalize_nfc(request_var('subject', '', true));
    $start = request_var('start', 0);
    $sort_days_old = request_var('st_old', 0);
    $forum_id = request_var('f', 0);
    $to_topic_id = request_var('to_topic_id', 0);
    $to_forum_id = request_var('to_forum_id', 0);
    $sort = isset($_POST['sort']) ? true : false;
    $submitted_id_list = request_var('post_ids', array(0));
    $checked_ids = $post_id_list = request_var('post_id_list', array(0));
    // Resync Topic?
    if ($action == 'resync') {
        if (!function_exists('mcp_resync_topics')) {
            include $phpbb_root_path . 'includes/mcp/mcp_forum.' . $phpEx;
        }
        mcp_resync_topics(array($topic_id));
    }
    // Split Topic?
    if ($action == 'split_all' || $action == 'split_beyond') {
        if (!$sort) {
            split_topic($action, $topic_id, $to_forum_id, $subject);
        }
        $action = 'split';
    }
    // Merge Posts?
    if ($action == 'merge_posts') {
        if (!$sort) {
            merge_posts($topic_id, $to_topic_id);
        }
        $action = 'merge';
    }
    if ($action == 'split' && !$subject) {
        $subject = $topic_info['topic_title'];
    }
    // Approve posts?
    if ($action == 'approve' && $auth->acl_get('m_approve', $topic_info['forum_id'])) {
        include $phpbb_root_path . 'includes/mcp/mcp_queue.' . $phpEx;
        include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx;
        include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
        if (!sizeof($post_id_list)) {
            trigger_error('NO_POST_SELECTED');
        }
        if (!$sort) {
            approve_post($post_id_list, $id, $mode);
        }
    }
    // Jumpbox, sort selects and that kind of things
    make_jumpbox($url . "&i={$id}&mode=forum_view", $topic_info['forum_id'], false, 'm_', true);
    $where_sql = $action == 'reports' ? 'WHERE post_reported = 1 AND ' : 'WHERE';
    $sort_days = $total = 0;
    $sort_key = $sort_dir = '';
    $sort_by_sql = $sort_order_sql = array();
    mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $topic_info['forum_id'], $topic_id, $where_sql);
    $limit_time_sql = $sort_days ? 'AND p.post_time >= ' . (time() - $sort_days * 86400) : '';
    if ($total == -1) {
        if ($auth->acl_get('m_approve', $topic_info['forum_id'])) {
            $total = $topic_info['topic_replies_real'] + 1;
        } else {
            $total = $topic_info['topic_replies'] + 1;
        }
    }
    $posts_per_page = max(0, request_var('posts_per_page', intval($config['posts_per_page'])));
    if ($posts_per_page == 0) {
        $posts_per_page = $total;
    }
    if (!empty($sort_days_old) && $sort_days_old != $sort_days || $total <= $posts_per_page) {
        $start = 0;
    }
    // Make sure $start is set to the last page if it exceeds the amount
    if ($start < 0 || $start >= $total) {
        $start = $start < 0 ? 0 : floor(($total - 1) / $posts_per_page) * $posts_per_page;
    }
    $sql = 'SELECT u.username, u.username_clean, u.user_colour, p.*
		FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
		WHERE ' . ($action == 'reports' ? 'p.post_reported = 1 AND ' : '') . '
			p.topic_id = ' . $topic_id . ' ' . (!$auth->acl_get('m_approve', $topic_info['forum_id']) ? ' AND p.post_approved = 1 ' : '') . '
			AND p.poster_id = u.user_id ' . $limit_time_sql . '
		ORDER BY ' . $sort_order_sql;
    $result = $db->sql_query_limit($sql, $posts_per_page, $start);
    $rowset = $post_id_list = array();
    $bbcode_bitfield = '';
    while ($row = $db->sql_fetchrow($result)) {
        $rowset[] = $row;
        $post_id_list[] = $row['post_id'];
        $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);
    }
    $db->sql_freeresult($result);
    if ($bbcode_bitfield !== '') {
        include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx;
        $bbcode = new bbcode(base64_encode($bbcode_bitfield));
    }
    $topic_tracking_info = array();
    // Get topic tracking info
    if ($config['load_db_lastread']) {
        $tmp_topic_data = array($topic_id => $topic_info);
        $topic_tracking_info = get_topic_tracking($topic_info['forum_id'], $topic_id, $tmp_topic_data, array($topic_info['forum_id'] => $topic_info['forum_mark_time']));
        unset($tmp_topic_data);
    } else {
        $topic_tracking_info = get_complete_topic_tracking($topic_info['forum_id'], $topic_id);
    }
    $has_unapproved_posts = false;
    // Grab extensions
    $extensions = $attachments = array();
    if ($topic_info['topic_attachment'] && sizeof($post_id_list)) {
        $extensions = $cache->obtain_attach_extensions($topic_info['forum_id']);
        // Get attachments...
        if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_info['forum_id'])) {
            $sql = 'SELECT *
				FROM ' . ATTACHMENTS_TABLE . '
				WHERE ' . $db->sql_in_set('post_msg_id', $post_id_list) . '
					AND in_message = 0
				ORDER BY filetime DESC, post_msg_id ASC';
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $attachments[$row['post_msg_id']][] = $row;
            }
            $db->sql_freeresult($result);
        }
    }
    foreach ($rowset as $i => $row) {
        $message = $row['post_text'];
        $post_subject = $row['post_subject'] != '' ? $row['post_subject'] : $topic_info['topic_title'];
        if ($row['bbcode_bitfield']) {
            $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
        }
        $message = bbcode_nl2br($message);
        $message = smiley_text($message);
        if (!empty($attachments[$row['post_id']])) {
            $update_count = array();
            parse_attachments($topic_info['forum_id'], $message, $attachments[$row['post_id']], $update_count);
        }
        if (!$row['post_approved']) {
            $has_unapproved_posts = true;
        }
        $post_unread = isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id] ? true : false;
        $template->assign_block_vars('postrow', array('POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_DATE' => $user->format_date($row['post_time']), 'POST_SUBJECT' => $post_subject, 'MESSAGE' => $message, 'POST_ID' => $row['post_id'], 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 't=' . $topic_id) . '">', '</a>'), 'MINI_POST_IMG' => $post_unread ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'S_POST_REPORTED' => $row['post_reported'] && $auth->acl_get('m_report', $topic_info['forum_id']), 'S_POST_UNAPPROVED' => !$row['post_approved'] && $auth->acl_get('m_approve', $topic_info['forum_id']), 'S_CHECKED' => $submitted_id_list && !in_array(intval($row['post_id']), $submitted_id_list) || in_array(intval($row['post_id']), $checked_ids) ? true : false, 'S_HAS_ATTACHMENTS' => !empty($attachments[$row['post_id']]) ? true : false, 'U_POST_DETAILS' => "{$url}&amp;i={$id}&amp;p={$row['post_id']}&amp;mode=post_details" . ($forum_id ? "&amp;f={$forum_id}" : ''), 'U_MCP_APPROVE' => $auth->acl_get('m_approve', $topic_info['forum_id']) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&amp;mode=approve_details&amp;f=' . $topic_info['forum_id'] . '&amp;p=' . $row['post_id']) : '', 'U_MCP_REPORT' => $auth->acl_get('m_report', $topic_info['forum_id']) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&amp;mode=report_details&amp;f=' . $topic_info['forum_id'] . '&amp;p=' . $row['post_id']) : ''));
        // Display not already displayed Attachments for this post, we already parsed them. ;)
        if (!empty($attachments[$row['post_id']])) {
            foreach ($attachments[$row['post_id']] as $attachment) {
                $template->assign_block_vars('postrow.attachment', array('DISPLAY_ATTACHMENT' => $attachment));
            }
        }
        unset($rowset[$i]);
    }
    // Display topic icons for split topic
    $s_topic_icons = false;
    if ($auth->acl_gets('m_split', 'm_merge', (int) $topic_info['forum_id'])) {
        include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx;
        $s_topic_icons = posting_gen_topic_icons('', $icon_id);
        // Has the user selected a topic for merge?
        if ($to_topic_id) {
            $to_topic_info = get_topic_data(array($to_topic_id), 'm_merge');
            if (!sizeof($to_topic_info)) {
                $to_topic_id = 0;
            } else {
                $to_topic_info = $to_topic_info[$to_topic_id];
                if (!$to_topic_info['enable_icons'] || $auth->acl_get('!f_icons', $topic_info['forum_id'])) {
                    $s_topic_icons = false;
                }
            }
        }
    }
    $s_hidden_fields = build_hidden_fields(array('st_old' => $sort_days, 'post_ids' => $post_id_list));
    $template->assign_vars(array('TOPIC_TITLE' => $topic_info['topic_title'], 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $topic_info['forum_id'] . '&amp;t=' . $topic_info['topic_id']), 'TO_TOPIC_ID' => $to_topic_id, 'TO_TOPIC_INFO' => $to_topic_id ? sprintf($user->lang['YOU_SELECTED_TOPIC'], $to_topic_id, '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $to_topic_info['forum_id'] . '&amp;t=' . $to_topic_id) . '">' . $to_topic_info['topic_title'] . '</a>') : '', 'SPLIT_SUBJECT' => $subject, 'POSTS_PER_PAGE' => $posts_per_page, 'ACTION' => $action, 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'), 'S_MCP_ACTION' => "{$url}&amp;i={$id}&amp;mode={$mode}&amp;action={$action}&amp;start={$start}", 'S_FORUM_SELECT' => $to_forum_id ? make_forum_select($to_forum_id, false, false, true, true, true) : make_forum_select($topic_info['forum_id'], false, false, true, true, true), 'S_CAN_SPLIT' => $auth->acl_get('m_split', $topic_info['forum_id']) ? true : false, 'S_CAN_MERGE' => $auth->acl_get('m_merge', $topic_info['forum_id']) ? true : false, 'S_CAN_DELETE' => $auth->acl_get('m_delete', $topic_info['forum_id']) ? true : false, 'S_CAN_APPROVE' => $has_unapproved_posts && $auth->acl_get('m_approve', $topic_info['forum_id']) ? true : false, 'S_CAN_LOCK' => $auth->acl_get('m_lock', $topic_info['forum_id']) ? true : false, 'S_CAN_REPORT' => $auth->acl_get('m_report', $topic_info['forum_id']) ? true : false, 'S_CAN_SYNC' => $auth->acl_get('m_', $topic_info['forum_id']), 'S_REPORT_VIEW' => $action == 'reports' ? true : false, 'S_MERGE_VIEW' => $action == 'merge' ? true : false, 'S_SPLIT_VIEW' => $action == 'split' ? true : false, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, 'S_TOPIC_ICON' => $icon_id, 'U_SELECT_TOPIC' => "{$url}&amp;i={$id}&amp;mode=forum_view&amp;action=merge_select" . ($forum_id ? "&amp;f={$forum_id}" : ''), 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$topic_info['forum_id']}&amp;t={$topic_info['topic_id']}&amp;start={$start}") . '">', '</a>'), 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.{$phpEx}", "f={$topic_info['forum_id']}&amp;start={$start}") . '">', '</a>'), 'PAGE_NUMBER' => on_page($total, $posts_per_page, $start), 'PAGINATION' => !$posts_per_page ? '' : generate_pagination(append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&amp;t={$topic_info['topic_id']}&amp;mode={$mode}&amp;action={$action}&amp;to_topic_id={$to_topic_id}&amp;posts_per_page={$posts_per_page}&amp;st={$sort_days}&amp;sk={$sort_key}&amp;sd={$sort_dir}"), $total, $posts_per_page, $start), 'TOTAL_POSTS' => $total == 1 ? $user->lang['VIEW_TOPIC_POST'] : sprintf($user->lang['VIEW_TOPIC_POSTS'], $total)));
}
Ejemplo n.º 2
0
/**
* MCP Forum View
*/
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'));
    include_once $phpbb_root_path . 'includes/functions_display.' . $phpEx;
    // 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;
    $forum_id = $forum_info['forum_id'];
    $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 ? "&amp;f={$forum_id}" : '';
    $url_extra .= $GLOBALS['topic_id'] ? '&amp;t=' . $GLOBALS['topic_id'] : '';
    $url_extra .= $GLOBALS['post_id'] ? '&amp;p=' . $GLOBALS['post_id'] : '';
    $url_extra .= $GLOBALS['user_id'] ? '&amp;u=' . $GLOBALS['user_id'] : '';
    $url = append_sid("{$phpbb_root_path}mcp.{$phpEx}?{$url_extra}");
    // Resync Topics
    switch ($action) {
        case 'resync':
            $topic_ids = $request->variable('topic_id_list', array(0));
            mcp_resync_topics($topic_ids);
            break;
        case 'merge_topics':
            $source_topic_ids = $topic_id_list;
        case 'merge_topic':
            if ($to_topic_id) {
                merge_topics($forum_id, $source_topic_ids, $to_topic_id);
            }
            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 = '';
    if (sizeof($post_id_list) && $action != 'merge_topics') {
        foreach ($post_id_list as $num => $post_id) {
            $selected_ids .= '&amp;post_id_list[' . $num . ']=' . $post_id;
        }
    } else {
        if (sizeof($topic_id_list) && $action == 'merge_topics') {
            foreach ($topic_id_list as $num => $topic_id) {
                $selected_ids .= '&amp;topic_id_list[' . $num . ']=' . $topic_id;
            }
        }
    }
    make_jumpbox($url . "&amp;i={$id}&amp;action={$action}&amp;mode={$mode}" . ($merge_select ? $selected_ids : ''), $forum_id, false, 'm_', true);
    $topics_per_page = $forum_info['forum_topics_per_page'] ? $forum_info['forum_topics_per_page'] : $config['topics_per_page'];
    $sort_days = $total = 0;
    $sort_key = $sort_dir = '';
    $sort_by_sql = $sort_order_sql = array();
    phpbb_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_approved'] : $total;
    $limit_time_sql = $sort_days ? 'AND t.topic_last_post_time >= ' . (time() - $sort_days * 86400) : '';
    $base_url = $url . "&amp;i={$id}&amp;action={$action}&amp;mode={$mode}&amp;sd={$sort_dir}&amp;sk={$sort_key}&amp;st={$sort_days}" . ($merge_select ? $selected_ids : '');
    $pagination->generate_template_pagination($base_url, 'pagination', 'start', $forum_topics, $topics_per_page, $start);
    $template->assign_vars(array('ACTION' => $action, 'FORUM_NAME' => $forum_info['forum_name'], 'FORUM_DESCRIPTION' => generate_text_for_display($forum_info['forum_desc'], $forum_info['forum_desc_uid'], $forum_info['forum_desc_bitfield'], $forum_info['forum_desc_options']), 'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'), 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), '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), 'S_CAN_LOCK' => $auth->acl_get('m_lock', $forum_id), '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', '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_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&amp;mode=forum_logs&amp;f=' . $forum_id) : '', 'S_MCP_ACTION' => $url . "&amp;i={$id}&amp;forum_action={$action}&amp;mode={$mode}&amp;start={$start}" . ($merge_select ? $selected_ids : ''), 'TOTAL_TOPICS' => $user->lang('VIEW_FORUM_TOPICS', (int) $forum_topics)));
    // Grab icons
    $icons = $cache->obtain_icons();
    $topic_rows = array();
    if ($config['load_db_lastread']) {
        $read_tracking_join = ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . ')';
        $read_tracking_select = ', tt.mark_time';
    } else {
        $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
		FROM ' . TOPICS_TABLE . ' t
		WHERE t.forum_id = ' . $forum_id . '
			AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.') . "\n\t\t\t{$limit_time_sql}\n\t\tORDER 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();
    while ($row_ary = $db->sql_fetchrow($result)) {
        $topic_list[] = $row_ary['topic_id'];
    }
    $db->sql_freeresult($result);
    $sql = "SELECT t.*{$read_tracking_select}\n\t\tFROM " . TOPICS_TABLE . " t {$read_tracking_join}\n\t\tWHERE " . $db->sql_in_set('t.topic_id', $topic_list, false, true);
    $result = $db->sql_query($sql);
    while ($row_ary = $db->sql_fetchrow($result)) {
        $topic_rows[$row_ary['topic_id']] = $row_ary;
    }
    $db->sql_freeresult($result);
    // If there is more than one page, but we have no topic list, then the start parameter is... erm... out of sync
    if (!sizeof($topic_list) && $forum_topics && $start > 0) {
        redirect($url . "&amp;i={$id}&amp;action={$action}&amp;mode={$mode}");
    }
    // Get topic tracking info
    if (sizeof($topic_list)) {
        if ($config['load_db_lastread']) {
            $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);
        }
    }
    foreach ($topic_list as $topic_id) {
        $row_ary =& $topic_rows[$topic_id];
        $replies = $phpbb_content_visibility->get_count('topic_posts', $row_ary, $forum_id) - 1;
        if ($row_ary['topic_status'] == ITEM_MOVED) {
            $unread_topic = false;
        } else {
            $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 = '';
        topic_status($row_ary, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);
        $topic_title = censor_text($row_ary['topic_title']);
        $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 . '&amp;i=queue&amp;mode=' . ($topic_unapproved ? 'approve_details' : 'unapproved_posts') . '&amp;t=' . $row_ary['topic_id'] : '';
        $u_mcp_queue = !$u_mcp_queue && $topic_deleted ? $url . '&amp;i=queue&amp;mode=deleted_topics&amp;t=' . $topic_id : $u_mcp_queue;
        $topic_row = array('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_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') : '', 'DELETED_IMG' => $topic_deleted ? $user->img('icon_topic_deleted', 'POSTS_DELETED') : '', '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_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, '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_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);
        if ($row_ary['topic_status'] == ITEM_MOVED) {
            $topic_row = array_merge($topic_row, array('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}&amp;f={$forum_id}&amp;topic_id_list[]={$row_ary['topic_id']}&amp;mode=forum_view&amp;action=delete_topic") : '', 'S_MOVED_TOPIC' => true, 'TOPIC_ID' => $row_ary['topic_moved_id']));
        } else {
            if ($action == 'merge_topic' || $action == 'merge_topics') {
                $u_select_topic = $url . "&amp;i={$id}&amp;mode=forum_view&amp;action={$action}&amp;to_topic_id=" . $row_ary['topic_id'] . $selected_ids;
            } else {
                $u_select_topic = $url . "&amp;i={$id}&amp;mode=topic_view&amp;action=merge&amp;to_topic_id=" . $row_ary['topic_id'] . $selected_ids;
            }
            $topic_row = array_merge($topic_row, array('U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&amp;f={$forum_id}&amp;t={$row_ary['topic_id']}&amp;mode=topic_view"), '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_MCP_REPORT' => $auth->acl_get('m_report', $forum_id) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main&amp;mode=topic_view&amp;t=' . $row_ary['topic_id'] . '&amp;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
         * @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)));
        $row_ary = $row;
        unset($row);
        $template->assign_block_vars('topicrow', $topic_row);
    }
    unset($topic_rows);
}
Ejemplo n.º 3
0
/**
* View topic in MCP
*/
function mcp_topic_view($id, $mode, $action)
{
    global $phpEx, $src_root_path, $config;
    global $template, $db, $user, $auth, $cache, $src_container, $src_dispatcher;
    $url = append_sid("{$src_root_path}mcp.{$phpEx}?" . src_extra_url());
    $user->add_lang('viewtopic');
    $pagination = $src_container->get('pagination');
    $topic_id = request_var('t', 0);
    $topic_info = src_get_topic_data(array($topic_id), false, true);
    if (!sizeof($topic_info)) {
        trigger_error('TOPIC_NOT_EXIST');
    }
    $topic_info = $topic_info[$topic_id];
    // Set up some vars
    $icon_id = request_var('icon', 0);
    $subject = utf8_normalize_nfc(request_var('subject', '', true));
    $start = request_var('start', 0);
    $sort_days_old = request_var('st_old', 0);
    $forum_id = request_var('f', 0);
    $to_topic_id = request_var('to_topic_id', 0);
    $to_forum_id = request_var('to_forum_id', 0);
    $sort = isset($_POST['sort']) ? true : false;
    $submitted_id_list = request_var('post_ids', array(0));
    $checked_ids = $post_id_list = request_var('post_id_list', array(0));
    // Resync Topic?
    if ($action == 'resync') {
        if (!function_exists('mcp_resync_topics')) {
            include $src_root_path . 'includes/mcp/mcp_forum.' . $phpEx;
        }
        mcp_resync_topics(array($topic_id));
    }
    // Split Topic?
    if ($action == 'split_all' || $action == 'split_beyond') {
        if (!$sort) {
            split_topic($action, $topic_id, $to_forum_id, $subject);
        }
        $action = 'split';
    }
    // Merge Posts?
    if ($action == 'merge_posts') {
        if (!$sort) {
            merge_posts($topic_id, $to_topic_id);
        }
        $action = 'merge';
    }
    if ($action == 'split' && !$subject) {
        $subject = $topic_info['topic_title'];
    }
    // Restore or pprove posts?
    if (($action == 'restore' || $action == 'approve') && $auth->acl_get('m_approve', $topic_info['forum_id'])) {
        include $src_root_path . 'includes/mcp/mcp_queue.' . $phpEx;
        include_once $src_root_path . 'includes/functions_posting.' . $phpEx;
        include_once $src_root_path . 'includes/functions_messenger.' . $phpEx;
        if (!sizeof($post_id_list)) {
            trigger_error('NO_POST_SELECTED');
        }
        if (!$sort) {
            mcp_queue::approve_posts($action, $post_id_list, $id, $mode);
        }
    }
    // Jumpbox, sort selects and that kind of things
    make_jumpbox($url . "&amp;i={$id}&amp;mode=forum_view", $topic_info['forum_id'], false, 'm_', true);
    $where_sql = $action == 'reports' ? 'WHERE post_reported = 1 AND ' : 'WHERE';
    $sort_days = $total = 0;
    $sort_key = $sort_dir = '';
    $sort_by_sql = $sort_order_sql = array();
    src_mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $topic_info['forum_id'], $topic_id, $where_sql);
    $limit_time_sql = $sort_days ? 'AND p.post_time >= ' . (time() - $sort_days * 86400) : '';
    $src_content_visibility = $src_container->get('content.visibility');
    if ($total == -1) {
        $total = $src_content_visibility->get_count('topic_posts', $topic_info, $topic_info['forum_id']);
    }
    $posts_per_page = max(0, request_var('posts_per_page', intval($config['posts_per_page'])));
    if ($posts_per_page == 0) {
        $posts_per_page = $total;
    }
    if (!empty($sort_days_old) && $sort_days_old != $sort_days || $total <= $posts_per_page) {
        $start = 0;
    }
    $start = $pagination->validate_start($start, $posts_per_page, $total);
    $sql = 'SELECT u.username, u.username_clean, u.user_colour, p.*
		FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
		WHERE ' . ($action == 'reports' ? 'p.post_reported = 1 AND ' : '') . '
			p.topic_id = ' . $topic_id . '
			AND ' . $src_content_visibility->get_visibility_sql('post', $topic_info['forum_id'], 'p.') . '
			AND p.poster_id = u.user_id ' . $limit_time_sql . '
		ORDER BY ' . $sort_order_sql;
    $result = $db->sql_query_limit($sql, $posts_per_page, $start);
    $rowset = $post_id_list = array();
    while ($row = $db->sql_fetchrow($result)) {
        $rowset[] = $row;
        $post_id_list[] = $row['post_id'];
    }
    $db->sql_freeresult($result);
    $topic_tracking_info = array();
    // Get topic tracking info
    if ($config['load_db_lastread']) {
        $tmp_topic_data = array($topic_id => $topic_info);
        $topic_tracking_info = get_topic_tracking($topic_info['forum_id'], $topic_id, $tmp_topic_data, array($topic_info['forum_id'] => $topic_info['forum_mark_time']));
        unset($tmp_topic_data);
    } else {
        $topic_tracking_info = get_complete_topic_tracking($topic_info['forum_id'], $topic_id);
    }
    $has_unapproved_posts = $has_deleted_posts = false;
    // Grab extensions
    $extensions = $attachments = array();
    if ($topic_info['topic_attachment'] && sizeof($post_id_list)) {
        $extensions = $cache->obtain_attach_extensions($topic_info['forum_id']);
        // Get attachments...
        if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_info['forum_id'])) {
            $sql = 'SELECT *
				FROM ' . ATTACHMENTS_TABLE . '
				WHERE ' . $db->sql_in_set('post_msg_id', $post_id_list) . '
					AND in_message = 0
				ORDER BY filetime DESC, post_msg_id ASC';
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $attachments[$row['post_msg_id']][] = $row;
            }
            $db->sql_freeresult($result);
        }
    }
    foreach ($rowset as $i => $row) {
        $message = $row['post_text'];
        $post_subject = $row['post_subject'] != '' ? $row['post_subject'] : $topic_info['topic_title'];
        $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES;
        $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, false);
        if (!empty($attachments[$row['post_id']])) {
            $update_count = array();
            parse_attachments($topic_info['forum_id'], $message, $attachments[$row['post_id']], $update_count);
        }
        if ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) {
            $has_unapproved_posts = true;
        }
        if ($row['post_visibility'] == ITEM_DELETED) {
            $has_deleted_posts = true;
        }
        $post_unread = isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id] ? true : false;
        $post_row = array('POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_DATE' => $user->format_date($row['post_time']), 'POST_SUBJECT' => $post_subject, 'MESSAGE' => $message, 'POST_ID' => $row['post_id'], 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$src_root_path}viewtopic.{$phpEx}", 't=' . $topic_id) . '">', '</a>'), 'MINI_POST_IMG' => $post_unread ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'S_POST_REPORTED' => $row['post_reported'] && $auth->acl_get('m_report', $topic_info['forum_id']), 'S_POST_UNAPPROVED' => ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $topic_info['forum_id']), 'S_POST_DELETED' => $row['post_visibility'] == ITEM_DELETED && $auth->acl_get('m_approve', $topic_info['forum_id']), 'S_CHECKED' => $submitted_id_list && !in_array(intval($row['post_id']), $submitted_id_list) || in_array(intval($row['post_id']), $checked_ids) ? true : false, 'S_HAS_ATTACHMENTS' => !empty($attachments[$row['post_id']]) ? true : false, 'U_POST_DETAILS' => "{$url}&amp;i={$id}&amp;p={$row['post_id']}&amp;mode=post_details" . ($forum_id ? "&amp;f={$forum_id}" : ''), 'U_MCP_APPROVE' => $auth->acl_get('m_approve', $topic_info['forum_id']) ? append_sid("{$src_root_path}mcp.{$phpEx}", 'i=queue&amp;mode=approve_details&amp;f=' . $topic_info['forum_id'] . '&amp;p=' . $row['post_id']) : '', 'U_MCP_REPORT' => $auth->acl_get('m_report', $topic_info['forum_id']) ? append_sid("{$src_root_path}mcp.{$phpEx}", 'i=reports&amp;mode=report_details&amp;f=' . $topic_info['forum_id'] . '&amp;p=' . $row['post_id']) : '');
        $current_row_number = $i;
        /**
         * Event to modify the template data block for topic reviews in the MCP
         *
         * @event core.mcp_topic_review_modify_row
         * @var	int		id					ID of the tab we are displaying
         * @var	string	mode				Mode of the MCP page we are displaying
         * @var	int		topic_id			The topic ID we are currently reviewing
         * @var	int		forum_id			The forum ID we are currently in
         * @var	int		start				Start item of this page
         * @var	int		current_row_number	Number of the post on this page
         * @var	array	post_row			Template block array of the current post
         * @var	array	row					Array with original post and user data
         * @var	array	topic_info			Array with topic data
         * @var	int		total				Total posts count
         * @since 3.1.4-RC1
         */
        $vars = array('id', 'mode', 'topic_id', 'forum_id', 'start', 'current_row_number', 'post_row', 'row', 'topic_info', 'total');
        extract($src_dispatcher->trigger_event('core.mcp_topic_review_modify_row', compact($vars)));
        $template->assign_block_vars('postrow', $post_row);
        // Display not already displayed Attachments for this post, we already parsed them. ;)
        if (!empty($attachments[$row['post_id']])) {
            foreach ($attachments[$row['post_id']] as $attachment) {
                $template->assign_block_vars('postrow.attachment', array('DISPLAY_ATTACHMENT' => $attachment));
            }
        }
        unset($rowset[$i]);
    }
    // Display topic icons for split topic
    $s_topic_icons = false;
    if ($auth->acl_gets('m_split', 'm_merge', (int) $topic_info['forum_id'])) {
        include_once $src_root_path . 'includes/functions_posting.' . $phpEx;
        $s_topic_icons = posting_gen_topic_icons('', $icon_id);
        // Has the user selected a topic for merge?
        if ($to_topic_id) {
            $to_topic_info = src_get_topic_data(array($to_topic_id), 'm_merge');
            if (!sizeof($to_topic_info)) {
                $to_topic_id = 0;
            } else {
                $to_topic_info = $to_topic_info[$to_topic_id];
                if (!$to_topic_info['enable_icons'] || $auth->acl_get('!f_icons', $topic_info['forum_id'])) {
                    $s_topic_icons = false;
                }
            }
        }
    }
    $s_hidden_fields = build_hidden_fields(array('st_old' => $sort_days, 'post_ids' => $post_id_list));
    $base_url = append_sid("{$src_root_path}mcp.{$phpEx}", "i={$id}&amp;t={$topic_info['topic_id']}&amp;mode={$mode}&amp;action={$action}&amp;to_topic_id={$to_topic_id}&amp;posts_per_page={$posts_per_page}&amp;st={$sort_days}&amp;sk={$sort_key}&amp;sd={$sort_dir}");
    if ($posts_per_page) {
        $pagination->generate_template_pagination($base_url, 'pagination', 'start', $total, $posts_per_page, $start);
    }
    $template->assign_vars(array('TOPIC_TITLE' => $topic_info['topic_title'], 'U_VIEW_TOPIC' => append_sid("{$src_root_path}viewtopic.{$phpEx}", 'f=' . $topic_info['forum_id'] . '&amp;t=' . $topic_info['topic_id']), 'TO_TOPIC_ID' => $to_topic_id, 'TO_TOPIC_INFO' => $to_topic_id ? sprintf($user->lang['YOU_SELECTED_TOPIC'], $to_topic_id, '<a href="' . append_sid("{$src_root_path}viewtopic.{$phpEx}", 'f=' . $to_topic_info['forum_id'] . '&amp;t=' . $to_topic_id) . '">' . $to_topic_info['topic_title'] . '</a>') : '', 'SPLIT_SUBJECT' => $subject, 'POSTS_PER_PAGE' => $posts_per_page, 'ACTION' => $action, 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), 'DELETED_IMG' => $user->img('icon_topic_deleted', 'POST_DELETED_RESTORE'), 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'), 'S_MCP_ACTION' => "{$url}&amp;i={$id}&amp;mode={$mode}&amp;action={$action}&amp;start={$start}", 'S_FORUM_SELECT' => $to_forum_id ? make_forum_select($to_forum_id, false, false, true, true, true) : make_forum_select($topic_info['forum_id'], false, false, true, true, true), 'S_CAN_SPLIT' => $auth->acl_get('m_split', $topic_info['forum_id']) ? true : false, 'S_CAN_MERGE' => $auth->acl_get('m_merge', $topic_info['forum_id']) ? true : false, 'S_CAN_DELETE' => $auth->acl_get('m_delete', $topic_info['forum_id']) ? true : false, 'S_CAN_APPROVE' => $has_unapproved_posts && $auth->acl_get('m_approve', $topic_info['forum_id']) ? true : false, 'S_CAN_RESTORE' => $has_deleted_posts && $auth->acl_get('m_approve', $topic_info['forum_id']) ? true : false, 'S_CAN_LOCK' => $auth->acl_get('m_lock', $topic_info['forum_id']) ? true : false, 'S_CAN_REPORT' => $auth->acl_get('m_report', $topic_info['forum_id']) ? true : false, 'S_CAN_SYNC' => $auth->acl_get('m_', $topic_info['forum_id']), 'S_REPORT_VIEW' => $action == 'reports' ? true : false, 'S_MERGE_VIEW' => $action == 'merge' ? true : false, 'S_SPLIT_VIEW' => $action == 'split' ? true : false, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, 'S_TOPIC_ICON' => $icon_id, 'U_SELECT_TOPIC' => "{$url}&amp;i={$id}&amp;mode=forum_view&amp;action=merge_select" . ($forum_id ? "&amp;f={$forum_id}" : ''), 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$src_root_path}viewtopic.{$phpEx}", "f={$topic_info['forum_id']}&amp;t={$topic_info['topic_id']}&amp;start={$start}") . '">', '</a>'), 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$src_root_path}viewforum.{$phpEx}", "f={$topic_info['forum_id']}&amp;start={$start}") . '">', '</a>'), 'TOTAL_POSTS' => $user->lang('VIEW_TOPIC_POSTS', (int) $total)));
}
Ejemplo n.º 4
0
/**
* MCP Forum View
*/
function mcp_forum_view($id, $mode, $action, $forum_info)
{
    global $template, $db, $user, $auth, $cache, $module;
    global $phpEx, $phpbb_root_path, $config;
    $user->add_lang(array('viewtopic', 'viewforum'));
    include_once $phpbb_root_path . 'includes/functions_display.' . $phpEx;
    // 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
        unset($_POST['sk'], $_POST['sd'], $_REQUEST['sk'], $_REQUEST['sd']);
    }
    $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);
    $url_extra = '';
    $url_extra .= $forum_id ? "&amp;f={$forum_id}" : '';
    $url_extra .= $GLOBALS['topic_id'] ? '&amp;t=' . $GLOBALS['topic_id'] : '';
    $url_extra .= $GLOBALS['post_id'] ? '&amp;p=' . $GLOBALS['post_id'] : '';
    $url_extra .= $GLOBALS['user_id'] ? '&amp;u=' . $GLOBALS['user_id'] : '';
    $url = append_sid("{$phpbb_root_path}mcp.{$phpEx}?{$url_extra}");
    // Resync Topics
    switch ($action) {
        case 'resync':
            $topic_ids = request_var('topic_id_list', array(0));
            mcp_resync_topics($topic_ids);
            break;
        case 'merge_topics':
            $source_topic_ids = $topic_id_list;
        case 'merge_topic':
            if ($to_topic_id) {
                merge_topics($forum_id, $source_topic_ids, $to_topic_id);
            }
            break;
    }
    $selected_ids = '';
    if (sizeof($post_id_list) && $action != 'merge_topics') {
        foreach ($post_id_list as $num => $post_id) {
            $selected_ids .= '&amp;post_id_list[' . $num . ']=' . $post_id;
        }
    } else {
        if (sizeof($topic_id_list) && $action == 'merge_topics') {
            foreach ($topic_id_list as $num => $topic_id) {
                $selected_ids .= '&amp;topic_id_list[' . $num . ']=' . $topic_id;
            }
        }
    }
    make_jumpbox($url . "&amp;i={$id}&amp;action={$action}&amp;mode={$mode}" . ($merge_select ? $selected_ids : ''), $forum_id, false, 'm_', true);
    $topics_per_page = $forum_info['forum_topics_per_page'] ? $forum_info['forum_topics_per_page'] : $config['topics_per_page'];
    $sort_days = $total = 0;
    $sort_key = $sort_dir = '';
    $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;
    $limit_time_sql = $sort_days ? 'AND t.topic_last_post_time >= ' . (time() - $sort_days * 86400) : '';
    $template->assign_vars(array('ACTION' => $action, 'FORUM_NAME' => $forum_info['forum_name'], 'FORUM_DESCRIPTION' => generate_text_for_display($forum_info['forum_desc'], $forum_info['forum_desc_uid'], $forum_info['forum_desc_bitfield'], $forum_info['forum_desc_options']), 'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'), 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), 'S_CAN_REPORT' => $auth->acl_get('m_report', $forum_id), 'S_CAN_DELETE' => $auth->acl_get('m_delete', $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), 'S_CAN_LOCK' => $auth->acl_get('m_lock', $forum_id), '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_STICKY' => $auth->acl_get('f_sticky', $forum_id), 'S_CAN_MAKE_ANNOUNCE' => $auth->acl_get('f_announce', $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&amp;mode=forum_logs&amp;f=' . $forum_id) : '', 'S_MCP_ACTION' => $url . "&amp;i={$id}&amp;forum_action={$action}&amp;mode={$mode}&amp;start={$start}" . ($merge_select ? $selected_ids : ''), 'PAGINATION' => generate_pagination($url . "&amp;i={$id}&amp;action={$action}&amp;mode={$mode}&amp;sd={$sort_dir}&amp;sk={$sort_key}&amp;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)));
    // Grab icons
    $icons = $cache->obtain_icons();
    $topic_rows = array();
    if ($config['load_db_lastread']) {
        $read_tracking_join = ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . ')';
        $read_tracking_select = ', tt.mark_time';
    } else {
        $read_tracking_join = $read_tracking_select = '';
    }
    $sql = "SELECT t.topic_id\n\t\tFROM " . TOPICS_TABLE . " t\n\t\tWHERE t.forum_id IN({$forum_id}, 0)\n\t\t\t" . ($auth->acl_get('m_approve', $forum_id) ? '' : 'AND t.topic_approved = 1') . "\n\t\t\t{$limit_time_sql}\n\t\tORDER BY t.topic_type DESC, {$sort_order_sql}";
    $result = $db->sql_query_limit($sql, $topics_per_page, $start);
    $topic_list = $topic_tracking_info = array();
    while ($row = $db->sql_fetchrow($result)) {
        $topic_list[] = $row['topic_id'];
    }
    $db->sql_freeresult($result);
    $sql = "SELECT t.*{$read_tracking_select}\n\t\tFROM " . TOPICS_TABLE . " t {$read_tracking_join}\n\t\tWHERE " . $db->sql_in_set('t.topic_id', $topic_list, false, true);
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
        $topic_rows[$row['topic_id']] = $row;
    }
    $db->sql_freeresult($result);
    // If there is more than one page, but we have no topic list, then the start parameter is... erm... out of sync
    if (!sizeof($topic_list) && $forum_topics && $start > 0) {
        redirect($url . "&amp;i={$id}&amp;action={$action}&amp;mode={$mode}");
    }
    // Get topic tracking info
    if (sizeof($topic_list)) {
        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());
        } else {
            $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list, array());
        }
    }
    foreach ($topic_list as $topic_id) {
        $topic_title = '';
        $row =& $topic_rows[$topic_id];
        $replies = $auth->acl_get('m_approve', $forum_id) ? $row['topic_replies_real'] : $row['topic_replies'];
        if ($row['topic_status'] == ITEM_MOVED) {
            $unread_topic = false;
        } else {
            $unread_topic = isset($topic_tracking_info[$topic_id]) && $row['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 = '';
        topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);
        $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;
        $u_mcp_queue = $topic_unapproved || $posts_unapproved ? $url . '&amp;i=queue&amp;mode=' . ($topic_unapproved ? 'approve_details' : 'unapproved_posts') . '&amp;t=' . $row['topic_id'] : '';
        $topic_row = array('SOLVED_TOPIC' => $row['topic_solved'] && $row['topic_type'] != POST_GLOBAL ? $forum_info['forum_solve_text'] ? $forum_info['forum_solve_text'] : $user->img('icon_topic_solved_list', 'TOPIC_SOLVED') : '', 'U_SOLVED_TOPIC' => $row['topic_solved'] ? append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'p=' . $row['topic_solved'] . '#p' . $row['topic_solved']) : '', 'SOLVED_STYLE' => $forum_info['forum_solve_color'] ? ' style="color: #' . $forum_info['forum_solve_color'] . '"' : '', '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_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') : '', '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']), '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']), 'TOPIC_TYPE' => $topic_type, 'TOPIC_TITLE' => $topic_title, 'REPLIES' => $auth->acl_get('m_approve', $row['forum_id']) ? $row['topic_replies_real'] : $row['topic_replies'], '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']), '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_UNREAD_TOPIC' => $unread_topic);
        if ($row['topic_status'] == ITEM_MOVED) {
            $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}&amp;f={$forum_id}&amp;topic_id_list[]={$row['topic_id']}&amp;mode=forum_view&amp;action=delete_topic") : '', 'S_MOVED_TOPIC' => true, 'TOPIC_ID' => $row['topic_moved_id']));
        } else {
            if ($action == 'merge_topic' || $action == 'merge_topics') {
                $u_select_topic = $url . "&amp;i={$id}&amp;mode=forum_view&amp;action={$action}&amp;to_topic_id=" . $row['topic_id'] . $selected_ids;
            } else {
                $u_select_topic = $url . "&amp;i={$id}&amp;mode=topic_view&amp;action=merge&amp;to_topic_id=" . $row['topic_id'] . $selected_ids;
            }
            $topic_row = array_merge($topic_row, array('U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&amp;f={$forum_id}&amp;t={$row['topic_id']}&amp;mode=topic_view"), 'S_SELECT_TOPIC' => $merge_select && !in_array($row['topic_id'], $source_topic_ids) ? true : false, '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&amp;mode=topic_view&amp;t=' . $row['topic_id'] . '&amp;action=reports') : '', 'TOPIC_ID' => $row['topic_id'], 'S_TOPIC_CHECKED' => $topic_id_list && in_array($row['topic_id'], $topic_id_list) ? true : false));
        }
        $template->assign_block_vars('topicrow', $topic_row);
    }
    unset($topic_rows);
}
Ejemplo n.º 5
0
/**
* MCP Forum View
*/
function mcp_forum_view($id, $mode, $action, $forum_info)
{
    global $template, $db, $user, $auth, $cache;
    global $phpEx, $phpbb_root_path, $config;
    $url = append_sid("{$phpbb_root_path}mcp.{$phpEx}?" . extra_url());
    if ($action == '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']);
    }
    $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));
    $topic_id = request_var('t', 0);
    // Resync Topics
    if ($action == 'resync') {
        $topic_ids = request_var('topic_id_list', array(0));
        mcp_resync_topics($topic_ids);
    }
    $selected_ids = '';
    if (sizeof($post_id_list)) {
        foreach ($post_id_list as $num => $post_id) {
            $selected_ids .= '&amp;post_id_list[' . $num . ']=' . $post_id;
        }
    }
    make_jumpbox($url . "&amp;i={$id}&amp;action={$action}&amp;mode={$mode}", $forum_id . ($action == 'merge_select' ? $selected_ids : ''), false, 'm_');
    $topics_per_page = $forum_info['forum_topics_per_page'] ? $forum_info['forum_topics_per_page'] : $config['topics_per_page'];
    $sort_days = $total = 0;
    $sort_key = $sort_dir = '';
    $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;
    $limit_time_sql = $sort_days ? 'AND t.topic_last_post_time >= ' . (time() - $sort_days * 86400) : '';
    $template->assign_vars(array('FORUM_NAME' => $forum_info['forum_name'], 'FORUM_DESCRIPTION' => generate_text_for_display($forum_info['forum_desc'], $forum_info['forum_desc_uid'], $forum_info['forum_desc_bitfield']), 'REPORTED_IMG' => $user->img('icon_reported', 'TOPIC_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_unapproved', 'TOPIC_UNAPPROVED'), 'S_CAN_DELETE' => $auth->acl_get('m_delete', $forum_id), 'S_CAN_MOVE' => $auth->acl_get('m_move', $forum_id), 'S_CAN_FORK' => $auth->acl_get('m_', $forum_id), 'S_CAN_LOCK' => $auth->acl_get('m_lock', $forum_id), 'S_CAN_SYNC' => $auth->acl_get('m_', $forum_id), 'S_CAN_APPROVE' => $auth->acl_get('m_approve', $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) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=logs&amp;mode=forum_logs&amp;f=' . $forum_id) : '', 'S_MCP_ACTION' => $url . "&amp;i={$id}&amp;action={$action}&amp;mode={$mode}&amp;start={$start}" . ($action == 'merge_select' ? $selected_ids : ''), 'PAGINATION' => generate_pagination($url . "&amp;i={$id}&amp;action={$action}&amp;mode={$mode}" . ($action == 'merge_select' ? $selected_ids : ''), $forum_topics, $topics_per_page, $start), 'PAGE_NUMBER' => on_page($forum_topics, $topics_per_page, $start), 'TOTAL' => $forum_topics));
    // Grab icons
    $icons = array();
    $cache->obtain_icons($icons);
    $topic_rows = array();
    $sql = 'SELECT t.*
		FROM ' . TOPICS_TABLE . " t\n\t\tWHERE (t.forum_id = {$forum_id} OR t.forum_id = 0)\n\t\t\t" . ($auth->acl_get('m_approve', $forum_id) ? '' : 'AND t.topic_approved = 1') . "\n\t\t\t{$limit_time_sql}\n\t\tORDER BY t.topic_type DESC, {$sort_order_sql}";
    $result = $db->sql_query_limit($sql, $topics_per_page, $start);
    while ($row = $db->sql_fetchrow($result)) {
        $topic_rows[] = $row;
    }
    $db->sql_freeresult($result);
    foreach ($topic_rows as $row) {
        $topic_title = '';
        if ($row['topic_status'] == ITEM_LOCKED) {
            $folder_img = 'folder_locked';
            $folder_alt = 'VIEW_TOPIC_LOCKED';
        } else {
            if ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) {
                $folder_img = 'folder_announce';
                $folder_alt = 'VIEW_TOPIC_ANNOUNCEMENT';
            } else {
                if ($row['topic_type'] == POST_STICKY) {
                    $folder_img = 'folder_sticky';
                    $folder_alt = 'VIEW_TOPIC_STICKY';
                } else {
                    if ($row['topic_status'] == ITEM_MOVED) {
                        $folder_img = 'folder_moved';
                        $folder_alt = 'VIEW_TOPIC_MOVED';
                    } else {
                        $folder_img = 'folder';
                        $folder_alt = 'NO_NEW_POSTS';
                    }
                }
            }
        }
        if ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) {
            $topic_type = $user->lang['VIEW_TOPIC_ANNOUNCEMENT'] . ' ';
        } else {
            if ($row['topic_type'] == POST_STICKY) {
                $topic_type = $user->lang['VIEW_TOPIC_STICKY'] . ' ';
            } else {
                if ($row['topic_status'] == ITEM_MOVED) {
                    $topic_type = $user->lang['VIEW_TOPIC_MOVED'] . ' ';
                } else {
                    $topic_type = '';
                }
            }
        }
        if (intval($row['poll_start'])) {
            $topic_type .= $user->lang['VIEW_TOPIC_POLL'] . ' ';
        }
        $topic_title = censor_text($row['topic_title']);
        $topic_unapproved = !$row['topic_approved'] && $auth->acl_gets('m_approve', $row['forum_id']) ? true : false;
        $posts_unapproved = $row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_gets('m_approve', $row['forum_id']) ? true : false;
        $u_mcp_queue = $topic_unapproved || $posts_unapproved ? $url . '&amp;i=queue&amp;mode=' . ($topic_unapproved ? 'approve_details' : 'unapproved_posts') . '&amp;t=' . $row['topic_id'] : '';
        $template->assign_block_vars('topicrow', array('U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&amp;f={$forum_id}&amp;t={$row['topic_id']}&amp;mode=topic_view"), 'S_SELECT_TOPIC' => $action == 'merge_select' && $row['topic_id'] != $topic_id ? true : false, 'U_SELECT_TOPIC' => $url . "&amp;i={$id}&amp;mode=topic_view&amp;action=merge&amp;to_topic_id=" . $row['topic_id'] . $selected_ids, 'U_MCP_QUEUE' => $u_mcp_queue, 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main&amp;mode=topic_view&amp;t=' . $row['topic_id'] . '&amp;action=reports'), 'ATTACH_ICON_IMG' => $auth->acl_gets('f_download', 'u_download', $row['forum_id']) && $row['topic_attachment'] ? $user->img('icon_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', '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_unapproved', $topic_unapproved ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', 'TOPIC_TYPE' => $topic_type, 'TOPIC_TITLE' => $topic_title, 'REPLIES' => $auth->acl_get('m_approve', $row['forum_id']) ? $row['topic_replies_real'] : $row['topic_replies'], 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), 'TOPIC_ID' => $row['topic_id'], 'S_TOPIC_CHECKED' => $topic_id_list && in_array($row['topic_id'], $topic_id_list) ? 'checked="checked" ' : '', 'S_TOPIC_REPORTED' => !empty($row['topic_reported']) && $auth->acl_gets('m_report', $row['forum_id']) ? true : false, 'S_TOPIC_UNAPPROVED' => $topic_unapproved, 'S_POSTS_UNAPPROVED' => $posts_unapproved));
    }
    unset($topic_rows);
}
Ejemplo n.º 6
0
$url = 'Forums&amp;file=mcp&amp;f=' . $forum_id;
$action = get_variable('action', 'REQUEST');
if ($action === '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']);
}
$start = get_variable('start', 'REQUEST', false, 'int');
$topic_id_list = array_unique(request_var('topic_id_list', array(0)));
$post_id_list = array_unique(request_var('post_id_list', array(0)));
$topic_id = get_variable('t', 'REQUEST', false, 'int');
// Resync Topics
if ($action == 'resync') {
    if (empty($topic_id_list)) {
        $_CLASS['core_template']->assign('MESSAGE', $_CLASS['core_user']->lang['NO_TOPIC_SELECTED']);
    } else {
        mcp_resync_topics($topic_id_list);
    }
}
$selected_ids = '';
if (!empty($post_id_list)) {
    foreach ($post_id_list as $num => $post_id) {
        $selected_ids .= '&amp;post_id_list[' . $num . ']=' . $post_id;
    }
}
make_jumpbox(generate_link($url . "&amp;action={$action}&amp;mode={$mode}", $forum_id . ($action == 'merge_select' ? $selected_ids : '')), false, 'm_');
$topics_per_page = $forum_info['forum_topics_per_page'] ? $forum_info['forum_topics_per_page'] : $config['topics_per_page'];
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;
$limit_time_sql = $sort_days ? 'AND t.topic_last_post_time >= ' . (time() - $sort_days * 86400) : '';
$pagination = generate_pagination($url . "&amp;action={$action}&amp;mode={$mode}" . ($action == 'merge_select' ? $selected_ids : ''), $forum_topics, $topics_per_page, $start);
$_CLASS['core_template']->assign_array(array('S_TOPIC_ICONS' => false, 'FORUM_NAME' => $forum_info['forum_name'], 'REPORTED_IMG' => $_CLASS['core_user']->img('icon_reported', 'TOPIC_REPORTED'), 'UNAPPROVED_IMG' => $_CLASS['core_user']->img('icon_unapproved', 'TOPIC_UNAPPROVED'), 'S_CAN_DELETE' => $_CLASS['auth']->acl_get('m_delete', $forum_id), 'S_CAN_MOVE' => $_CLASS['auth']->acl_get('m_move', $forum_id), 'S_CAN_FORK' => $_CLASS['auth']->acl_get('m_', $forum_id), 'S_CAN_LOCK' => $_CLASS['auth']->acl_get('m_lock', $forum_id), 'S_CAN_SYNC' => $_CLASS['auth']->acl_get('m_', $forum_id), 'S_CAN_APPROVE' => $_CLASS['auth']->acl_get('m_approve', $forum_id), 'U_VIEW_FORUM' => generate_link('Forums&amp;file=viewforum&amp;f=' . $forum_id), 'S_MCP_ACTION' => generate_link($url . "&amp;mode={$mode}&amp;start={$start}" . ($action == 'merge_select' ? $selected_ids : '')), 'PAGINATION' => $pagination['formated'], 'PAGINATION_ARRAY' => $pagination['array'], 'PAGE_NUMBER' => on_page($forum_topics, $topics_per_page, $start), 'TOTAL' => $forum_topics));