81 'check-label' =>
'revdelete-hide-text',
82 'success' =>
'revdelete-success',
83 'failure' =>
'revdelete-failure',
84 'text' =>
'revdelete-text-text',
85 'selected' =>
'revdelete-selected-text',
88 'check-label' =>
'revdelete-hide-text',
89 'success' =>
'revdelete-success',
90 'failure' =>
'revdelete-failure',
91 'text' =>
'revdelete-text-text',
92 'selected' =>
'revdelete-selected-text',
95 'check-label' =>
'revdelete-hide-image',
96 'success' =>
'revdelete-success',
97 'failure' =>
'revdelete-failure',
98 'text' =>
'revdelete-text-file',
99 'selected' =>
'revdelete-selected-file',
102 'check-label' =>
'revdelete-hide-image',
103 'success' =>
'revdelete-success',
104 'failure' =>
'revdelete-failure',
105 'text' =>
'revdelete-text-file',
106 'selected' =>
'revdelete-selected-file',
109 'check-label' =>
'revdelete-hide-name',
110 'success' =>
'logdelete-success',
111 'failure' =>
'logdelete-failure',
112 'text' =>
'logdelete-text',
113 'selected' =>
'logdelete-selected',
124 parent::__construct(
'Revisiondelete',
'deleterevision' );
146 $this->submitClicked = $request->wasPosted() && $request->getBool(
'wpSubmit' );
147 # Handle our many different possible input types.
148 $ids = $request->getVal(
'ids' );
149 if (
$ids !==
null ) {
150 # Allow CSV, for backwards compatibility, or a single ID for show/hide links
151 $this->ids = explode(
',',
$ids );
154 $this->ids = array_keys( $request->getArray(
'ids', [] ) );
157 $this->ids = array_unique( array_filter( $this->ids ) );
159 $this->typeName = $request->getVal(
'type' );
160 $this->targetObj = Title::newFromText( $request->getText(
'target' ) );
162 # For reviewing deleted files...
163 $this->archiveName = $request->getVal(
'file' );
164 $this->token = $request->getVal(
'token' );
165 if ( $this->archiveName && $this->targetObj ) {
174 if ( !$this->typeName || count( $this->ids ) == 0 ) {
175 throw new ErrorPageError(
'revdelete-nooldid-title',
'revdelete-nooldid-text' );
178 # Allow the list type to adjust the passed target
185 # We need a target page!
186 if ( $this->targetObj ===
null ) {
187 $output->addWikiMsg(
'undelete-header' );
195 $this->permissionManager->isBlockedFrom(
204 $this->getLanguage(),
212 $this->mIsAllowed = $this->permissionManager->userHasRight( $user,
214 $canViewSuppressedOnly = $this->permissionManager->userHasRight( $user,
'viewsuppressed' ) &&
215 !$this->permissionManager->userHasRight( $user,
'suppressrevision' );
216 $pageIsSuppressed = $list->areAnySuppressed();
217 $this->mIsAllowed = $this->mIsAllowed && !( $canViewSuppressedOnly && $pageIsSuppressed );
219 $this->otherReason = $request->getVal(
'wpReason' );
220 # Give a link to the logs/hist for this page
223 # Initialise checkboxes
225 # Messages: revdelete-hide-text, revdelete-hide-image, revdelete-hide-name
226 [ $this->typeLabels[
'check-label'],
'wpHidePrimary',
229 [
'revdelete-hide-comment',
'wpHideComment', RevisionRecord::DELETED_COMMENT ],
230 [
'revdelete-hide-user',
'wpHideUser', RevisionRecord::DELETED_USER ]
232 if ( $this->permissionManager->userHasRight( $user,
'suppressrevision' ) ) {
233 $this->checks[] = [
'revdelete-hide-restricted',
234 'wpHideRestricted', RevisionRecord::DELETED_RESTRICTED ];
237 # Either submit or create our form
238 if ( $this->mIsAllowed && $this->submitClicked ) {
244 if ( $this->permissionManager->userHasRight( $user,
'deletedhistory' ) ) {
245 # Show relevant lines from the deletion log
246 $deleteLogPage =
new LogPage(
'delete' );
247 $output->addHTML(
"<h2>" . $deleteLogPage->getName()->escaped() .
"</h2>\n" );
248 LogEventsList::showLogExtract(
253 [
'lim' => 25,
'conds' => $this->
getLogQueryCond(),
'useMaster' => $this->wasSaved ]
256 # Show relevant lines from the suppression log
257 if ( $this->permissionManager->userHasRight( $user,
'suppressionlog' ) ) {
258 $suppressLogPage =
new LogPage(
'suppress' );
259 $output->addHTML(
"<h2>" . $suppressLogPage->getName()->escaped() .
"</h2>\n" );
260 LogEventsList::showLogExtract(
265 [
'lim' => 25,
'conds' => $this->
getLogQueryCond(),
'useMaster' => $this->wasSaved ]
275 # Give a link to the logs/hist for this page
276 if ( $this->targetObj ) {
278 $this->
getSkin()->setRelevantTitle( $this->targetObj );
283 $this->
msg(
'viewpagelogs' )->text(),
285 [
'page' => $this->targetObj->getPrefixedText() ]
287 if ( !$this->targetObj->isSpecialPage() ) {
288 # Give a link to the page history
291 $this->
msg(
'pagehist' )->text(),
293 [
'action' =>
'history' ]
295 # Link to deleted edits
296 if ( $this->permissionManager->userHasRight( $this->getUser(),
'undelete' ) ) {
300 $this->
msg(
'deletedhist' )->text(),
302 [
'target' => $this->targetObj->getPrefixedDBkey() ]
306 # Logs themselves don't have histories or archived revisions
318 $conds[
'log_type'] = [
'delete',
'suppress' ];
319 $conds[
'log_action'] = $this->
getList()->getLogAction();
323 $conds[
'ls_value'] = array_map(
'strval', $this->ids );
336 $repo = $this->repoGroup->getLocalRepo();
337 $oimage = $repo->newFromArchiveName( $this->targetObj,
$archiveName );
340 if ( !$oimage->exists() ) {
341 $this->
getOutput()->addWikiMsg(
'revdelete-no-file' );
346 if ( !$oimage->userCan( File::DELETED_FILE, $user ) ) {
347 if ( $oimage->isDeleted( File::DELETED_RESTRICTED ) ) {
353 if ( !$user->matchEditToken( $this->token,
$archiveName ) ) {
355 $this->
getOutput()->addWikiMsg(
'revdelete-show-file-confirm',
356 $this->targetObj->getText(),
357 $lang->userDate( $oimage->getTimestamp(), $user ),
358 $lang->userTime( $oimage->getTimestamp(), $user ) );
360 Xml::openElement(
'form', [
363 'target' => $this->targetObj->getPrefixedDBkey(),
369 Xml::submitButton( $this->msg(
'revdelete-show-file-submit' )->text() ) .
376 # We mustn't allow the output to be CDN cached, otherwise
377 # if an admin previews a deleted image, and it's cached, then
378 # a user without appropriate permissions can toddle off and
379 # nab the image, and CDN will serve it
380 $this->
getRequest()->response()->header(
'Expires: ' . gmdate(
'D, d M Y H:i:s', 0 ) .
' GMT' );
382 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate'
384 $this->
getRequest()->response()->header(
'Pragma: no-cache' );
386 $key = $oimage->getStorageKey();
387 $path = $repo->getZonePath(
'deleted' ) .
'/' . $repo->getDeletedHashPath( $key ) . $key;
388 $repo->streamFileWithStatus(
$path );
396 if ( $this->revDelList ===
null ) {
398 $this->typeName, $this->
getContext(), $this->targetObj, $this->ids
414 $out->wrapWikiMsg(
"<strong>$1</strong>", [ $this->typeLabels[
'selected'],
415 $this->
getLanguage()->formatNum( count( $this->ids ) ), $this->targetObj->getPrefixedText() ] );
418 $out->addHTML(
"<ul>" );
423 for ( $list->reset(); $list->current(); $list->next() ) {
424 $item = $list->current();
426 if ( !$item->canView() ) {
427 if ( !$this->submitClicked ) {
430 $userAllowed =
false;
434 $out->addHTML( $item->getHTML() );
437 if ( !$numRevisions ) {
438 throw new ErrorPageError(
'revdelete-nooldid-title',
'revdelete-nooldid-text' );
441 $out->addHTML(
"</ul>" );
446 if ( !$userAllowed ) {
451 if ( $this->mIsAllowed ) {
452 $suppressAllowed = $this->permissionManager
453 ->userHasRight( $this->
getUser(),
'suppressrevision' );
454 $out->addModules( [
'mediawiki.special.revisionDelete' ] );
455 $out->addModuleStyles( [
'mediawiki.special',
456 'mediawiki.interface.helpers.styles' ] );
458 $dropDownReason = $this->
msg(
'revdelete-reason-dropdown' )->inContentLanguage()->text();
460 if ( $suppressAllowed ) {
461 $dropDownReason .=
"\n" . $this->
msg(
'revdelete-reason-dropdown-suppress' )
462 ->inContentLanguage()->text();
465 $form = Xml::openElement(
'form', [
'method' =>
'post',
466 'action' => $this->
getPageTitle()->getLocalURL( [
'action' =>
'submit' ] ),
467 'id' =>
'mw-revdel-form-revisions' ] ) .
468 Xml::fieldset( $this->
msg(
'revdelete-legend' )->text() ) .
470 Xml::openElement(
'table' ) .
472 '<td class="mw-label">' .
473 Xml::label( $this->
msg(
'revdelete-log' )->text(),
'wpRevDeleteReasonList' ) .
475 '<td class="mw-input">' .
476 Xml::listDropDown(
'wpRevDeleteReasonList',
478 $this->
msg(
'revdelete-reasonotherlist' )->inContentLanguage()->text(),
479 $this->
getRequest()->getText(
'wpRevDeleteReasonList',
'other' ),
'wpReasonDropDown'
483 '<td class="mw-label">' .
484 Xml::label( $this->
msg(
'revdelete-otherreason' )->text(),
'wpReason' ) .
486 '<td class="mw-input">' .
487 Xml::input(
'wpReason', 60, $this->otherReason, [
493 'maxlength' => CommentStore::COMMENT_CHARACTER_LIMIT - 155,
498 '<td class="mw-submit">' .
499 Xml::submitButton( $this->
msg(
'revdelete-submit', $numRevisions )->text(),
500 [
'name' =>
'wpSubmit' ] ) .
503 Xml::closeElement(
'table' ) .
504 Html::hidden(
'wpEditToken', $this->
getUser()->getEditToken() ) .
505 Html::hidden(
'target', $this->targetObj->getPrefixedText() ) .
506 Html::hidden(
'type', $this->typeName ) .
507 Html::hidden(
'ids', implode(
',', $this->ids ) ) .
508 Xml::closeElement(
'fieldset' ) .
"\n" .
509 Xml::closeElement(
'form' ) .
"\n";
511 if ( $this->permissionManager->userHasRight( $this->getUser(),
'editinterface' ) ) {
514 if ( $suppressAllowed ) {
516 $this->
msg(
'revdelete-reason-dropdown-suppress' )->inContentLanguage()->
getTitle(),
517 $this->
msg(
'revdelete-edit-reasonlist-suppress' )->text(),
519 [
'action' =>
'edit' ]
521 $link .= $this->
msg(
'pipe-separator' )->escaped();
524 $this->
msg(
'revdelete-reason-dropdown' )->inContentLanguage()->
getTitle(),
525 $this->
msg(
'revdelete-edit-reasonlist' )->text(),
527 [
'action' =>
'edit' ]
529 $form .= Xml::tags(
'p', [
'class' =>
'mw-revdel-editreasons' ], $link ) .
"\n";
534 $out->addHTML( $form );
544 "<strong>$1</strong>\n$2", $this->typeLabels[
'text'],
545 'revdelete-text-others'
548 if ( $this->permissionManager->userHasRight( $this->getUser(),
'suppressrevision' ) ) {
549 $this->
getOutput()->addWikiMsg(
'revdelete-suppress-text' );
552 if ( $this->mIsAllowed ) {
553 $this->
getOutput()->addWikiMsg(
'revdelete-confirm' );
564 if ( $list->length() == 1 ) {
566 $bitfield = $list->current()->getBits();
568 if ( $this->submitClicked ) {
572 foreach ( $this->checks as $item ) {
575 list( $message, $name, $field ) = $item;
576 $innerHTML = Xml::checkLabel(
577 $this->
msg( $message )->text(),
583 if ( $field == RevisionRecord::DELETED_RESTRICTED ) {
584 $innerHTML =
"<b>$innerHTML</b>";
587 $line = Xml::tags(
'td', [
'class' =>
'mw-input' ], $innerHTML );
588 $html .=
"<tr>$line</tr>\n";
593 $html .=
'<th class="mw-revdel-checkbox">'
594 . $this->
msg(
'revdelete-radio-same' )->escaped() .
'</th>';
595 $html .=
'<th class="mw-revdel-checkbox">'
596 . $this->
msg(
'revdelete-radio-unset' )->escaped() .
'</th>';
597 $html .=
'<th class="mw-revdel-checkbox">'
598 . $this->
msg(
'revdelete-radio-set' )->escaped() .
'</th>';
599 $html .=
"<th></th></tr>\n";
600 foreach ( $this->checks as $item ) {
603 list( $message, $name, $field ) = $item;
605 if ( $this->submitClicked ) {
606 $selected = $this->
getRequest()->getInt( $name, 0 );
610 $line =
'<td class="mw-revdel-checkbox">' . Xml::radio( $name, -1, $selected == -1 ) .
'</td>';
611 $line .=
'<td class="mw-revdel-checkbox">' . Xml::radio( $name, 0, $selected == 0 ) .
'</td>';
612 $line .=
'<td class="mw-revdel-checkbox">' . Xml::radio( $name, 1, $selected == 1 ) .
'</td>';
613 $label = $this->
msg( $message )->escaped();
614 if ( $field == RevisionRecord::DELETED_RESTRICTED ) {
615 $label =
"<b>$label</b>";
617 $line .=
"<td>$label</td>";
618 $html .=
"<tr>$line</tr>\n";
633 # Check edit token on submission
635 if ( $this->submitClicked && !$this->
getUser()->matchEditToken(
$token ) ) {
636 $this->
getOutput()->addWikiMsg(
'sessionfailure' );
642 $listReason = $this->
getRequest()->getText(
'wpRevDeleteReasonList',
'other' );
643 $comment = $listReason;
644 if ( $comment ===
'other' ) {
646 } elseif ( $this->otherReason !==
'' ) {
648 $comment .= $this->
msg(
'colon-separator' )->inContentLanguage()->text()
651 # Can the user set this field?
652 if ( $bitParams[RevisionRecord::DELETED_RESTRICTED] == 1
653 && !$this->permissionManager->userHasRight( $this->getUser(),
'suppressrevision' )
657 # If the save went through, go to success message...
658 $status = $this->
save( $bitParams, $comment );
659 if ( $status->isGood() ) {
664 # ...otherwise, bounce back to form...
676 $this->
getOutput()->setPageTitle( $this->
msg(
'actioncomplete' ) );
678 "<div class=\"successbox\">\n$1\n</div>",
679 $this->typeLabels[
'success']
681 $this->wasSaved =
true;
682 $this->revDelList->reloadFromPrimary();
692 $this->
getOutput()->setPageTitle( $this->
msg(
'actionfailed' ) );
693 $this->
getOutput()->wrapWikiTextAsInterface(
695 $status->getWikiText( $this->typeLabels[
'failure'],
false, $this->getLanguage() )
707 foreach ( $this->checks as $item ) {
708 list( , $name, $field ) = $item;
709 $val = $this->
getRequest()->getInt( $name, 0 );
710 if ( $val < -1 || $val > 1 ) {
713 $bitfield[$field] = $val;
715 if ( !isset( $bitfield[RevisionRecord::DELETED_RESTRICTED] ) ) {
716 $bitfield[RevisionRecord::DELETED_RESTRICTED] = 0;
728 protected function save( array $bitPars, $reason ) {
729 return $this->
getList()->setVisibility(
730 [
'value' => $bitPars,
'comment' => $reason ]
An error page which can definitely be safely rendered using the OutputPage.
Class to simplify the use of log pages.
Show an error when a user tries to do something they do not have the necessary permissions for.
Prioritized list of file repositories.
static getCanonicalTypeName( $typeName)
Gets the canonical type name, if any.
static getRelationType( $typeName)
Get DB field name for URL param... Future code for other things may also track other types of revisio...
static suggestTarget( $typeName, $target, array $ids)
Suggest a target for the revision deletion.
static extractBitfield(array $bitPars, $oldfield)
Put together a rev_deleted bitfield.
static getRevdelConstant( $typeName)
Get the revision deletion constant for the RevDel type.
static getRestriction( $typeName)
Get the user right required for the RevDel type.
static createList( $typeName, IContextSource $context, PageIdentity $page, array $ids)
Instantiate the appropriate list class for a given list of IDs.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
getSkin()
Shortcut to get the skin being used for this instance.
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
getContext()
Gets the context this SpecialPage is executed in.
LinkRenderer null $linkRenderer
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getRequest()
Get the WebRequest being used for this instance.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
getPageTitle( $subpage=false)
Get a self-referential title object.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
getLanguage()
Shortcut to get user's language.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Special page allowing users with the appropriate permissions to view and hide revisions.
string $token
Edit token for securing image views against XSS.
bool $mIsAllowed
Whether user is allowed to perform the action.
const UI_LABELS
UI labels for each type.
showForm()
Show a list of items that we will operate on, and show a form with checkboxes which will allow the us...
tryShowFile( $archiveName)
Show a deleted file version requested by the visitor.
string $archiveName
Archive name, for reviewing deleted files.
save(array $bitPars, $reason)
Do the write operations.
success()
Report that the submit operation succeeded.
addUsageText()
Show some introductory text.
array $typeLabels
UI Labels about the current type.
bool $wasSaved
Was the DB modified in this request.
getLogQueryCond()
Get the condition used for fetching log snippets.
PermissionManager $permissionManager
RevDelList $revDelList
RevDelList object, storing the list of items to be deleted/undeleted.
showConvenienceLinks()
Show some useful links in the subtitle.
doesWrites()
Indicates whether this special page may perform database writes.
execute( $par)
Default execute method Checks user permissions.
array $checks
Array of checkbox specs (message, name, deletion bits)
failure( $status)
Report that the submit operation failed.
__construct(PermissionManager $permissionManager, RepoGroup $repoGroup)
submit()
UI entry point for form submission.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Title $targetObj
Title object for target parameter.
extractBitParams()
Put together an array that contains -1, 0, or the *_deleted const for each bit.
bool $submitClicked
True if the submit button was clicked, and the form was posted.
string $typeName
Deletion type, may be revision, archive, oldimage, filearchive, logging.
getList()
Get the list object for this request.
array $ids
Target ID list.
Represents a title within MediaWiki.
Shortcut to construct a special page which is unlisted by default.
Show an error when the user tries to do something whilst blocked.
if(!isset( $args[0])) $lang