public function isNew($user = null) { $user = KunenaUserHelper::get($user); if (!KunenaFactory::getConfig()->shownew || !$user->exists()) { return false; } $session = KunenaFactory::getSession(); if ($this->time < $session->lasttime) { return false; } $allreadtime = KunenaForumCategoryUserHelper::get($this->getCategory(), $user)->allreadtime; if ($allreadtime && $this->time < JFactory::getDate($allreadtime)->toUnix()) { return false; } $read = KunenaForumTopicUserReadHelper::get($this->getTopic(), $user); if ($this->id == $read->message_id || $this->time < $read->time) { return false; } return true; }
/** * @param mixed $user * * @return bool */ public function markRead($user = null) { $user = KunenaUserHelper::get($user); if (!KunenaFactory::getConfig()->shownew || !$user->exists()) { return false; } $read = KunenaForumTopicUserReadHelper::get($this, $user); $read->time = JFactory::getDate()->toUnix(); $read->message_id = $this->last_post_id; $read->save(); return true; }
/** * @return KunenaForumTopicUserRead */ public function getTopic() { return KunenaForumTopicUserReadHelper::get($this->topic_id); }
/** * Method to save the KunenaForumTopic object to the database. * * @param bool $cascade * * @return bool True on success. * */ public function save($cascade = true) { $topicDelta = $this->delta(); $postDelta = $this->posts - $this->_posts; $isNew = !$this->exists(); if (!parent::save()) { return false; } $this->_posts = $this->posts; // Clear authentication cache $this->_authfcache = $this->_authccache = $this->_authcache = array(); if ($cascade) { $category = $this->getCategory(); if (!$category->update($this, $topicDelta, $postDelta)) { $this->setError($category->getError()); } } if ($isNew) { KunenaForumTopicUserReadHelper::purge(); } return true; }