class content_visibility

phpbb_visibility Handle fetching and setting the visibility for topics and posts

Properties

protected driver_interface $db

Database object

protected user $user

User object

protected auth $auth

Auth object

protected config $config

config object

protected dispatcher_interface $phpbb_dispatcher

Event dispatcher object

protected string $phpbb_root_path

phpBB root path

protected string $php_ext

PHP Extension

Methods

__construct(auth $auth, config $config, dispatcher_interface $phpbb_dispatcher, driver_interface $db, user $user, string $phpbb_root_path, string $php_ext, string $forums_table, string $posts_table, string $topics_table, string $users_table)

Constructor

bool
can_soft_delete($forum_id, $poster_id, $post_locked)

Can the current logged-in user soft-delete posts?

int
get_count($mode, $data, $forum_id)

Get the topics post count or the forums post/topic count based on permissions

bool
is_visible($mode, $forum_id, $data)

Check topic/post visibility for a given forum ID

string
get_visibility_sql($mode, $forum_id, $table_alias = '')

Create topic/post visibility SQL for a given forum ID

string
get_forums_visibility_sql($mode, $forum_ids = array(), $table_alias = '')

Create topic/post visibility SQL for a set of forums

string
get_global_visibility_sql($mode, $exclude_forum_ids = array(), $table_alias = '')

Create topic/post visibility SQL for all forums on the board

array
set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest, $limit_visibility = false, $limit_delete_time = false)

Change visibility status of one post or all posts of a topic

array
set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all = false)

Set topic visibility

null
add_post_to_statistic($data, $sql_data)

Add post to topic and forum statistics

null
remove_post_from_statistic($data, $sql_data)

Remove post from topic and forum statistics

null
remove_topic_from_statistic($data, $sql_data)

Remove topic from forum statistics

Details

at line 79
__construct(auth $auth, config $config, dispatcher_interface $phpbb_dispatcher, driver_interface $db, user $user, string $phpbb_root_path, string $php_ext, string $forums_table, string $posts_table, string $topics_table, string $users_table)

Constructor

Parameters

auth $auth

Auth object

config $config

Config object

dispatcher_interface $phpbb_dispatcher

Event dispatcher object

driver_interface $db

Database object

user $user

User object

string $phpbb_root_path

Root path

string $php_ext

PHP Extension

string $forums_table

Forums table name

string $posts_table

Posts table name

string $topics_table

Topics table name

string $users_table

Users table name

at line 102
bool can_soft_delete($forum_id, $poster_id, $post_locked)

Can the current logged-in user soft-delete posts?

Parameters

$forum_id

int Forum ID whose permissions to check

$poster_id

int Poster ID of the post in question

$post_locked

bool Is the post locked?

Return Value

bool

at line 124
int get_count($mode, $data, $forum_id)

Get the topics post count or the forums post/topic count based on permissions

Parameters

$mode

string One of topic_posts, forum_posts or forum_topics

$data

array Array with the topic/forum data to calculate from

$forum_id

int The forum id is used for permission checks

Return Value

int

Number of posts/topics the user can see in the topic/forum

at line 145
bool is_visible($mode, $forum_id, $data)

Check topic/post visibility for a given forum ID

Note: Read permissions are not checked.

Parameters

$mode

string Either "topic" or "post"

$forum_id

int The forum id is used for permission checks

$data

array Array with item information to check visibility

Return Value

bool

True if the item is visible, false if not

at line 187
string get_visibility_sql($mode, $forum_id, $table_alias = '')

Create topic/post visibility SQL for a given forum ID

Note: Read permissions are not checked.

Parameters

$mode

string Either "topic" or "post"

$forum_id

int The forum id is used for permission checks

$table_alias

string Table alias to prefix in SQL queries

Return Value

string

The appropriate combination SQL logic for topic/post_visibility

at line 250
string get_forums_visibility_sql($mode, $forum_ids = array(), $table_alias = '')

Create topic/post visibility SQL for a set of forums

Note: Read permissions are not checked. Forums without read permissions should not be in $forum_ids

Parameters

$mode

string Either "topic" or "post"

$forum_ids

array Array of forum ids which the posts/topics are limited to

$table_alias

string Table alias to prefix in SQL queries

Return Value

string

The appropriate combination SQL logic for topic/post_visibility

at line 311
string get_global_visibility_sql($mode, $exclude_forum_ids = array(), $table_alias = '')

Create topic/post visibility SQL for all forums on the board

Note: Read permissions are not checked. Forums without read permissions should be in $exclude_forum_ids

Parameters

$mode

string Either "topic" or "post"

$exclude_forum_ids

array Array of forum ids which are excluded

$table_alias

string Table alias to prefix in SQL queries

Return Value

string

The appropriate combination SQL logic for topic/post_visibility

at line 376
array set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest, $limit_visibility = false, $limit_delete_time = false)

Change visibility status of one post or all posts of a topic

Parameters

$visibility

int Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE}

$post_id

mixed Post ID or array of post IDs to act on, if it is empty, all posts of topic_id will be modified

$topic_id

int Topic where $post_id is found

$forum_id

int Forum where $topic_id is found

$user_id

int User performing the action

$time

int Timestamp when the action is performed

$reason

string Reason why the visibility was changed.

$is_starter

bool Is this the first post of the topic changed?

$is_latest

bool Is this the last post of the topic changed?

$limit_visibility

mixed Limit updating per topic_id to a certain visibility

$limit_delete_time

mixed Limit updating per topic_id to a certain deletion time

Return Value

array

Changed post data, empty array if an error occurred.

at line 714
array set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all = false)

Set topic visibility

Allows approving (which is akin to undeleting/restore) or soft deleting an entire topic. Calls set_post_visibility as needed.

Note: By default, when a soft deleted topic is restored. Only posts that were approved at the time of soft deleting, are being restored. Same applies to soft deleting. Only approved posts will be marked as soft deleted. If you want to update all posts, use the force option.

Parameters

$visibility

int Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE}

$topic_id

mixed Topic ID to act on

$forum_id

int Forum where $topic_id is found

$user_id

int User performing the action

$time

int Timestamp when the action is performed

$reason

string Reason why the visibilty was changed.

$force_update_all

bool Force to update all posts within the topic

Return Value

array

Changed topic data, empty array if an error occurred.

at line 835
null add_post_to_statistic($data, $sql_data)

Add post to topic and forum statistics

Parameters

$data

array Contains information from the topics table about given topic

$sql_data

array Populated with the SQL changes, may be empty at call time (by reference)

Return Value

null

at line 856
null remove_post_from_statistic($data, $sql_data)

Remove post from topic and forum statistics

Parameters

$data

array Contains information from the topics table about given topic

$sql_data

array Populated with the SQL changes, may be empty at call time (by reference)

Return Value

null

at line 889
null remove_topic_from_statistic($data, $sql_data)

Remove topic from forum statistics

Parameters

$data

array Post and topic data

$sql_data

array Populated with the SQL changes, may be empty at call time (by reference)

Return Value

null