diff options
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/mcp/mcp_forum.php | 162 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_main.php | 3 | ||||
-rw-r--r-- | phpBB/includes/search/fulltext_mysql.php | 28 |
3 files changed, 152 insertions, 41 deletions
diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index 3f11c96e21..52b9a5af73 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -22,7 +22,10 @@ function mcp_forum_view($id, $mode, $action, $forum_info) $url = append_sid("{$phpbb_root_path}mcp.$phpEx?" . extra_url()); - if ($action == 'merge_select') + // 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']); @@ -32,14 +35,25 @@ function mcp_forum_view($id, $mode, $action, $forum_info) $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_id = request_var('t', 0); + $source_topic_ids = array(request_var('t', 0)); + $to_topic_id = request_var('to_topic_id', 0); // Resync Topics - if ($action == 'resync') + switch ($action) { - $topic_ids = request_var('topic_id_list', array(0)); - - mcp_resync_topics($topic_ids); + 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 = ''; @@ -50,8 +64,15 @@ function mcp_forum_view($id, $mode, $action, $forum_info) $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", $forum_id . (($action == 'merge_select') ? $selected_ids : ''), false, 'm_'); + make_jumpbox($url . "&i=$id&action=$action&mode=$mode", $forum_id . (($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']; @@ -64,6 +85,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info) $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']), @@ -74,12 +96,13 @@ 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_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' => ($action == 'merge_select') ? true : false, + '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), @@ -87,9 +110,9 @@ function mcp_forum_view($id, $mode, $action, $forum_info) 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id), 'U_VIEW_FORUM_LOGS' => ($auth->acl_gets('a_', 'm_', $forum_id) && $module->loaded('logs')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=logs&mode=forum_logs&f=' . $forum_id) : '', - 'S_MCP_ACTION' => $url . "&i=$id&mode=$mode&start=$start" . (($action == 'merge_select') ? $selected_ids : ''), + 'S_MCP_ACTION' => $url . "&i=$id&mode=$mode&start=$start" . (($merge_select) ? $selected_ids : ''), - 'PAGINATION' => generate_pagination($url . "&i=$id&action=$action&mode=$mode" . (($action == 'merge_select') ? $selected_ids : ''), $forum_topics, $topics_per_page, $start), + 'PAGINATION' => generate_pagination($url . "&i=$id&action=$action&mode=$mode" . (($merge_select) ? $selected_ids : ''), $forum_topics, $topics_per_page, $start), 'PAGE_NUMBER' => on_page($forum_topics, $topics_per_page, $start), 'TOTAL' => $forum_topics) ); @@ -213,11 +236,19 @@ function mcp_forum_view($id, $mode, $action, $forum_info) } 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("{$phpbb_root_path}mcp.$phpEx", "i=$id&f=$forum_id&t={$row['topic_id']}&mode=topic_view"), - 'S_SELECT_TOPIC' => ($action == 'merge_select' && $row['topic_id'] != $source_topic_id) ? true : false, - 'U_SELECT_TOPIC' => $url . "&i=$id&mode=topic_view&action=merge&to_topic_id=" . $row['topic_id'] . $selected_ids, + '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&mode=topic_view&t=' . $row['topic_id'] . '&action=reports') : '', 'TOPIC_ID' => $row['topic_id'], @@ -274,4 +305,111 @@ function mcp_resync_topics($topic_ids) return; } +/** +* Merge selected topics into selected topic +*/ +function merge_topics($forum_id, $topic_ids, $to_topic_id) +{ + global $db, $template, $user, $phpEx, $phpbb_root_path, $auth; + + if (!$to_topic_id) + { + $template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']); + return; + } + + $topic_data = get_topic_data(array($to_topic_id), 'm_merge'); + + if (!sizeof($topic_data)) + { + $template->assign_var('MESSAGE', $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 ' . $db->sql_in_set('topic_id', $topic_ids); + $result = $db->sql_query($sql); + + $post_id_list = array(); + while ($row = $db->sql_fetchrow($result)) + { + $post_id_list[] = $row['post_id']; + } + $db->sql_freeresult($result); + } + + if (!sizeof($post_id_list)) + { + $template->assign_var('MESSAGE', $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('_f_', '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... + $db->sql_return_on_error(true); + $db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . ' SET topic_id = ' . $to_topic_id . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids)); + $db->sql_return_on_error(false); + + $db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids)); + + // 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', "index.$phpEx"); + $redirect = reapply_sid($redirect); + + if (!$success_msg) + { + return; + } + 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); + } +} + ?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index 32a4edb6ca..ab43f53b6c 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -953,7 +953,8 @@ function mcp_fork_topic($topic_ids) 'bbcode_uid' => (string) $row['bbcode_uid'], 'post_edit_time' => (int) $row['post_edit_time'], 'post_edit_count' => (int) $row['post_edit_count'], - 'post_edit_locked' => (int) $row['post_edit_locked'] + 'post_edit_locked' => (int) $row['post_edit_locked'], + 'post_postcount' => 0, ); $db->sql_query('INSERT INTO ' . POSTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index 7edfedc424..bd15f86334 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -114,9 +114,6 @@ class fulltext_mysql extends search_backend { global $config; - $this->get_ignore_words(); - $this->get_synonyms(); - if ($terms == 'all') { $match = array('#\sand\s#iu', '#\sor\s#iu', '#\snot\s#iu', '#\+#', '#-#', '#\|#'); @@ -171,18 +168,6 @@ class fulltext_mysql extends search_backend $this->split_words = $matches[1]; } - - if (sizeof($this->ignore_words)) - { - $this->common_words = array_intersect($this->split_words, $this->ignore_words); - $this->split_words = array_diff($this->split_words, $this->ignore_words); - } - - if (sizeof($this->replace_synonym)) - { - $this->split_words = str_replace($this->replace_synonym, $this->match_synonym, $this->split_words); - } - foreach ($this->split_words as $i => $word) { $clean_word = preg_replace('#^[+\-|]#', '', $word); @@ -214,9 +199,6 @@ class fulltext_mysql extends search_backend { global $config; - $this->get_ignore_words(); - $this->get_synonyms(); - // Split words if ($this->pcre_properties) { @@ -255,16 +237,6 @@ class fulltext_mysql extends search_backend $text = $matches[1]; } - if (sizeof($this->ignore_words)) - { - $text = array_diff($text, $this->ignore_words); - } - - if (sizeof($this->replace_synonym)) - { - $text = str_replace($this->replace_synonym, $this->match_synonym, $text); - } - // remove too short or too long words $text = array_values($text); for ($i = 0, $n = sizeof($text); $i < $n; $i++) |