TopicMerge
in package
implements
ActionInterface
Uses
BackwardCompatibility
Handles merging of topics.
Table of Contents
Interfaces
- ActionInterface
- Interface for all action classes.
Properties
- $subaction : string
- $subactions : array<string|int, mixed>
- $topics : array<string|int, mixed>
- $approved : int
- $boards : array<string|int, mixed>
- $boardTotals : array<string|int, mixed>
- $can_approve_boards : array<string|int, mixed>
- $firstTopic : int
- $is_sticky : int
- $lowestTopicBoard : int
- $lowestTopicId : int
- $merge_boards : array<string|int, mixed>
- $num_views : int
- $obj : object
- $polls : array<string|int, mixed>
- $topic_data : array<string|int, mixed>
- $backcompat : array<string|int, mixed>
Methods
- call() : void
- Convenience method to load() and execute() an instance of this class.
- done() : mixed
- Shows a 'merge completed' screen.
- execute() : void
- Merges two or more topics into one topic.
- exportStatic() : void
- Provides a way to export a class's public static properties and methods to global namespace.
- index() : mixed
- Screen shown before the actual merge.
- initiate() : mixed
- Initiates a merge of the specified topics.
- load() : object
- Static wrapper for constructor.
- merge() : void
- Performs the merge
- mergeDone() : void
- Backward compatibility wrapper for the split sub-action.
- mergeExecute() : mixed
- Backward compatibility wrapper for the options and/or merge sub-actions.
- mergeIndex() : void
- Backward compatibility wrapper for the index sub-action.
- options() : void
- The merge options screen.
- __construct() : mixed
- Constructor. Protected to force instantiation via self::load().
- getMergeBoards() : mixed
- Gets the boards in which the user is allowed to merge topics.
- getTopicData() : mixed
- Gets info about the topics and polls that will be merged.
- getTopics() : mixed
- Sets the value of $this->topics.
- initOptionsAndMerge() : mixed
- Sets up some stuff needed for both $this->options() and $this->merge().
Properties
$subaction
public
string
$subaction
= 'index'
The requested sub-action. This should be set by the constructor.
$subactions
public
static array<string|int, mixed>
$subactions
= ['index' => 'index', 'done' => 'done', 'merge' => 'merge', 'options' => 'options']
Available sub-actions.
$topics
public
array<string|int, mixed>
$topics
= []
IDs of the topics to merge.
$approved
protected
int
$approved
= 1
$boards
protected
array<string|int, mixed>
$boards
= []
$boardTotals
protected
array<string|int, mixed>
$boardTotals
= []
$can_approve_boards
protected
array<string|int, mixed>
$can_approve_boards
= []
$firstTopic
protected
int
$firstTopic
= 0
$is_sticky
protected
int
$is_sticky
= 0
$lowestTopicBoard
protected
int
$lowestTopicBoard
= 0
$lowestTopicId
protected
int
$lowestTopicId
= 0
$merge_boards
protected
array<string|int, mixed>
$merge_boards
= []
$num_views
protected
int
$num_views
= 0
$obj
protected
static object
$obj
An instance of this class. This is used by the load() method to prevent mulitple instantiations.
$polls
protected
array<string|int, mixed>
$polls
= []
$topic_data
protected
array<string|int, mixed>
$topic_data
= []
$backcompat
private
static array<string|int, mixed>
$backcompat
= ['func_names' => ['call' => 'MergeTopics', 'mergeIndex' => 'MergeIndex', 'mergeExecute' => 'MergeExecute', 'mergeDone' => 'MergeDone']]
BackwardCompatibility settings for this class.
Methods
call()
Convenience method to load() and execute() an instance of this class.
public
static call() : void
done()
Shows a 'merge completed' screen.
public
done() : mixed
- Accessed via ?action=mergetopics;sa=done.
- Uses 'merge_done' sub template of the SplitTopics template.
execute()
Merges two or more topics into one topic.
public
execute() : void
- Delegates to the other functions (based on the URL parameter sa).
- Loads the SplitTopics template.
- Requires the merge_any permission.
- Accessed via ?action=mergetopics.
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.
index()
Screen shown before the actual merge.
public
index() : mixed
- Allows user to choose a topic to merge the current topic with.
- Accessed via ?action=mergetopics;sa=index
- Default sub action for ?action=mergetopics.
- Uses 'merge' sub template of the MoveTopic template.
- Allows setting a different target board.
initiate()
Initiates a merge of the specified topics.
public
static initiate([array<string|int, mixed> $topics = [] ]) : mixed
Called from SMF\MessageIndex::QuickModeration().
Parameters
- $topics : array<string|int, mixed> = []
-
The IDs of the topics to merge
load()
Static wrapper for constructor.
public
static load() : object
Return values
object —An instance of this class.
merge()
Performs the merge
public
merge() : void
- Accessed via ?action=mergetopics;sa=merge.
- Updates the statistics to reflect the merge.
- Logs the action in the moderation log.
- Sends a notification to all users monitoring this topic.
- Redirects to ?action=mergetopics;sa=done.
mergeDone()
Backward compatibility wrapper for the split sub-action.
public
static mergeDone() : void
mergeExecute()
Backward compatibility wrapper for the options and/or merge sub-actions.
public
static mergeExecute([array<string|int, mixed> $topics = [] ]) : mixed
(The old procedural function with this name did both.)
Parameters
- $topics : array<string|int, mixed> = []
-
The IDs of the topics to merge
mergeIndex()
Backward compatibility wrapper for the index sub-action.
public
static mergeIndex() : void
options()
The merge options screen.
public
options() : void
- Shows topics to be merged and allows to set some merge options.
- Accessed via ?action=mergetopics;sa=options
- Can also be called internally by SMF\MessageIndex::QuickModeration().
- Uses 'merge_extra_options' sub template of the MoveTopic template.
__construct()
Constructor. Protected to force instantiation via self::load().
protected
__construct() : mixed
getMergeBoards()
Gets the boards in which the user is allowed to merge topics.
protected
getMergeBoards() : mixed
getTopicData()
Gets info about the topics and polls that will be merged.
protected
getTopicData() : mixed
getTopics()
Sets the value of $this->topics.
protected
getTopics() : mixed
initOptionsAndMerge()
Sets up some stuff needed for both $this->options() and $this->merge().
protected
initOptionsAndMerge() : mixed