Skip to content

Commit

Permalink
Version is now 1.14
Browse files Browse the repository at this point in the history
- Now sends notifications of user groups change.
- Documented the change in readme file.
  • Loading branch information
kulttuuri committed Mar 7, 2019
1 parent 7e59459 commit cfd1217
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This is a extension for [MediaWiki](https://www.mediawiki.org/wiki/MediaWiki) th
* Article protection settings are changed.
* New user is added.
* User is blocked.
* User groups (rights) are changed.
* File is uploaded.
* ... and each notification can be individually enabled or disabled :)

Expand Down Expand Up @@ -145,6 +146,8 @@ MediaWiki actions that will be sent notifications of into Slack. Set desired opt
$wgSlackNotificationNewUser = true;
// User or IP blocked in MediaWiki
$wgSlackNotificationBlockedUser = true;
// User groups changed in MediaWiki
$wgSlackNotificationUserGroupsChanged = true;
// Article added to MediaWiki
$wgSlackNotificationAddedArticle = true;
// Article removed from MediaWiki
Expand Down
19 changes: 19 additions & 0 deletions SlackNotificationsCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,25 @@ static function slack_user_blocked(Block $block, $user)
return true;
}

/**
* Occurs after the user groups (rights) have been changed
* @see https://www.mediawiki.org/wiki/Manual:Hooks/UserGroupsChanged
*/
static function slack_user_groups_changed(User $user, array $added, array $removed, $performer, $reason, $oldUGMs, $newUGMs)
{
global $wgSlackNotificationUserGroupsChanged;
if (!$wgSlackNotificationUserGroupsChanged) return;

global $wgWikiUrl, $wgWikiUrlEnding, $wgWikiUrlEndingUserRights;
$message = sprintf(
"%s has changed user groups for %s. New groups: %s",
self::getSlackUserText($performer),
self::getSlackUserText($user),
implode(", ", $user->getGroups()));
self::push_slack_notify($message, "green", $user);
return true;
}

/**
* Sends the message into Slack room.
* @param message Message to be sent.
Expand Down
8 changes: 7 additions & 1 deletion extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Slack Notifications",
"version": "1.13",
"version": "1.14",
"author": "Aleksi Postari",
"url": "https://github.com/kulttuuri/slack_mediawiki",
"description": "Sends Slack notifications for selected actions that have occurred in your MediaWiki sites.",
Expand Down Expand Up @@ -48,6 +48,11 @@
[
"SlackNotifications::slack_article_protected"
]
],
"UserGroupsChanged": [
[
"SlackNotifications::slack_user_groups_changed"
]
]
},
"config": {
Expand Down Expand Up @@ -81,6 +86,7 @@
"SlackNotificationMovedArticle": true,
"SlackNotificationEditedArticle": true,
"SlackNotificationFileUpload": true,
"SlackNotificationUserGroupsChanged": true,
"SlackNotificationProtectedArticle": true,
"SlackIncludeDiffSize": true,
"SlackShowNewUserEmail": true,
Expand Down

0 comments on commit cfd1217

Please sign in to comment.