Documentation

Unread
in package
implements ActionInterface Uses BackwardCompatibility

Finds and retrieves information about new posts and topics.

Table of Contents

Interfaces

ActionInterface
Interface for all action classes.

Properties

$sort_methods  : array<string|int, mixed>
$action_url  : string
$ascending  : bool
$boards  : array<string|int, mixed>
$cat_name  : string
$earliest_msg  : int
$have_temp_table  : int
$is_topics  : bool
$linktree_name  : string
$min_message  : int
$num_topics  : int
$obj  : object
$query_parameters  : array<string|int, mixed>
$query_this_board  : string
$see_board  : string
$selects  : array<string|int, mixed>
$sub_template  : string
$topic_request  : object
$backcompat  : array<string|int, mixed>

Methods

call()  : void
Convenience method to load() and execute() an instance of this class.
execute()  : void
Find unread topics and replies.
exportStatic()  : void
Provides a way to export a class's public static properties and methods to global namespace.
load()  : object
Static wrapper for constructor.
__construct()  : mixed
Constructor. Protected to force instantiation via self::load().
buildButtons()  : mixed
checkLoadAverage()  : mixed
Checks that the load averages aren't too high to show unread posts.
checkLoadAverageAll()  : mixed
Checks that the load averages aren't too high to show all unread posts.
finalizeSelects()  : mixed
Makes any needed adjustments to $this->selects.
getBoards()  : mixed
Figures out what boards we want to get messages from.
getCatName()  : mixed
Gets the category name, if applicable.
getEarliestMsg()  : mixed
Gets the ID of the earliest message that the current user has not read.
getTopicRequestWithoutTempTable()  : mixed
Sets $this->topic_request without the help of a temporary table.
getTopicRequestWithTempTable()  : mixed
For large forums, sets $this->topic_request with the help of a temporary table.
getTopics()  : mixed
makeTempTable()  : mixed
For large forums, creates a temporary table to use when showing all unread topics.
setNoTopics()  : mixed
setPaginationAndLinks()  : mixed
Constructs page index, sets the linktree, next/prev/up links, etc.
setSortMethod()  : mixed
Figures out how to sort the results.
setTopicRequest()  : mixed
Sets $this->topic_request to the appropriate query.

Properties

$sort_methods

public array<string|int, mixed> $sort_methods = ['subject' => 'ms.subject', 'starter' => 'COALESCE(mems.real_name, ms.poster_name)', 'replies' => 't.num_replies', 'views' => 't.num_views', 'first_post' => 't.id_topic', 'last_post' => 't.id_last_msg']

Ways to sort the posts. Keys are requestable methods, values are SQL ORDER BY statements

$action_url

protected string $action_url

Base URL for this action.

$ascending

protected bool $ascending

Whether to sort in ascending or descending order.

$boards

protected array<string|int, mixed> $boards = []

The boards to look in.

$cat_name

protected string $cat_name

Name of the category we are in, if applicable.

$earliest_msg

protected int $earliest_msg = 0

Earliest unread message.

$have_temp_table

protected int $have_temp_table = 0

Which temporary table we using, if any.

$is_topics

protected bool $is_topics = true

Whether we are getting topics or replies.

$linktree_name

protected string $linktree_name

Name of this action for the linktree

$min_message

protected int $min_message = 0

Lowest unread message ID.

$num_topics

protected int $num_topics = 0

How many unread topics we found.

$obj

protected static object $obj

An instance of this class. This is used by the load() method to prevent mulitple instantiations.

$query_parameters

protected array<string|int, mixed> $query_parameters = []

Parameters for the main query.

$query_this_board

protected string $query_this_board

SQL statement indicating the boards to look in.

$see_board

protected string $see_board = 'query_wanna_see_board'

Either 'query_see_board' or 'query_wanna_see_board'.

$selects

