diff options
Diffstat (limited to 'phpBB/modules/mcp/mcp_forum.php')
-rw-r--r-- | phpBB/modules/mcp/mcp_forum.php | 445 |
1 files changed, 0 insertions, 445 deletions
diff --git a/phpBB/modules/mcp/mcp_forum.php b/phpBB/modules/mcp/mcp_forum.php deleted file mode 100644 index e09ed93923..0000000000 --- a/phpBB/modules/mcp/mcp_forum.php +++ /dev/null @@ -1,445 +0,0 @@ -<?php -/** -* -* @package mcp -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* MCP Forum View -*/ -function mcp_forum_view($id, $mode, $action, $forum_info) -{ - global $module; - - phpbb::$user->add_lang(array('viewtopic', 'viewforum')); - - include_once(PHPBB_ROOT_PATH . 'includes/functions_display.' . PHP_EXT); - - // 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 - phpbb_request::overwrite('sk', null, phpbb_request::POST); - phpbb_request::overwrite('sd', null, phpbb_request::POST); - phpbb_request::overwrite('sk', null, phpbb_request::REQUEST); - phpbb_request::overwrite('sd', null, phpbb_request::REQUEST); - } - - $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) ? "&f=$forum_id" : ''; - $url_extra .= ($GLOBALS['topic_id']) ? '&t=' . $GLOBALS['topic_id'] : ''; - $url_extra .= ($GLOBALS['post_id']) ? '&p=' . $GLOBALS['post_id'] : ''; - $url_extra .= ($GLOBALS['user_id']) ? '&u=' . $GLOBALS['user_id'] : ''; - - $url = ($url_extra) ? append_sid('mcp', $url_extra) : append_sid('mcp'); - - // 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 .= '&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 .= '&topic_id_list[' . $num . ']=' . $topic_id; - } - } - - make_jumpbox($url . "&i=$id&action=$action&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'] : phpbb::$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)) : ''; - - phpbb::$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' => phpbb::$user->img('icon_topic_reported', 'TOPIC_REPORTED'), - 'UNAPPROVED_IMG' => phpbb::$user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'), - 'LAST_POST_IMG' => phpbb::$user->img('icon_topic_latest', 'VIEW_LATEST_POST'), - 'NEWEST_POST_IMG' => phpbb::$user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), - - 'S_CAN_REPORT' => phpbb::$acl->acl_get('m_report', $forum_id), - 'S_CAN_DELETE' => phpbb::$acl->acl_get('m_delete', $forum_id), - 'S_CAN_MERGE' => phpbb::$acl->acl_get('m_merge', $forum_id), - 'S_CAN_MOVE' => phpbb::$acl->acl_get('m_move', $forum_id), - 'S_CAN_FORK' => phpbb::$acl->acl_get('m_', $forum_id), - 'S_CAN_LOCK' => phpbb::$acl->acl_get('m_lock', $forum_id), - 'S_CAN_SYNC' => phpbb::$acl->acl_get('m_', $forum_id), - 'S_CAN_APPROVE' => phpbb::$acl->acl_get('m_approve', $forum_id), - 'S_MERGE_SELECT' => ($merge_select) ? true : false, - 'S_CAN_MAKE_NORMAL' => phpbb::$acl->acl_gets('f_sticky', 'f_announce', $forum_id), - 'S_CAN_MAKE_STICKY' => phpbb::$acl->acl_get('f_sticky', $forum_id), - 'S_CAN_MAKE_ANNOUNCE' => phpbb::$acl->acl_get('f_announce', $forum_id), - - 'U_VIEW_FORUM' => append_sid('viewforum', 'f=' . $forum_id), - 'U_VIEW_FORUM_LOGS' => (phpbb::$acl->acl_gets('a_', 'm_', $forum_id) && $module->loaded('logs')) ? append_sid('mcp', 'i=logs&mode=forum_logs&f=' . $forum_id) : '', - - '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) ? phpbb::$user->lang['VIEW_FORUM_TOPIC'] : sprintf(phpbb::$user->lang['VIEW_FORUM_TOPICS'], $forum_topics), - )); - - // Grab icons - $icons = phpbb_cache::obtain_icons(); - - $topic_rows = array(); - - if (phpbb::$config['load_db_lastread']) - { - $read_tracking_join = ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . phpbb::$user->data['user_id'] . ')'; - $read_tracking_select = ', tt.mark_time'; - } - else - { - $read_tracking_join = $read_tracking_select = ''; - } - - $sql = "SELECT t.topic_id - FROM " . TOPICS_TABLE . " t - WHERE t.forum_id IN($forum_id, 0) - " . ((phpbb::$acl->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1') . " - $limit_time_sql - ORDER BY t.topic_type DESC, $sort_order_sql"; - $result = phpbb::$db->sql_query_limit($sql, $topics_per_page, $start); - - $topic_list = $topic_tracking_info = array(); - - while ($row = phpbb::$db->sql_fetchrow($result)) - { - $topic_list[] = $row['topic_id']; - } - phpbb::$db->sql_freeresult($result); - - $sql = "SELECT t.*$read_tracking_select - FROM " . TOPICS_TABLE . " t $read_tracking_join - WHERE " . phpbb::$db->sql_in_set('t.topic_id', $topic_list, false, true); - - $result = phpbb::$db->sql_query($sql); - while ($row = phpbb::$db->sql_fetchrow($result)) - { - $topic_rows[$row['topic_id']] = $row; - } - phpbb::$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 . "&i=$id&action=$action&mode=$mode"); - } - - // Get topic tracking info - if (sizeof($topic_list)) - { - if (phpbb::$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 = (phpbb::$acl->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'] && phpbb::$acl->acl_get('m_approve', $row['forum_id'])) ? true : false; - $posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && phpbb::$acl->acl_get('m_approve', $row['forum_id'])) ? true : false; - $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? $url . '&i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . '&t=' . $row['topic_id'] : ''; - - $topic_row = array( - 'ATTACH_ICON_IMG' => (phpbb::$acl->acl_get('u_download') && phpbb::$acl->acl_get('f_download', $row['forum_id']) && $row['topic_attachment']) ? phpbb::$user->img('icon_topic_attach', 'TOTAL_ATTACHMENTS') : '', - 'TOPIC_FOLDER_IMG' => phpbb::$user->img($folder_img, $folder_alt), - 'TOPIC_FOLDER_IMG_SRC' => phpbb::$user->img($folder_img, $folder_alt, '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) ? phpbb::$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' => (phpbb::$acl->acl_get('m_approve', $row['forum_id'])) ? $row['topic_replies_real'] : $row['topic_replies'], - 'LAST_POST_TIME' => phpbb::$user->format_date($row['topic_last_post_time']), - 'FIRST_POST_TIME' => phpbb::$user->format_date($row['topic_time']), - 'LAST_POST_SUBJECT' => $row['topic_last_post_subject'], - 'LAST_VIEW_TIME' => phpbb::$user->format_date($row['topic_last_view_time']), - - 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && empty($row['topic_moved_id']) && phpbb::$acl->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('viewtopic', "t={$row['topic_moved_id']}"), - 'U_DELETE_TOPIC' => (phpbb::$acl->acl_get('m_delete', $forum_id)) ? append_sid('mcp', "i=$id&f=$forum_id&topic_id_list[]={$row['topic_id']}&mode=forum_view&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 . "&i=$id&mode=forum_view&action=$action&to_topic_id=" . $row['topic_id'] . $selected_ids; - } - else - { - $u_select_topic = $url . "&i=$id&mode=topic_view&action=merge&to_topic_id=" . $row['topic_id'] . $selected_ids; - } - $topic_row = array_merge($topic_row, array( - 'U_VIEW_TOPIC' => append_sid('mcp', "i=$id&f=$forum_id&t={$row['topic_id']}&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' => (phpbb::$acl->acl_get('m_report', $forum_id)) ? append_sid('mcp', '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, - )); - } - - phpbb::$template->assign_block_vars('topicrow', $topic_row); - } - unset($topic_rows); -} - -/** -* Resync topics -*/ -function mcp_resync_topics($topic_ids) -{ - if (!sizeof($topic_ids)) - { - trigger_error('NO_TOPIC_SELECTED'); - } - - if (!check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_'))) - { - return; - } - - // Sync everything and perform extra checks separately - sync('topic_reported', 'topic_id', $topic_ids, false, true); - sync('topic_attachment', 'topic_id', $topic_ids, false, true); - sync('topic', 'topic_id', $topic_ids, true, false); - - $sql = 'SELECT topic_id, forum_id, topic_title - FROM ' . TOPICS_TABLE . ' - WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids); - $result = phpbb::$db->sql_query($sql); - - // Log this action - while ($row = phpbb::$db->sql_fetchrow($result)) - { - add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_TOPIC_RESYNC', $row['topic_title']); - } - phpbb::$db->sql_freeresult($result); - - $msg = (sizeof($topic_ids) == 1) ? phpbb::$user->lang['TOPIC_RESYNC_SUCCESS'] : phpbb::$user->lang['TOPICS_RESYNC_SUCCESS']; - - $redirect = request_var('redirect', phpbb::$user->data['session_page']); - - meta_refresh(3, $redirect); - trigger_error($msg . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>')); - - return; -} - -/** -* Merge selected topics into selected topic -*/ -function merge_topics($forum_id, $topic_ids, $to_topic_id) -{ - if (!sizeof($topic_ids)) - { - phpbb::$template->assign_var('MESSAGE', phpbb::$user->lang['NO_TOPIC_SELECTED']); - return; - } - if (!$to_topic_id) - { - phpbb::$template->assign_var('MESSAGE', phpbb::$user->lang['NO_FINAL_TOPIC_SELECTED']); - return; - } - - $topic_data = get_topic_data(array($to_topic_id), 'm_merge'); - - if (!sizeof($topic_data)) - { - phpbb::$template->assign_var('MESSAGE', phpbb::$user->lang['NO_FINAL_TOPIC_SELECTED']); - return; - } - - $topic_data = $topic_data[$to_topic_id]; - - $post_id_list = request_var('post_id_list', array(0)); - $start = request_var('start', 0); - - if (!sizeof($post_id_list) && sizeof($topic_ids)) - { - $sql = 'SELECT post_id - FROM ' . POSTS_TABLE . ' - WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids); - $result = phpbb::$db->sql_query($sql); - - $post_id_list = array(); - while ($row = phpbb::$db->sql_fetchrow($result)) - { - $post_id_list[] = $row['post_id']; - } - phpbb::$db->sql_freeresult($result); - } - - if (!sizeof($post_id_list)) - { - phpbb::$template->assign_var('MESSAGE', phpbb::$user->lang['NO_POST_SELECTED']); - return; - } - - if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_merge'))) - { - return; - } - - $redirect = request_var('redirect', build_url(array('quickmod'))); - - $s_hidden_fields = build_hidden_fields(array( - 'i' => 'main', - 'f' => $forum_id, - 'post_id_list' => $post_id_list, - 'to_topic_id' => $to_topic_id, - 'mode' => 'forum_view', - 'action' => 'merge_topics', - 'start' => $start, - 'redirect' => $redirect, - 'topic_id_list' => $topic_ids) - ); - $success_msg = $return_link = ''; - - if (confirm_box(true)) - { - $to_forum_id = $topic_data['forum_id']; - - move_posts($post_id_list, $to_topic_id); - add_log('mod', $to_forum_id, $to_topic_id, 'LOG_MERGE', $topic_data['topic_title']); - - // Message and return links - $success_msg = 'POSTS_MERGED_SUCCESS'; - - // If the topic no longer exist, we will update the topic watch table. - // To not let it error out on users watching both topics, we just return on an error... - phpbb::$db->sql_return_on_error(true); - phpbb::$db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . ' SET topic_id = ' . (int) $to_topic_id . ' WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids)); - phpbb::$db->sql_return_on_error(false); - - phpbb::$db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids)); - - // Link to the new topic - $return_link .= (($return_link) ? '<br /><br />' : '') . sprintf(phpbb::$user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid('viewtopic', 'f=' . $to_forum_id . '&t=' . $to_topic_id) . '">', '</a>'); - } - else - { - confirm_box(false, 'MERGE_TOPICS', $s_hidden_fields); - } - - $redirect = request_var('redirect', 'index.' . PHP_EXT); - $redirect = reapply_sid($redirect); - - if (!$success_msg) - { - return; - } - else - { - meta_refresh(3, append_sid('viewtopic', "f=$to_forum_id&t=$to_topic_id")); - trigger_error(phpbb::$user->lang[$success_msg] . '<br /><br />' . $return_link); - } -} - -?>
\ No newline at end of file |