From 6e6e0ae540a8f27cc05f61ee27e10a341d18f627 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Thu, 7 Jul 2005 21:40:25 +0000 Subject: [PATCH] new feature: $wgBlockAllowsUTEdit --- includes/DefaultSettings.php | 1 + includes/EditPage.php | 4 ++-- includes/User.php | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index c598379a13..0beccfb39e 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -673,6 +673,7 @@ $wgSysopUserBans = true; # Allow sysops to ban logged-in users $wgSysopRangeBans = true; # Allow sysops to ban IP ranges $wgAutoblockExpiry = 86400; # Number of seconds before autoblock entries expire +$wgBlockAllowsUTEdit = false; # Blocks allow users to edit their own user talk page /** * Permission keys given to users in each group. diff --git a/includes/EditPage.php b/includes/EditPage.php index 3bc5ade0c6..562682a4a3 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -149,7 +149,7 @@ class EditPage { $wgOut->readOnlyPage( $this->mArticle->getContent( true ), true ); return; } - if ( !$this->preview && !$this->diff && $wgUser->isBlocked( !$this->save ) ) { + if ( !$this->preview && !$this->diff && $wgUser->isBlockedFrom( $this->mTitle, !$this->save ) ) { # When previewing, don't check blocked state - will get caught at save time. # Also, check when starting edition is done against slave to improve performance. $this->blockedIPpage(); @@ -348,7 +348,7 @@ class EditPage { # Error messages or other handling should be performed by the filter function return; } - if ( $wgUser->isBlocked( false ) ) { + if ( $wgUser->isBlockedFrom( $this->mTitle, false ) ) { # Check block state against master, thus 'false'. $this->blockedIPpage(); return; diff --git a/includes/User.php b/includes/User.php index 2d676c6e8f..58118b5b40 100644 --- a/includes/User.php +++ b/includes/User.php @@ -512,6 +512,20 @@ class User { $this->getBlockedStatus( $bFromSlave ); return $this->mBlockedby !== 0; } + + /** + * Check if user is blocked from editing a particular article + */ + function isBlockedFrom( $title, $bFromSlave = false ) { + global $wgBlockAllowsUTEdit; + if ( $wgBlockAllowsUTEdit && $title->getText() === $this->getName() && + $title->getNamespace() == NS_USER_TALK ) + { + return false; + } else { + return $this->isBlocked( $bFromSlave ); + } + } /** * Get name of blocker -- 2.20.1