Skip to content

Commit

Permalink
- Version is now 1.06.
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 20, 2016
1 parent 08bf957 commit 7c18e12
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ This is a extension for [MediaWiki](https://www.mediawiki.org/wiki/MediaWiki) th

## Supported MediaWiki operations to send notifications

* When article is added.
* When article is removed.
* When article is moved.
* When article is edited.
* When new user is added.
* When user is blocked.
* When file is uploaded.
* Article is added, removed, moved or edited.
* Article protection settings are changed.
* New user is added.
* User is blocked.
* File is uploaded.
* ... and each notification can be individually enabled or disabled :)

## Requirements

* [cURL](http://curl.haxx.se/). This extension also supports using file_get_contents for sending the data. See the configuration parameter $wgSlackSendMethod below to change this.
* [cURL](http://curl.haxx.se/). This extension also supports using `file_get_contents` for sending the data. See the configuration parameter `$wgSlackSendMethod` below to change this.
* MediaWiki 1.8+ (tested with version 1.8, also tested and works with 1.25+)
* Apache should have NE (NoEscape) flag on to prevent issues in URLs. By default you should have this enabled.

Expand All @@ -28,7 +27,7 @@ This is a extension for [MediaWiki](https://www.mediawiki.org/wiki/MediaWiki) th

2) After setting up the Webhook you will get a Webhook URL. Copy that URL as you will need it in step 4.

3) Send folder SlackNotifications into your `mediawiki_installation/extensions` folder.
3) [Download latest release of this extension](https://github.com/kulttuuri/slack_mediawiki/archive/master.zip), uncompress the archive and move folder `SlackNotifications` into your `mediawiki_installation/extensions` folder.

4) Add settings listed below in your `localSettings.php`. Note that it is mandatory to set these settings for this extension to work:

Expand Down Expand Up @@ -117,6 +116,8 @@ $wgSlackNotificationMovedArticle = true;
$wgSlackNotificationEditedArticle = true;
// File uploaded
$wgSlackNotificationFileUpload = true;
// Article protection settings changed
$wgSlackNotificationProtectedArticle = true;
```

## Additional MediaWiki URL Settings
Expand Down
18 changes: 18 additions & 0 deletions SlackNotifications/SlackNotificationsCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,24 @@ static function slack_article_moved($title, $newtitle, $user, $oldid, $newid, $r
return true;
}

/**
* Occurs after the protect article request has been processed.
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ArticleProtectComplete
*/
static function slack_article_protected($article, $user, $protect, $reason, $moveonly)
{
global $wgSlackNotificationProtectedArticle;
if (!$wgSlackNotificationProtectedArticle) return;
$message = sprintf(
"%s has %s article %s. Reason: %s",
self::getSlackUserText($user),
$protect ? "changed protection of" : "removed protection of",
self::getSlackArticleText($article),
$reason);
self::push_slack_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 SlackNotifications/extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Slack Notifications",
"version": "1.05",
"version": "1.06",
"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 @@ -43,6 +43,11 @@
[
"SlackNotifications::slack_file_uploaded"
]
],
"ArticleProtectComplete": [
[
"SlackNotifications::slack_article_protected"
]
]
},
"config": {
Expand Down Expand Up @@ -74,6 +79,7 @@
"SlackNotificationMovedArticle": true,
"SlackNotificationEditedArticle": true,
"SlackNotificationFileUpload": true,
"SlackNotificationProtectedArticle": true,
"SlackIncludeDiffSize": true
},
"manifest_version": 1
Expand Down

0 comments on commit 7c18e12

Please sign in to comment.