Skip to content

Commit

Permalink
- Version is now 1.02.
Browse files Browse the repository at this point in the history
- Added new notification event: when article is protected.
- Updated readme file with information about the new event.
  • Loading branch information
kulttuuri committed Dec 19, 2016
1 parent c8bfe0d commit 16017ee
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
19 changes: 19 additions & 0 deletions DiscordNotifications/DiscordNotificationsCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion DiscordNotifications/extension.json
Original file line number Diff line number Diff line change
@@ -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.",
Expand Down Expand Up @@ -43,6 +43,11 @@
[
"DiscordNotifications::discord_file_uploaded"
]
],
"ArticleProtectComplete": [
[
"DiscordNotifications::discord_article_protected"
]
]
},
"config": {
Expand Down Expand Up @@ -72,6 +77,7 @@
"DiscordNotificationMovedArticle": true,
"DiscordNotificationEditedArticle": true,
"DiscordNotificationFileUpload": true,
"DiscordNotificationProtectedArticle": true,
"DiscordIncludeDiffSize": true,
"DiscordShowNewUserEmail": true,
"DiscordShowNewUserFullName": true,
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 16017ee

Please sign in to comment.