From 09176e8c7b083df7b62487bd913b8cd90bf8b927 Mon Sep 17 00:00:00 2001 From: Robin Pepermans Date: Tue, 26 May 2009 19:16:49 +0000 Subject: [PATCH] Per comment at r50961: keep the messages saying "you need to be logged in to ...", but only show it when normal logged-in users can upload --- includes/Title.php | 9 ++++++++- includes/specials/SpecialUpload.php | 9 ++++++++- languages/messages/MessagesEn.php | 4 ++++ maintenance/language/messages.inc | 4 ++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/includes/Title.php b/includes/Title.php index 74cd6f0129..baea55ef57 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1171,7 +1171,14 @@ class Title { if( !$user->isAllowed( 'move' ) ) { // User can't move anything - $errors[] = array ('movenotallowed'); + global $wgGroupPermissions; + if( $user->isAnon() && ( $wgGroupPermissions['user']['move'] + || $wgGroupPermissions['autoconfirmed']['move'] ) ) { + // custom message if logged-in users without any special rights can move + $errors[] = array ( 'movenologintext' ); + } else { + $errors[] = array ('movenotallowed'); + } } } elseif ( $action == 'create' ) { if( ( $this->isTalkPage() && !$user->isAllowed( 'createtalk' ) ) || diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index ad8366b519..fcd19ce3d3 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -244,8 +244,15 @@ class UploadForm { } # Check permissions + global $wgGroupPermissions; if( !$wgUser->isAllowed( 'upload' ) ) { - $wgOut->permissionRequired( 'upload' ); + if( !$wgUser->isLoggedIn() && ( $wgGroupPermissions['user']['upload'] + || $wgGroupPermissions['autoconfirmed']['upload'] ) ) { + // Custom message if logged-in users without any special rights can upload + $wgOut->showErrorPage( 'uploadnologin', 'uploadnologintext' ); + } else { + $wgOut->permissionRequired( 'upload' ); + } return; } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index ecf49f4a8d..7c47c0fd3a 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1820,6 +1820,8 @@ Pages on [[Special:Watchlist|your watchlist]] are '''bold'''.", 'uploadbtn' => 'Upload file', 'reupload' => 'Re-upload', 'reuploaddesc' => 'Cancel upload and return to the upload form', +'uploadnologin' => 'Not logged in', +'uploadnologintext' => 'You must be [[Special:UserLogin|logged in]] to upload files.', 'upload_directory_missing' => 'The upload directory ($1) is missing and could not be created by the webserver.', 'upload_directory_read_only' => 'The upload directory ($1) is not writable by the webserver.', 'uploaderror' => 'Upload error', @@ -2773,6 +2775,8 @@ please be sure you understand the consequences of this before proceeding.", In those cases, you will have to move or merge the page manually if desired.", 'movearticle' => 'Move page:', +'movenologin' => 'Not logged in', +'movenologintext' => 'You must be a registered user and [[Special:UserLogin|logged in]] to move a page.', 'movenotallowed' => 'You do not have permission to move pages.', 'movenotallowedfile' => 'You do not have permission to move files.', 'cant-move-user-page' => 'You do not have permission to move user pages (apart from subpages).', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 22a366fff5..438ef5ac8d 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1130,6 +1130,8 @@ $wgMessageStructure = array( 'uploadbtn', 'reupload', 'reuploaddesc', + 'uploadnologin', + 'uploadnologintext', 'upload_directory_missing', 'upload_directory_read_only', 'uploaderror', @@ -1922,6 +1924,8 @@ $wgMessageStructure = array( 'movepagetext', 'movepagetalktext', 'movearticle', + 'movenologin', + 'movenologintext', 'movenotallowed', 'movenotallowedfile', 'cant-move-user-page', -- 2.20.1