Jump to content

Extension:EditNotify

From mediawiki.org
MediaWiki extensions manual
EditNotify
Release status: stable
Implementation Notify
Description Extension for page creation/editing notifications
Author(s) Abhinand and Yaron Koren
Latest version 1.1 (2024-02-21)
Compatibility policy Snapshots releases along with MediaWiki. Master is not backward compatible.
License MIT License
Download
  • $wgEditNotifyEnableFoo
  • $wgEditNotifyAlerts
Quarterly downloads 6 (Ranked 123rd)
Translate the EditNotify extension if it is available at translatewiki.net
Issues Open tasks · Report a bug

EditNotify is an extension to MediaWiki that allows users to receive notifications while creating and editing a page. The extension uses the Echo extension to notify users.

Features

[edit]

The extension allows registered users to get notified for:

  • Creation of new pages
  • Any edit to existing pages
  • Change of a specific template field
  • Change of a specific template field to a specific template value

All users subscribed for any of the events listed above will be notified with a simple alert message (Echo notification) and an email. The possible sets of pages for which users can choose to be notified are:

  • All pages - keep track of changes or creation of all pages
  • All pages in one or more namespaces
  • All pages in one or more categories

Installation

[edit]
  • Install the Echo extension required for this extension to work.
  • Download the code via Git or zip file and place the file(s) in a directory called EditNotify in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'EditNotify' );
    
  • Configure as required.
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Configuration

[edit]
  • The array $wgEditNotifyAlerts should be added to your "LocalSettings.php", and usernames can be added to each sub-array within it to get that set of users notified of the respective events.
  • Template field names, or template field name/value pairs, can be added if you wish to track those changes. Namespaces or categories to be tracked can also be added to the respective 'namespace' or 'category' keys in the array.
  • If a user wishes to receive a notification on all pages, then the category and namespace keys can be omitted.
$wgEditNotifyAlerts = [
	[
		'action' => 'create',
		'users' => [ 'user1', 'user2' ]
	],
	[
		'action' => 'edit',
		'namespace' => 'namespace name',
		'users' => [ 'user2' ]
	],
	[
		'action' => 'edit',
		'namespace' => 'namespace name',
		'category' => 'category name',
		'users' => [ 'user1' ]
	],
	[
		'action' => 'edit',
		'namespace' => 'namespace name',
		'category' => 'category name',
		'template' => 'template name',
		'templateField' => 'field name',
		'users' => [ 'user1', 'user2' ]
	],
	[
		'action' => 'edit',
		'namespace' => 'namespace name',
		'category' => 'category name',
		'template' => 'template name',
		'templateField' => 'field name',
		'templateFieldValue' => 'field value',
		'users' => [ 'user1', 'user2' ]
	],
	...
];
Email notification when there is a change in template field to specific value

Examples

[edit]

Users can be notified of create and edit events for all pages. In the example below, Joe will be notified if any page is created or edited.

    [
		'action' => [ 'create', 'edit' ],
		'users' => [ 'Joe' ]
	],

Say, if users David and Ram have to get notified when a page is created, the user John has to get notified when a non-template page in the 'User' namespace is edited, and Charles has to track the edit event in 'Uniwiki' category, then the array would look something like:

$wgEditNotifyAlerts = [
	[
		'action' => 'create',
		'users' => [ 'David', 'Ram' ]
	],
	[
		'action' => 'edit',
		'namespace' => 'User',
		'users' => [ 'John' ]
	],
	[
		'action' => 'edit',
		'category' => 'Uniwiki',
		'users' => [ 'Charles' ]
	],
    ....
];

George and Ann will be notified of the change in template value if the field value of 'full name' changes in the template 'User info' in the 'User' and 'Talk' namespaces. Mia will be notified of the change in the field value of 'full name' in the template 'User info' on any page.

    ....
   	[
		'action' => 'edit',
		'namespace' => [ 'User', 'Talk' ],
		'template' => 'User info',
		'templateField' => 'full name',
		'users' => [ 'George', 'Ann' ]
	],
	[
		'action' => 'edit',
		'template' => 'User info',
		'templateField' => 'full name',
		'users' => [ 'Mia' ]
	],
    ...

If a page in the 'User' namespace includes a template called 'User info' with a field called 'full name' whose value changes to 'Albert Albertson', Brennan will be notified of this event.

   	[
		'action' => 'edit',
		'namespace' => 'User',
		'template' => 'User info',
		'templateField' => 'full name',
		'templateFieldValue' => 'Albert Albertson',
		'users' => [ 'Brennan' ]
	],
	...

As expected, you can add as many arrays to $wgEditNotifyAlerts as you want to handle additional events.

Version history

[edit]
  • 1.0.0 - August 22, 2016 - Initial version
  • 1.1 - February 21, 2024 - Removed support for MW < 1.36; many coding improvements and bug fixes

See also

[edit]