/** * Returns class instance * * @return FORUM_BOL_ReadTopicDao */ public static function getInstance() { if (self::$classInstance === null) { self::$classInstance = new self(); } return self::$classInstance; }
/** * Deletes topic * * @param int $topicId */ public function deleteTopic($topicId) { //delete flags BOL_FlagService::getInstance()->deleteByTypeAndEntityId(FORUM_CLASS_ContentProvider::ENTITY_TYPE, $topicId); $editPostDao = FORUM_BOL_EditPostDao::getInstance(); $readTopicDao = FORUM_BOL_ReadTopicDao::getInstance(); $postIds = $this->postDao->findTopicPostIdList($topicId); if ($postIds) { //delete topic posts edit info $editPostDao->deleteByPostIdList($postIds); //delete topic posts foreach ($postIds as $post) { $this->deletePost($post); } } //delete topic read info $readTopicDao->deleteByTopicId($topicId); OW::getEventManager()->trigger(new OW_Event(self::EVENT_BEFORE_TOPIC_DELETE, array('topicId' => $topicId))); //delete topic $this->topicDao->deleteById($topicId); OW::getEventManager()->trigger(new OW_Event('feed.delete_item', array('entityType' => 'forum-topic', 'entityId' => $topicId))); $event = new OW_Event(self::EVENT_AFTER_TOPIC_DELETE, array('topicId' => $topicId)); OW::getEventManager()->trigger($event); }