Extension:WatchEmailOptional
|
WatchEmailOptional Release status: beta |
|||
|---|---|---|---|
| Implementation | User interface, Notify | ||
| Description | Enable users to configure watched-article email notification on a per-article basis. | ||
| Author(s) | Jlernertalk | ||
| Last version | 0.1 | ||
| MediaWiki | 1.13 | ||
| License | GPL | ||
| Download | see below | ||
| Example | http://wiki.name.com/ | ||
|
|||
| Check usage and version matrix; stats | |||
WatchEmailOptional enables users to set email notifications on watched articles on a per-article basis.
Questions welcome, but please be careful hacking up your local copy of MediaWiki and altering your database. Always make backups first before attempting such changes. You have been warned.
The extension is geared to give a solution for Bugzilla 2555 Secondary watchlist adds checkboxes for watched pages: watching with or without E-mail notification (enotif). If there is sufficient interest, I'll add features to this extension and/or try to get it added to MediaWiki itself.
Contents |
Usage[edit]
Watch some articles, then visit your [[Special:Watchlist/edit]] page.
Download instructions[edit]
Please cut and paste the code found below and place it in $IP/extensions/ExtensionName/ExtensionName.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.
Installation[edit]
Be careful hacking up your local copy of MediaWiki and altering your database. Always make backups first before attempting such changes.
To install this extension:
- Patch the files listed below (UserMailer.php and WatchlistEditor):
- Add the following to LocalSettings.php:
require_once("$IP/extensions/WatchEmailOptional/WatchEmailOptional.php");
WatchEmailOptional.php[edit]
<?php if ( ! defined( 'MEDIAWIKI' ) ) die(); $wgHooks['WatchArticleComplete'][] = 'setEnotifWatchlist'; function setEnotifWatchlist( &$user, &$article ) { global $wgUser; if( !$wgUser->getBoolOption( 'enotifwatchlistdefault' ) ) { $dbw =& wfGetDB( DB_MASTER ); $title = $article->getTitle(); $res = $dbw->update( 'watchlist', array( 'wl_enotif' => 0 ), array( 'wl_user' => $wgUser->getId(), 'wl_title' => $title->getPartialURL(), 'wl_namespace' => $title->getNamespace() ), __METHOD__ ); } return true; } function getEnotif( $title ) { global $wgUser; $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'watchlist', 1, array( 'wl_user' => $wgUser->getID(), 'wl_namespace' => $title->getNamespace(), 'wl_title' => $title->getPartialURL(), 'wl_enotif' => 1 ), __METHOD__ ); return ($dbr->numRows( $res ) > 0) ? true : false; } function setEnotif( $list ) { global $wgUser; $dbw = wfGetDB( DB_MASTER ); if( !is_array( $list ) ) { $list = explode( "\n", trim( $list ) ); if( !is_array( $list ) ) return; } foreach( $list as $key => $value ) { $value = trim( $value ); if( !strlen( $value ) ) continue; $text = trim( $key ); if( strlen( $key ) ) { $title = Title::newFromText( $key ); if( $title instanceof Title && $title->isWatchable() ) { if( $value == 'enotif' ) { $dbw->update( 'watchlist', array( 'wl_enotif' => 1 ), array( 'wl_user' => $wgUser->getID(), 'wl_namespace' => $title->getNamespace(), 'wl_title' => $title->getPartialURL() ), __METHOD__ ); } elseif( $value == 'noenotif' ) { $dbw->update( 'watchlist', array( 'wl_enotif' => 0 ), array( 'wl_user' => $wgUser->getID(), 'wl_namespace' => $title->getNamespace(), 'wl_title' => $title->getPartialURL() ), __METHOD__ ); } } } } return true; }
Change to UserMailer.php[edit]
Add after line 376:
'wl_enotif' => 1,
Change to WatchlistEditor.php[edit]
Add after line 69:
setEnotif( $request->getValues() );
Add after line 394 :
. wfRadio( $title, getEnotif( $title ) ? '' : 'enotif', getEnotif( $title ) ) .' (email) ' . wfRadio( $title, getEnotif( $title ) ? 'noenotif' : '', !getEnotif( $title ) ) .' (no email) '
watchlist.sql[edit]
/* use wiki prefix for your setup, if any */ ALTER TABLE watchlist ADD COLUMN wl_enotif bool NOT NULL DEFAULT 1;
