Merge "Cleanup and expand Status tests"
[lhc/web/wiklou.git] / includes / specials / SpecialWatchlist.php
index 11632a3..c51b61b 100644 (file)
@@ -41,18 +41,7 @@ class SpecialWatchlist extends SpecialPage {
                $output = $this->getOutput();
 
                # Anons don't get a watchlist
-               if ( $user->isAnon() ) {
-                       $output->setPageTitle( $this->msg( 'watchnologin' ) );
-                       $output->setRobotPolicy( 'noindex,nofollow' );
-                       $llink = Linker::linkKnown(
-                               SpecialPage::getTitleFor( 'Userlogin' ),
-                               $this->msg( 'loginreqlink' )->escaped(),
-                               array(),
-                               array( 'returnto' => $this->getTitle()->getPrefixedText() )
-                       );
-                       $output->addHTML( $this->msg( 'watchlistanontext' )->rawParams( $llink )->parse() );
-                       return;
-               }
+               $this->requireLogin( 'watchlistanontext', 'watchnologin' );
 
                // Check permissions
                $this->checkPermissions();
@@ -60,32 +49,32 @@ class SpecialWatchlist extends SpecialPage {
                // Add feed links
                $wlToken = $user->getTokenFromOption( 'watchlisttoken' );
                if ( $wlToken ) {
-                       $this->addFeedLinks( array( 'action' => 'feedwatchlist', 'allrev' => 'allrev',
-                                                               'wlowner' => $user->getName(), 'wltoken' => $wlToken ) );
+                       $this->addFeedLinks( array(
+                               'action' => 'feedwatchlist',
+                               'allrev' => 1,
+                               'wlowner' => $user->getName(),
+                               'wltoken' => $wlToken,
+                       ) );
                }
 
                $this->setHeaders();
                $this->outputHeader();
 
-               $output->addSubtitle( $this->msg( 'watchlistfor2', $user->getName()
-                       )->rawParams( SpecialEditWatchlist::buildTools( null ) ) );
+               $output->addSubtitle(
+                       $this->msg( 'watchlistfor2', $user->getName() )
+                               ->rawParams( SpecialEditWatchlist::buildTools( null ) )
+               );
 
                $request = $this->getRequest();
 
                $mode = SpecialEditWatchlist::getMode( $request, $par );
                if ( $mode !== false ) {
-                       # TODO: localise?
-                       switch ( $mode ) {
-                               case SpecialEditWatchlist::EDIT_CLEAR:
-                                       $mode = 'clear';
-                                       break;
-                               case SpecialEditWatchlist::EDIT_RAW:
-                                       $mode = 'raw';
-                                       break;
-                               default:
-                                       $mode = null;
+                       if ( $mode === SpecialEditWatchlist::EDIT_RAW ) {
+                               $title = SpecialPage::getTitleFor( 'EditWatchlist', 'raw' );
+                       } else {
+                               $title = SpecialPage::getTitleFor( 'EditWatchlist' );
                        }
-                       $title = SpecialPage::getTitleFor( 'EditWatchlist', $mode );
+
                        $output->redirect( $title->getLocalURL() );
                        return;
                }
@@ -208,7 +197,17 @@ class SpecialWatchlist extends SpecialPage {
                        $usePage = false;
                } else {
                        # Top log Ids for a page are not stored
-                       $conds[] = 'rc_this_oldid=page_latest OR rc_type=' . RC_LOG;
+                       $nonRevisionTypes = array( RC_LOG );
+                       wfRunHooks( 'SpecialWatchlistGetNonRevisionTypes', array( &$nonRevisionTypes ) );
+                       if ( $nonRevisionTypes ) {
+                               $conds[] = $dbr->makeList(
+                                       array(
+                                               'rc_this_oldid=page_latest',
+                                               'rc_type' => $nonRevisionTypes,
+                                       ),
+                                       LIST_OR
+                               );
+                       }
                        $limitWatchlist = 0;
                        $usePage = true;
                }