From b8113918f5ee7a56414bc4acc185ece189a85a1f Mon Sep 17 00:00:00 2001 From: Matthias Mullie Date: Tue, 14 Feb 2017 12:39:02 +0100 Subject: [PATCH] Enable extensions to allow software-specific tags to be added by users Bug: T121880 Bug: T121872 Change-Id: I6e054cfc065c8d8ae7d20a518b1963cd0551c5c2 --- RELEASE-NOTES-1.30 | 2 ++ docs/hooks.txt | 7 +++++++ includes/changetags/ChangeTags.php | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES-1.30 b/RELEASE-NOTES-1.30 index 1351c00f38..590dc2c857 100644 --- a/RELEASE-NOTES-1.30 +++ b/RELEASE-NOTES-1.30 @@ -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 === diff --git a/docs/hooks.txt b/docs/hooks.txt index 7c09a5551c..d95e39b986 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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 diff --git a/includes/changetags/ChangeTags.php b/includes/changetags/ChangeTags.php index 46cae8f011..80a4fe3e4e 100644 --- a/includes/changetags/ChangeTags.php +++ b/includes/changetags/ChangeTags.php @@ -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', -- 2.20.1