From: Aryeh Gregor Date: Thu, 16 Nov 2006 22:53:01 +0000 (+0000) Subject: * urlencode username so rollback-on-history works for users with funny names X-Git-Tag: 1.31.0-rc.0~55172 X-Git-Url: http://git.cyclocoop.org/%7D%7Cconcat%7B?a=commitdiff_plain;h=3a0c45e93cf7cdcfadfd2545a497562968e023ee;p=lhc%2Fweb%2Fwiklou.git * urlencode username so rollback-on-history works for users with funny names * Move rollback-link-generating code to Linker::generateRollback --- diff --git a/includes/DifferenceEngine.php b/includes/DifferenceEngine.php index 72ba3469b5..2bccc8f71a 100644 --- a/includes/DifferenceEngine.php +++ b/includes/DifferenceEngine.php @@ -148,11 +148,7 @@ CONTROL; $contribs = wfMsg( 'contribslink' ); if ( $this->mNewRev->isCurrent() && $wgUser->isAllowed('rollback') ) { - $username = $this->mNewRev->getUserText(); - $rollback = '   [' . $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'rollbacklink' ), - 'action=rollback&from=' . urlencode( $username ) . - '&token=' . urlencode( $wgUser->editToken( array( $this->mTitle->getPrefixedText(), $username ) ) ) ) . - ']'; + $rollback = '   ' . $sk->generateRollback( $this->mNewRev ); } else { $rollback = ''; } diff --git a/includes/Linker.php b/includes/Linker.php index 9bebea2c96..ff86912fb2 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1095,5 +1095,29 @@ class Linker { return array( $inside, $trail ); } + /** + * Generate a rollback link for a given revision. Currently it's the + * caller's responsibility to ensure that the revision is the top one. If + * it's not, of course, the user will get an error message. + * + * If the calling page is called with the parameter &bot=1, all rollback + * links also get that parameter. It causes the edit itself and the rollback + * to be marked as "bot" edits. Bot edits are hidden by default from recent + * changes, so this allows sysops to combat a busy vandal without bothering + * other users. + * + * @param Revision $rev + */ + function generateRollback( $rev ) { + global $wgUser, $wgRequest; + $title = $rev->getTitle(); + + $extraRollback = $wgRequest->getBool( 'bot' ) ? '&bot=1' : ''; + $extraRollback .= '&token=' . urlencode( + $wgUser->editToken( array( $title->getPrefixedText(), $rev->getUserText() ) ) ); + return '['. $this->makeKnownLinkObj( $title, + wfMsg('rollbacklink'), + 'action=rollback&from=' . urlencode( $rev->getUserText() ) . $extraRollback ) .']'; + } } ?> diff --git a/includes/PageHistory.php b/includes/PageHistory.php index 780b5a0013..16c405c43c 100644 --- a/includes/PageHistory.php +++ b/includes/PageHistory.php @@ -168,7 +168,7 @@ class PageHistory { /** @todo document */ function historyLine( $row, $next, $counter = '', $notificationtimestamp = false, $latest = false, $firstInList = false ) { - global $wgUser, $wgRequest, $wgTitle; + global $wgUser; $rev = new Revision( $row ); $rev->setTitle( $this->mTitle ); @@ -211,12 +211,7 @@ class PageHistory { $s .= ' ' . wfMsgHtml( 'deletedrev' ); } if( $wgUser->isAllowed( 'rollback' ) && $firstInList ) { - $extraRollback = $wgRequest->getBool( 'bot' ) ? '&bot=1' : ''; - $extraRollback .= '&token=' . urlencode( - $wgUser->editToken( array( $wgTitle->getPrefixedText(), $rev->getUserText() ) ) ); - $s .= ' ['. $this->mSkin->makeKnownLinkObj( $wgTitle, - wfMsg('rollbacklink'), - 'action=rollback&from=' . $rev->getUserText() . $extraRollback ) .']'; + $s .= ' '.$this->mSkin->generateRollback( $rev ); } $s .= "\n"; diff --git a/includes/SpecialContributions.php b/includes/SpecialContributions.php index 29198bb1af..239fb8b689 100644 --- a/includes/SpecialContributions.php +++ b/includes/SpecialContributions.php @@ -369,12 +369,6 @@ function contributionsForm( $options ) { * privileges. The rollback link restores the most recent version that was not * written by the target user. * - * If the contributions page is called with the parameter &bot=1, all rollback - * links also get that parameter. It causes the edit itself and the rollback - * to be marked as "bot" edits. Bot edits are hidden by default from recent - * changes, so this allows sysops to combat a busy vandal without bothering - * other users. - * * @todo This would probably look a lot nicer in a table. */ function ucListEdit( $sk, $row ) { @@ -390,7 +384,7 @@ function ucListEdit( $sk, $row ) { } $rev = new Revision( $row ); - + $page = Title::makeTitle( $row->page_namespace, $row->page_title ); $link = $sk->makeKnownLinkObj( $page ); $difftext = $topmarktext = ''; @@ -403,12 +397,7 @@ function ucListEdit( $sk, $row ) { } if( $wgUser->isAllowed( 'rollback' ) ) { - $extraRollback = $wgRequest->getBool( 'bot' ) ? '&bot=1' : ''; - $extraRollback .= '&token=' . urlencode( - $wgUser->editToken( array( $page->getPrefixedText(), $row->rev_user_text ) ) ); - $topmarktext .= ' ['. $sk->makeKnownLinkObj( $page, - $messages['rollbacklink'], - 'action=rollback&from=' . urlencode( $row->rev_user_text ) . $extraRollback ) .']'; + $topmarktext .= ' '.$sk->generateRollback( $rev ); } }