/** * Merge topic(s) */ function topic_merge($topics, $new_topic_id, $forum_id) { global $db, $cache, $config, $user, $lang; $topics_ids = array(); for ($i = 0; $i < sizeof($topics); $i++) { if ($topics[$i] != $new_topic_id) { $topics_ids[] = $topics[$i]; } } $db->sql_transaction('begin'); $sql = "UPDATE " . POSTS_TABLE . "\n\t\t\tSET topic_id = '" . $new_topic_id . "'\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids); $result = $db->sql_query($sql); // UPI2DB - BEGIN $sql = "UPDATE " . UPI2DB_ALWAYS_READ_TABLE . "\n\t\t\tSET topic_id = '" . $new_topic_id . "'\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids); $db->sql_query($sql); $sql = "UPDATE " . UPI2DB_UNREAD_POSTS_TABLE . "\n\t\t\tSET topic_id = '" . $new_topic_id . "'\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids); $db->sql_query($sql); $sql = "UPDATE " . UPI2DB_LAST_POSTS_TABLE . "\n\t\t\tSET topic_id = '" . $new_topic_id . "'\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids); $db->sql_query($sql); // UPI2DB - END $sql = "DELETE FROM " . TOPICS_TABLE . "\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids); $result = $db->sql_query($sql); $sql = "DELETE FROM " . TOPICS_WATCH_TABLE . "\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids); $result = $db->sql_query($sql); $sql = "DELETE FROM " . BOOKMARK_TABLE . "\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids); $db->sql_query($sql); $sql = "DELETE FROM " . RATINGS_TABLE . "\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids); $db->sql_query($sql); $sql = "DELETE FROM " . TOPIC_VIEW_TABLE . "\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids); $db->sql_query($sql); $sql = "UPDATE " . DRAFTS_TABLE . "\n\t\t\tSET topic_id = '" . $new_topic_id . "'\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids); $db->sql_query($sql); $sql = "UPDATE " . POSTS_LIKES_TABLE . "\n\t\t\tSET topic_id = '" . $new_topic_id . "'\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids); $db->sql_query($sql); $sql = "DELETE FROM " . REGISTRATION_TABLE . "\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids); $db->sql_query($sql); $sql = "DELETE FROM " . REGISTRATION_DESC_TABLE . "\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids); $db->sql_query($sql); // TAGS - BEGIN @(include_once IP_ROOT_PATH . 'includes/class_topics_tags.' . PHP_EXT); $class_topics_tags = new class_topics_tags(); $tags = $class_topics_tags->get_topics_tags($topics); if (sizeof($tags) > 0) { $class_topics_tags->remove_tag_from_match($tags, $topics[$i]); $class_topics_tags->update_tag_entry($tags); } // TAGS - END // LIKES - BEGIN @(include_once IP_ROOT_PATH . 'includes/class_topics.' . PHP_EXT); $class_topics = new class_topics(); $class_topics->topics_posts_likes_resync(); // LIKES - END $db->sql_transaction('commit'); $this->topic_poll_delete($topics); $this->sync_cache(array($forum_id), array($new_topic_id)); return true; }