CMS  Version 3.9
ForumTopic Class Reference

Inherits DataItem.

Public Member Functions

 FirstPost ()
 
 LastPost ()
 
 Forum ()
 
 getTitle ()
 
 Messages ($constraint="")
 
 countReplies ()
 When counting forum message replies to a topic, exclude the forum message that has a parent id of 0, that is the topic message, the initial post to which others may reply. More...
 

Public Attributes

 $primary_key = "topic_id"
 
 $table = "forum_topic"
 
 $fields
 
 $relations
 

Detailed Description

Definition at line 248 of file forum.inc.

Member Function Documentation

◆ countReplies()

ForumTopic::countReplies ( )

When counting forum message replies to a topic, exclude the forum message that has a parent id of 0, that is the topic message, the initial post to which others may reply.

Definition at line 298 of file forum.inc.

299  {
300  return Query::create(ForumMessage, "WHERE topic_id=:topic_id and parent_id > 0 and deleted=0")
301  ->bind(":topic_id", $this->topic_id)
302  ->executeValue("COUNT(1)");
303  }

◆ FirstPost()

ForumTopic::FirstPost ( )

Definition at line 267 of file forum.inc.

268  {
269  return $this->getRelated(ForumMessage);
270  }

◆ Forum()

ForumTopic::Forum ( )

Definition at line 278 of file forum.inc.

279  {
280  return $this->getRelated(Forum);
281  }
Definition: forum.inc:42

◆ getTitle()

ForumTopic::getTitle ( )

Definition at line 283 of file forum.inc.

284  {
285  return $this->FirstPost()->title;
286  }
FirstPost()
Definition: forum.inc:267

◆ LastPost()

ForumTopic::LastPost ( )

Definition at line 272 of file forum.inc.

273  {
274  $messages = $this->Messages("WHERE deleted=false ORDER BY date_posted DESC LIMIT 1");
275  return count($messages) > 0 ? $messages[0] : null;
276  }
Messages($constraint="")
Definition: forum.inc:288
$messages

◆ Messages()

ForumTopic::Messages (   $constraint = "")

Definition at line 288 of file forum.inc.

289  {
290  return $this->getRelatedList(ForumMessage, "", $constraint);
291  }
$constraint

Member Data Documentation

◆ $fields

ForumTopic::$fields
Initial value:
= array("topic_id" => Number,
"message_id" => Number,
"forum_id" => Number,
"views" => Number,
"replies" => Number,
"date_created" => Date)

Definition at line 254 of file forum.inc.

◆ $primary_key

ForumTopic::$primary_key = "topic_id"

Definition at line 250 of file forum.inc.

◆ $relations

ForumTopic::$relations
Initial value:
= array( "FirstPost" => ForumMessage,
"Forum" => Forum,
"LastPost" => ForumMessage,
"Messages" => ForumMessage)

Definition at line 262 of file forum.inc.

◆ $table

ForumTopic::$table = "forum_topic"

Definition at line 251 of file forum.inc.


The documentation for this class was generated from the following file: