Merge "Avoid Database::tableName in WikiExporter"
[lhc/web/wiklou.git] / includes / specials / SpecialContributions.php
index 0425a58..e8b85fa 100644 (file)
@@ -55,13 +55,6 @@ class SpecialContributions extends IncludableSpecialPage {
 
                $target = $par ?? $request->getVal( 'target' );
 
-               if ( $request->getVal( 'contribs' ) == 'newbie' || $par === 'newbies' ) {
-                       $target = 'newbies';
-                       $this->opts['contribs'] = 'newbie';
-               } else {
-                       $this->opts['contribs'] = 'user';
-               }
-
                $this->opts['deletedOnly'] = $request->getBool( 'deletedOnly' );
 
                if ( !strlen( $target ) ) {
@@ -81,14 +74,7 @@ class SpecialContributions extends IncludableSpecialPage {
                $this->opts['hideMinor'] = $request->getBool( 'hideMinor' );
 
                $id = 0;
-               if ( $this->opts['contribs'] === 'newbie' ) {
-                       $userObj = User::newFromName( $target ); // hysterical raisins
-                       $out->addSubtitle( $this->msg( 'sp-contributions-newbies-sub' ) );
-                       $out->setHTMLTitle( $this->msg(
-                               'pagetitle',
-                               $this->msg( 'sp-contributions-newbies-title' )->plain()
-                       )->inContentLanguage() );
-               } elseif ( ExternalUserNames::isExternal( $target ) ) {
+               if ( ExternalUserNames::isExternal( $target ) ) {
                        $userObj = User::newFromName( $target, false );
                        if ( !$userObj ) {
                                $out->addHTML( $this->getForm() );
@@ -140,7 +126,10 @@ class SpecialContributions extends IncludableSpecialPage {
 
                // Allows reverts to have the bot flag in recent changes. It is just here to
                // be passed in the form at the top of the page
-               if ( $user->isAllowed( 'markbotedits' ) && $request->getBool( 'bot' ) ) {
+               if ( MediaWikiServices::getInstance()
+                                ->getPermissionManager()
+                                ->userHasRight( $user, 'markbotedits' ) && $request->getBool( 'bot' )
+               ) {
                        $this->opts['bot'] = '1';
                }
 
@@ -217,7 +206,6 @@ class SpecialContributions extends IncludableSpecialPage {
                        }
                        $pager = new ContribsPager( $this->getContext(), [
                                'target' => $target,
-                               'contribs' => $this->opts['contribs'],
                                'namespace' => $this->opts['namespace'],
                                'tagfilter' => $this->opts['tagfilter'],
                                'start' => $this->opts['start'],
@@ -228,7 +216,7 @@ class SpecialContributions extends IncludableSpecialPage {
                                'hideMinor' => $this->opts['hideMinor'],
                                'nsInvert' => $this->opts['nsInvert'],
                                'associated' => $this->opts['associated'],
-                       ] );
+                       ], $this->getLinkRenderer() );
 
                        if ( IP::isValidRange( $target ) && !$pager->isQueryableRange( $target ) ) {
                                // Valid range, but outside CIDR limit.
@@ -256,9 +244,7 @@ class SpecialContributions extends IncludableSpecialPage {
                        $out->preventClickjacking( $pager->getPreventClickjacking() );
 
                        # Show the appropriate "footer" message - WHOIS tools, etc.
-                       if ( $this->opts['contribs'] == 'newbie' ) {
-                               $message = 'sp-contributions-footer-newbies';
-                       } elseif ( IP::isValidRange( $target ) ) {
+                       if ( IP::isValidRange( $target ) ) {
                                $message = 'sp-contributions-footer-anon-range';
                        } elseif ( IP::isIPAddress( $target ) ) {
                                $message = 'sp-contributions-footer-anon';
@@ -381,6 +367,7 @@ class SpecialContributions extends IncludableSpecialPage {
 
                $linkRenderer = $sp->getLinkRenderer();
 
+               $tools = [];
                # No talk pages for IP ranges.
                if ( !$isRange ) {
                        $tools['user-talk'] = $linkRenderer->makeLink(
@@ -389,7 +376,9 @@ class SpecialContributions extends IncludableSpecialPage {
                        );
                }
 
-               if ( $sp->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
+               # Block / Change block / Unblock links
+               $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
+               if ( $permissionManager->userHasRight( $sp->getUser(), 'block' ) ) {
                        if ( $target->getBlock() && $target->getBlock()->getType() != DatabaseBlock::TYPE_AUTO ) {
                                $tools['block'] = $linkRenderer->makeKnownLink( # Change block link
                                        SpecialPage::getTitleFor( 'Block', $username ),
@@ -416,7 +405,7 @@ class SpecialContributions extends IncludableSpecialPage {
                );
 
                # Suppression log link (T61120)
-               if ( $sp->getUser()->isAllowed( 'suppressionlog' ) ) {
+               if ( $permissionManager->userHasRight( $sp->getUser(), 'suppressionlog' ) ) {
                        $tools['log-suppression'] = $linkRenderer->makeKnownLink(
                                SpecialPage::getTitleFor( 'Log', 'suppress' ),
                                $sp->msg( 'sp-contributions-suppresslog', $username )->text(),
@@ -428,7 +417,7 @@ class SpecialContributions extends IncludableSpecialPage {
                # Don't show some links for IP ranges
                if ( !$isRange ) {
                        # Uploads: hide if IPs cannot upload (T220674)
-                       if ( !$isIP || $target->isAllowed( 'upload' ) ) {
+                       if ( !$isIP || $permissionManager->userHasRight( $target, 'upload' ) ) {
                                $tools['uploads'] = $linkRenderer->makeKnownLink(
                                        SpecialPage::getTitleFor( 'Listfiles', $username ),
                                        $sp->msg( 'sp-contributions-uploads' )->text()
@@ -444,7 +433,7 @@ class SpecialContributions extends IncludableSpecialPage {
 
                        # Add link to deleted user contributions for priviledged users
                        # Todo: T183457
-                       if ( $sp->getUser()->isAllowed( 'deletedhistory' ) ) {
+                       if ( $permissionManager->userHasRight( $sp->getUser(), 'deletedhistory' ) ) {
                                $tools['deletedcontribs'] = $linkRenderer->makeKnownLink(
                                        SpecialPage::getTitleFor( 'DeletedContributions', $username ),
                                        $sp->msg( 'sp-contributions-deleted', $username )->text()
@@ -491,10 +480,6 @@ class SpecialContributions extends IncludableSpecialPage {
                        $this->opts['associated'] = false;
                }
 
-               if ( !isset( $this->opts['contribs'] ) ) {
-                       $this->opts['contribs'] = 'user';
-               }
-
                if ( !isset( $this->opts['start'] ) ) {
                        $this->opts['start'] = '';
                }
@@ -503,10 +488,6 @@ class SpecialContributions extends IncludableSpecialPage {
                        $this->opts['end'] = '';
                }
 
-               if ( $this->opts['contribs'] == 'newbie' ) {
-                       $this->opts['target'] = '';
-               }
-
                if ( !isset( $this->opts['tagfilter'] ) ) {
                        $this->opts['tagfilter'] = '';
                }
@@ -578,21 +559,9 @@ class SpecialContributions extends IncludableSpecialPage {
                        $filterSelection = Html::rawElement( 'div', [], '' );
                }
 
-               $labelNewbies = Xml::radioLabel(
-                       $this->msg( 'sp-contributions-newbies' )->text(),
-                       'contribs',
-                       'newbie',
-                       'newbie',
-                       $this->opts['contribs'] == 'newbie',
-                       [ 'class' => 'mw-input' ]
-               );
-               $labelUsername = Xml::radioLabel(
+               $labelUsername = Xml::label(
                        $this->msg( 'sp-contributions-username' )->text(),
-                       'contribs',
-                       'user',
-                       'user',
-                       $this->opts['contribs'] == 'user',
-                       [ 'class' => 'mw-input' ]
+                       'mw-target-user-or-ip'
                );
                $input = Html::input(
                        'target',
@@ -607,16 +576,15 @@ class SpecialContributions extends IncludableSpecialPage {
                                        'mw-autocomplete-user', // used by mediawiki.userSuggest
                                ],
                        ] + (
-                               // Only autofocus if target hasn't been specified or in non-newbies mode
-                               ( $this->opts['contribs'] === 'newbie' || $this->opts['target'] )
-                                       ? [] : [ 'autofocus' => true ]
-                               )
+                               // Only autofocus if target hasn't been specified
+                               $this->opts['target'] ? [] : [ 'autofocus' => true ]
+                       )
                );
 
                $targetSelection = Html::rawElement(
                        'div',
                        [],
-                       $labelNewbies . '<br>' . $labelUsername . ' ' . $input . ' '
+                       $labelUsername . ' ' . $input . ' '
                );
 
                $hidden = $this->opts['namespace'] === '' ? ' mw-input-hidden' : '';
@@ -665,7 +633,10 @@ class SpecialContributions extends IncludableSpecialPage {
 
                $filters = [];
 
-               if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
+               if ( MediaWikiServices::getInstance()
+                               ->getPermissionManager()
+                               ->userHasRight( $this->getUser(), 'deletedhistory' )
+               ) {
                        $filters[] = Html::rawElement(
                                'span',
                                [ 'class' => 'mw-input-with-label' ],