Posts
in package
implements
ActionInterface
Uses
BackwardCompatibility
Handles things related to post moderation.
Table of Contents
Interfaces
- ActionInterface
- Interface for all action classes.
Properties
- $subaction : string
- $subactions : array<string|int, mixed>
- $obj : object
- $backcompat : array<string|int, mixed>
Methods
- approve() : void
- Approve a post, just the one.
- approveAllData() : void
- This is a helper function - basically approve everything!
- approveMessage() : void
- Backward compatibility wrapper for the approve sub-action.
- attachments() : void
- View all unapproved attachments.
- call() : void
- Convenience method to load() and execute() an instance of this class.
- 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.
- list_getNumUnapprovedAttachments() : int
- Callback function for UnapprovedAttachments count all the attachments waiting for approval that this approver can approve
- list_getUnapprovedAttachments() : array<string|int, mixed>
- Callback function for UnapprovedAttachments retrieve all the attachments waiting for approval the approver can approve
- load() : object
- Static wrapper for constructor.
- posts() : void
- View all unapproved posts.
- unapprovedAttachments() : void
- Backward compatibility wrapper for the attachments sub-action.
- unapprovedPosts() : void
- Backward compatibility wrapper for the replies sub-action.
- __construct() : mixed
- Constructor. Protected to force instantiation via self::load().
- approveMessages() : void
- Approve a batch of posts (or topics in their own right)
- removeMessages() : void
- Remove a batch of messages (or topics)
Properties
$subaction
public
string
$subaction
= 'replies'
The requested sub-action. This should be set by the constructor.
$subactions
public
static array<string|int, mixed>
$subactions
= ['replies' => 'posts', 'topics' => 'posts', 'attachments' => 'attachments', 'approve' => 'approve']
Available sub-actions.
$obj
protected
static object
$obj
An instance of this class. This is used by the load() method to prevent mulitple instantiations.
$backcompat
private
static array<string|int, mixed>
$backcompat
= ['func_names' => ['call' => 'PostModerationMain', 'approveAllData' => 'approveAllData', 'list_getUnapprovedAttachments' => 'list_getUnapprovedAttachments', 'list_getNumUnapprovedAttachments' => 'list_getNumUnapprovedAttachments', 'unapprovedPosts' => 'UnapprovedPosts', 'unapprovedAttachments' => 'UnapprovedAttachments', 'approveMessage' => 'ApproveMessage']]
BackwardCompatibility settings for this class.
Methods
approve()
Approve a post, just the one.
public
approve() : void
approveAllData()
This is a helper function - basically approve everything!
public
static approveAllData() : void
approveMessage()
Backward compatibility wrapper for the approve sub-action.
public
static approveMessage() : void
attachments()
View all unapproved attachments.
public
attachments() : void
call()
Convenience method to load() and execute() an instance of this class.
public
static call() : 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:
- Use this trait in the class.
- 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.
list_getNumUnapprovedAttachments()
Callback function for UnapprovedAttachments count all the attachments waiting for approval that this approver can approve
public
static list_getNumUnapprovedAttachments(string $approve_query) : int
Parameters
- $approve_query : string
-
Additional restrictions based on the boards the approver can see
Return values
int —The number of unapproved attachments
list_getUnapprovedAttachments()
Callback function for UnapprovedAttachments retrieve all the attachments waiting for approval the approver can approve
public
static list_getUnapprovedAttachments(int $start, int $items_per_page, string $sort, string $approve_query) : array<string|int, mixed>
Parameters
- $start : int
-
The item to start with (for pagination purposes)
- $items_per_page : int
-
How many items to show on each page
- $sort : string
-
A string indicating how to sort the results
- $approve_query : string
-
Additional restrictions based on the boards the approver can see
Return values
array<string|int, mixed> —An array of information about the unapproved attachments
load()
Static wrapper for constructor.
public
static load() : object
Return values
object —An instance of this class.
posts()
View all unapproved posts.
public
posts() : void
unapprovedAttachments()
Backward compatibility wrapper for the attachments sub-action.
public
static unapprovedAttachments() : void
unapprovedPosts()
Backward compatibility wrapper for the replies sub-action.
public
static unapprovedPosts() : void
__construct()
Constructor. Protected to force instantiation via self::load().
protected
__construct() : mixed
approveMessages()
Approve a batch of posts (or topics in their own right)
protected
approveMessages(array<string|int, mixed> $messages, array<string|int, mixed> $messageDetails[, string $current_view = 'replies' ]) : void
Parameters
- $messages : array<string|int, mixed>
-
The IDs of the messages to approve
- $messageDetails : array<string|int, mixed>
-
An array of information about each message, for the log
- $current_view : string = 'replies'
-
What type of unapproved items we're approving - can be 'topics' or 'replies'
removeMessages()
Remove a batch of messages (or topics)
protected
removeMessages(array<string|int, mixed> $messages, array<string|int, mixed> $messageDetails[, string $current_view = 'replies' ]) : void
Parameters
- $messages : array<string|int, mixed>
-
The IDs of the messages to remove
- $messageDetails : array<string|int, mixed>
-
An array of information about the messages for the log
- $current_view : string = 'replies'
-
What type of item we're removing - can be 'topics' or 'replies'