Open main menu

Extension:AutoWatch/zh

MediaWiki扩展手册
OOjs UI icon advanced.svg
AutoWatch
发布状态: 稳定版
实现 用户界面
描述 Add a custom defined list of user to watch any new or edited page + send an email on any new talk page
作者 Brice Lenfant (Briceltalk)
最新版本 1.0 (2007-11-21)
MediaWiki 1.10+
数据庫更新
许可协议 GNU通用公眾授權條款2.0 or later
下载 下载
$wgMultiWatchUserIDs
翻译AutoWatch扩展如果在translatewiki.net可用
检查使用和版本矩阵。

Template:Extension/archived

The AutoWatch extension adds a custom list of users to watch any new or edited page plus send an email on any new talk page.

用法Edit

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

将以下文本加入至LocalSettings.php 文件:

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

代码Edit

本代码已在MediaWiki 1.12上测试。

历史:

  • 2007-11-21 -- Version 1.1 -- 首次释出。
<?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:  require_once("extensions/AutoWatch.php");
#
########################################################################
// Protect against register_globals
if ( !defined( 'MEDIAWIKI' ) ) {
    echo "Not a valid entry point";
    exit( 1 );
}

$wgExtensionCredits['other'][] = array(
	'name' => 'AutoWatch',
	'version' => '1.0',
	'author' => 'Brice Lenfant',
	'description' => 'Adds any new edited/created page to the watch list of defined users',
	'url' => 'https://www.mediawiki.org/wiki/Extension:AutoWatch',
);

$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;
}