From: Bryan Tong Minh Date: Fri, 4 Apr 2008 13:59:04 +0000 (+0000) Subject: Show a normal permissionsErrorPage when the user does not have permissions to delete... X-Git-Tag: 1.31.0-rc.0~48617 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=0c8c6a4936facbf1981e70476bc792f967ad92e9;p=lhc%2Fweb%2Fwiklou.git Show a normal permissionsErrorPage when the user does not have permissions to delete. Statify isValidOldSpec and haveDeletable file to be used by the API --- diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index e9a252fed8..3824d10653 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -35,14 +35,10 @@ class FileDeleteForm { 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; } @@ -51,14 +47,14 @@ class FileDeleteForm { # 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; @@ -234,10 +230,10 @@ class FileDeleteForm { * * @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; } /** @@ -247,10 +243,10 @@ class FileDeleteForm { * * @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(); } /**