/** * @depends testAddForum * @depends testCreateUser */ public function testAddThread($forum_id, $User) { $Forum = ForumsFactory::CreateForum($forum_id); $Thread = new Thread(); $Thread->setAuthor($User)->setForum($Forum); $Thread->title = "Test thread"; $Thread->commit(); $Post = new Post(); $Post->setAuthor($User)->setThread($Thread); $Post->text = "asdfasffasasfa87s9fsas989sfa9ffds"; $Post->commit(); $NewThread = ForumsFactory::CreateThread($Thread->id); $NewPost = ForumsFactory::CreatePost($Post->id); $Index = ForumsFactory::CreateIndex(); ForumsUtility::updateUserThreadView($Thread, $User); ForumsUtility::updateUserThreadView($Thread); ForumsUtility::getForumNotifications($User); }
/** * Constructor * @since Version 3.0.1 * @version 3.0.1 * @param object $database * @param int $postid */ public function __construct($postid = false) { $post_timer_start = Debug::GetTimer(); parent::__construct(); $this->Module = new Module("forums"); $this->timestamp = time(); $this->mckey = sprintf("railpage:forums;post=%d", $postid); $this->Memcached = AppCore::getMemcached(); if (!($row = $this->Memcached->fetch($this->mckey))) { Debug::LogEvent("Could not find forum post in Redis using cache key " . $this->mckey); if (filter_var($postid, FILTER_VALIDATE_INT)) { $timer = Debug::GetTimer(); $query = "SELECT p.*, t.*, u.username, u.user_avatar FROM nuke_bbposts p, nuke_bbposts_text t, nuke_users AS u WHERE u.user_id = p.poster_id AND p.post_id = ? AND t.post_id = p.post_id LIMIT 1"; $row = $this->db->fetchRow($query, $postid); $rs = $this->Memcached->save($this->mckey, $row, 43200); Debug::LogEvent("Fetch forum post from database", $timer); if (!$rs) { Debug::LogEvent("!! Failed to store forum post in cache provider"); } } elseif (is_string($postid)) { $query = "SELECT p.*, t.*, u.username, u.user_avatar FROM nuke_bbposts p, nuke_bbposts_text t, nuke_users AS u WHERE u.user_id = p.poster_id AND t.url_slug = ? AND t.post_id = p.post_id LIMIT 1"; $row = $this->db->fetchRow($query, $postid); $rs = $this->Memcached->save($this->mckey, $row, 43200); } } if (isset($row) && is_array($row)) { $this->id = $row['post_id']; $this->thread = ForumsFactory::CreateThread($row['topic_id']); $this->uid = $row['poster_id']; $this->username = $row['username']; $this->user_avatar = $row['user_avatar']; $this->timestamp = $row['post_time']; $this->ip = $row['poster_ip']; $this->flag_bbCode = $row['enable_bbcode']; $this->flag_html = $row['enable_html']; $this->flag_smilies = $row['enable_smilies']; $this->flag_signature = $row['enable_sig']; $this->edit_timestamp = $row['post_edit_time']; $this->edit_count = $row['post_edit_count']; $this->reported = $row['post_reported']; $this->herring_count = $row['post_edit_count']; $this->bbcodeuid = $row['bbcode_uid']; $this->subject = $row['post_subject']; $this->text = stripslashes($row['post_text']); $this->old_text = stripslashes($row['post_text']); $this->rating = $row['post_rating']; $this->bbcode_uid = $row['bbcode_uid']; $this->editor_version = $row['editor_version']; $this->url_slug = $row['url_slug']; $this->pinned = isset($row['pinned']) ? (bool) $row['pinned'] : false; if (empty($this->url_slug)) { $this->createSlug(); $this->commit(); } $this->lat = $row['lat']; $this->lon = $row['lon']; $this->Date = new DateTime(); $this->Date->setTimestamp($row['post_time']); $this->Author = UserFactory::CreateUser($row['poster_id']); $this->makeLinks(); } Debug::LogEvent(__METHOD__, $post_timer_start); }