Extension:AutoWatch

From MediaWiki.org

Jump to: navigation, search
Manual on MediaWiki Extensions
List of MediaWiki Extensions
AutoWatch

Release status: stable

Implementation User interface
Description Add a custom defined list of user to watch any new or edited page + send an email on any new talk page
Author(s) Brice Lenfant
Version 1.0
MediaWiki 1.10
Download no link
Hooks used

ArticleSaveComplete

[edit] Usage

Save the code below to AutoWatch.php in MediaWiki's extensions folder.

Add the following line in the LocalSettings.php file:

$wgMultiWatchUserIDs= array (5,3,2,6,64,9); # this is the list of your users IDs to include in this mailing list
include("extensions/AutoWatch.php");

[edit] Code

This code has been tested on MediaWiki 1.10.

History:

  • 21 Nov 2007 -- Version 1.0 -- First release.
<?php
#########################################################################
# Installation notes, add array $wgMultiWatchUserIDs to localsettings.php with all uses ID's to include
# Example
#                     $wgMultiWatchUserIDs= array (5,3,2,6);
# then add the line : include("extensions/AutoWatch.php");
#
########################################################################
$wgExtensionCredits['other'][] = array(
    'name' => 'AutoWatch',
    'description' => 'Add any new edited/created page to the watch list of defined users ',
    'url' => 'http://www.mediawiki.org/wiki/Extension:AutoWatch',
    'author' => 'Brice Lenfant',
    'version' => '1.0'
);
 
 
$wgHooks['ArticleSaveComplete'][] = 'fnAddToWatch';
 
function fnAddToWatch(&$article, &$user, &$text, &$summary, &$minoredit, &$watchthis, &$sectionanchor, &$flags, $revision)
 {
    global $wgMultiWatchUserIDs;
    foreach ($wgMultiWatchUserIDs as $value){
       #add to watch
       $user=User::newFromId($value);
       $user->addWatch( $article->mTitle ); 
       # send email if it's a new talk 
       if (       $article->mTitle->isTalkPage ()){
          $eTitle="Talk Page changed or created in Wiki  - ".$article->mTitle->getTalkNsText().':'.$article->mTitle->getDBkey();
          $eBody=$article->mTitle->GetFullURL();
          $user->sendMail($eTitle, $eBody ) ;
       }
    }
    return true;
}
Personal tools