diff --git a/DiscordNotifications/DiscordNotificationsCore.php b/DiscordNotifications/DiscordNotificationsCore.php index 9dd9a72..923f483 100644 --- a/DiscordNotifications/DiscordNotificationsCore.php +++ b/DiscordNotifications/DiscordNotificationsCore.php @@ -203,6 +203,25 @@ static function discord_article_moved($title, $newtitle, $user, $oldid, $newid, return true; } + /** + * Occurs after the protect article request has been processed. + * @see https://www.mediawiki.org/wiki/Manual:Hooks/ArticleProtectComplete + */ + static function discord_article_protected($article, $user, $protect, $reason, $moveonly) + { + global $wgDiscordNotificationProtectedArticle; + if (!$wgDiscordNotificationProtectedArticle) return; + + $message = sprintf( + "%s has %s article %s. Reason: %s", + self::getDiscordUserText($user), + $protect ? "changed protection of" : "removed protection of", + self::getDiscordArticleText($article), + $reason); + self::push_discord_notify($message, $user); + return true; + } + /** * Called after a user account is created. * @see http://www.mediawiki.org/wiki/Manual:Hooks/AddNewAccount diff --git a/DiscordNotifications/extension.json b/DiscordNotifications/extension.json index 23c6700..574da1c 100644 --- a/DiscordNotifications/extension.json +++ b/DiscordNotifications/extension.json @@ -1,6 +1,6 @@ { "name": "Discord Notifications", - "version": "1.0.1", + "version": "1.0.2", "author": "Aleksi Postari", "url": "https://github.com/kulttuuri/discord_mediawiki", "description": "Sends Discord notifications for selected actions that have occurred in your MediaWiki sites.", @@ -43,6 +43,11 @@ [ "DiscordNotifications::discord_file_uploaded" ] + ], + "ArticleProtectComplete": [ + [ + "DiscordNotifications::discord_article_protected" + ] ] }, "config": { @@ -72,6 +77,7 @@ "DiscordNotificationMovedArticle": true, "DiscordNotificationEditedArticle": true, "DiscordNotificationFileUpload": true, + "DiscordNotificationProtectedArticle": true, "DiscordIncludeDiffSize": true, "DiscordShowNewUserEmail": true, "DiscordShowNewUserFullName": true, diff --git a/README.md b/README.md index 16703d8..bad3122 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ This is a extension for [MediaWiki](https://www.mediawiki.org/wiki/MediaWiki) th ## Supported MediaWiki operations to send notifications * Article is added, removed, moved or edited. +* Article protection settings are changed. * New user is added. * User is blocked. * File is uploaded. @@ -112,8 +113,10 @@ $wgDiscordNotificationMovedArticle = true; $wgDiscordNotificationEditedArticle = true; // File uploaded $wgDiscordNotificationFileUpload = true; +// Article protection settings changed +$wgDiscordNotificationProtectedArticle = true; ``` - + ## Additional MediaWiki URL Settings Should any of these default MediaWiki system page URLs differ in your installation, change them here.