Wikia code/includes/WatchlistEditor.php
< Wikia code | includes
This page is obsolete. It is being retained for archival purposes. It may document extensions or features that are obsolete and/or no longer supported. Do not rely on the information here being up-to-date. The information shown below refers to the now unmaintained 1.16 MediaWiki release. The current stable release number is 1.42.1. |
--- D:\Programming\SVN\mediawiki\branches\REL1_16\phase3\includes\WatchlistEditor.php 2011-07-18 22:31:28.095703100 +0100
+++ D:\Programming\SVN\wikia\trunk\includes\WatchlistEditor.php 2011-08-17 15:28:46.459960900 +0100
@@ -255,6 +255,8 @@
private function clearWatchlist( $user ) {
$dbw = wfGetDB( DB_MASTER );
$dbw->delete( 'watchlist', array( 'wl_user' => $user->getId() ), __METHOD__ );
+
+ wfRunHooks( 'WatchlistEditor::clearWatchlist', array ( $user ) );
}
/**
@@ -273,21 +275,11 @@
if( !$title instanceof Title )
$title = Title::newFromText( $title );
if( $title instanceof Title ) {
- $rows[] = array(
- 'wl_user' => $user->getId(),
- 'wl_namespace' => ( $title->getNamespace() & ~1 ),
- 'wl_title' => $title->getDBkey(),
- 'wl_notificationtimestamp' => null,
- );
- $rows[] = array(
- 'wl_user' => $user->getId(),
- 'wl_namespace' => ( $title->getNamespace() | 1 ),
- 'wl_title' => $title->getDBkey(),
- 'wl_notificationtimestamp' => null,
- );
+ $wl = WatchedItem::fromUserTitle( $user, $title );
+ $wl->addWatch();
+ unset($wl);
}
}
- $dbw->insert( 'watchlist', $rows, __METHOD__, 'IGNORE' );
}
/**
@@ -302,32 +294,19 @@
private function unwatchTitles( $titles, $user ) {
$dbw = wfGetDB( DB_MASTER );
foreach( $titles as $title ) {
- if( !$title instanceof Title )
+ if ( !$title instanceof Title ) {
$title = Title::newFromText( $title );
+ }
+
if( $title instanceof Title ) {
- $dbw->delete(
- 'watchlist',
- array(
- 'wl_user' => $user->getId(),
- 'wl_namespace' => ( $title->getNamespace() & ~1 ),
- 'wl_title' => $title->getDBkey(),
- ),
- __METHOD__
- );
- $dbw->delete(
- 'watchlist',
- array(
- 'wl_user' => $user->getId(),
- 'wl_namespace' => ( $title->getNamespace() | 1 ),
- 'wl_title' => $title->getDBkey(),
- ),
- __METHOD__
- );
$article = new Article($title);
+ if ( wfRunHooks( 'UnwatchArticle', array( &$user, &$article ) ) ) {
+ $user->removeWatch( $title );
wfRunHooks('UnwatchArticleComplete',array(&$user,&$article));
}
}
}
+ }
/**
* Show the standard watchlist editing form