/** * * Deletes a topic from the database. * This function completely deletes a topic and all associated objects (like * ratings, subscriptions, etc.). Before deleting the topic itself, all posts * are deleted using the "delete_post" method. * * @author Martin Helmich <*****@*****.**> * @version 2009-12-20 * @param int $topicId The UID of the topic that is to be deleted * @return void */ function delete_topic($topicId) { /* * Load the topic from the database. */ $arr = $this->databaseHandle->sql_fetch_assoc($this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_topics', 'uid=' . intval($topicId))); $uA = array('deleted' => 1, 'tstamp' => $GLOBALS['EXEC_TIME']); /* * Load all posts of this topic and delete them all. */ $res = $this->databaseHandle->exec_SELECTquery('uid', 'tx_mmforum_posts', 'topic_id=' . intval($topicId) . ' AND deleted=0'); while (list($postId) = $this->databaseHandle->sql_fetch_row($res)) { $this->delete_post($postId, true); } /* * Now delete all favorites, subscriptions, ratings and search index entries. */ $this->databaseHandle->exec_UPDATEquery('tx_mmforum_favorites', $uA, 'topic_id=' . intval($postId)); $this->databaseHandle->exec_UPDATEquery('tx_mmforum_havealook', $uA, 'topic_id=' . intval($postId)); $this->databaseHandle->exec_DELETEquery('tx_mmforum_wordmatch', 'topic_id=' . intval($topicId) . ''); if (ExtensionManagementUtility::extLoaded('ratings')) { $this->databaseHandle->exec_DELETEquery('tx_ratings_data', $uA, 'reference="tx_mmforum_topics_' . intval($postId) . '"'); } /* * Congratulations. Now delete the topic itself. */ $this->databaseHandle->exec_UPDATEquery('tx_mmforum_topics', $uA, 'uid=' . intval($postId)); /* * Now update all the internal counters. */ $this->updateQueue_addForum($arr['forum_id']); $this->updateQueue_addUser($arr['topic_poster']); $this->updateQueue_process(); }