X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FFileDeleteForm.php;h=1241e1c7cb15800f97ac322846f141e8ef2e7d88;hp=5aa6edf879c7029bdd6a1c0fff8b3e4587d8b856;hb=e390198c4e4be7632b01173e42050061f1cc346a;hpb=9eafd89011b9b031d902a4381e13254fb67e1e07 diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index 5aa6edf879..1241e1c7cb 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -79,7 +79,9 @@ class FileDeleteForm { $this->oldimage = $wgRequest->getText( 'oldimage', false ); $token = $wgRequest->getText( 'wpEditToken' ); # Flag to hide all contents of the archived revisions - $suppress = $wgRequest->getCheck( 'wpSuppress' ) && $wgUser->isAllowed( 'suppressrevision' ); + $permissionManager = MediaWikiServices::getInstance()->getPermissionManager(); + $suppress = $wgRequest->getCheck( 'wpSuppress' ) && + $permissionManager->userHasRight( $wgUser, 'suppressrevision' ); if ( $this->oldimage ) { $this->oldfile = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( @@ -145,7 +147,7 @@ class FileDeleteForm { * Really delete the file * * @param Title &$title - * @param File &$file + * @param LocalFile &$file * @param string &$oldimage Archive name * @param string $reason Reason of the deletion * @param bool $suppress Whether to mark all deleted versions as restricted @@ -165,7 +167,7 @@ class FileDeleteForm { if ( $oldimage ) { $page = null; $status = $file->deleteOld( $oldimage, $reason, $suppress, $user ); - if ( $status->ok ) { + if ( $status->isOK() ) { // Need to do a log item $logComment = wfMessage( 'deletedrevision', $oldimage )->inContentLanguage()->text(); if ( trim( $reason ) != '' ) { @@ -179,7 +181,7 @@ class FileDeleteForm { $logEntry->setPerformer( $user ); $logEntry->setTarget( $title ); $logEntry->setComment( $logComment ); - $logEntry->setTags( $tags ); + $logEntry->addTags( $tags ); $logid = $logEntry->insert(); $logEntry->publish( $logid ); @@ -210,7 +212,7 @@ class FileDeleteForm { $logEntry->setPerformer( $user ); $logEntry->setTarget( clone $title ); $logEntry->setComment( $reason ); - $logEntry->setTags( $tags ); + $logEntry->addTags( $tags ); $logid = $logEntry->insert(); $dbw->onTransactionPreCommitOrIdle( function () use ( $logEntry, $logid ) { @@ -245,6 +247,7 @@ class FileDeleteForm { */ private function showForm() { global $wgOut, $wgUser, $wgRequest; + $permissionManager = MediaWikiServices::getInstance()->getPermissionManager(); $wgOut->addModules( 'mediawiki.action.delete.file' ); @@ -252,16 +255,18 @@ class FileDeleteForm { $wgOut->enableOOUI(); + $fields = []; + + $fields[] = new OOUI\LabelWidget( [ 'label' => new OOUI\HtmlSnippet( + $this->prepareMessage( 'filedelete-intro' ) ) ] + ); + $options = Xml::listDropDownOptions( $wgOut->msg( 'filedelete-reason-dropdown' )->inContentLanguage()->text(), [ 'other' => $wgOut->msg( 'filedelete-reason-otherlist' )->inContentLanguage()->text() ] ); $options = Xml::listDropDownOptionsOoui( $options ); - $fields[] = new OOUI\LabelWidget( [ 'label' => new OOUI\HtmlSnippet( - $this->prepareMessage( 'filedelete-intro' ) ) ] - ); - $fields[] = new OOUI\FieldLayout( new OOUI\DropdownInputWidget( [ 'name' => 'wpDeleteReasonList', @@ -296,7 +301,7 @@ class FileDeleteForm { ] ); - if ( $wgUser->isAllowed( 'suppressrevision' ) ) { + if ( $permissionManager->userHasRight( $wgUser, 'suppressrevision' ) ) { $fields[] = new OOUI\FieldLayout( new OOUI\CheckboxInputWidget( [ 'name' => 'wpSuppress', @@ -370,7 +375,7 @@ class FileDeleteForm { ] ) ); - if ( $wgUser->isAllowed( 'editinterface' ) ) { + if ( $permissionManager->userHasRight( $wgUser, 'editinterface' ) ) { $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); $link = $linkRenderer->makeKnownLink( $wgOut->msg( 'filedelete-reason-dropdown' )->inContentLanguage()->getTitle(),