/** * Copies all SQL data of the threads with the given thread ids. */ public static function copyAll($threadIDs, $boardID) { if (empty($threadIDs)) { return; } // copy 'thread' data $mapping = array(); $sql = "SELECT\t*\n\t\t\tFROM \twbb" . WBB_N . "_thread\n\t\t\tWHERE \tthreadID IN (" . $threadIDs . ")"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $thread = new ThreadEditor(null, $row); $mapping[$thread->threadID] = $thread->copy($boardID); } // copy 'thread_announcement' data $sql = "SELECT\t*\n\t\t\tFROM \twbb" . WBB_N . "_thread_announcement\n\t\t\tWHERE \tthreadID IN (" . $threadIDs . ")"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $sql = "INSERT INTO\twbb" . WBB_N . "_thread_announcement\n\t\t\t\t\t\t(boardID, threadID)\n\t\t\t\tVALUES \t\t(" . $row['boardID'] . ", " . $mapping[$row['threadID']] . ")"; WCF::getDB()->registerShutdownUpdate($sql); } // copy 'thread_rating' data $sql = "SELECT\t*\n\t\t\tFROM \twbb" . WBB_N . "_thread_rating\n\t\t\tWHERE \tthreadID IN (" . $threadIDs . ")"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $sql = "INSERT INTO\twbb" . WBB_N . "_thread_rating\n\t\t\t\t\t\t(threadID, rating, userID, ipAddress)\n\t\t\t\tVALUES\t\t(" . $mapping[$row['threadID']] . ", " . $row['rating'] . ",\n\t\t\t\t\t\t" . $row['userID'] . ", '" . escapeString($row['ipAddress']) . "')"; WCF::getDB()->registerShutdownUpdate($sql); } // copy 'thread_subscription' data $sql = "SELECT\t*\n\t\t\tFROM \twbb" . WBB_N . "_thread_subscription\n\t\t\tWHERE \tthreadID IN (" . $threadIDs . ")"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $sql = "INSERT INTO \twbb" . WBB_N . "_thread_subscription\n\t\t\t\t\t\t(userID, threadID, enableNotification, emails)\n\t\t\t\tVALUES\t\t(" . $row['userID'] . ", " . $mapping[$row['threadID']] . ",\n\t\t\t\t\t\t" . $row['enableNotification'] . ", " . $row['emails'] . ")"; WCF::getDB()->registerShutdownUpdate($sql); } // copy 'thread_visit' data $sql = "SELECT \t*\n\t\t\tFROM \twbb" . WBB_N . "_thread_visit\n\t\t\tWHERE \tthreadID IN (" . $threadIDs . ")"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $sql = "INSERT INTO \twbb" . WBB_N . "_thread_visit\n\t\t\t\t\t\t(threadID, userID, lastVisitTime)\n\t\t\t\tVALUES\t\t(" . $mapping[$row['threadID']] . ", " . $row['userID'] . ", " . $row['lastVisitTime'] . ")"; WCF::getDB()->registerShutdownUpdate($sql); } // update user posts & activity points self::updateUserStats($threadIDs, 'copy', $boardID); // copy posts (and polls, attachments) PostEditor::copyAll(self::getAllPostIds($threadIDs), null, $mapping, $boardID); // check prefixes self::checkPrefixes(implode(',', $mapping), $boardID); }