From 24a463ab5fe99939945761425fe931bb34287983 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Mon, 6 Feb 2006 09:49:28 +0000 Subject: [PATCH] Introduce "semiprotectedpagewarning" which appears when a user edits a page that requires autoconfirmed permissions to edit. Note that other protection levels will take precedence over this; the regular "protectedpagewarning" will show in these cases. --- includes/EditPage.php | 14 +++++++++++--- includes/Title.php | 17 +++++++++++++++++ languages/Messages.php | 1 + 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/includes/EditPage.php b/includes/EditPage.php index d5c4095cb5..66bf97f2f2 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -726,10 +726,18 @@ class EditPage { $wgOut->addWikiText( wfMsg( 'anoneditwarning' ) ); } - if( $this->mTitle->isProtected('edit') ) { - $wgOut->addWikiText( wfMsg( 'protectedpagewarning' ) ); + if( $this->mTitle->isProtected( 'edit' ) ) { + if( $this->mTitle->isSemiProtected() ) { + $notice = wfMsg( 'semiprotectedpagewarning' ); + if( wfEmptyMsg( 'semiprotectedpagewarning', $notice ) || $notice == '-' ) { + $notice = ''; + } + } else { + $notice = wfMsg( 'protectedpagewarning' ); + } + $wgOut->addWikiText( $notice ); } - + $kblength = (int)(strlen( $this->textbox1 ) / 1024); if( $kblength > 29 ) { $wgOut->addWikiText( wfMsg( 'longpagewarning', $wgLang->formatNum( $kblength ) ) ); diff --git a/includes/Title.php b/includes/Title.php index 4cfce2b831..2c1932529a 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -866,6 +866,23 @@ class Title { */ function isExternal() { return ( '' != $this->mInterwiki ); } + /** + * Is this page "semi-protected" - the *only* protection is autoconfirm? + * + * @param string Action to check (default: edit) + * @return bool + */ + function isSemiProtected( $action = 'edit' ) { + $restrictions = $this->getRestrictions( $action ); + # We do a full compare because this could be an array + foreach( $restrictions as $restriction ) { + if( strtolower( $restriction ) != 'autoconfirmed' ) { + return( false ); + } + } + return( true ); + } + /** * Does the title correspond to a protected article? * @param string $what the action the page is protected from, diff --git a/languages/Messages.php b/languages/Messages.php index 8924eb998e..1beb6a5dc9 100644 --- a/languages/Messages.php +++ b/languages/Messages.php @@ -524,6 +524,7 @@ Please consider breaking the page into smaller sections.", so you will not be able to save your edits right now. You may wish to cut-n-paste the text into a text file and save it for later.', 'protectedpagewarning' => "WARNING: This page has been locked so that only users with sysop privileges can edit it. Be sure you are following the [[Project:Protected_page_guidelines|protected page guidelines]].", +'semiprotectedpagewarning' => "'''Note:''' This page has been locked so that only registered users can edit it.", 'templatesused' => 'Templates used on this page:', 'edittools' => '', 'nocreatetitle' => 'Page creation limited', -- 2.20.1