Hide uploads link on IP contributions page
[lhc/web/wiklou.git] / includes / specials / SpecialContributions.php
index f60d5f0..dc4d1bd 100644 (file)
@@ -267,14 +267,10 @@ class SpecialContributions extends IncludableSpecialPage {
                                $message = 'sp-contributions-footer';
                        }
 
-                       if ( $message ) {
-                               if ( !$this->including() ) {
-                                       if ( !$this->msg( $message, $target )->isDisabled() ) {
-                                               $out->wrapWikiMsg(
-                                                       "<div class='mw-contributions-footer'>\n$1\n</div>",
-                                                       [ $message, $target ] );
-                                       }
-                               }
+                       if ( $message && !$this->including() && !$this->msg( $message, $target )->isDisabled() ) {
+                               $out->wrapWikiMsg(
+                                       "<div class='mw-contributions-footer'>\n$1\n</div>",
+                                       [ $message, $target ] );
                        }
                }
        }
@@ -313,7 +309,11 @@ class SpecialContributions extends IncludableSpecialPage {
                $links = '';
                if ( $talk ) {
                        $tools = self::getUserLinks( $this, $userObj );
-                       $links = $this->getLanguage()->pipeList( $tools );
+                       $links = Html::openElement( 'span', [ 'class' => 'mw-changeslist-links' ] );
+                       foreach ( $tools as $tool ) {
+                               $links .= Html::rawElement( 'span', [], $tool ) . ' ';
+                       }
+                       $links = trim( $links ) . Html::closeElement( 'span' );
 
                        // Show a note if the user is blocked and display the last block log entry.
                        // Do not expose the autoblocks, since that may lead to a leak of accounts' IPs,
@@ -354,7 +354,8 @@ class SpecialContributions extends IncludableSpecialPage {
                }
 
                return Html::rawElement( 'div', [ 'class' => 'mw-contributions-user-tools' ],
-                       $this->msg( 'contribsub2' )->rawParams( $user, $links )->params( $userObj->getName() )
+                       $this->msg( 'contributions-subtitle' )->rawParams( $user )->params( $userObj->getName() )
+                       . ' ' . $links
                );
        }
 
@@ -371,70 +372,74 @@ class SpecialContributions extends IncludableSpecialPage {
                $username = $target->getName();
                $userpage = $target->getUserPage();
                $talkpage = $target->getTalkPage();
+               $isIP = IP::isValid( $username );
+               $isRange = IP::isValidRange( $username );
 
                $linkRenderer = $sp->getLinkRenderer();
 
                # No talk pages for IP ranges.
-               if ( !IP::isValidRange( $username ) ) {
+               if ( !$isRange ) {
                        $tools['user-talk'] = $linkRenderer->makeLink(
                                $talkpage,
                                $sp->msg( 'sp-contributions-talk' )->text()
                        );
                }
 
-               if ( ( $id !== null ) || ( $id === null && IP::isIPAddress( $username ) ) ) {
-                       if ( $sp->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
-                               if ( $target->isBlocked() && $target->getBlock()->getType() != Block::TYPE_AUTO ) {
-                                       $tools['block'] = $linkRenderer->makeKnownLink( # Change block link
-                                               SpecialPage::getTitleFor( 'Block', $username ),
-                                               $sp->msg( 'change-blocklink' )->text()
-                                       );
-                                       $tools['unblock'] = $linkRenderer->makeKnownLink( # Unblock link
-                                               SpecialPage::getTitleFor( 'Unblock', $username ),
-                                               $sp->msg( 'unblocklink' )->text()
-                                       );
-                               } else { # User is not blocked
-                                       $tools['block'] = $linkRenderer->makeKnownLink( # Block link
-                                               SpecialPage::getTitleFor( 'Block', $username ),
-                                               $sp->msg( 'blocklink' )->text()
-                                       );
-                               }
+               if ( $sp->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
+                       if ( $target->getBlock() && $target->getBlock()->getType() != Block::TYPE_AUTO ) {
+                               $tools['block'] = $linkRenderer->makeKnownLink( # Change block link
+                                       SpecialPage::getTitleFor( 'Block', $username ),
+                                       $sp->msg( 'change-blocklink' )->text()
+                               );
+                               $tools['unblock'] = $linkRenderer->makeKnownLink( # Unblock link
+                                       SpecialPage::getTitleFor( 'Unblock', $username ),
+                                       $sp->msg( 'unblocklink' )->text()
+                               );
+                       } else { # User is not blocked
+                               $tools['block'] = $linkRenderer->makeKnownLink( # Block link
+                                       SpecialPage::getTitleFor( 'Block', $username ),
+                                       $sp->msg( 'blocklink' )->text()
+                               );
                        }
+               }
 
-                       # Block log link
-                       $tools['log-block'] = $linkRenderer->makeKnownLink(
-                               SpecialPage::getTitleFor( 'Log', 'block' ),
-                               $sp->msg( 'sp-contributions-blocklog' )->text(),
+               # Block log link
+               $tools['log-block'] = $linkRenderer->makeKnownLink(
+                       SpecialPage::getTitleFor( 'Log', 'block' ),
+                       $sp->msg( 'sp-contributions-blocklog' )->text(),
+                       [],
+                       [ 'page' => $userpage->getPrefixedText() ]
+               );
+
+               # Suppression log link (T61120)
+               if ( $sp->getUser()->isAllowed( 'suppressionlog' ) ) {
+                       $tools['log-suppression'] = $linkRenderer->makeKnownLink(
+                               SpecialPage::getTitleFor( 'Log', 'suppress' ),
+                               $sp->msg( 'sp-contributions-suppresslog', $username )->text(),
                                [],
-                               [ 'page' => $userpage->getPrefixedText() ]
+                               [ 'offender' => $username ]
                        );
-
-                       # Suppression log link (T61120)
-                       if ( $sp->getUser()->isAllowed( 'suppressionlog' ) ) {
-                               $tools['log-suppression'] = $linkRenderer->makeKnownLink(
-                                       SpecialPage::getTitleFor( 'Log', 'suppress' ),
-                                       $sp->msg( 'sp-contributions-suppresslog', $username )->text(),
-                                       [],
-                                       [ 'offender' => $username ]
-                               );
-                       }
                }
 
                # Don't show some links for IP ranges
-               if ( !IP::isValidRange( $username ) ) {
-                       # Uploads
-                       $tools['uploads'] = $linkRenderer->makeKnownLink(
-                               SpecialPage::getTitleFor( 'Listfiles', $username ),
-                               $sp->msg( 'sp-contributions-uploads' )->text()
-                       );
+               if ( !$isRange ) {
+                       # Uploads: hide if IPs cannot upload (T220674)
+                       if ( !$isIP || $target->isAllowed( 'upload' ) ) {
+                               $tools['uploads'] = $linkRenderer->makeKnownLink(
+                                       SpecialPage::getTitleFor( 'Listfiles', $username ),
+                                       $sp->msg( 'sp-contributions-uploads' )->text()
+                               );
+                       }
 
                        # Other logs link
+                       # Todo: T146628
                        $tools['logs'] = $linkRenderer->makeKnownLink(
                                SpecialPage::getTitleFor( 'Log', $username ),
                                $sp->msg( 'sp-contributions-logs' )->text()
                        );
 
                        # Add link to deleted user contributions for priviledged users
+                       # Todo: T183457
                        if ( $sp->getUser()->isAllowed( 'deletedhistory' ) ) {
                                $tools['deletedcontribs'] = $linkRenderer->makeKnownLink(
                                        SpecialPage::getTitleFor( 'DeletedContributions', $username ),