/** * Create object from database row. * * @param stdClass $row Database row * @param ForumCategory $category Used for caching the category, if present. * * @return Forum */ public static function fromRow($row, ForumCategory $category = null) { global $user, $userManager; $forum = new self(!is_null($category) ? $category : $row->category_id, $row->title, $row->description, $row->order, $row->closed == '1', $row->id); if ($userManager->loggedIn()) { $lastPost = $forum->getLastPost(); $lastPostTime = $lastPost instanceof ForumPost ? $lastPost->getDate() : 0; $available = max($row->mark_time, $user->getRegisterDate()) < $lastPostTime ? true : false; $forum->setNewEntriesAvailable($available); } return $forum; }
public static function fromRow($row, Forum $forum = null) { global $user, $userManager, $db; $topic = new self(!is_null($forum) ? $forum : $row->forum_id, $row->user_id, $row->topic_title, $row->id); $topic->setImportant($row->topic_important == '1'); $topic->setClosed($row->topic_closed == '1'); // if user is logged in, use new entry-icons if ($userManager->loggedIn()) { $available = max($row->mark_time, $user->getRegisterDate()) < $topic->getLastPost()->getDate() ? true : false; $topic->setNewEntriesAvailable($available); } return $topic; }