Merge "User#getOption: Check ignoreHidden before $wgHiddenPrefs"
[lhc/web/wiklou.git] / includes / specials / SpecialWatchlist.php
index 0296a63..b322547 100644 (file)
@@ -26,8 +26,8 @@ class SpecialWatchlist extends SpecialPage {
        /**
         * Constructor
         */
-       public function __construct( $page = 'Watchlist' ) {
-               parent::__construct( $page );
+       public function __construct( $page = 'Watchlist', $restriction = 'viewmywatchlist' ) {
+               parent::__construct( $page, $restriction );
        }
 
        /**
@@ -54,17 +54,16 @@ class SpecialWatchlist extends SpecialPage {
                        return;
                }
 
+               // Check permissions
+               $this->checkPermissions();
+
                // Add feed links
-               $wlToken = $user->getOption( 'watchlisttoken' );
-               if ( !$wlToken ) {
-                       $wlToken = MWCryptRand::generateHex( 40 );
-                       $user->setOption( 'watchlisttoken', $wlToken );
-                       $user->saveSettings();
+               $wlToken = $user->getTokenFromOption( 'watchlisttoken' );
+               if ( $wlToken ) {
+                       $this->addFeedLinks( array( 'action' => 'feedwatchlist', 'allrev' => 'allrev',
+                                                               'wlowner' => $user->getName(), 'wltoken' => $wlToken ) );
                }
 
-               $this->addFeedLinks( array( 'action' => 'feedwatchlist', 'allrev' => 'allrev',
-                                                       'wlowner' => $user->getName(), 'wltoken' => $wlToken ) );
-
                $this->setHeaders();
                $this->outputHeader();
 
@@ -99,7 +98,7 @@ class SpecialWatchlist extends SpecialPage {
                        return;
                }
 
-               // @TODO: use FormOptions!
+               // @todo use FormOptions!
                $defaults = array(
                /* float */ 'days' => floatval( $user->getOption( 'watchlistdays' ) ), /* 3.0 or 0.5, watch further below */
                /* bool  */ 'hideMinor' => (int)$user->getBoolOption( 'watchlisthideminor' ),
@@ -241,26 +240,35 @@ class SpecialWatchlist extends SpecialPage {
                }
 
                # Create output form
-               $form = Xml::fieldset( $this->msg( 'watchlist-options' )->text(), false, array( 'id' => 'mw-watchlist-options' ) );
+               $form = Xml::fieldset(
+                       $this->msg( 'watchlist-options' )->text(),
+                       false,
+                       array( 'id' => 'mw-watchlist-options' )
+               );
 
                # Show watchlist header
+               $form .= "<p>";
                $form .= $this->msg( 'watchlist-details' )->numParams( $nitems )->parse() . "\n";
-
-               if ( $user->getOption( 'enotifwatchlistpages' ) && $wgEnotifWatchlist ) {
-                       $form .= $this->msg( 'wlheader-enotif' )->parseAsBlock() . "\n";
+               if ( $wgEnotifWatchlist && $user->getOption( 'enotifwatchlistpages' ) ) {
+                       $form .= $this->msg( 'wlheader-enotif' )->parse() . "\n";
+               }
+               if ( $wgShowUpdatedMarker ) {
+                       $form .= $this->msg( 'wlheader-showupdated' )->parse() . "\n";
                }
+               $form .= "</p>";
+
                if ( $wgShowUpdatedMarker ) {
                        $form .= Xml::openElement( 'form', array( 'method' => 'post',
-                                               'action' => $this->getTitle()->getLocalURL(),
-                                               'id' => 'mw-watchlist-resetbutton' ) ) . "\n" .
-                                       $this->msg( 'wlheader-showupdated' )->parse() .
-                                       Xml::submitButton( $this->msg( 'enotif_reset' )->text(), array( 'name' => 'dummy' ) ) . "\n" .
-                                       Html::hidden( 'reset', 'all' ) . "\n";
-                                       foreach ( $nondefaults as $key => $value ) {
-                                               $form .= Html::hidden( $key, $value ) . "\n";
-                                       }
-                                       $form .= Xml::closeElement( 'form' ) . "\n";
+                               'action' => $this->getTitle()->getLocalURL(),
+                               'id' => 'mw-watchlist-resetbutton' ) ) . "\n" .
+                       Xml::submitButton( $this->msg( 'enotif_reset' )->text(), array( 'name' => 'dummy' ) ) . "\n" .
+                       Html::hidden( 'reset', 'all' ) . "\n";
+                       foreach ( $nondefaults as $key => $value ) {
+                               $form .= Html::hidden( $key, $value ) . "\n";
+                       }
+                       $form .= Xml::closeElement( 'form' ) . "\n";
                }
+
                $form .= "<hr />\n";
 
                $tables = array( 'recentchanges', 'watchlist' );
@@ -378,7 +386,9 @@ class SpecialWatchlist extends SpecialPage {
 
                # If there's nothing to show, stop here
                if ( $numRows == 0 ) {
-                       $output->addWikiMsg( 'watchnochange' );
+                       $output->wrapWikiMsg(
+                               "<div class='mw-changeslist-empty'>\n$1\n</div>", 'recentchanges-noresult'
+                       );
                        return;
                }