示例#1
0
 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;
 }
示例#2
0
 /**
  * @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;
 }
示例#3
0
文件: read.php 项目: madcsaba/li-de
 /**
  * @return KunenaForumTopicUserRead
  */
 public function getTopic()
 {
     return KunenaForumTopicUserReadHelper::get($this->topic_id);
 }
示例#4
0
文件: topic.php 项目: madcsaba/li-de
 /**
  * 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;
 }