Merge "Remove zh-tw message "editing""
[lhc/web/wiklou.git] / includes / specials / SpecialRevisiondelete.php
1 <?php
2 /**
3 * Implements Special:Revisiondelete
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup SpecialPage
22 */
23
24 /**
25 * Special page allowing users with the appropriate permissions to view
26 * and hide revisions. Log items can also be hidden.
27 *
28 * @ingroup SpecialPage
29 */
30 class SpecialRevisionDelete extends UnlistedSpecialPage {
31 /** @var bool Was the DB modified in this request */
32 protected $wasSaved = false;
33
34 /** @var bool True if the submit button was clicked, and the form was posted */
35 private $submitClicked;
36
37 /** @var array Target ID list */
38 private $ids;
39
40 /** @var string Archive name, for reviewing deleted files */
41 private $archiveName;
42
43 /** @var string Edit token for securing image views against XSS */
44 private $token;
45
46 /** @var Title Title object for target parameter */
47 private $targetObj;
48
49 /** @var string Deletion type, may be revision, archive, oldimage, filearchive, logging. */
50 private $typeName;
51
52 /** @var array Array of checkbox specs (message, name, deletion bits) */
53 private $checks;
54
55 /** @var array UI Labels about the current type */
56 private $typeLabels;
57
58 /** @var RevDelList RevDelList object, storing the list of items to be deleted/undeleted */
59 private $revDelList;
60
61 /** @var bool Whether user is allowed to perform the action */
62 private $mIsAllowed;
63
64 /** @var string */
65 private $otherReason;
66
67 /**
68 * UI labels for each type.
69 */
70 private static $UILabels = array(
71 'revision' => array(
72 'check-label' => 'revdelete-hide-text',
73 'success' => 'revdelete-success',
74 'failure' => 'revdelete-failure',
75 'text' => 'revdelete-text-text',
76 'selected'=> 'revdelete-selected-text',
77 ),
78 'archive' => array(
79 'check-label' => 'revdelete-hide-text',
80 'success' => 'revdelete-success',
81 'failure' => 'revdelete-failure',
82 'text' => 'revdelete-text-text',
83 'selected'=> 'revdelete-selected-text',
84 ),
85 'oldimage' => array(
86 'check-label' => 'revdelete-hide-image',
87 'success' => 'revdelete-success',
88 'failure' => 'revdelete-failure',
89 'text' => 'revdelete-text-file',
90 'selected'=> 'revdelete-selected-file',
91 ),
92 'filearchive' => array(
93 'check-label' => 'revdelete-hide-image',
94 'success' => 'revdelete-success',
95 'failure' => 'revdelete-failure',
96 'text' => 'revdelete-text-file',
97 'selected'=> 'revdelete-selected-file',
98 ),
99 'logging' => array(
100 'check-label' => 'revdelete-hide-name',
101 'success' => 'logdelete-success',
102 'failure' => 'logdelete-failure',
103 'text' => 'logdelete-text',
104 'selected' => 'logdelete-selected',
105 ),
106 );
107
108 public function __construct() {
109 parent::__construct( 'Revisiondelete', 'deletedhistory' );
110 }
111
112 public function execute( $par ) {
113 $this->checkPermissions();
114 $this->checkReadOnly();
115
116 $output = $this->getOutput();
117 $user = $this->getUser();
118
119 $this->setHeaders();
120 $this->outputHeader();
121 $request = $this->getRequest();
122 $this->submitClicked = $request->wasPosted() && $request->getBool( 'wpSubmit' );
123 # Handle our many different possible input types.
124 $ids = $request->getVal( 'ids' );
125 if ( !is_null( $ids ) ) {
126 # Allow CSV, for backwards compatibility, or a single ID for show/hide links
127 $this->ids = explode( ',', $ids );
128 } else {
129 # Array input
130 $this->ids = array_keys( $request->getArray( 'ids', array() ) );
131 }
132 // $this->ids = array_map( 'intval', $this->ids );
133 $this->ids = array_unique( array_filter( $this->ids ) );
134
135 if ( $request->getVal( 'action' ) == 'historysubmit'
136 || $request->getVal( 'action' ) == 'revisiondelete'
137 ) {
138 // For show/hide form submission from history page
139 // Since we are access through index.php?title=XXX&action=historysubmit
140 // getFullTitle() will contain the target title and not our title
141 $this->targetObj = $this->getFullTitle();
142 $this->typeName = 'revision';
143 } else {
144 $this->typeName = $request->getVal( 'type' );
145 $this->targetObj = Title::newFromText( $request->getText( 'target' ) );
146 }
147
148 # For reviewing deleted files...
149 $this->archiveName = $request->getVal( 'file' );
150 $this->token = $request->getVal( 'token' );
151 if ( $this->archiveName && $this->targetObj ) {
152 $this->tryShowFile( $this->archiveName );
153
154 return;
155 }
156
157 $this->typeName = RevisionDeleter::getCanonicalTypeName( $this->typeName );
158
159 # No targets?
160 if ( !$this->typeName || count( $this->ids ) == 0 ) {
161 throw new ErrorPageError( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
162 }
163
164 # Allow the list type to adjust the passed target
165 $this->targetObj = RevisionDeleter::suggestTarget(
166 $this->typeName,
167 $this->targetObj,
168 $this->ids
169 );
170
171 $this->typeLabels = self::$UILabels[$this->typeName];
172 $list = $this->getList();
173 $list->reset();
174 $bitfield = $list->current()->getBits();
175 $this->mIsAllowed = $user->isAllowed( RevisionDeleter::getRestriction( $this->typeName ) );
176 $canViewSuppressedOnly = $this->getUser()->isAllowed( 'viewsuppressed' ) &&
177 !$this->getUser()->isAllowed( 'suppressrevision' );
178 $pageIsSuppressed = $bitfield & Revision::DELETED_RESTRICTED;
179 $this->mIsAllowed = $this->mIsAllowed && !( $canViewSuppressedOnly && $pageIsSuppressed );
180
181 $this->otherReason = $request->getVal( 'wpReason' );
182 # We need a target page!
183 if ( is_null( $this->targetObj ) ) {
184 $output->addWikiMsg( 'undelete-header' );
185
186 return;
187 }
188 # Give a link to the logs/hist for this page
189 $this->showConvenienceLinks();
190
191 # Initialise checkboxes
192 $this->checks = array(
193 # Messages: revdelete-hide-text, revdelete-hide-image, revdelete-hide-name
194 array( $this->typeLabels['check-label'], 'wpHidePrimary',
195 RevisionDeleter::getRevdelConstant( $this->typeName )
196 ),
197 array( 'revdelete-hide-comment', 'wpHideComment', Revision::DELETED_COMMENT ),
198 array( 'revdelete-hide-user', 'wpHideUser', Revision::DELETED_USER )
199 );
200 if ( $user->isAllowed( 'suppressrevision' ) ) {
201 $this->checks[] = array( 'revdelete-hide-restricted',
202 'wpHideRestricted', Revision::DELETED_RESTRICTED );
203 }
204
205 # Either submit or create our form
206 if ( $this->mIsAllowed && $this->submitClicked ) {
207 $this->submit( $request );
208 } else {
209 $this->showForm();
210 }
211
212 $qc = $this->getLogQueryCond();
213 # Show relevant lines from the deletion log
214 $deleteLogPage = new LogPage( 'delete' );
215 $output->addHTML( "<h2>" . $deleteLogPage->getName()->escaped() . "</h2>\n" );
216 LogEventsList::showLogExtract(
217 $output,
218 'delete',
219 $this->targetObj,
220 '', /* user */
221 array( 'lim' => 25, 'conds' => $qc, 'useMaster' => $this->wasSaved )
222 );
223 # Show relevant lines from the suppression log
224 if ( $user->isAllowed( 'suppressionlog' ) ) {
225 $suppressLogPage = new LogPage( 'suppress' );
226 $output->addHTML( "<h2>" . $suppressLogPage->getName()->escaped() . "</h2>\n" );
227 LogEventsList::showLogExtract(
228 $output,
229 'suppress',
230 $this->targetObj,
231 '',
232 array( 'lim' => 25, 'conds' => $qc, 'useMaster' => $this->wasSaved )
233 );
234 }
235 }
236
237 /**
238 * Show some useful links in the subtitle
239 */
240 protected function showConvenienceLinks() {
241 # Give a link to the logs/hist for this page
242 if ( $this->targetObj ) {
243 // Also set header tabs to be for the target.
244 $this->getSkin()->setRelevantTitle( $this->targetObj );
245
246 $links = array();
247 $links[] = Linker::linkKnown(
248 SpecialPage::getTitleFor( 'Log' ),
249 $this->msg( 'viewpagelogs' )->escaped(),
250 array(),
251 array( 'page' => $this->targetObj->getPrefixedText() )
252 );
253 if ( !$this->targetObj->isSpecialPage() ) {
254 # Give a link to the page history
255 $links[] = Linker::linkKnown(
256 $this->targetObj,
257 $this->msg( 'pagehist' )->escaped(),
258 array(),
259 array( 'action' => 'history' )
260 );
261 # Link to deleted edits
262 if ( $this->getUser()->isAllowed( 'undelete' ) ) {
263 $undelete = SpecialPage::getTitleFor( 'Undelete' );
264 $links[] = Linker::linkKnown(
265 $undelete,
266 $this->msg( 'deletedhist' )->escaped(),
267 array(),
268 array( 'target' => $this->targetObj->getPrefixedDBkey() )
269 );
270 }
271 }
272 # Logs themselves don't have histories or archived revisions
273 $this->getOutput()->addSubtitle( $this->getLanguage()->pipeList( $links ) );
274 }
275 }
276
277 /**
278 * Get the condition used for fetching log snippets
279 * @return array
280 */
281 protected function getLogQueryCond() {
282 $conds = array();
283 // Revision delete logs for these item
284 $conds['log_type'] = array( 'delete', 'suppress' );
285 $conds['log_action'] = $this->getList()->getLogAction();
286 $conds['ls_field'] = RevisionDeleter::getRelationType( $this->typeName );
287 $conds['ls_value'] = $this->ids;
288
289 return $conds;
290 }
291
292 /**
293 * Show a deleted file version requested by the visitor.
294 * @todo Mostly copied from Special:Undelete. Refactor.
295 * @param string $archiveName
296 * @throws MWException
297 * @throws PermissionsError
298 */
299 protected function tryShowFile( $archiveName ) {
300 $repo = RepoGroup::singleton()->getLocalRepo();
301 $oimage = $repo->newFromArchiveName( $this->targetObj, $archiveName );
302 $oimage->load();
303 // Check if user is allowed to see this file
304 if ( !$oimage->exists() ) {
305 $this->getOutput()->addWikiMsg( 'revdelete-no-file' );
306
307 return;
308 }
309 $user = $this->getUser();
310 if ( !$oimage->userCan( File::DELETED_FILE, $user ) ) {
311 if ( $oimage->isDeleted( File::DELETED_RESTRICTED ) ) {
312 throw new PermissionsError( 'suppressrevision' );
313 } else {
314 throw new PermissionsError( 'deletedtext' );
315 }
316 }
317 if ( !$user->matchEditToken( $this->token, $archiveName ) ) {
318 $lang = $this->getLanguage();
319 $this->getOutput()->addWikiMsg( 'revdelete-show-file-confirm',
320 $this->targetObj->getText(),
321 $lang->userDate( $oimage->getTimestamp(), $user ),
322 $lang->userTime( $oimage->getTimestamp(), $user ) );
323 $this->getOutput()->addHTML(
324 Xml::openElement( 'form', array(
325 'method' => 'POST',
326 'action' => $this->getPageTitle()->getLocalURL( array(
327 'target' => $this->targetObj->getPrefixedDBkey(),
328 'file' => $archiveName,
329 'token' => $user->getEditToken( $archiveName ),
330 ) )
331 )
332 ) .
333 Xml::submitButton( $this->msg( 'revdelete-show-file-submit' )->text() ) .
334 '</form>'
335 );
336
337 return;
338 }
339 $this->getOutput()->disable();
340 # We mustn't allow the output to be Squid cached, otherwise
341 # if an admin previews a deleted image, and it's cached, then
342 # a user without appropriate permissions can toddle off and
343 # nab the image, and Squid will serve it
344 $this->getRequest()->response()->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
345 $this->getRequest()->response()->header(
346 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate'
347 );
348 $this->getRequest()->response()->header( 'Pragma: no-cache' );
349
350 $key = $oimage->getStorageKey();
351 $path = $repo->getZonePath( 'deleted' ) . '/' . $repo->getDeletedHashPath( $key ) . $key;
352 $repo->streamFile( $path );
353 }
354
355 /**
356 * Get the list object for this request
357 * @return RevDelList
358 */
359 protected function getList() {
360 if ( is_null( $this->revDelList ) ) {
361 $this->revDelList = RevisionDeleter::createList(
362 $this->typeName, $this->getContext(), $this->targetObj, $this->ids
363 );
364 }
365
366 return $this->revDelList;
367 }
368
369 /**
370 * Show a list of items that we will operate on, and show a form with checkboxes
371 * which will allow the user to choose new visibility settings.
372 */
373 protected function showForm() {
374 $userAllowed = true;
375
376 // Messages: revdelete-selected-text, revdelete-selected-file, logdelete-selected
377 $out = $this->getOutput();
378 $out->wrapWikiMsg( "<strong>$1</strong>", array( $this->typeLabels['selected'],
379 $this->getLanguage()->formatNum( count( $this->ids ) ), $this->targetObj->getPrefixedText() ) );
380
381 $out->addHelpLink( 'Help:RevisionDelete' );
382 $out->addHTML( "<ul>" );
383
384 $numRevisions = 0;
385 // Live revisions...
386 $list = $this->getList();
387 // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
388 for ( $list->reset(); $list->current(); $list->next() ) {
389 // @codingStandardsIgnoreEnd
390 $item = $list->current();
391
392 if ( !$item->canView() ) {
393 if ( !$this->submitClicked ) {
394 throw new PermissionsError( 'suppressrevision' );
395 }
396 $userAllowed = false;
397 }
398
399 $numRevisions++;
400 $out->addHTML( $item->getHTML() );
401 }
402
403 if ( !$numRevisions ) {
404 throw new ErrorPageError( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
405 }
406
407 $out->addHTML( "</ul>" );
408 // Explanation text
409 $this->addUsageText();
410
411 // Normal sysops can always see what they did, but can't always change it
412 if ( !$userAllowed ) {
413 return;
414 }
415
416 // Show form if the user can submit
417 if ( $this->mIsAllowed ) {
418 $form = Xml::openElement( 'form', array( 'method' => 'post',
419 'action' => $this->getPageTitle()->getLocalURL( array( 'action' => 'submit' ) ),
420 'id' => 'mw-revdel-form-revisions' ) ) .
421 Xml::fieldset( $this->msg( 'revdelete-legend' )->text() ) .
422 $this->buildCheckBoxes() .
423 Xml::openElement( 'table' ) .
424 "<tr>\n" .
425 '<td class="mw-label">' .
426 Xml::label( $this->msg( 'revdelete-log' )->text(), 'wpRevDeleteReasonList' ) .
427 '</td>' .
428 '<td class="mw-input">' .
429 Xml::listDropDown( 'wpRevDeleteReasonList',
430 $this->msg( 'revdelete-reason-dropdown' )->inContentLanguage()->text(),
431 $this->msg( 'revdelete-reasonotherlist' )->inContentLanguage()->text(),
432 $this->getRequest()->getText( 'wpRevDeleteReasonList', 'other' ), 'wpReasonDropDown'
433 ) .
434 '</td>' .
435 "</tr><tr>\n" .
436 '<td class="mw-label">' .
437 Xml::label( $this->msg( 'revdelete-otherreason' )->text(), 'wpReason' ) .
438 '</td>' .
439 '<td class="mw-input">' .
440 Xml::input(
441 'wpReason',
442 60,
443 $this->otherReason,
444 array( 'id' => 'wpReason', 'maxlength' => 100 )
445 ) .
446 '</td>' .
447 "</tr><tr>\n" .
448 '<td></td>' .
449 '<td class="mw-submit">' .
450 Xml::submitButton( $this->msg( 'revdelete-submit', $numRevisions )->text(),
451 array( 'name' => 'wpSubmit' ) ) .
452 '</td>' .
453 "</tr>\n" .
454 Xml::closeElement( 'table' ) .
455 Html::hidden( 'wpEditToken', $this->getUser()->getEditToken() ) .
456 Html::hidden( 'target', $this->targetObj->getPrefixedText() ) .
457 Html::hidden( 'type', $this->typeName ) .
458 Html::hidden( 'ids', implode( ',', $this->ids ) ) .
459 Xml::closeElement( 'fieldset' ) . "\n" .
460 Xml::closeElement( 'form' ) . "\n";
461 // Show link to edit the dropdown reasons
462 if ( $this->getUser()->isAllowed( 'editinterface' ) ) {
463 $title = Title::makeTitle( NS_MEDIAWIKI, 'Revdelete-reason-dropdown' );
464 $link = Linker::link(
465 $title,
466 $this->msg( 'revdelete-edit-reasonlist' )->escaped(),
467 array(),
468 array( 'action' => 'edit' )
469 );
470 $form .= Xml::tags( 'p', array( 'class' => 'mw-revdel-editreasons' ), $link ) . "\n";
471 }
472 } else {
473 $form = '';
474 }
475 $out->addHTML( $form );
476 }
477
478 /**
479 * Show some introductory text
480 * @todo FIXME: Wikimedia-specific policy text
481 */
482 protected function addUsageText() {
483 // Messages: revdelete-text-text, revdelete-text-file, logdelete-text
484 $this->getOutput()->wrapWikiMsg(
485 "<strong>$1</strong>\n$2", $this->typeLabels['text'],
486 'revdelete-text-others'
487 );
488
489 if ( $this->getUser()->isAllowed( 'suppressrevision' ) ) {
490 $this->getOutput()->addWikiMsg( 'revdelete-suppress-text' );
491 }
492
493 if ( $this->mIsAllowed ) {
494 $this->getOutput()->addWikiMsg( 'revdelete-confirm' );
495 }
496 }
497
498 /**
499 * @return string HTML
500 */
501 protected function buildCheckBoxes() {
502 $html = '<table>';
503 // If there is just one item, use checkboxes
504 $list = $this->getList();
505 if ( $list->length() == 1 ) {
506 $list->reset();
507 $bitfield = $list->current()->getBits(); // existing field
508
509 if ( $this->submitClicked ) {
510 $bitfield = RevisionDeleter::extractBitfield( $this->extractBitParams(), $bitfield );
511 }
512
513 foreach ( $this->checks as $item ) {
514 // Messages: revdelete-hide-text, revdelete-hide-image, revdelete-hide-name,
515 // revdelete-hide-comment, revdelete-hide-user, revdelete-hide-restricted
516 list( $message, $name, $field ) = $item;
517 $innerHTML = Xml::checkLabel(
518 $this->msg( $message )->text(),
519 $name,
520 $name,
521 $bitfield & $field
522 );
523
524 if ( $field == Revision::DELETED_RESTRICTED ) {
525 $innerHTML = "<b>$innerHTML</b>";
526 }
527
528 $line = Xml::tags( 'td', array( 'class' => 'mw-input' ), $innerHTML );
529 $html .= "<tr>$line</tr>\n";
530 }
531 } else {
532 // Otherwise, use tri-state radios
533 $html .= '<tr>';
534 $html .= '<th class="mw-revdel-checkbox">'
535 . $this->msg( 'revdelete-radio-same' )->escaped() . '</th>';
536 $html .= '<th class="mw-revdel-checkbox">'
537 . $this->msg( 'revdelete-radio-unset' )->escaped() . '</th>';
538 $html .= '<th class="mw-revdel-checkbox">'
539 . $this->msg( 'revdelete-radio-set' )->escaped() . '</th>';
540 $html .= "<th></th></tr>\n";
541 foreach ( $this->checks as $item ) {
542 // Messages: revdelete-hide-text, revdelete-hide-image, revdelete-hide-name,
543 // revdelete-hide-comment, revdelete-hide-user, revdelete-hide-restricted
544 list( $message, $name, $field ) = $item;
545 // If there are several items, use third state by default...
546 if ( $this->submitClicked ) {
547 $selected = $this->getRequest()->getInt( $name, 0 /* unchecked */ );
548 } else {
549 $selected = -1; // use existing field
550 }
551 $line = '<td class="mw-revdel-checkbox">' . Xml::radio( $name, -1, $selected == -1 ) . '</td>';
552 $line .= '<td class="mw-revdel-checkbox">' . Xml::radio( $name, 0, $selected == 0 ) . '</td>';
553 $line .= '<td class="mw-revdel-checkbox">' . Xml::radio( $name, 1, $selected == 1 ) . '</td>';
554 $label = $this->msg( $message )->escaped();
555 if ( $field == Revision::DELETED_RESTRICTED ) {
556 $label = "<b>$label</b>";
557 }
558 $line .= "<td>$label</td>";
559 $html .= "<tr>$line</tr>\n";
560 }
561 }
562
563 $html .= '</table>';
564
565 return $html;
566 }
567
568 /**
569 * UI entry point for form submission.
570 * @throws PermissionsError
571 * @return bool
572 */
573 protected function submit() {
574 # Check edit token on submission
575 $token = $this->getRequest()->getVal( 'wpEditToken' );
576 if ( $this->submitClicked && !$this->getUser()->matchEditToken( $token ) ) {
577 $this->getOutput()->addWikiMsg( 'sessionfailure' );
578
579 return false;
580 }
581 $bitParams = $this->extractBitParams();
582 // from dropdown
583 $listReason = $this->getRequest()->getText( 'wpRevDeleteReasonList', 'other' );
584 $comment = $listReason;
585 if ( $comment === 'other' ) {
586 $comment = $this->otherReason;
587 } elseif ( $this->otherReason !== '' ) {
588 // Entry from drop down menu + additional comment
589 $comment .= $this->msg( 'colon-separator' )->inContentLanguage()->text()
590 . $this->otherReason;
591 }
592 # Can the user set this field?
593 if ( $bitParams[Revision::DELETED_RESTRICTED] == 1
594 && !$this->getUser()->isAllowed( 'suppressrevision' )
595 ) {
596 throw new PermissionsError( 'suppressrevision' );
597 }
598 # If the save went through, go to success message...
599 $status = $this->save( $bitParams, $comment, $this->targetObj );
600 if ( $status->isGood() ) {
601 $this->success();
602
603 return true;
604 } else {
605 # ...otherwise, bounce back to form...
606 $this->failure( $status );
607 }
608
609 return false;
610 }
611
612 /**
613 * Report that the submit operation succeeded
614 */
615 protected function success() {
616 // Messages: revdelete-success, logdelete-success
617 $this->getOutput()->setPageTitle( $this->msg( 'actioncomplete' ) );
618 $this->getOutput()->wrapWikiMsg(
619 "<span class=\"success\">\n$1\n</span>",
620 $this->typeLabels['success']
621 );
622 $this->wasSaved = true;
623 $this->revDelList->reloadFromMaster();
624 $this->showForm();
625 }
626
627 /**
628 * Report that the submit operation failed
629 * @param Status $status
630 */
631 protected function failure( $status ) {
632 // Messages: revdelete-failure, logdelete-failure
633 $this->getOutput()->setPageTitle( $this->msg( 'actionfailed' ) );
634 $this->getOutput()->addWikiText( $status->getWikiText( $this->typeLabels['failure'] ) );
635 $this->showForm();
636 }
637
638 /**
639 * Put together an array that contains -1, 0, or the *_deleted const for each bit
640 *
641 * @return array
642 */
643 protected function extractBitParams() {
644 $bitfield = array();
645 foreach ( $this->checks as $item ) {
646 list( /* message */, $name, $field ) = $item;
647 $val = $this->getRequest()->getInt( $name, 0 /* unchecked */ );
648 if ( $val < -1 || $val > 1 ) {
649 $val = -1; // -1 for existing value
650 }
651 $bitfield[$field] = $val;
652 }
653 if ( !isset( $bitfield[Revision::DELETED_RESTRICTED] ) ) {
654 $bitfield[Revision::DELETED_RESTRICTED] = 0;
655 }
656
657 return $bitfield;
658 }
659
660 /**
661 * Do the write operations. Simple wrapper for RevDel*List::setVisibility().
662 * @param int $bitfield
663 * @param string $reason
664 * @param Title $title
665 * @return Status
666 */
667 protected function save( $bitfield, $reason, $title ) {
668 return $this->getList()->setVisibility(
669 array( 'value' => $bitfield, 'comment' => $reason )
670 );
671 }
672
673 protected function getGroupName() {
674 return 'pagetools';
675 }
676 }