From: Ilmari Karonen Date: Thu, 22 May 2008 01:29:33 +0000 (+0000) Subject: Make Special:Upload display detailed permissions errors. Also avoid checking for... X-Git-Tag: 1.31.0-rc.0~47478 X-Git-Url: http://git.cyclocoop.org//%27http:/jquery.khurshid.com/ifixpng.php/%27?a=commitdiff_plain;h=974a0b5b017b30c2f6deaa8ff03d29a4049e749e;p=lhc%2Fweb%2Fwiklou.git Make Special:Upload display detailed permissions errors. Also avoid checking for 'create' permissions if the target title already exists. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index aa2310b107..5ca8f7b669 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -43,6 +43,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN be filtered to only those within the range of $wgRCMaxAge. * $wgRCLinkLimits and $wgRCLinkDays allow for customization of the list and limits displayed on the recent changes special pages. +* The "createpage" permission is no longer required when uploading if the target + image page already exists. === New features in 1.13 === diff --git a/includes/SpecialUpload.php b/includes/SpecialUpload.php index fa70f252d7..147db6cce4 100644 --- a/includes/SpecialUpload.php +++ b/includes/SpecialUpload.php @@ -307,7 +307,7 @@ class UploadForm { break; case self::PROTECTED_PAGE: - $this->uploadError( wfMsgWikiHtml( 'protectedpage' ) ); + $wgOut->showPermissionsErrorPage( $details['permissionserrors'] ); break; case self::OVERWRITE_EXISTING_FILE: @@ -436,9 +436,15 @@ class UploadForm { * If the image is protected, non-sysop users won't be able * to modify it by uploading a new revision. */ - if( !$nt->userCan( 'edit' ) || - !$nt->userCan( 'create' ) || - !$nt->userCan( 'upload' ) ){ + $permErrors = $nt->getUserPermissionsErrors( 'edit', $wgUser ); + $permErrorsUpload = $nt->getUserPermissionsErrors( 'upload', $wgUser ); + $permErrorsCreate = ( $nt->exists() ? array() : $nt->getUserPermissionsErrors( 'create', $wgUser ) ); + + if( $permErrors || $permErrorsUpload || $permErrorsCreate ) { + // merge all the problems into one list, avoiding duplicates + $permErrors = array_merge( $permErrors, wfArrayDiff2( $permErrorsUpload, $permErrors ) ); + $permErrors = array_merge( $permErrors, wfArrayDiff2( $permErrorsCreate, $permErrors ) ); + $resultDetails = array( 'permissionserrors' => $permErrors ); return self::PROTECTED_PAGE; }