} else {
$this->showForm();
}
+
$qc = $this->getLogQueryCond();
# Show relevant lines from the deletion log
$wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'delete' ) ) . "</h2>\n" );
$this->targetObj->getPrefixedText(), count( $this->ids ) );
}
- $bitfields = 0;
$wgOut->addHTML( "<ul>" );
$where = $revObjs = array();
$UserAllowed = false;
}
$numRevisions++;
- $bitfields |= $item->getBits();
$wgOut->addHTML( $item->getHTML() );
}
'action' => $this->getTitle()->getLocalUrl( array( 'action' => 'submit' ) ),
'id' => 'mw-revdel-form-revisions' ) ) .
Xml::fieldset( wfMsg( 'revdelete-legend' ) ) .
- $this->buildCheckBoxes( $bitfields ) .
+ $this->buildCheckBoxes() .
Xml::openElement( 'table' ) .
"<tr>\n" .
'<td class="mw-label">' .
"</tr><tr>\n" .
'<td></td>' .
'<td class="mw-submit">' .
- Xml::submitButton( wfMsg( 'revdelete-submit' ), array( 'name' => 'wpSubmit' ) ) .
+ Xml::submitButton( wfMsgExt('revdelete-submit','parsemag',$numRevisions),
+ array( 'name' => 'wpSubmit' ) ) .
'</td>' .
"</tr>\n" .
Xml::closeElement( 'table' ) .
if( $wgUser->isAllowed( 'suppressrevision' ) ) {
$wgOut->addWikiMsg( 'revdelete-suppress-text' );
}
+ if( $this->mIsAllowed ) {
+ $wgOut->addWikiMsg( 'revdelete-confirm' );
+ }
}
/**
- * @param $bitfields Interger: aggregate bitfield of all the bitfields
* @return String: HTML
*/
- protected function buildCheckBoxes( $bitfields ) {
+ protected function buildCheckBoxes() {
+ global $wgRequest;
+
$html = '<table>';
- // FIXME: all items checked for just one rev are checked, even if not set for the others
- foreach( $this->checks as $item ) {
- list( $message, $name, $field ) = $item;
- $innerHTML = Xml::checkLabel( wfMsg($message), $name, $name, $bitfields & $field );
- if( $field == Revision::DELETED_RESTRICTED )
- $innerHTML = "<b>$innerHTML</b>";
- $line = Xml::tags( 'td', array( 'class' => 'mw-input' ), $innerHTML );
- $html .= '<tr>' . $line . "</tr>\n";
+ // If there is just one item, use checkboxes
+ $list = $this->getList();
+ if( $list->length() == 1 ) {
+ $list->reset();
+ $bitfield = $list->current()->getBits(); // existing field
+ if( $this->submitClicked ) {
+ $bitfield = $this->extractBitfield( $this->extractBitParams($wgRequest), $bitfield );
+ }
+ foreach( $this->checks as $item ) {
+ list( $message, $name, $field ) = $item;
+ $innerHTML = Xml::checkLabel( wfMsg($message), $name, $name, $bitfield & $field );
+ if( $field == Revision::DELETED_RESTRICTED )
+ $innerHTML = "<b>$innerHTML</b>";
+ $line = Xml::tags( 'td', array( 'class' => 'mw-input' ), $innerHTML );
+ $html .= "<tr>$line</tr>\n";
+ }
+ // Otherwise, use tri-state radios
+ } else {
+ $html .= '<tr>';
+ $html .= '<th>'.wfMsgHtml('revdelete-radio-same').'</th><th> </th>';
+ $html .= '<th>'.wfMsgHtml('revdelete-radio-unset').'</th><th> </th>';
+ $html .= '<th>'.wfMsgHtml('revdelete-radio-set').'</th><th> </th>';
+ $html .= '<th></th></tr>';
+ foreach( $this->checks as $item ) {
+ list( $message, $name, $field ) = $item;
+ // If there are several items, use third state by default...
+ if( $this->submitClicked ) {
+ $selected = $wgRequest->getInt( $name, 0 /* unchecked */ );
+ } else {
+ $selected = -1; // use existing field
+ }
+ $line = '<td>' . Xml::radio( $name, -1, $selected == -1 ) . '</td><td> </td>';
+ $line .= '<td>' . Xml::radio( $name, 0, $selected == 0 ) . '</td><td> </td>';
+ $line .= '<td>' . Xml::radio( $name, 1, $selected == 1 ) . '</td><td> </td>';
+ $label = wfMsgHtml($message);
+ if( $field == Revision::DELETED_RESTRICTED ) {
+ $label = "<b>$label</b>";
+ }
+ $line .= "<td>$label</td>";
+ $html .= "<tr>$line</tr>\n";
+ }
}
+
$html .= '</table>';
return $html;
}
$wgOut->addWikiMsg( 'sessionfailure' );
return false;
}
- $bitfield = $this->extractBitfield( $request );
+ $bitParams = $this->extractBitParams( $request );
$listReason = $request->getText( 'wpRevDeleteReasonList', 'other' ); // from dropdown
$comment = $listReason;
if( $comment != 'other' && $this->otherReason != '' ) {
$comment = $this->otherReason;
}
# Can the user set this field?
- if( $bitfield & Revision::DELETED_RESTRICTED && !$wgUser->isAllowed('suppressrevision') ) {
+ if( $bitParams[Revision::DELETED_RESTRICTED]==1 && !$wgUser->isAllowed('suppressrevision') ) {
$wgOut->permissionRequired( 'suppressrevision' );
return false;
}
# If the save went through, go to success message...
- $status = $this->save( $bitfield, $comment, $this->targetObj );
+ $status = $this->save( $bitParams, $comment, $this->targetObj );
if ( $status->isGood() ) {
$this->success();
return true;
}
/**
- * Put together a rev_deleted bitfield from the submitted checkboxes
+ * Put together an array that contains -1, 0, or the *_deleted const for each bit
* @param $request WebRequest
- * @return Integer
+ * @return array
*/
- protected function extractBitfield( $request ) {
- $bitfield = 0;
+ protected function extractBitParams( $request ) {
+ $bitfield = array();
foreach( $this->checks as $item ) {
list( /* message */ , $name, $field ) = $item;
- if( $request->getCheck( $name ) ) {
- $bitfield |= $field;
+ $val = $request->getInt( $name, 0 /* unchecked */ );
+ if( $val < -1 || $val > 1) {
+ $val = -1; // -1 for existing value
}
+ $bitfield[$field] = $val;
+ }
+ if( !isset($bitfield[Revision::DELETED_RESTRICTED]) ) {
+ $bitfield[Revision::DELETED_RESTRICTED] = 0;
}
return $bitfield;
}
+
+ /**
+ * Put together a rev_deleted bitfield
+ * @param $bitPars array extractBitParams() params
+ * @param $oldfield int current bitfield
+ * @return array
+ */
+ public static function extractBitfield( $bitPars, $oldfield ) {
+ // Build the actual new rev_deleted bitfield
+ $newBits = 0;
+ foreach( $bitPars as $const => $val ) {
+ if( $val == 1 ) {
+ $newBits |= $const; // $const is the *_deleted const
+ } else if( $val == -1 ) {
+ $newBits |= ($oldfield & $const); // use existing
+ }
+ }
+ return $newBits;
+ }
/**
* Do the write operations. Simple wrapper for RevDel_*List::setVisibility().
*/
protected function save( $bitfield, $reason, $title ) {
- // Don't allow simply locking the interface for no reason
- if( $bitfield == Revision::DELETED_RESTRICTED ) {
- return Status::newFatal( 'revdelete-only-restricted' );
- }
- return $this->getList()->setVisibility( array(
- 'value' => $bitfield,
- 'comment' => $reason ) );
+ return $this->getList()->setVisibility(
+ array( 'value' => $bitfield, 'comment' => $reason )
+ );
}
}
* @return Status
*/
public function setVisibility( $params ) {
- $newBits = $params['value'];
+ $bitPars = $params['value'];
$comment = $params['comment'];
$this->res = false;
$item = $this->current();
unset( $missing[ $item->getId() ] );
- // Make error messages less vague
$oldBits = $item->getBits();
+ // Build the actual new rev_deleted bitfield
+ $newBits = SpecialRevisionDelete::extractBitfield( $bitPars, $oldBits );
+
if ( $oldBits == $newBits ) {
$status->warning( 'revdelete-no-change', $item->formatDate(), $item->formatTime() );
$status->failCount++;
}
if ( !$item->canView() ) {
// Cannot access this revision
- $msg = $opType == 'show' ? 'revdelete-show-no-access' : 'revdelete-modify-no-access';
+ $msg = ($opType == 'show') ?
+ 'revdelete-show-no-access' : 'revdelete-modify-no-access';
$status->error( $msg, $item->formatDate(), $item->formatTime() );
$status->failCount++;
continue;
}
+ // Cannot just "hide from Sysops" without hiding any fields
+ if( $newBits == Revision::DELETED_RESTRICTED ) {
+ $status->warning( 'revdelete-only-restricted', $item->formatDate(), $item->formatTime() );
+ $status->failCount++;
+ continue;
+ }
// Update the revision
$ok = $item->setBits( $newBits );
$this->initCurrent();
return $this->current;
}
+
+ /**
+ * Get the number of items in the list.
+ */
+ public function length() {
+ if( !$this->res ) {
+ return 0;
+ } else {
+ return $this->res->numRows();
+ }
+ }
/**
* Clear any data structures needed for doPreCommitUpdates() and doPostCommitUpdates()
* Returns true if the current user can view the item
*/
abstract public function canView();
+
+ /**
+ * Returns true if the current user can view the item text/file
+ */
+ abstract public function canViewContent();
/**
* Get the current deletion bitfield value
'rev_id' => $ids,
'rev_page = page_id'
),
- __METHOD__
+ __METHOD__,
+ array( 'ORDER BY' => 'rev_id DESC' )
);
}
public function canView() {
return $this->revision->userCan( Revision::DELETED_RESTRICTED );
}
+
+ public function canViewContent() {
+ return $this->revision->userCan( Revision::DELETED_TEXT );
+ }
public function getBits() {
return $this->revision->mDeleted;
protected function getRevisionLink() {
global $wgLang;
$date = $wgLang->timeanddate( $this->revision->getTimestamp(), true );
- if ( $this->isDeleted() && !$this->canView() ) {
+ if ( $this->isDeleted() && !$this->canViewContent() ) {
return $date;
}
return $this->special->skin->link(
* Overridden by RevDel_ArchiveItem
*/
protected function getDiffLink() {
- if ( $this->isDeleted() && !$this->canView() ) {
+ if ( $this->isDeleted() && !$this->canViewContent() ) {
return wfMsgHtml('diff');
} else {
return
'ar_title' => $this->title->getDBkey(),
'ar_timestamp' => $timestamps
),
- __METHOD__
+ __METHOD__,
+ array( 'ORDER BY' => 'ar_timestamp DESC' )
);
}
global $wgLang;
$undelete = SpecialPage::getTitleFor( 'Undelete' );
$date = $wgLang->timeanddate( $this->revision->getTimestamp(), true );
- if ( $this->isDeleted() && !$this->canView() ) {
+ if ( $this->isDeleted() && !$this->canViewContent() ) {
return $date;
}
return $this->special->skin->link( $undelete, $date, array(),
}
protected function getDiffLink() {
- if ( $this->isDeleted() && !$this->canView() ) {
+ if ( $this->isDeleted() && !$this->canViewContent() ) {
return wfMsgHtml( 'diff' );
}
$undelete = SpecialPage::getTitleFor( 'Undelete' );
'oi_name' => $this->title->getDBkey(),
'oi_archive_name' => $archiveNames
),
- __METHOD__
+ __METHOD__,
+ array( 'ORDER BY' => 'oi_timestamp DESC' )
);
}
public function canView() {
return $this->file->userCan( File::DELETED_RESTRICTED );
}
+
+ public function canViewContent() {
+ return $this->file->userCan( File::DELETED_FILE );
+ }
public function getBits() {
return $this->file->getVisibility();
$date = $wgLang->timeanddate( $this->file->getTimestamp(), true );
if ( $this->isDeleted() ) {
# Hidden files...
- if ( !$this->canView() ) {
+ if ( !$this->canViewContent() ) {
$link = $date;
} else {
$link = $this->special->skin->link(
'fa_name' => $this->title->getDBkey(),
'fa_id' => $ids
),
- __METHOD__
+ __METHOD__,
+ array( 'ORDER BY' => 'fa_id DESC' )
);
}
$undelete = SpecialPage::getTitleFor( 'Undelete' );
$key = $this->file->getKey();
# Hidden files...
- if( !$this->canView() ) {
+ if( !$this->canViewContent() ) {
$link = $date;
} else {
$link = $this->special->skin->link( $undelete, $date, array(),
$ids = array_map( 'intval', $this->ids );
return $db->select( 'logging', '*',
array( 'log_id' => $ids ),
- __METHOD__
+ __METHOD__,
+ array( 'ORDER BY' => 'log_id DESC' )
);
}
public function canView() {
return LogEventsList::userCan( $this->row, Revision::DELETED_RESTRICTED );
}
+
+ public function canViewContent() {
+ return true; // none
+ }
public function getBits() {
return $this->row->log_deleted;