Topic model represents a discussion topic in ForkBB. It extends DataModel and provides properties and methods for managing topics, posts, subscriptions, and table of contents.
Location
app/Models/Topic/Topic.php
Properties
Unique topic identifier
Topic subject/title
ID of the parent forum
ID of the user who created the topic
Timestamp when topic was created
Timestamp of the last post
ID of the last post
ID of the first post
Number of replies (posts minus one)
Total view count
Topic closed status (0=open, 1=closed)
Sticky/pinned status (0=normal, 1=sticky)
ID of topic this was moved to (for move stubs)
Poll type (0=no poll, >0=has poll)
Post ID marked as solution (0=no solution)
Whether to stick first post on all pages
JSON-encoded table of contents data
Current page number
Color number for colored subjects
Computed Properties
Parent forum object
Censored topic subject
URL-friendly topic name
Poll object if topic has a poll, otherwise
nullTotal number of pages in the topic
Pagination array for topic pages
Whether view counts are enabled
Formatted table of contents for the topic
Color number if colored subjects are enabled
Permission Properties
Returns
true if current user can reply to this topicReturns
true if current user can subscribe to topic updatesReturns
true if current user can change the solution postNew/Unread Properties
Timestamp of last visit if topic has new posts, otherwise
falseTimestamp if topic has unread posts, otherwise
falsePost ID of first new post (0 if none)
Post ID of first unread post (0 if none)
Link Properties
URL to the topic page
URL to reply to the topic
URL to jump to the last post
URL to jump to first new post
URL to jump to first unread post
URL to subscribe to topic
URL to unsubscribe from topic
Extended breadcrumb link (for scrolling to topic in forum)
URL to jump to the solution post
Methods
hasPage()
Checks if the current page number is valid for this topic.bool - true if page is valid
Example:
pageData()
Returns an array of posts for the current page.InvalidArgumentException if page number is invalid
Example:
review()
Returns posts for topic review (latest posts in reverse order).calcPage()
Calculates which page a specific post is on.Post ID to find
incViews()
Increments the view count for the topic.updateVisits()
Updates the current user’s last visit and last read markers for this topic.addPostToToc()
Adds or updates a post in the topic’s table of contents.The post to add (must be parsed by Parser first)
Whether to merge with existing TOC entries
deleteFromToc()
Removes specific posts from the table of contents.Variable number of post IDs to remove