Make Special:Upload display detailed permissions errors. Also avoid checking for...
authorIlmari Karonen <vyznev@users.mediawiki.org>
Thu, 22 May 2008 01:29:33 +0000 (01:29 +0000)
committerIlmari Karonen <vyznev@users.mediawiki.org>
Thu, 22 May 2008 01:29:33 +0000 (01:29 +0000)
RELEASE-NOTES
includes/SpecialUpload.php

index aa2310b..5ca8f7b 100644 (file)
@@ -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 ===
 
index fa70f25..147db6c 100644 (file)
@@ -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;
                }