Page MenuHomePhabricator
Authored By
bzimport
Nov 21 2014, 10:02 PM
Size
2 KB
Referenced Files
None
Subscribers
None
Index: ChangesList.php
===================================================================
--- ChangesList.php (revision 38874)
+++ ChangesList.php (working copy)
@@ -240,6 +240,32 @@
}
}
}
+
+ /** Insert a rollback link, if the user has permission */
+ protected function maybeInsertRollbackLink( &$s, &$rc ) {
+ global $wgUser; // We don't have time to check perms properly.
+ if( $wgUser->isAllowed('rollback') && $rc->mAttribs['rc_this_oldid'] != 0) {
+ $title = Title::makeTitle( $rc->mAttribs['rc_namespace'], $rc->mAttribs['rc_title'] );
+ $s .= ' <span class="mw-rollback-link">['.$this->buildRollbackLink( $title, $rc->mAttribs['rc_user_text'] ).']</span>';
+ }
+ }
+
+ /** Build a rollback link, from only the username and prefixed title */
+ public function buildRollbackLink( $title, $edit_user ) {
+ global $wgRequest, $wgUser;
+
+ $query = array(
+ 'action' => 'rollback',
+ 'from' => $edit_user
+ );
+ if( $wgRequest->getBool( 'bot' ) ) {
+ $query['bot'] = '1';
+ }
+ $query['token'] = $wgUser->editToken( array( $title->getPrefixedText(),
+ $edit_user ) );
+ return $this->skin->link( $title, wfMsgHtml( 'rollbacklink' ), array(),
+ $query, array( 'known', 'noclasses' ) );
+ }
/**
* Check whether to enable recent changes patrol features
@@ -371,6 +397,8 @@
if($rc->numberofWatchingusers > 0) {
$s .= ' ' . wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rc->numberofWatchingusers));
}
+
+ $this->maybeInsertRollbackLink( $s, $rc );
$s .= "</li>\n";
Index: specials/SpecialContributions.php
===================================================================
--- specials/SpecialContributions.php (revision 38874)
+++ specials/SpecialContributions.php (working copy)
@@ -115,8 +115,8 @@
$difftext .= $this->messages['newarticle'];
}
- if( !$page->getUserPermissionsErrors( 'rollback', $wgUser )
- && !$page->getUserPermissionsErrors( 'edit', $wgUser ) ) {
+ if( !count($page->getUserPermissionsErrors( 'rollback', $wgUser ) )
+ && !count($page->getUserPermissionsErrors( 'edit', $wgUser ) ) ) {
$topmarktext .= ' '.$sk->generateRollback( $rev );
}

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4208
Default Alt Text
tmp (2 KB)

Event Timeline