$opts->add( 'hideliu', false );
$opts->add( 'hidepatrolled', false );
$opts->add( 'hidemyself', false );
+ $opts->add( 'hidebyothers', false );
if ( $config->get( 'RCWatchCategoryMembership' ) ) {
$opts->add( 'hidecategorization', false );
$conds[] = 'rc_user != 0';
}
}
+
if ( $opts['hidemyself'] ) {
if ( $user->getId() ) {
$conds[] = 'rc_user != ' . $dbr->addQuotes( $user->getId() );
$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
) {
protected $rc;
/** helper to test SpecialRecentchanges::buildMainQueryConds() */
- private function assertConditions( $expected, $requestOptions = null, $message = '' ) {
+ private function assertConditions(
+ $expected,
+ $requestOptions = null,
+ $message = '',
+ $user = null
+ ) {
$context = new RequestContext;
$context->setRequest( new FauxRequest( $requestOptions ) );
+ if ( $user ) {
+ $context->setUser( $user );
+ }
# setup the rc object
$this->rc = new SpecialRecentChanges();
[ NS_TALK, NS_MAIN ],
];
}
+
+ public function testRcHidemyselfFilter() {
+ $user = $this->getTestUser()->getUser();
+ $this->assertConditions(
+ [ # expected
+ 'rc_bot' => 0,
+ 0 => "rc_user != '{$user->getId()}'",
+ 1 => "rc_type != '6'",
+ ],
+ [
+ 'hidemyself' => 1,
+ ],
+ "rc conditions: hidemyself=1 (logged in)",
+ $user
+ );
+
+ $user = User::newFromName( '10.11.12.13', false );
+ $this->assertConditions(
+ [ # expected
+ 'rc_bot' => 0,
+ 0 => "rc_user_text != '10.11.12.13'",
+ 1 => "rc_type != '6'",
+ ],
+ [
+ 'hidemyself' => 1,
+ ],
+ "rc conditions: hidemyself=1 (anon)",
+ $user
+ );
+ }
+
+ public function testRcHidebyothersFilter() {
+ $user = $this->getTestUser()->getUser();
+ $this->assertConditions(
+ [ # expected
+ 'rc_bot' => 0,
+ 0 => "rc_user = '{$user->getId()}'",
+ 1 => "rc_type != '6'",
+ ],
+ [
+ 'hidebyothers' => 1,
+ ],
+ "rc conditions: hidebyothers=1 (logged in)",
+ $user
+ );
+
+ $user = User::newFromName( '10.11.12.13', false );
+ $this->assertConditions(
+ [ # expected
+ 'rc_bot' => 0,
+ 0 => "rc_user_text = '10.11.12.13'",
+ 1 => "rc_type != '6'",
+ ],
+ [
+ 'hidebyothers' => 1,
+ ],
+ "rc conditions: hidebyothers=1 (anon)",
+ $user
+ );
+ }
+
+ public function testRcHidemyselfHidebyothersFilter() {
+ $user = $this->getTestUser()->getUser();
+ $this->assertConditions(
+ [ # expected
+ 'rc_bot' => 0,
+ 0 => "rc_user != '{$user->getId()}'",
+ 1 => "rc_user = '{$user->getId()}'",
+ 2 => "rc_type != '6'",
+ ],
+ [
+ 'hidemyself' => 1,
+ 'hidebyothers' => 1,
+ ],
+ "rc conditions: hidemyself=1 hidebyothers=1 (logged in)",
+ $user
+ );
+ }
}