Documentation

ReportedContent
in package
implements ActionInterface Uses BackwardCompatibility

Handles reported members and posts, as well as moderation comments.

Table of Contents

Interfaces

ActionInterface
Interface for all action classes.

Properties

$subaction  : string
$subactions  : array<string|int, mixed>
$type  : string
$types  : array<string|int, mixed>
$manage_bans  : bool
$obj  : object
$remove_any_boards  : array<string|int, mixed>
$backcompat  : array<string|int, mixed>

Methods

call()  : void
Convenience method to load() and execute() an instance of this class.
comment()  : void
Creates and deletes moderator comments.
details()  : void
Shows detailed information about a report, such as report comments and moderator comments.
editComment()  : void
Backward compatibility wrapper for the editcomment sub-action.
execute()  : void
Dispatcher to whichever sub-action method is necessary.
exportStatic()  : void
Provides a way to export a class's public static properties and methods to global namespace.
handleComment()  : void
Backward compatibility wrapper for the handlecomment sub-action.
handleReport()  : void
Backward compatibility wrapper for the handle sub-action.
load()  : object
Static wrapper for constructor.
modifyComment()  : void
Shows a textarea for editing a moderator comment.
recountOpenReports()  : int
Recount all open reports. Sets a SESSION var with the updated info.
reportDetails()  : void
Backward compatibility wrapper for the details sub-action.
setState()  : void
Performs closing and ignoring actions for a given report.
show()  : void
Shows all currently open reported posts.
showClosed()  : void
Shows all currently closed reported posts.
showClosedReports()  : void
Backward compatibility wrapper for the closed sub-action.
showReports()  : void
Backward compatibility wrapper for the show sub-action.
__construct()  : mixed
Constructor. Protected to force instantiation via self::load().
buildQuickButtons()  : void
clearReportAlerts()  : void
Upon close/ignore, mark unread alerts as read.
countReports()  : int
Counts how many reports there are in total. Used for creating pagination.
deleteModComment()  : void
Deletes a moderator comment from the DB.
editModComment()  : void
Saves the new information whenever a moderator comment is edited.
getCommentModDetails()  : array<string|int, mixed>
Gets specific details about a moderator comment.
getReportComments()  : array<string|int, mixed>
Gets both report comments as well as any moderator comment.
getReportDetails()  : array<string|int, mixed>
Gets additional information for a specific report.
getReports()  : array<string|int, mixed>
Get all possible reports the current user can see.
saveModComment()  : void
Inserts a new moderator comment to the DB.
updateReport()  : void
Updates a report with the given parameters.

Properties

$subaction

public string $subaction = 'show'

The requested sub-action. This should be set by the constructor.

$subactions

public static array<string|int, mixed> $subactions = ['show' => 'show', 'closed' => 'showClosed', 'details' => 'details', 'handle' => 'setState', 'handlecomment' => 'comment', 'editcomment' => 'modifyComment']

Available sub-actions.

$types

public static array<string|int, mixed> $types = ['posts', 'members']

Supported report types

$manage_bans

protected bool $manage_bans = false

Whether the current user has the manage_bans permission.

$obj

protected static object $obj

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

$remove_any_boards

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

Boards where the current user can remove any message.

$backcompat

private static array<string|int, mixed> $backcompat = ['func_names' => ['call' => 'ReportedContent', 'recountOpenReports' => 'recountOpenReports', 'showReports' => 'ShowReports', 'showClosedReports' => 'ShowClosedReports', 'reportDetails' => 'ReportDetails', 'handleReport' => 'HandleReport', 'handleComment' => 'HandleComment', 'editComment' => 'EditComment']]

BackwardCompatibility settings for this class.

Methods

call()

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

public static call() : void

comment()

Creates and deletes moderator comments.

public comment() : void

details()

Shows detailed information about a report, such as report comments and moderator comments.

public details() : void

Shows a list of moderation actions for the specific report.

editComment()

Backward compatibility wrapper for the editcomment sub-action.

public static editComment() : void

execute()