protected array<string|int, mixed> $selects = ['ms.subject AS first_subject', 'ms.poster_time AS first_poster_time', 'ms.id_topic', 't.id_board', 'b.name AS bname', 't.num_replies', 't.num_views', 'ms.id_member AS first_id_member', 'ml.id_member AS last_id_member', 'ml.poster_time AS last_poster_time', 'ms.poster_name as first_member_name', 'ml.poster_name as last_member_name', 'COALESCE(mems.real_name, ms.poster_name) AS first_display_name', 'COALESCE(meml.real_name, ml.poster_name) AS last_display_name', 'ml.subject AS last_subject', 'ml.icon AS last_icon', 'ms.icon AS first_icon', 't.id_poll', 't.is_sticky', 't.locked', 'ml.modified_time AS last_modified_time', 'COALESCE(lt.id_msg, lmr.id_msg, -1) + 1 AS new_from', 'SUBSTRING(ml.body, 1, 385) AS last_body', 'SUBSTRING(ms.body, 1, 385) AS first_body', 'ml.smileys_enabled AS last_smileys', 'ms.smileys_enabled AS first_smileys', 't.id_first_msg', 't.id_last_msg', 'ml.id_msg_modified', 't.approved', 't.unapproved_posts']

Columns for the SQL SELECT clause. This part is the same for each query. More columns will be added at runtime if avatars are shown on indices.

$sub_template

protected string $sub_template = 'unread'

Name of the sub-template to use.

$topic_request

protected object $topic_request

Database request to get the topics.

$backcompat

private static array<string|int, mixed> $backcompat = ['func_names' => ['call' => 'UnreadTopics']]

BackwardCompatibility settings for this class.

Methods

call()

Convenience method to load() and execute() an instance of this class.

public static call() : void

execute()

Find unread topics and replies.

public execute() : void

exportStatic()

Provides a way to export a class's public static properties and methods to global namespace.

public static exportStatic() : void

To do so:

  1. Use this trait in the class.
  2. At the END of the class's file, call its exportStatic() method.

Although it might not seem that way at first glance, this approach conforms to section 2.3 of PSR 1, since executing this method is simply a dynamic means of declaring functions when the file is included; it has no other side effects.

Regarding the $backcompat items:

A class's static properties are not exported to global variables unless explicitly included in $backcompat['prop_names']. Likewise, a class's static methods are not exported as global functions unless explicitly included in $backcompat['func_names'].

$backcompat['prop_names'] is a simple array where the keys are the names of one or more of a class's static properties, and the values are the names of global variables. In each case, the global variable will be set to a reference to the static property. Static properties that are not named in this array will not be exported.

$backcompat['func_names'] is a simple array where the keys are the names of one or more of a class's static methods, and the values are the names that should be used for global functions that will encapsulate those methods. Methods that are not named in this array will not be exported.

Adding non-static properties or methods to the $backcompat arrays will produce runtime errors. It is the responsibility of the developer to make sure not to do this.

load()

Static wrapper for constructor.

public static load() : object
Return values
object

An instance of this class.

__construct()

Constructor. Protected to force instantiation via self::load().

protected __construct() : mixed

buildButtons()

protected buildButtons() : mixed

checkLoadAverage()

Checks that the load averages aren't too high to show unread posts.

protected checkLoadAverage() : mixed

checkLoadAverageAll()

Checks that the load averages aren't too high to show all unread posts.

protected checkLoadAverageAll() : mixed

finalizeSelects()

Makes any needed adjustments to $this->selects.

protected finalizeSelects() : mixed

getBoards()

Figures out what boards we want to get messages from.

protected getBoards() : mixed

Sets $this->boards, $this->query_this_board, and $this->query_parameters.

Tags
todo

Break this up further.

getCatName()

Gets the category name, if applicable.

protected getCatName() : mixed

getEarliestMsg()

Gets the ID of the earliest message that the current user has not read.

protected getEarliestMsg() : mixed

getTopicRequestWithoutTempTable()

Sets $this->topic_request without the help of a temporary table.

protected getTopicRequestWithoutTempTable() : mixed

getTopicRequestWithTempTable()

For large forums, sets $this->topic_request with the help of a temporary table.

protected getTopicRequestWithTempTable() : mixed

getTopics()

protected getTopics() : mixed

makeTempTable()

For large forums, creates a temporary table to use when showing all unread topics.

protected makeTempTable() : mixed

setNoTopics()

protected setNoTopics() : mixed

Constructs page index, sets the linktree, next/prev/up links, etc.

protected setPaginationAndLinks() : mixed

setSortMethod()

Figures out how to sort the results.

protected setSortMethod() : mixed

setTopicRequest()

Sets $this->topic_request to the appropriate query.

protected setTopicRequest() : mixed

        
On this page

Search results