phpBB API Documentation
Class

phpbb\content_visibility

class content_visibility

phpbb_visibility Handle fetching and setting the visibility for topics and posts

Methods

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

Constructor

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

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

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

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

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

Create topic/post visibility SQL for a given forum ID

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

Create topic/post visibility SQL for a set of forums

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

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

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

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

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

Set topic visibility

null add_post_to_statistic($data $data, &$sql_data $sql_data)

Add post to topic and forum statistics

null remove_post_from_statistic($data $data, &$sql_data $sql_data)

Remove post from topic and forum statistics

null remove_topic_from_statistic($data $data, &$sql_data $sql_data)

Remove topic from forum statistics

Details

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

Constructor

Parameters

auth $auth
config $config
dispatcher_interface $phpbb_dispatcher
driver_interface $db
user $user
$phpbb_root_path
$php_ext
$forums_table
$posts_table
$topics_table
$users_table

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

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

Parameters

$forum_id $forum_id int Forum ID whose permissions to check
$poster_id $poster_id int Poster ID of the post in question
$post_locked $post_locked bool Is the post locked?

Return Value

bool

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

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

Parameters

$mode $mode string One of topicposts, forumposts or forum_topics
$data $data array Array with the topic/forum data to calculate from
$forum_id $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 144
public string get_visibility_sql($mode $mode, $forum_id $forum_id, $table_alias $table_alias = '')

Create topic/post visibility SQL for a given forum ID

Note: Read permissions are not checked.

Parameters

$mode $mode string Either "topic" or "post"
$forum_id $forum_id int The forum id is used for permission checks
$table_alias $table_alias string Table alias to prefix in SQL queries

Return Value

string The appropriate combination SQL logic for topic/post_visibility

at line 196
public string get_forums_visibility_sql($mode $mode, $forum_ids $forum_ids = array(), $table_alias $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 $mode string Either "topic" or "post"
$forum_ids $forum_ids array Array of forum ids which the posts/topics are limited to
$table_alias $table_alias string Table alias to prefix in SQL queries

Return Value

string The appropriate combination SQL logic for topic/post_visibility

at line 272
public string get_global_visibility_sql($mode $mode, $exclude_forum_ids $exclude_forum_ids = array(), $table_alias $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 $excludeforumids

Parameters

$mode $mode string Either "topic" or "post"
$exclude_forum_ids $exclude_forum_ids array Array of forum ids which are excluded
$table_alias $table_alias string Table alias to prefix in SQL queries

Return Value

string The appropriate combination SQL logic for topic/post_visibility

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

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

Parameters

$visibility $visibility int Element of {ITEMAPPROVED, ITEMDELETED, ITEM_REAPPROVE}
$post_id $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 $topic_id int Topic where $post_id is found
$forum_id $forum_id int Forum where $topic_id is found
$user_id $user_id int User performing the action
$time $time int Timestamp when the action is performed
$reason $reason string Reason why the visibility was changed.
$is_starter $is_starter bool Is this the first post of the topic changed?
$is_latest $is_latest bool Is this the last post of the topic changed?
$limit_visibility $limit_visibility mixed Limit updating per topic_id to a certain visibility
$limit_delete_time $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 669
public array set_topic_visibility($visibility $visibility, $topic_id $topic_id, $forum_id $forum_id, $user_id $user_id, $time $time, $reason $reason, $force_update_all $force_update_all = false)

Set topic visibility

Allows approving (which is akin to undeleting/restore) or soft deleting an entire topic. Calls setpostvisibility 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 $visibility int Element of {ITEMAPPROVED, ITEMDELETED, ITEM_REAPPROVE}
$topic_id $topic_id mixed Topic ID to act on
$forum_id $forum_id int Forum where $topic_id is found
$user_id $user_id int User performing the action
$time $time int Timestamp when the action is performed
$reason $reason string Reason why the visibilty was changed.
$force_update_all $force_update_all bool Force to update all posts within the topic

Return Value

array Changed topic data, empty array if an error occured.

at line 788
public null add_post_to_statistic($data $data, &$sql_data $sql_data)

Add post to topic and forum statistics

Parameters

$data $data array Contains information from the topics table about given topic
&$sql_data $sql_data array Populated with the SQL changes, may be empty at call time

Return Value

null

at line 809
public null remove_post_from_statistic($data $data, &$sql_data $sql_data)

Remove post from topic and forum statistics

Parameters

$data $data array Contains information from the topics table about given topic
&$sql_data $sql_data array Populated with the SQL changes, may be empty at call time

Return Value

null

at line 842
public null remove_topic_from_statistic($data $data, &$sql_data $sql_data)

Remove topic from forum statistics

Parameters

$data $data array Post and topic data
&$sql_data $sql_data array Populated with the SQL changes, may be empty at call time

Return Value

null