From 99d0ab83dea47059a2eaf754ee2f2650c98e13b4 Mon Sep 17 00:00:00 2001 From: Shinjiman Date: Sun, 2 Aug 2009 08:31:29 +0000 Subject: [PATCH] Added back 'editusercssjs' right for regression and backward compatibility, per Code Review on r54153. --- includes/Title.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/includes/Title.php b/includes/Title.php index 42143488ba..41fa9444b5 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1282,11 +1282,14 @@ class Title { # XXX: this might be better using restrictions # XXX: Find a way to work around the php bug that prevents using $this->userCanEditCssSubpage() # and $this->userCanEditJsSubpage() from working - if( $this->isCssSubpage() && !$user->isAllowed('editusercss' ) && $action != 'patrol' + # XXX: right 'editusercssjs' is deprecated, for backward compatibility only + if( $this->isCssSubpage() && ( !$user->isAllowed('editusercssjs') || !$user->isAllowed('editusercss') ) + && $action != 'patrol' && !preg_match('/^'.preg_quote($user->getName(), '/').'\//', $this->mTextform) ) { $errors[] = array('customcssjsprotected'); - } else if( $this->isJsSubpage() && !$user->isAllowed('edituserjs' ) && $action != 'patrol' + } else if( $this->isJsSubpage() && ( !$user->isAllowed('editusercssjs') || !$user->isAllowed('edituserjs') ) + && $action != 'patrol' && !preg_match('/^'.preg_quote($user->getName(), '/').'\//', $this->mTextform) ) { $errors[] = array('customcssjsprotected'); @@ -1725,7 +1728,8 @@ class Title { */ public function userCanEditCssSubpage() { global $wgUser; - return ( $wgUser->isAllowed('editusercss') || preg_match('/^'.preg_quote($wgUser->getName(), '/').'\//', $this->mTextform) ); + return ( ( $wgUser->isAllowed('editusercssjs') && $wgUser->isAllowed('editusercss') ) + || preg_match('/^'.preg_quote($wgUser->getName(), '/').'\//', $this->mTextform) ); } /** * Protect js subpages of user pages: can $wgUser edit @@ -1736,7 +1740,8 @@ class Title { */ public function userCanEditJsSubpage() { global $wgUser; - return ( $wgUser->isAllowed('edituserjs') || preg_match('/^'.preg_quote($wgUser->getName(), '/').'\//', $this->mTextform) ); + return ( ( $wgUser->isAllowed('editusercssjs') && $wgUser->isAllowed('edituserjs') ) + || preg_match('/^'.preg_quote($wgUser->getName(), '/').'\//', $this->mTextform) ); } /** -- 2.20.1