if( wfReadOnly() ) {
$wgOut->readOnlyPage();
return;
- } elseif( !$wgUser->isLoggedIn() ) {
- $wgOut->showErrorPage( 'uploadnologin', 'uploadnologintext' );
- return;
- } elseif( !$wgUser->isAllowed( 'delete' ) ) {
- $wgOut->permissionRequired( 'delete' );
- return;
- } elseif( $wgUser->isBlocked() ) {
- $wgOut->blockedPage();
+ }
+ $permission_errors = $this->title->getUserPermissionsErrors('delete', $wgUser);
+ if (count($permission_errors)>0) {
+ $wgOut->showPermissionsErrorPage( $permission_errors );
return;
}
# Flag to hide all contents of the archived revisions
$suppress = $wgRequest->getVal( 'wpSuppress' ) && $wgUser->isAllowed('deleterevision');
- if( $this->oldimage && !$this->isValidOldSpec() ) {
+ if( $this->oldimage && !self::isValidOldSpec($this->oldimage) ) {
$wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars( $this->oldimage ) );
return;
}
if( $this->oldimage )
$this->oldfile = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $this->title, $this->oldimage );
- if( !$this->haveDeletableFile() ) {
+ if( !self::haveDeletableFile($this->file, $this->oldfile, $this->oldimage) ) {
$wgOut->addHtml( $this->prepareMessage( 'filedelete-nofile' ) );
$wgOut->addReturnTo( $this->title );
return;
*
* @return bool
*/
- private function isValidOldSpec() {
- return strlen( $this->oldimage ) >= 16
- && strpos( $this->oldimage, '/' ) === false
- && strpos( $this->oldimage, '\\' ) === false;
+ public static function isValidOldSpec($oldimage) {
+ return strlen( $oldimage ) >= 16
+ && strpos( $oldimage, '/' ) === false
+ && strpos( $oldimage, '\\' ) === false;
}
/**
*
* @return bool
*/
- private function haveDeletableFile() {
- return $this->oldimage
- ? $this->oldfile && $this->oldfile->exists() && $this->oldfile->isLocal()
- : $this->file && $this->file->exists() && $this->file->isLocal();
+ public static function haveDeletableFile(&$file, &$oldfile, $oldimage) {
+ return $oldimage
+ ? $oldfile && $oldfile->exists() && $oldfile->isLocal()
+ : $file && $file->exists() && $file->isLocal();
}
/**