X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FWatchedItem.php;h=2d2d34f147624c74b4e782249ca6f6e6c71fcb2e;hb=56c2036f1e780e4ede9e83f803fdf57929daacfb;hp=f21b1b814bf9a0972d0eb75977da17d104263eb6;hpb=15d1e1ec7e232c491663217100750fba997ccafe;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/WatchedItem.php b/includes/WatchedItem.php index f21b1b814b..2d2d34f147 100644 --- a/includes/WatchedItem.php +++ b/includes/WatchedItem.php @@ -1,30 +1,30 @@ mUser =& $user; - $wl->mTitle =& $title; + $wl->mUser = $user; + $wl->mTitle = $title; $wl->id = $user->getId(); -# Patch (also) for email notification on page changes T.Gries/M.Arndt 11.09.2004 -# TG patch: here we do not consider pages and their talk pages equivalent - why should we ? -# The change results in talk-pages not automatically included in watchlists, when their parent page is included -# $wl->ns = $title->getNamespace() & ~1; + # Patch (also) for email notification on page changes T.Gries/M.Arndt 11.09.2004 + # TG patch: here we do not consider pages and their talk pages equivalent - why should we ? + # The change results in talk-pages not automatically included in watchlists, when their parent page is included + # $wl->ns = $title->getNamespace() & ~1; $wl->ns = $title->getNamespace(); $wl->ti = $title->getDBkey(); @@ -33,13 +33,14 @@ class WatchedItem { /** * Is mTitle being watched by mUser? + * @return bool */ - function isWatched() { + public function isWatched() { # Pages and their talk pages are considered equivalent for watching; # remember that talk namespaces are numbered as page namespace+1. $fname = 'WatchedItem::isWatched'; - $dbr =& wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'watchlist', 1, array( 'wl_user' => $this->id, 'wl_namespace' => $this->ns, 'wl_title' => $this->ti ), $fname ); $iswatched = ($dbr->numRows( $res ) > 0) ? 1 : 0; @@ -47,15 +48,17 @@ class WatchedItem { } /** - * @todo document + * Given a title and user (assumes the object is setup), add the watch to the + * database. + * @return bool (always true) */ - function addWatch() { + public function addWatch() { $fname = 'WatchedItem::addWatch'; wfProfileIn( $fname ); // Use INSERT IGNORE to avoid overwriting the notification timestamp // if there's already an entry for this page - $dbw =& wfGetDB( DB_MASTER ); + $dbw = wfGetDB( DB_MASTER ); $dbw->insert( 'watchlist', array( 'wl_user' => $this->id, @@ -78,11 +81,15 @@ class WatchedItem { return true; } - function removeWatch() { + /** + * Same as addWatch, only the opposite. + * @return bool + */ + public function removeWatch() { $fname = 'WatchedItem::removeWatch'; $success = false; - $dbw =& wfGetDB( DB_MASTER ); + $dbw = wfGetDB( DB_MASTER ); $dbw->delete( 'watchlist', array( 'wl_user' => $this->id, @@ -116,27 +123,25 @@ class WatchedItem { * Check if the given title already is watched by the user, and if so * add watches on a new title. To be used for page renames and such. * - * @param Title $ot Page title to duplicate entries from, if present - * @param Title $nt Page title to add watches on - * @static + * @param $ot Title: page title to duplicate entries from, if present + * @param $nt Title: page title to add watches on */ - function duplicateEntries( $ot, $nt ) { + public static function duplicateEntries( $ot, $nt ) { WatchedItem::doDuplicateEntries( $ot->getSubjectPage(), $nt->getSubjectPage() ); WatchedItem::doDuplicateEntries( $ot->getTalkPage(), $nt->getTalkPage() ); } /** - * @static - * @access private + * Handle duplicate entries. Backend for duplicateEntries(). */ - function doDuplicateEntries( $ot, $nt ) { + private static function doDuplicateEntries( $ot, $nt ) { $fname = "WatchedItem::duplicateEntries"; $oldnamespace = $ot->getNamespace(); $newnamespace = $nt->getNamespace(); $oldtitle = $ot->getDBkey(); $newtitle = $nt->getDBkey(); - $dbw =& wfGetDB( DB_MASTER ); + $dbw = wfGetDB( DB_MASTER ); $res = $dbw->select( 'watchlist', 'wl_user', array( 'wl_namespace' => $oldnamespace, 'wl_title' => $oldtitle ), $fname, 'FOR UPDATE' @@ -163,8 +168,4 @@ class WatchedItem { $dbw->replace( 'watchlist', array(array( 'wl_user', 'wl_namespace', 'wl_title')), $values, $fname ); return true; } - - } - -?>