Enable extensions to allow software-specific tags to be added by users
authorMatthias Mullie <git@mullie.eu>
Tue, 14 Feb 2017 11:39:02 +0000 (12:39 +0100)
committerMatthias Mullie <git@mullie.eu>
Mon, 8 May 2017 15:19:18 +0000 (17:19 +0200)
Bug: T121880
Bug: T121872
Change-Id: I6e054cfc065c8d8ae7d20a518b1963cd0551c5c2

RELEASE-NOTES-1.30
docs/hooks.txt
includes/changetags/ChangeTags.php

index 1351c00..590dc2c 100644 (file)
@@ -17,6 +17,8 @@ production.
 * (T37247) Output from Parser::parse() will now be wrapped in a div with
   class="mw-parser-output" by default. This may be changed or disabled using
   ParserOptions::setWrapOutputClass().
+* Added 'ChangeTagsAllowedAdd' hook, enabling extensions to allow software-
+  specific tags to be added by users.
 
 === External library changes in 1.30 ===
 
index 7c09a55..d95e39b 100644 (file)
@@ -1070,6 +1070,13 @@ $params: tag params
 $rc: RecentChange being tagged when the tagging accompanies the action or null
 $user: User who performed the tagging when the tagging is subsequent to the action or null
 
+'ChangeTagsAllowedAdd': Called when checking if a user can add tags to a change.
+&$allowedTags: List of all the tags the user is allowed to add. Any tags the
+  user wants to add ($addTags) that are not in this array will cause it to fail.
+  You may add or remove tags to this array as required.
+$addTags: List of tags user intends to add.
+$user: User who is adding the tags.
+
 'ChangeUserGroups': Called before user groups are changed.
 $performer: The User who will perform the change
 $user: The User whose groups will be changed
index 46cae8f..80a4fe3 100644 (file)
@@ -404,8 +404,8 @@ class ChangeTags {
                }
 
                // to be applied, a tag has to be explicitly defined
-               // @todo Allow extensions to define tags that can be applied by users...
                $allowedTags = self::listExplicitlyDefinedTags();
+               Hooks::run( 'ChangeTagsAllowedAdd', [ &$allowedTags, $tags, $user ] );
                $disallowedTags = array_diff( $tags, $allowedTags );
                if ( $disallowedTags ) {
                        return self::restrictedTagError( 'tags-apply-not-allowed-one',