Merge "Date range filtering in Special:NewFiles"
[lhc/web/wiklou.git] / includes / specials / SpecialWatchlist.php
index 9066148..e9d3f26 100644 (file)
@@ -81,6 +81,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                if ( ( $config->get( 'EnotifWatchlist' ) || $config->get( 'ShowUpdatedMarker' ) )
                        && $request->getVal( 'reset' )
                        && $request->wasPosted()
+                       && $user->matchEditToken( $request->getVal( 'token' ) )
                ) {
                        $user->clearAllNotifications();
                        $output->redirect( $this->getPageTitle()->getFullURL( $opts->getChangedValues() ) );
@@ -108,16 +109,12 @@ class SpecialWatchlist extends ChangesListSpecialPage {
        /**
         * @inheritdoc
         */
-       protected function registerFiltersFromDefinitions( array $definition ) {
-               foreach ( $definition as $groupName => &$groupDefinition ) {
-                       foreach ( $groupDefinition['filters'] as &$filterDefinition ) {
-                               if ( isset( $filterDefinition['showHideSuffix'] ) ) {
-                                       $filterDefinition['showHide'] = 'wl' . $filterDefinition['showHideSuffix'];
-                               }
-                       }
+       protected function transformFilterDefinition( array $filterDefinition ) {
+               if ( isset( $filterDefinition['showHideSuffix'] ) ) {
+                       $filterDefinition['showHide'] = 'wl' . $filterDefinition['showHideSuffix'];
                }
 
-               parent::registerFiltersFromDefinitions( $definition );
+               return $filterDefinition;
        }
 
        /**
@@ -143,8 +140,11 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                $hideLiu->setDefault( $user->getBoolOption( 'watchlisthideliu' ) );
 
                $reviewStatus = $this->getFilterGroup( 'reviewStatus' );
-               $hidePatrolled = $reviewStatus->getFilter( 'hidepatrolled' );
-               $hidePatrolled->setDefault( $user->getBoolOption( 'watchlisthidepatrolled' ) );
+               if ( $reviewStatus !== null ) {
+                       // Conditional on feature being available and rights
+                       $hidePatrolled = $reviewStatus->getFilter( 'hidepatrolled' );
+                       $hidePatrolled->setDefault( $user->getBoolOption( 'watchlisthidepatrolled' ) );
+               }
 
                $authorship = $this->getFilterGroup( 'authorship' );
                $hideMyself = $authorship->getFilter( 'hidemyself' );
@@ -152,7 +152,10 @@ class SpecialWatchlist extends ChangesListSpecialPage {
 
                $changeType = $this->getFilterGroup( 'changeType' );
                $hideCategorization = $changeType->getFilter( 'hidecategorization' );
-               $hideCategorization->setDefault( $user->getBoolOption( 'watchlisthidecategorization' ) );
+               if ( $hideCategorization !== null ) {
+                       // Conditional on feature being available
+                       $hideCategorization->setDefault( $user->getBoolOption( 'watchlisthidecategorization' ) );
+               }
        }
 
        /**
@@ -658,6 +661,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                                'id' => 'mw-watchlist-resetbutton' ] ) . "\n" .
                        Xml::submitButton( $this->msg( 'enotif_reset' )->text(),
                                [ 'name' => 'mw-watchlist-reset-submit' ] ) . "\n" .
+                       Html::hidden( 'token', $user->getEditToken() ) . "\n" .
                        Html::hidden( 'reset', 'all' ) . "\n";
                        foreach ( $nondefaults as $key => $value ) {
                                $form .= Html::hidden( $key, $value ) . "\n";