From: Luke Faraone Date: Sun, 13 Dec 2015 20:50:17 +0000 (+0000) Subject: Allow easy suppression of multiple deleted revs X-Git-Tag: 1.31.0-rc.0~8050^2 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=85f9ba92178fbed8fec655bcc6e2ceb0b527e5a9;p=lhc%2Fweb%2Fwiklou.git Allow easy suppression of multiple deleted revs Add checkboxes to revisisons on Special:Undelete, with an accompanying button to submit the form. Handle the form submission and redirect to the appropriate Special:RevisionDelete page. Bug: T22189 Co-Authored-By: Rohan Change-Id: I2a0a53c3b5ae2145472e4b5a3d3cf61bd3cf4f28 --- diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index aada064feb..570b336dcf 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -667,13 +667,14 @@ class PageArchive { * @ingroup SpecialPage */ class SpecialUndelete extends SpecialPage { - private $mAction; + private $mAction; private $mTarget; private $mTimestamp; private $mRestore; + private $mRevdel; private $mInvert; private $mFilename; - private $mTargetTimestamp; + private $mTargetTimestamp; private $mAllowed; private $mCanView; private $mComment; @@ -711,6 +712,7 @@ class SpecialUndelete extends SpecialPage { $posted = $request->wasPosted() && $user->matchEditToken( $request->getVal( 'wpEditToken' ) ); $this->mRestore = $request->getCheck( 'restore' ) && $posted; + $this->mRevdel = $request->getCheck( 'revdel' ) && $posted; $this->mInvert = $request->getCheck( 'invert' ) && $posted; $this->mPreview = $request->getCheck( 'preview' ) && $posted; $this->mDiff = $request->getCheck( 'diff' ); @@ -823,13 +825,42 @@ class SpecialUndelete extends SpecialPage { } else { $this->showFile( $this->mFilename ); } - } elseif ( $this->mRestore && $this->mAction == 'submit' ) { - $this->undelete(); + } elseif ( $this->mAction === "submit" ) { + if ( $this->mRestore ) { + $this->undelete(); + } elseif ( $this->mRevdel ) { + $this->redirectToRevDel(); + } + } else { $this->showHistory(); } } + /** + * Convert submitted form data to format expected by RevisionDelete and + * redirect the request + */ + private function redirectToRevDel() { + $archive = new PageArchive( $this->mTargetObj ); + + $revisions = array(); + + foreach ( $this->getRequest()->getValues() as $key => $val ) { + $matches = array(); + if ( preg_match( "/^ts(\d{14})$/", $key, $matches ) ) { + $revisions[ $archive->getRevision( $matches[1] )->getId() ] = 1; + } + } + $query = array( + "type" => "revision", + "ids" => $revisions, + "target" => wfUrlencode( $this->mTargetObj->getPrefixedText() ) + ); + $url = SpecialPage::getTitleFor( "RevisionDelete" )->getFullURL( $query ); + $this->getOutput()->redirect( $url ); + } + function showSearchForm() { $out = $this->getOutput(); $out->setPageTitle( $this->msg( 'undelete-search-title' ) ); @@ -1348,7 +1379,20 @@ class SpecialUndelete extends SpecialPage { $out->addHTML( Xml::element( 'h2', null, $this->msg( 'history' )->text() ) . "\n" ); if ( $haveRevisions ) { - # The page's stored (deleted) history: + # Show the page's stored (deleted) history + + if ( $this->getUser()->isAllowed( 'deleterevision' ) ) { + $out->addHTML( Html::element( + 'button', + array( + 'name' => 'revdel', + 'type' => 'submit', + 'class' => 'deleterevision-log-submit mw-log-deleterevision-button' + ), + $this->msg( 'showhideselectedversions' )->text() + ) . "\n" ); + } + $out->addHTML( '