Extension:Recent Activity Notify

With this extension installed, if anything new happens on the wiki, selected users will get an email. Whenever a page edit, page creation, or page move occurs on the wiki from new or anonymous users, selected users will get an email on the following conditions: Both of these times can be changed in the extension. It is not a lot of emails and it is very helpful in preventing you from checking the recent changes page all the time. If there are two new users within 4 hours who make an edit, you will get only one email. So this is useful if say, it has been 3 days since you had an edit. If you set your email to your cell phone SMS email, you can get an alert on your cell phone as an sms.
 * An email is sent only for a user who is anonymous or is a registered user younger than 4 hours.
 * Only one email is sent every 4 hours

This extension is based upon Extension:New User Email Notification. This is a useful extension to have for small wikis. In small wikis, no one wants to keep checking Recent Changes all the time just to see if there was any vandalism or spam or activity from new users. This way you can catch and revert spam or vandalism in its early stages without having to check RC all the time. Most of us check our emails more frequently than a Recent Changes page or have email alerts set up on our computers.

There's a variable that right now called $wgUsersNotifiedOnAllChanges, which can be configured but it sends an email for every edit, even from known older users of a wiki, something which is not necessary. We only need the alerts from new users. This extension also allows you to change that list of users from the wiki. You wont have to get into LocalSettings.php for that.

Installation

 * 1) Create a page on your wiki that will have the list of users who want to be notified:
 * 2) *The title of the new page must be in this exact case-sensitive format: SITENAME:Users For Recent Activity Email Notification Where Site Name is value of the variable $wgSitename. An easy way to get the correct title for this page: Copy paste the following into your wiki, do a preview of the edit and create a page for that red link: ---   So if your Site Name is "My Wiki", the page you create will have the title of: "My Wiki:Users For Recent Activity Email Notification". This will give you the ease of editing the notify list from the wiki in the browser and you wont have to go into LocalSettings.php
 * 3) * Model your new page on the following page: Sample Notify List (On this page you can edit the list of usernames and the comments with the hashes too. Leave everything else as it is).
 * 4) Your wiki database must have the ability to create a table in the database. The extension will automatically try to create a table. If you dont have the CREATE right for your database, try the SQL query at the end of this section in MyPHPAdmin or whatever way you can use to create the table.
 * 5) Download the files and extract them to /extensions/RecentActivityNotify
 * 6) Add the following line in the LocalSettings.php file:

CREATE TABLE IF NOT EXISTS `mw_ext_email_notify` (   `user` varbinary(255) NOT NULL,    `last_email_sent_time` varbinary(14) NOT NULL,    PRIMARY KEY (`user`) ); This assumes your table prefix is 'mw_'. Adjust this if you have a different table naming prefix.
 * Database query for table creation (only if your wiki database configuration doesnt have the Sql CREATE right):

Customization

 * Inside the file "RecentActivityNotify.php", you can edit the value of the function email_duration to reflect how often an email can be sent. Default value: 4 hours
 * Inside the same file, change users_age_for_notify to set how young a user must be in order for an email to be sent. Default value: 4 hours.

Versions
This code has been tested on MediaWiki 1.15. It should work in other versions too but it has not been tested.

Troubleshooting
If there are any errors, make sure:
 * your wiki is version 1.15. I've not tested it on older wikis.
 * You have the correct table created in your database.
 * You have followed the format of the Sample Notify List
 * The selected users have valid emails in their Preferences

Questions/Requests
Sorry I haven't made any effort to translate this or add additional features or make it work for other versions of MW. I don't plan on doing any of that due to lack of time. I just wanted to do something quick for myself and wanted to share it with anyone else who could use it and wanted to give back to the MW community. I hope this is useful for someone. Its a good small useful utility to have for wikis that are small and don't have many edits frequently from new users. The code may not be clean but it works.

MW 1.18 fix
I am only a new user about MW system, so I fixed by easy way: First You need Copy a DatabaseFunctions.php From old version (1.15) Into includes folder. I think there are no conflict.

Next, fix some rows in RecentActivityNotify.php File: include_once './includes/DatabaseFunctions.php'; to include_once 'includes/DatabaseFunctions.php';

If you see an error about "Cannot redeclare wfGetDB" in your server logs, the line with "includes/DatabaseFunctions.php" must be commented out.

require_once( 'UserMailer.php' ); to require_once( 'includes/UserMailer.php' );

userMailer(new MailAddress( $emailtarget ), to  userMailer::send(new MailAddress( $emailtarget ),

function NotifyArticleSaved ( &$article, &$user, $text, $summary, &$minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId ) { to function NotifyArticleSaved ( &$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId, &$redirect ) {

$result = $db->doQuery($query); to $result = $db->Query($query);

that's it! I tested in my wiki site!

Notify for change by any user
This Extension only check and send notification when change by new (any) user. If you want it send email for every change by any user, fix this line: //return true; // UNCOMMENT for debug to return true; // UNCOMMENT for debug