X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fspecials%2Fpagers%2FNewPagesPager.php;h=1db32e6142c23f2a11238c107e78ba9febeecc2d;hb=246edb94a2ba8b6c94d52cb60c7c884d28d59190;hp=5788bb2bacfac4d10ee94f8bc6a16ad856e30cb3;hpb=90f5b55fa48a719905e828dbf731b078e71f6374;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/pagers/NewPagesPager.php b/includes/specials/pagers/NewPagesPager.php index 5788bb2bac..1db32e6142 100644 --- a/includes/specials/pagers/NewPagesPager.php +++ b/includes/specials/pagers/NewPagesPager.php @@ -22,6 +22,8 @@ /** * @ingroup Pager */ +use MediaWiki\MediaWikiServices; + class NewPagesPager extends ReverseChronologicalPager { /** @@ -50,9 +52,6 @@ class NewPagesPager extends ReverseChronologicalPager { $conds = []; $conds['rc_new'] = 1; - $namespace = $this->opts->getValue( 'namespace' ); - $namespace = ( $namespace === 'all' ) ? false : intval( $namespace ); - $username = $this->opts->getValue( 'username' ); $user = Title::makeTitleSafe( NS_USER, $username ); @@ -65,25 +64,17 @@ class NewPagesPager extends ReverseChronologicalPager { } } - if ( $namespace !== false ) { - if ( $this->opts->getValue( 'invert' ) ) { - $conds[] = 'rc_namespace != ' . $this->mDb->addQuotes( $namespace ); - } else { - $conds['rc_namespace'] = $namespace; - } - } - if ( $user ) { $conds[] = ActorMigration::newMigration()->getWhere( $this->mDb, 'rc_user', User::newFromName( $user->getText(), false ), false )['conds']; - } elseif ( User::groupHasPermission( '*', 'createpage' ) && - $this->opts->getValue( 'hideliu' ) - ) { + } elseif ( $this->canAnonymousUsersCreatePages() && $this->opts->getValue( 'hideliu' ) ) { # If anons cannot make new pages, don't "exclude logged in users"! $conds[] = ActorMigration::newMigration()->isAnon( $rcQuery['fields']['rc_user'] ); } + $conds = array_merge( $conds, $this->getNamespaceCond() ); + # If this user cannot see patrolled edits or they are off, don't do dumb queries! if ( $this->opts->getValue( 'hidepatrolled' ) && $this->getUser()->useNPPatrol() ) { $conds['rc_patrolled'] = RecentChange::PRC_UNPATROLLED; @@ -130,6 +121,42 @@ class NewPagesPager extends ReverseChronologicalPager { return $info; } + private function canAnonymousUsersCreatePages() { + $pm = MediaWikiServices::getInstance()->getPermissionManager(); + return ( $pm->groupHasPermission( '*', 'createpage' ) || + $pm->groupHasPermission( '*', 'createtalk' ) + ); + } + + // Based on ContribsPager.php + function getNamespaceCond() { + $namespace = $this->opts->getValue( 'namespace' ); + if ( $namespace === 'all' || $namespace === '' ) { + return []; + } + + $namespace = intval( $namespace ); + $invert = $this->opts->getValue( 'invert' ); + $associated = $this->opts->getValue( 'associated' ); + + $eq_op = $invert ? '!=' : '='; + $bool_op = $invert ? 'AND' : 'OR'; + + $selectedNS = $this->mDb->addQuotes( $namespace ); + if ( !$associated ) { + return [ "rc_namespace $eq_op $selectedNS" ]; + } + + $associatedNS = $this->mDb->addQuotes( + MediaWikiServices::getInstance()->getNamespaceInfo()->getAssociated( $namespace ) + ); + return [ + "rc_namespace $eq_op $selectedNS " . + $bool_op . + " rc_namespace $eq_op $associatedNS" + ]; + } + function getIndexField() { return 'rc_timestamp'; }