TopicSplit
in package
implements
ActionInterface
Uses
BackwardCompatibility
Handles splitting of topics.
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
- call() : void
- Convenience method to load() and execute() an instance of this class.
- execute() : void
- Splits a topic into two topics.
- 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 split.
- load() : object
- Static wrapper for constructor.
- select() : mixed
- Allows the user to select the messages to be split.
- split() : mixed
- Do the actual split.
- splitExecute() : void
- Backward compatibility wrapper for the split sub-action.
- splitIndex() : void
- Backward compatibility wrapper for the index sub-action.
- splitSelection() : mixed
- Do the actual split of a selection of topics.
- SplitSelectionExecute() : void
- Backward compatibility wrapper for the splitSelection sub-action.
- splitSelectTopics() : void
- Backward compatibility wrapper for the selectTopics sub-action.
- splitTopic() : int
- General function to split off a topic.
- __construct() : mixed
- Constructor. Protected to force instantiation via self::load().
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', 'split' => 'split', 'selectTopics' => 'select', 'splitSelection' => 'splitSelection']
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' => 'SplitTopics', 'splitTopic' => 'splitTopic', 'splitIndex' => 'SplitIndex', 'splitExecute' => 'SplitExecute', 'splitSelectTopics' => 'SplitSelectTopics', 'SplitSelectionExecute' => 'SplitSelectionExecute']]
BackwardCompatibility settings for this class.
Methods
call()
Convenience method to load() and execute() an instance of this class.
public
static call() : void
execute()
Splits a topic into two topics.
public
execute() : void
- Delegates to the other functions (based on the URL parameter 'sa').
- Loads the SplitTopics template.
- Requires the split_any permission.
- Accessed via ?action=splittopics.
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 split.
public
index() : mixed
- Default sub action for ?action=splittopics.
- Accessed via ?action=splittopics;sa=index.
- Uses 'ask' sub template of the SplitTopics template.
- Redirects to select if the message given turns out to be the first message of a topic.
- Shows the user three ways to split the current topic.
load()
Static wrapper for constructor.
public
static load() : object
Return values
object —An instance of this class.
select()
Allows the user to select the messages to be split.
public
select() : mixed
- Accessed via ?action=splittopics;sa=selectTopics.
- Uses 'select' sub template of the SplitTopics template or (for XMLhttp) the 'split' sub template of the Xml template.
- Supports XMLhttp for adding/removing a message to the selection.
- Uses a session variable to store the selected topics.
- Shows two independent page indexes for both the selected and not-selected messages (;topic=1.x;start2=y).
split()
Do the actual split.
public
split() : mixed
- Accessed via ?action=splittopics;sa=merge.
- Uses the main SplitTopics template.
- Supports three ways of splitting: (1) only one message is split off. (2) all messages after and including a given message are split off. (3) select topics to split (redirects to select()).
- Uses splitTopic function to do the actual splitting.
splitExecute()
Backward compatibility wrapper for the split sub-action.
public
static splitExecute() : void
splitIndex()
Backward compatibility wrapper for the index sub-action.
public
static splitIndex() : void
splitSelection()
Do the actual split of a selection of topics.
public
splitSelection() : mixed
- Accessed via ?action=splittopics;sa=splitSelection.
- Uses the main SplitTopics template.
- Uses splitTopic function to do the actual splitting.
SplitSelectionExecute()
Backward compatibility wrapper for the splitSelection sub-action.
public
static SplitSelectionExecute() : void
splitSelectTopics()
Backward compatibility wrapper for the selectTopics sub-action.
public
static splitSelectTopics() : void
splitTopic()
General function to split off a topic.
public
static splitTopic(int $split1_ID_TOPIC, array<string|int, mixed> $splitMessages, string $new_subject) : int
- Creates a new topic and moves the messages with the IDs in array messagesToBeSplit to the new topic.
- The subject of the newly created topic is set to 'newSubject'.
- Marks the newly created message as read for the user splitting it.
- Updates the statistics to reflect a newly created topic.
- Logs the action in the moderation log.
- A notification is sent to all users monitoring this topic.
Parameters
- $split1_ID_TOPIC : int
-
The ID of the topic we're splitting
- $splitMessages : array<string|int, mixed>
-
The IDs of the messages being split
- $new_subject : string
-
The subject of the new topic
Return values
int —The ID of the new split topic.
__construct()
Constructor. Protected to force instantiation via self::load().
protected
__construct() : mixed