From c0e0aa1de78864e488c96a7f3f7f9487fa0f1083 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Mon, 2 Apr 2007 07:39:32 +0000 Subject: [PATCH] (bug 9033) Use a more specific error message when users are not able/allowed to edit page protection levels due to a block, database lock or permissions --- RELEASE-NOTES | 4 +++- includes/ProtectionForm.php | 24 ++++++++++++++++++++---- languages/messages/MessagesEn.php | 8 ++++++-- maintenance/language/messages.inc | 4 +++- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index c2c72a629c..73f6f7c4f2 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -298,7 +298,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 9472) Invalid XHTML on cached special pages * (bug 9472) Invalid XHTML on Special:Newpages * (bug 4764) "My contributions" not bold when viewing own contributions -* (bug 9194) Add {{PLURAL:...}} to navigation bar of special:whatlinkshere +* (bug 9194) Add {{PLURAL:...}} to navigation bar of Special:Whatlinkshere +* (bug 9033) Use a more specific error message when users are not able/allowed + to edit page protection levels due to a block, database lock or permissions == Maintenance == * New script maintenance/language/checkExtensioni18n.php used to check i18n diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index 659ba1f16c..f799624071 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -86,7 +86,7 @@ class ProtectionForm { } function show( $err = null ) { - global $wgOut; + global $wgOut, $wgUser; $wgOut->setRobotpolicy( 'noindex,nofollow' ); @@ -119,9 +119,25 @@ class ProtectionForm { $wgOut->setPageTitle( wfMsg( 'confirmprotect' ) ); $wgOut->setSubtitle( wfMsg( 'protectsub', $this->mTitle->getPrefixedText() ) ); - $wgOut->addWikiText( - wfMsg( $this->disabled ? "protect-viewtext" : "protect-text", - wfEscapeWikiText( $this->mTitle->getPrefixedText() ) ) ); + # Show an appropriate message if the user isn't allowed or able to change + # the protection settings at this time + if( $this->disabled ) { + if( $wgUser->isAllowed( 'protect' ) ) { + if( $wgUser->isBlocked() ) { + # Blocked + $message = 'protect-locked-blocked'; + } else { + # Database lock + $message = 'protect-locked-dblock'; + } + } else { + # Permission error + $message = 'protect-locked-access'; + } + } else { + $message = 'protect-text'; + } + $wgOut->addWikiText( wfMsg( $message, wfEscapeWikiText( $this->mTitle->getPrefixedText() ) ) ); $wgOut->addHTML( $this->buildForm() ); diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index bdadbe2567..2232aeaa3e 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1809,8 +1809,12 @@ Please hit "back" and reload the page you came from, then try again.', 'unprotectcomment' => 'Reason for unprotecting', 'protect-unchain' => 'Unlock move permissions', 'protect-text' => 'You may view and change the protection level here for the page $1.', -'protect-viewtext' => 'Your account does not have permission to change -page protection levels. Here are the current settings for the page $1:', +'protect-locked-blocked' => 'You cannot change protection levels while blocked. Here are the +current settings for the page $1:', +'protect-locked-dblock' => 'Protection levels cannot be changed due to an active database lock. +Here are the current settings for the page $1:', +'protect-locked-access' => 'Your account does not have permission to change page protection levels. +Here are the current settings for the page $1:', 'protect-cascadeon' => "This page is currently protected because it is included in the following pages, which have cascading protection turned on. You can change this page's protection level, but it will not affect the cascading protection.", 'protect-default' => '(default)', 'protect-level-autoconfirmed' => 'Block unregistered users', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index eeca58fbc9..62bcda73ca 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1155,7 +1155,9 @@ $wgMessageStructure = array( 'unprotectcomment', 'protect-unchain', 'protect-text', - 'protect-viewtext', + 'protect-locked-blocked', + 'protect-locked-dblock', + 'protect-locked-access', 'protect-cascadeon', 'protect-default', 'protect-level-autoconfirmed', -- 2.20.1