X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FFileDeleteForm.php;h=1f0c19576436b118a9fc1cd532797f0c187e70f5;hb=392af46809d831514f49618cdef1e1529d7fddf4;hp=d86c8d82f36ab126242256c3848767e879ef2b86;hpb=7521a3ffa4ff3017624e59278c4fd67a6f70e868;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index d86c8d82f3..1f0c195764 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -1,10 +1,31 @@ + * @ingroup Media + */ /** * File deletion user interface * * @ingroup Media - * @author Rob Church */ class FileDeleteForm { @@ -98,10 +119,12 @@ class FileDeleteForm { // file, otherwise go back to the description page $wgOut->addReturnTo( $this->oldimage ? $this->title : Title::newMainPage() ); - if ( $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn() ) { - WatchAction::doWatch( $this->title, $wgUser ); - } elseif ( $this->title->userIsWatching() ) { - WatchAction::doUnwatch( $this->title, $wgUser ); + if ( $wgUser->isLoggedIn() && $wgRequest->getCheck( 'wpWatch' ) != $wgUser->isWatched( $this->title ) ) { + if ( $wgRequest->getCheck( 'wpWatch' ) ) { + WatchAction::doWatch( $this->title, $wgUser ); + } else { + WatchAction::doUnwatch( $this->title, $wgUser ); + } } } return; @@ -133,12 +156,19 @@ class FileDeleteForm { $status = $file->deleteOld( $oldimage, $reason, $suppress ); if( $status->ok ) { // Need to do a log item - $log = new LogPage( 'delete' ); $logComment = wfMsgForContent( 'deletedrevision', $oldimage ); if( trim( $reason ) != '' ) { $logComment .= wfMsgForContent( 'colon-separator' ) . $reason; } - $log->addEntry( 'delete', $title, $logComment ); + + $logtype = $suppress ? 'suppress' : 'delete'; + + $logEntry = new ManualLogEntry( $logtype, 'delete' ); + $logEntry->setPerformer( $user ); + $logEntry->setTarget( $title ); + $logEntry->setComment( $logComment ); + $logid = $logEntry->insert(); + $logEntry->publish( $logid ); } } else { $status = Status::newFatal( 'cannotdelete', @@ -149,7 +179,10 @@ class FileDeleteForm { try { // delete the associated article first $error = ''; - if ( $page->doDeleteArticleReal( $reason, $suppress, 0, false, $error, $user ) >= WikiPage::DELETE_SUCCESS ) { + $deleteStatus = $page->doDeleteArticleReal( $reason, $suppress, 0, false, $error, $user ); + // doDeleteArticleReal() returns a non-fatal error status if the page + // or revision is missing, so check for isOK() rather than isGood() + if ( $deleteStatus->isOK() ) { $status = $file->delete( $reason, $suppress ); if( $status->isOK() ) { $dbw->commit( __METHOD__ ); @@ -189,7 +222,7 @@ class FileDeleteForm { $suppress = ''; } - $checkWatch = $wgUser->getBoolOption( 'watchdeletion' ) || $this->title->userIsWatching(); + $checkWatch = $wgUser->getBoolOption( 'watchdeletion' ) || $wgUser->isWatched( $this->title ); $form = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getAction(), 'id' => 'mw-img-deleteconfirm' ) ) . Xml::openElement( 'fieldset' ) . @@ -258,7 +291,8 @@ class FileDeleteForm { */ private function showLogEntries() { global $wgOut; - $wgOut->addHTML( '

' . htmlspecialchars( LogPage::logName( 'delete' ) ) . "

\n" ); + $deleteLogPage = new LogPage( 'delete' ); + $wgOut->addHTML( '

' . $deleteLogPage->getName()->escaped() . "

\n" ); LogEventsList::showLogExtract( $wgOut, 'delete', $this->title ); }