Merge "(bug 31704) Allow selection of associated namespace on the watchlist"
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 1 May 2012 22:22:09 +0000 (22:22 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 1 May 2012 22:22:09 +0000 (22:22 +0000)
1  2 
includes/specials/SpecialWatchlist.php

@@@ -116,6 -116,7 +116,7 @@@ class SpecialWatchlist extends SpecialP
                /* bool  */ 'hideOwn'   => (int)$user->getBoolOption( 'watchlisthideown' ),
                /* ?     */ 'namespace' => 'all',
                /* ?     */ 'invert'    => false,
+               /* bool  */ 'associated' => false,
                );
                $this->customFilters = array();
                wfRunHooks( 'SpecialWatchlistFilters', array( $this, &$this->customFilters ) );
  
                # Get namespace value, if supplied, and prepare a WHERE fragment
                $nameSpace = $request->getIntOrNull( 'namespace' );
-               $invert = $request->getIntOrNull( 'invert' );
+               $invert = $request->getBool( 'invert' );
+               $associated = $request->getBool( 'associated' );
                if ( !is_null( $nameSpace ) ) {
+                       $eq_op = $invert ? '!=' : '=';\r
+                       $bool_op = $invert ? 'AND' : 'OR';
                        $nameSpace = intval( $nameSpace ); // paranioa
-                       if ( $invert ) {
-                               $nameSpaceClause = "rc_namespace != $nameSpace";
+                       if ( !$associated ) {
+                               $nameSpaceClause = "rc_namespace $eq_op $nameSpace";
                        } else {
-                               $nameSpaceClause = "rc_namespace = $nameSpace";
+                               $associatedNS = MWNamespace::getAssociated( $nameSpace );\r
+                               $nameSpaceClause =
+                                       "rc_namespace $eq_op $nameSpace " .\r
+                                       $bool_op .\r
+                                       " rc_namespace $eq_op $associatedNS";
                        }
                } else {
                        $nameSpace = '';
                }
                $values['namespace'] = $nameSpace;
                $values['invert'] = $invert;
+               $values['associated'] = $associated;
  
                if( is_null( $values['days'] ) || !is_numeric( $values['days'] ) ) {
                        $big = 1000; /* The magical big */
                $tables = array( 'recentchanges', 'watchlist' );
                $fields = array( $dbr->tableName( 'recentchanges' ) . '.*' );
                $join_conds = array(
 -                      'watchlist' => array('INNER JOIN',"wl_user='{$user->getId()}' AND wl_namespace=rc_namespace AND wl_title=rc_title"),
 +                      'watchlist' => array(
 +                              'INNER JOIN',
 +                              array(
 +                                      'wl_user' => $user->getId(),
 +                                      'wl_namespace=rc_namespace',
 +                                      'wl_title=rc_title'
 +                              ),
 +                      ),
                );
                $options = array( 'ORDER BY' => 'rc_timestamp DESC' );
                if( $wgShowUpdatedMarker ) {
                                'class' => 'namespaceselector',
                        )
                ) . '&#160;';
-               $form .= Xml::checkLabel( $this->msg( 'invert' )->text(), 'invert', 'nsinvert', $invert ) . '&#160;';
+               $form .= Xml::checkLabel(
+                       $this->msg( 'invert' )->text(),
+                       'invert',
+                       'nsinvert',
+                       $invert,
+                       array( 'title' => $this->msg( 'tooltip-invert' )->text() )
+               ) . '&#160;';
+               $form .= Xml::checkLabel(
+                       $this->msg( 'namespace_association' )->text(),
+                       'associated',
+                       'associated',
+                       $associated,
+                       array( 'title' => $this->msg( 'tooltip-namespace_association' )->text() )
+               ) . '&#160;';
                $form .= Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . '</p>';
                $form .= Html::hidden( 'days', $values['days'] );
                foreach ( $filters as $key => $msg ) {