Merge "Add CollationFa"
[lhc/web/wiklou.git] / includes / specialpage / ChangesListSpecialPage.php
index 01782f3..00efeae 100644 (file)
@@ -140,15 +140,22 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                $opts = new FormOptions();
 
                $opts->add( 'hideminor', false );
+               $opts->add( 'hidemajor', false );
                $opts->add( 'hidebots', false );
+               $opts->add( 'hidehumans', false );
                $opts->add( 'hideanons', false );
                $opts->add( 'hideliu', false );
                $opts->add( 'hidepatrolled', false );
+               $opts->add( 'hideunpatrolled', false );
                $opts->add( 'hidemyself', false );
+               $opts->add( 'hidebyothers', false );
 
                if ( $config->get( 'RCWatchCategoryMembership' ) ) {
                        $opts->add( 'hidecategorization', false );
                }
+               $opts->add( 'hidepageedits', false );
+               $opts->add( 'hidenewpages', false );
+               $opts->add( 'hidelog', false );
 
                $opts->add( 'namespace', '', FormOptions::INTNULL );
                $opts->add( 'invert', false );
@@ -229,13 +236,24 @@ abstract class ChangesListSpecialPage extends SpecialPage {
 
                // Toggles
                if ( $opts['hideminor'] ) {
-                       $conds['rc_minor'] = 0;
+                       $conds[] = 'rc_minor = 0';
+               }
+               if ( $opts['hidemajor'] ) {
+                       $conds[] = 'rc_minor = 1';
                }
                if ( $opts['hidebots'] ) {
                        $conds['rc_bot'] = 0;
                }
-               if ( $user->useRCPatrol() && $opts['hidepatrolled'] ) {
-                       $conds['rc_patrolled'] = 0;
+               if ( $opts['hidehumans'] ) {
+                       $conds[] = 'rc_bot = 1';
+               }
+               if ( $user->useRCPatrol() ) {
+                       if ( $opts['hidepatrolled'] ) {
+                               $conds[] = 'rc_patrolled = 0';
+                       }
+                       if ( $opts['hideunpatrolled'] ) {
+                               $conds[] = 'rc_patrolled = 1';
+                       }
                }
                if ( $botsonly ) {
                        $conds['rc_bot'] = 1;
@@ -247,6 +265,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                                $conds[] = 'rc_user != 0';
                        }
                }
+
                if ( $opts['hidemyself'] ) {
                        if ( $user->getId() ) {
                                $conds[] = 'rc_user != ' . $dbr->addQuotes( $user->getId() );
@@ -254,11 +273,28 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                                $conds[] = 'rc_user_text != ' . $dbr->addQuotes( $user->getName() );
                        }
                }
+               if ( $opts['hidebyothers'] ) {
+                       if ( $user->getId() ) {
+                               $conds[] = 'rc_user = ' . $dbr->addQuotes( $user->getId() );
+                       } else {
+                               $conds[] = 'rc_user_text = ' . $dbr->addQuotes( $user->getName() );
+                       }
+               }
+
                if ( $this->getConfig()->get( 'RCWatchCategoryMembership' )
                        && $opts['hidecategorization'] === true
                ) {
                        $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_CATEGORIZE );
                }
+               if ( $opts['hidepageedits'] ) {
+                       $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_EDIT );
+               }
+               if ( $opts['hidenewpages'] ) {
+                       $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_NEW );
+               }
+               if ( $opts['hidelog'] ) {
+                       $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_LOG );
+               }
 
                // Namespace filtering
                if ( $opts['namespace'] !== '' ) {
@@ -485,4 +521,23 @@ abstract class ChangesListSpecialPage extends SpecialPage {
        protected function getGroupName() {
                return 'changes';
        }
+
+       /**
+        * Get filters that can be rendered.
+        *
+        * Filters with 'msg' => false can be used to filter data but won't
+        * be presented as show/hide toggles in the UI. They are not returned
+        * by this function.
+        *
+        * @param array $allFilters Map of filter URL param names to properties (msg/default)
+        * @return array Map of filter URL param names to properties (msg/default)
+        */
+       protected function getRenderableCustomFilters( $allFilters ) {
+               return array_filter(
+                       $allFilters,
+                       function( $filter ) {
+                               return isset( $filter['msg'] ) && ( $filter['msg'] !== false );
+                       }
+               );
+       }
 }