From f702338228281dadd8d69e2b5112edcea80cf5d5 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Sat, 14 Nov 2009 20:16:38 +0000 Subject: [PATCH] Sync contributionsSub from SpecialContributions.php and getSubTitle in SpecialDeletedContributions.php. Refactoring opportunity. --- includes/specials/SpecialContributions.php | 15 ++--- .../specials/SpecialDeletedContributions.php | 62 +++++++++++++++---- 2 files changed, 59 insertions(+), 18 deletions(-) diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index 1e52cb5159..d35503cc83 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -142,17 +142,18 @@ class SpecialContributions extends SpecialPage { } /** - * Generates the subheading with links - * @param Title $nt Title object for the target - * @param integer $id User ID for the target - * @return String: appropriately-escaped HTML to be output literally - */ + * Generates the subheading with links + * @param Title $nt @see Title object for the target + * @param integer $id User ID for the target + * @return String: appropriately-escaped HTML to be output literally + * @fixme Almost the same as getSubTitle in SpecialDeletedContributions.php. Could be combined. + */ protected function contributionsSub( $nt, $id ) { global $wgSysopUserBans, $wgLang, $wgUser, $wgOut; $sk = $wgUser->getSkin(); - if( 0 == $id ) { + if ( 0 == $id ) { $user = htmlspecialchars( $nt->getText() ); } else { $user = $sk->link( $nt, htmlspecialchars( $nt->getText() ) ); @@ -223,7 +224,7 @@ class SpecialContributions extends SpecialPage { } wfRunHooks( 'ContributionsToolLinks', array( $id, $nt, &$tools ) ); - + $links = $wgLang->pipeList( $tools ); // Show a note if the user is blocked and display the last block log entry. diff --git a/includes/specials/SpecialDeletedContributions.php b/includes/specials/SpecialDeletedContributions.php index e41e732493..4842ef7c26 100644 --- a/includes/specials/SpecialDeletedContributions.php +++ b/includes/specials/SpecialDeletedContributions.php @@ -325,10 +325,13 @@ class DeletedContributionsPage extends SpecialPage { /** * Generates the subheading with links - * @param $nt @see Title object for the target + * @param Title $nt @see Title object for the target + * @param integer $id User ID for the target + * @return String: appropriately-escaped HTML to be output literally + * @fixme Almost the same as contributionsSub in SpecialContributions.php. Could be combined. */ function getSubTitle( $nt, $id ) { - global $wgSysopUserBans, $wgLang, $wgUser; + global $wgSysopUserBans, $wgLang, $wgUser, $wgOut; $sk = $wgUser->getSkin(); @@ -337,17 +340,35 @@ class DeletedContributionsPage extends SpecialPage { } else { $user = $sk->link( $nt, htmlspecialchars( $nt->getText() ) ); } + $userObj = User::newFromName( $nt->getText(), /* check for username validity not needed */ false ); $talk = $nt->getTalkPage(); if( $talk ) { # Talk page link - $tools[] = $sk->link( $talk, wfMsgHtml( 'talkpagelinktext' ) ); - if( ( $id != 0 && $wgSysopUserBans ) || ( $id == 0 && User::isIP( $nt->getText() ) ) ) { - # Block link - if( $wgUser->isAllowed( 'block' ) ) - $tools[] = $sk->linkKnown( - SpecialPage::getTitleFor( 'Blockip', $nt->getDBkey() ), - wfMsgHtml( 'blocklink' ) - ); + $tools[] = $sk->link( $talk, wfMsgHtml( 'sp-contributions-talk' ) ); + if( ( $id != 0 && $wgSysopUserBans ) || ( $id == 0 && IP::isIPAddress( $nt->getText() ) ) ) { + if( $wgUser->isAllowed( 'block' ) ) { # Block / Change block / Unblock links + if ( $userObj->isBlocked() ) { + $tools[] = $sk->linkKnown( # Change block link + SpecialPage::getTitleFor( 'Blockip', $nt->getDBkey() ), + wfMsgHtml( 'change-blocklink' ) + ); + $tools[] = $sk->linkKnown( # Unblock link + SpecialPage::getTitleFor( 'BlockList' ), + wfMsgHtml( 'unblocklink' ), + array(), + array( + 'action' => 'unblock', + 'ip' => $nt->getDBkey() + ) + ); + } + else { # User is not blocked + $tools[] = $sk->linkKnown( # Block link + SpecialPage::getTitleFor( 'Blockip', $nt->getDBkey() ), + wfMsgHtml( 'blocklink' ) + ); + } + } # Block log link $tools[] = $sk->linkKnown( SpecialPage::getTitleFor( 'Log' ), @@ -366,7 +387,7 @@ class DeletedContributionsPage extends SpecialPage { array(), array( 'user' => $nt->getText() ) ); - # Link to undeleted contributions + # Link to contributions $tools[] = $sk->linkKnown( SpecialPage::getTitleFor( 'Contributions', $nt->getDBkey() ), wfMsgHtml( 'sp-deletedcontributions-contribs' ) @@ -384,6 +405,25 @@ class DeletedContributionsPage extends SpecialPage { wfRunHooks( 'ContributionsToolLinks', array( $id, $nt, &$tools ) ); $links = $wgLang->pipeList( $tools ); + + // Show a note if the user is blocked and display the last block log entry. + if ( $userObj->isBlocked() ) { + LogEventsList::showLogExtract( + $wgOut, + 'block', + $nt->getPrefixedText(), + '', + array( + 'lim' => 1, + 'showIfEmpty' => false, + 'msgKey' => array( + 'sp-contributions-blocked-notice', + $nt->getText() # Support GENDER in 'sp-contributions-blocked-notice' + ), + 'offset' => '' # don't use $wgRequest parameter offset + ) + ); + } } // Old message 'contribsub' had one parameter, but that doesn't work for -- 2.20.1