Forum
in package
Forum class
Tags
Table of Contents
Properties
- $_count_cache : array<string|int, mixed>
- $_db : DB
- $_permission_cache : array<string|int, mixed>
Methods
- __construct() : mixed
- canEditTopic() : bool
- Determine if the groups can edit [psts] in the forum or not.
- canModerateForum() : bool
- Determine if groups have permission to moderate a forum.
- canPostReply() : bool
- Determine if the groups can post replies in the forum or not.
- canPostTopic() : bool
- Determine if the groups can post topics in the forum or not.
- canViewForum() : bool
- Determine if the groups can view the forum or not.
- canViewOtherTopics() : bool
- forumExist() : bool
- Determine if a forum exists (in the context of a specific user)
- getAccessibleLabels() : array<string|int, mixed>
- Get an array returned of accessible labels when providing group ids
- getAnySubforums() : array<string|int, mixed>
- Get any subforums at any level for a forum
- getBannedTerms() : array<string|int, mixed>
- Get banned terms from the Forum module
- getForumTitle() : string
- Get the title of a specific forum.
- getIndividualPost() : array<string|int, mixed>|false
- Get data of a specific post.
- getLatestDiscussions() : array<string|int, mixed>
- Get the newest x topics this user/group can view
- getLatestNews() : array<string|int, mixed>
- Get the latest news posts to display on homepage.
- getPostCount() : int
- Get a user's post count
- getPosts() : array<string|int, mixed>|false
- Get posts on a specific topic.
- getTopicCount() : int
- Get a user's topic count
- listAllForums() : array<string|int, mixed>
- Get an array of forums a user can access, including topic information
- titleToURL() : string
- topicExist() : bool
- Determine if a topic exists or not.
- updateForumLatestPosts() : void
- Update the database with the new latest forum posts.
- updateTopicLatestPosts() : void
- Update the database with the new latest forum topic posts.
- getLatestPostInOwnTopicForum() : array<string|int, mixed>|null
- Get the latest post in a "View own topic" forum This could be a topic created by the user, or a sticky topic
- hasPermission() : bool
- Determines if any groups have permission to do a certain action on a forum
Properties
$_count_cache
private
static array<string|int, mixed>
$_count_cache
= []
$_db
private
DB
$_db
$_permission_cache
private
static array<string|int, mixed>
$_permission_cache
= []
Methods
__construct()
public
__construct() : mixed
canEditTopic()
Determine if the groups can edit [psts] in the forum or not.
public
canEditTopic(int $forum_id[, array<string|int, mixed> $groups = [0] ]) : bool
Parameters
- $forum_id : int
-
The forum ID
- $groups : array<string|int, mixed> = [0]
-
The user's groups
Return values
bool —Whether the groups can edit posts in the forum or not
canModerateForum()
Determine if groups have permission to moderate a forum.
public
canModerateForum([int|null $forum_id = null ][, array<string|int, mixed> $groups = [0] ]) : bool
Parameters
- $forum_id : int|null = null
-
The forum ID to check.
- $groups : array<string|int, mixed> = [0]
-
The groups to check.
Return values
bool —Whether the groups can moderate the forum.
canPostReply()
Determine if the groups can post replies in the forum or not.
public
canPostReply(int $forum_id[, array<string|int, mixed> $groups = [0] ]) : bool
Parameters
- $forum_id : int
-
The forum ID
- $groups : array<string|int, mixed> = [0]
-
The user's groups
Return values
bool —Whether the groups can post replies in the forum or not
canPostTopic()
Determine if the groups can post topics in the forum or not.
public
canPostTopic(int $forum_id[, array<string|int, mixed> $groups = [0] ]) : bool
Parameters
- $forum_id : int
-
The forum ID
- $groups : array<string|int, mixed> = [0]
-
The user's groups
Return values
bool —Whether the groups can post topics in the forum or not
canViewForum()
Determine if the groups can view the forum or not.
public
canViewForum(int $forum_id[, array<string|int, mixed> $groups = [0] ]) : bool
Parameters
- $forum_id : int
-
The forum ID
- $groups : array<string|int, mixed> = [0]
-
The user's groups
Return values
bool —Whether the groups can view the forum or not
canViewOtherTopics()
public
canViewOtherTopics(int $forum_id[, array<string|int, mixed> $groups = [0] ]) : bool
Parameters
- $forum_id : int
- $groups : array<string|int, mixed> = [0]
Return values
boolforumExist()
Determine if a forum exists (in the context of a specific user)
public
forumExist(int $forum_id[, array<string|int, mixed> $groups = [0] ]) : bool
Parameters
- $forum_id : int
-
ID of the forum
- $groups : array<string|int, mixed> = [0]
-
Array of groups the user is in
Return values
bool —Whether the forum exists or not
getAccessibleLabels()
Get an array returned of accessible labels when providing group ids
public
static getAccessibleLabels(array<string|int, mixed> $labels, array<string|int, mixed> $user_groups) : array<string|int, mixed>
Parameters
- $labels : array<string|int, mixed>
-
of label ids
- $user_groups : array<string|int, mixed>
-
array of a user their group ids
Return values
array<string|int, mixed> —An array of the ids of the labels the user has access to
getAnySubforums()
Get any subforums at any level for a forum
public
getAnySubforums(int $forum_id[, array<string|int, mixed> $groups = [0] ][, int $depth = 0 ][, bool|null $onlyOwnTopics = false ][, int|null $user_id = 0 ]) : array<string|int, mixed>
Parameters
- $forum_id : int
-
The forum ID
- $groups : array<string|int, mixed> = [0]
-
The user groups
- $depth : int = 0
-
The depth of the subforums to get
- $onlyOwnTopics : bool|null = false
-
Whether to only get forums in which the user can only view their own topics (default false)
- $user_id : int|null = 0
-
Current user ID (default 0) - only used if $onlyOwnTopics is true
Return values
array<string|int, mixed> —Subforums at any level for a forum
getBannedTerms()
Get banned terms from the Forum module
public
static getBannedTerms() : array<string|int, mixed>
Return values
array<string|int, mixed> —Array of banned terms
getForumTitle()
Get the title of a specific forum.
public
getForumTitle(int $forum_id) : string
Parameters
- $forum_id : int
-
The forum ID to get the title of.
Return values
string —The forum title.
getIndividualPost()
Get data of a specific post.
public
getIndividualPost(int $post_id) : array<string|int, mixed>|false
Parameters
- $post_id : int
-
The post ID to data about.
Return values
array<string|int, mixed>|false —The post data or false on failure.
getLatestDiscussions()
Get the newest x topics this user/group can view
public
getLatestDiscussions([array<string|int, mixed> $groups = [0] ][, int $user_id = 0 ][, int $limit = 50 ]) : array<string|int, mixed>
Parameters
- $groups : array<string|int, mixed> = [0]
-
Array of groups the user is in
- $user_id : int = 0
-
User ID
- $limit : int = 50
-
Limit of topics to return, default 50
Return values
array<string|int, mixed> —Latest topics
getLatestNews()
Get the latest news posts to display on homepage.
public
getLatestNews([int $number = 5 ][, array<string|int, mixed> $groups = [0] ]) : array<string|int, mixed>
TODO: can be optimised by including posts in the initial query?
Parameters
- $number : int = 5
-
The number of posts to get.
- $groups : array<string|int, mixed> = [0]
-
Array containing user's group IDs, default [0] for guests
Return values
array<string|int, mixed> —The latest news posts.
getPostCount()
Get a user's post count
public
getPostCount([int|null $user_id = null ]) : int
Parameters
- $user_id : int|null = null
-
User ID to check
Return values
int —Number of posts
getPosts()
Get posts on a specific topic.
public
getPosts([int|null $tid = null ]) : array<string|int, mixed>|false
Parameters
- $tid : int|null = null
-
The topic ID to check.
Return values
array<string|int, mixed>|false —Array of topics or false on failure.
getTopicCount()
Get a user's topic count
public
getTopicCount([int|null $user_id = null ]) : int
Parameters
- $user_id : int|null = null
-
User ID to check
Return values
int —Number of topics
listAllForums()
Get an array of forums a user can access, including topic information
public
listAllForums([array<string|int, mixed> $groups = [0] ][, int $user_id = 0 ]) : array<string|int, mixed>
Parameters
- $groups : array<string|int, mixed> = [0]
-
Users groups
- $user_id : int = 0
-
User ID
Return values
array<string|int, mixed> —Array of forums a user can access
titleToURL()
public
titleToURL([string $topic = null ]) : string
Parameters
- $topic : string = null
Return values
stringtopicExist()
Determine if a topic exists or not.
public
topicExist(int $topic_id) : bool
Parameters
- $topic_id : int
-
The topic ID
Return values
bool —Whether the topic exists or not
updateForumLatestPosts()
Update the database with the new latest forum posts.
public
updateForumLatestPosts(int $forum_id) : void
Parameters
- $forum_id : int
-
The forum ID to update
updateTopicLatestPosts()
Update the database with the new latest forum topic posts.
public
updateTopicLatestPosts(int $topic_id, int|null $forum_id) : void
Parameters
- $topic_id : int
-
The topic ID to update
- $forum_id : int|null
-
The forum ID to update if topic does not exist
getLatestPostInOwnTopicForum()
Get the latest post in a "View own topic" forum This could be a topic created by the user, or a sticky topic
private
getLatestPostInOwnTopicForum(int $forumId, int $userId) : array<string|int, mixed>|null
Parameters
- $forumId : int
- $userId : int
Return values
array<string|int, mixed>|null —Time of latest post, post creator ID, topic ID
hasPermission()
Determines if any groups have permission to do a certain action on a forum
private
hasPermission(int $forum_id, string $required_permission, array<string|int, mixed> $groups) : bool
Parameters
- $forum_id : int
-
ID of the forum
- $required_permission : string
-
Required permission
- $groups : array<string|int, mixed>
-
Array of groups the user is in
Return values
bool —Whether the groups have permission or not