Dispatcher to whichever sub-action method is necessary.

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.

handleComment()

Backward compatibility wrapper for the handlecomment sub-action.

public static handleComment() : void

handleReport()

Backward compatibility wrapper for the handle sub-action.

public static handleReport() : void

load()

Static wrapper for constructor.

public static load() : object
Return values
object

An instance of this class.

modifyComment()

Shows a textarea for editing a moderator comment.

public modifyComment() : void

Handles the edited comment and stores it in the DB.

recountOpenReports()

Recount all open reports. Sets a SESSION var with the updated info.

public static recountOpenReports(string $type) : int
Parameters
$type : string

the type of reports to count

Return values
int

the update open report count.

reportDetails()

Backward compatibility wrapper for the details sub-action.

public static reportDetails() : void

setState()

Performs closing and ignoring actions for a given report.

public setState() : void

show()

Shows all currently open reported posts.

public show() : void

Handles closing multiple reports.

showClosed()

Shows all currently closed reported posts.

public showClosed() : void

showClosedReports()

Backward compatibility wrapper for the closed sub-action.

public static showClosedReports() : void

showReports()

Backward compatibility wrapper for the show sub-action.

public static showReports() : void

__construct()

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

protected __construct() : mixed

clearReportAlerts()

Upon close/ignore, mark unread alerts as read.

protected clearReportAlerts(string $log_report, array<string|int, mixed> $extra) : void
Parameters
$log_report : string

What action is being taken.

$extra : array<string|int, mixed>

Detailed info about the report.

countReports()

Counts how many reports there are in total. Used for creating pagination.

protected countReports([int $closed = 0 ]) : int
Parameters
$closed : int = 0

1 for counting closed reports, 0 for open ones.

Return values
int

How many reports.

deleteModComment()

Deletes a moderator comment from the DB.

protected deleteModComment(int $comment_id) : void
Parameters
$comment_id : int

The moderator comment ID used to identify which report will be deleted.

editModComment()

Saves the new information whenever a moderator comment is edited.

protected editModComment(int $comment_id, string $edited_comment) : void
Parameters
$comment_id : int

The edited moderator comment ID.

$edited_comment : string

The edited moderator comment text.

getCommentModDetails()

Gets specific details about a moderator comment.

protected getCommentModDetails(int $comment_id) : array<string|int, mixed>

It also adds a permission for editing/deleting the comment. By default only admins and the author of the comment can edit/delete it.

Parameters
$comment_id : int

The moderator comment ID to get the info from.

Return values
array<string|int, mixed>

An array with the fetched data.

getReportComments()

Gets both report comments as well as any moderator comment.

protected getReportComments(int $report_id) : array<string|int, mixed>
Parameters
$report_id : int

The report ID to get the info from.

Return values
array<string|int, mixed>

An associative array with 2 keys: comments and mod_comments.

getReportDetails()

Gets additional information for a specific report.

protected getReportDetails(int $report_id) : array<string|int, mixed>
Parameters
$report_id : int

The report ID to get the info from.

Return values
array<string|int, mixed>

The report data.

getReports()

Get all possible reports the current user can see.

protected getReports([int $closed = 0 ]) : array<string|int, mixed>
Parameters
$closed : int = 0

1 for closed reports, 0 for open ones.

Return values
array<string|int, mixed>

The reports data, with the report ID as key.

saveModComment()

Inserts a new moderator comment to the DB.

protected saveModComment(int $report_id, array<string|int, mixed> $data) : void
Parameters
$report_id : int

The report ID is used to fire a notification about the event.

$data : array<string|int, mixed>

a formatted array of data to be inserted. Should be already properly sanitized.

updateReport()

Updates a report with the given parameters.

protected updateReport(string $action, int $value, int|array<string|int, mixed> $report_id) : void

Logs each action via Logging::logAction().

Parameters
$action : string

The action to perform. Accepts "closed" and "ignore".

$value : int

The new value to update.

$report_id : int|array<string|int, mixed>

The affected report(s).


        
On this page

Search results