Page MenuHomePhabricator
Authored By
bzimport
Nov 21 2014, 8:19 PM
Size
15 KB
Referenced Files
None
Subscribers
None
Index: includes/EditPage.php
===================================================================
--- includes/EditPage.php (revision 13688)
+++ includes/EditPage.php (working copy)
@@ -160,7 +160,6 @@
*/
function edit() {
global $wgOut, $wgUser, $wgRequest, $wgTitle;
- global $wgEmailConfirmToEdit;
if ( ! wfRunHooks( 'AlternateEdit', array( &$this ) ) )
return;
@@ -183,10 +182,27 @@
if ( ! $this->mTitle->userCanEdit() ) {
wfDebug( "$fname: user can't edit\n" );
- $wgOut->readOnlyPage( $this->mArticle->getContent(), true );
+ global $wgEmailConfirmToEdit;
+ if ( $wgEmailConfirmToEdit && !$wgUser->isEmailConfirmed() ) {
+ $message = 'editemailconfirm';
+ } else if ( !$wgUser->isAllowed( 'edit' ) ) {
+ $message = 'editrestricted';
+ } else {
+ $message = 'protectedtext';
+ }
+ $wgOut->readOnlyPage( $this->mArticle->getContent(), true, $message.( $wgUser->isLoggedIn() ?
+ '' : 'anon' ) );
wfProfileOut( $fname );
return;
}
+ if ( !$this->mTitle->userCanCreate() && !$this->mTitle->exists() ) {
+ wfDebug( "$fname: no create permission\n" );
+ global $wgEmailConfirmToEdit;
+ $wgOut->readOnlyPage( $this->mArticle->getContent(), true, 'createrestricted'.
+ ( $wgUser->isLoggedIn() ? '' : 'anon' ) );
+ wfProfileOut( $fname );
+ return;
+ }
wfDebug( "$fname: Checking blocks\n" );
if ( !$this->preview && !$this->diff && $wgUser->isBlockedFrom( $this->mTitle, !$this->save ) ) {
# When previewing, don't check blocked state - will get caught at save time.
@@ -196,31 +212,6 @@
wfProfileOut( $fname );
return;
}
- if ( !$wgUser->isAllowed('edit') ) {
- if ( $wgUser->isAnon() ) {
- wfDebug( "$fname: user must log in\n" );
- $this->userNotLoggedInPage();
- wfProfileOut( $fname );
- return;
- } else {
- wfDebug( "$fname: read-only page\n" );
- $wgOut->readOnlyPage( $this->mArticle->getContent(), true );
- wfProfileOut( $fname );
- return;
- }
- }
- if ($wgEmailConfirmToEdit && !$wgUser->isEmailConfirmed()) {
- wfDebug("$fname: user must confirm e-mail address\n");
- $this->userNotConfirmedPage();
- wfProfileOut($fname);
- return;
- }
- if ( !$this->mTitle->userCan( 'create' ) && !$this->mTitle->exists() ) {
- wfDebug( "$fname: no create permission\n" );
- $this->noCreatePermission();
- wfProfileOut( $fname );
- return;
- }
if ( wfReadOnly() ) {
wfDebug( "$fname: read-only mode is engaged\n" );
if( $this->save || $this->preview ) {
@@ -511,28 +502,6 @@
wfProfileOut( $fname );
return true;
}
-
- if ( !$wgUser->isAllowed('edit') ) {
- if ( $wgUser->isAnon() ) {
- $this->userNotLoggedInPage();
- wfProfileOut( "$fname-checks" );
- wfProfileOut( $fname );
- return false;
- }
- else {
- $wgOut->readOnlyPage();
- wfProfileOut( "$fname-checks" );
- wfProfileOut( $fname );
- return false;
- }
- }
-
- if ( wfReadOnly() ) {
- $wgOut->readOnlyPage();
- wfProfileOut( "$fname-checks" );
- wfProfileOut( $fname );
- return false;
- }
if ( $wgUser->pingLimiter() ) {
$wgOut->rateLimited();
wfProfileOut( "$fname-checks" );
@@ -553,14 +522,6 @@
# If article is new, insert it.
$aid = $this->mTitle->getArticleID( GAID_FOR_UPDATE );
if ( 0 == $aid ) {
- // Late check for create permission, just in case *PARANOIA*
- if ( !$this->mTitle->userCan( 'create' ) ) {
- wfDebug( "$fname: no create permission\n" );
- $this->noCreatePermission();
- wfProfileOut( $fname );
- return;
- }
-
# Don't save a new article if it's blank.
if ( ( '' == $this->textbox1 ) ) {
$wgOut->redirect( $this->mTitle->getFullURL() );
@@ -1304,36 +1265,6 @@
/**
* @todo document
*/
- function userNotLoggedInPage() {
- global $wgOut;
-
- $wgOut->setPageTitle( wfMsg( 'whitelistedittitle' ) );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
- $wgOut->setArticleRelated( false );
-
- $wgOut->addWikiText( wfMsg( 'whitelistedittext' ) );
- $wgOut->returnToMain( false );
- }
-
- /**
- * Creates a basic error page which informs the user that
- * they have to validate their email address before being
- * allowed to edit.
- */
- function userNotConfirmedPage() {
-
- global $wgOut;
-
- $wgOut->setPageTitle( wfMsg( 'confirmedittitle' ) );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
- $wgOut->setArticleRelated( false );
- $wgOut->addWikiText( wfMsg( 'confirmedittext' ) );
- $wgOut->returnToMain( false );
- }
-
- /**
- * @todo document
- */
function spamPage ( $match = false )
{
global $wgOut;
@@ -1720,12 +1651,6 @@
return strtr( $result, array( "&#x0" => "&#x" ) );
}
- function noCreatePermission() {
- global $wgOut;
- $wgOut->setPageTitle( wfMsg( 'nocreatetitle' ) );
- $wgOut->addWikiText( wfMsg( 'nocreatetext' ) );
- }
-
}
?>
Index: includes/OutputPage.php
===================================================================
--- includes/OutputPage.php (revision 13688)
+++ includes/OutputPage.php (working copy)
@@ -798,7 +798,7 @@
wfErrorExit();
}
- function readOnlyPage( $source = null, $protected = false ) {
+ function readOnlyPage( $source = null, $protected = false, $message = NULL ) {
global $wgUser, $wgReadOnlyFile, $wgReadOnly, $wgTitle;
$this->setRobotpolicy( 'noindex,nofollow' );
@@ -808,7 +808,7 @@
$skin = $wgUser->getSkin();
$this->setPageTitle( wfMsg( 'viewsource' ) );
$this->setSubtitle( wfMsg( 'viewsourcefor', $skin->makeKnownLinkObj( $wgTitle ) ) );
- $this->addWikiText( wfMsg( 'protectedtext' ) );
+ $this->addWikiText( wfMsg( $message ) );
} else {
$this->setPageTitle( wfMsg( 'readonly' ) );
if ( $wgReadOnly ) {
@@ -824,15 +824,16 @@
global $wgTitle;
if ( $wgTitle->getNamespace() == NS_MEDIAWIKI ) {
$source = wfMsgWeirdKey ( $wgTitle->getText() );
- } else {
- $source = wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' );
}
}
- $rows = $wgUser->getOption( 'rows' );
- $cols = $wgUser->getOption( 'cols' );
- $text = "\n<textarea cols='$cols' rows='$rows' readonly='readonly'>" .
- htmlspecialchars( $source ) . "\n</textarea>";
- $this->addHTML( $text );
+ if( strcmp( $source, '' ) != 0 ) {
+ $this->addWikiText( wfMsg( 'viewsourcetext' ) );
+ $rows = $wgUser->getOption( 'rows' );
+ $cols = $wgUser->getOption( 'cols' );
+ $text = "\n<textarea cols='$cols' rows='$rows' readonly='readonly'>" .
+ htmlspecialchars( $source ) . "\n</textarea>";
+ $this->addHTML( $text );
+ }
}
$this->returnToMain( false );
Index: includes/Title.php
===================================================================
--- includes/Title.php (revision 13688)
+++ includes/Title.php (working copy)
@@ -1038,6 +1038,11 @@
}
}
+ if( ( $action == 'edit' || $action == 'create' ) && (!$wgUser->isAllowed( 'edit' ) ) ) {
+ wfProfileOut( $fname );
+ return false;
+ }
+
if( $action == 'move' &&
!( $this->isMovable() && $wgUser->isAllowed( 'move' ) ) ) {
wfProfileOut( $fname );
@@ -1051,6 +1056,11 @@
}
}
+ global $wgEmailConfirmToEdit;
+ if ($wgEmailConfirmToEdit && !$wgUser->isEmailConfirmed()) {
+ return false;
+ }
+
wfProfileOut( $fname );
return true;
}
@@ -1074,6 +1084,15 @@
}
/**
+ * Can $wgUser create this page?
+ * @return boolean
+ * @access public
+ */
+ function userCanCreate() {
+ return $this->userCan('create');
+ }
+
+ /**
* Would anybody with sufficient privileges be able to move this page?
* Some pages just aren't movable.
*
Index: includes/SkinTemplate.php
===================================================================
--- includes/SkinTemplate.php (revision 13688)
+++ includes/SkinTemplate.php (working copy)
@@ -616,7 +616,7 @@
true);
wfProfileIn( "$fname-edit" );
- if ( $this->mTitle->userCanEdit() ) {
+ if ( $this->mTitle->userCanEdit() && ( $this->mTitle->exists() || $this->mTitle->userCanCreate() ) ) {
$istalk = $this->mTitle->isTalkPage();
$istalkclass = $istalk?' istalk':'';
$content_actions['edit'] = array(
Index: languages/Messages.php
===================================================================
--- languages/Messages.php (revision 13688)
+++ languages/Messages.php (working copy)
@@ -332,13 +332,6 @@
'wrong_wfQuery_params' => 'Incorrect parameters to wfQuery()<br />
Function: $1<br />
Query: $2',
-'viewsource' => 'View source',
-'viewsourcefor' => 'for $1',
-'protectedtext' => 'This page has been locked to prevent editing; there are
-a number of reasons why this may be so, please see
-[[Project:Protected page]].
-
-You can view and copy the source of this page:',
'sqlhidden' => '(SQL query hidden)',
# Login and logout pages
@@ -475,14 +468,10 @@
Note that you may not use the "e-mail this user" feature unless you have a valid e-mail address registered in your [[Special:Preferences|user preferences]].
Your IP address is $3. Please include this address in any queries you make.',
-'whitelistedittitle' => 'Login required to edit',
-'whitelistedittext' => 'You have to [[Special:Userlogin|login]] to edit pages.',
'whitelistreadtitle' => 'Login required to read',
'whitelistreadtext' => 'You have to [[Special:Userlogin|login]] to read pages.',
'whitelistacctitle' => 'You are not allowed to create an account',
'whitelistacctext' => 'To be allowed to create accounts in this Wiki you have to [[Special:Userlogin|log]] in and have the appropriate permissions.',
-'confirmedittitle' => 'E-mail confirmation required to edit',
-'confirmedittext' => 'You must confirm your e-mail address before editing pages. Please set and validate your e-mail address through your [[Special:Preferences|user preferences]].',
'loginreqtitle' => 'Login Required',
'loginreqlink' => 'login',
'loginreqpagetext' => 'You must $1 to view other pages.',
@@ -548,10 +537,21 @@
'semiprotectedpagewarning' => "'''Note:''' This page has been locked so that only registered users can edit it.",
'templatesused' => 'Templates used on this page:',
'edittools' => '<!-- Text here will be shown below edit and upload forms. -->',
-'nocreatetitle' => 'Page creation limited',
-'nocreatetext' => 'This site has restricted the ability to create new pages.
-You can go back and edit an existing page, or [[Special:Userlogin|log in or create an account]].',
+# Read-only pages
+'viewsource' => 'View source',
+'viewsourcefor' => 'for $1',
+'protectedtext' => 'This page is a \'\'\'protected page\'\'\' and you cannot edit it; there are
+a number of reasons why this may be so.',
+'protectedtextanon' => '{{int:protectedtext}}',
+'editrestricted' => 'You are not allowed to edit pages in this site.',
+'editrestrictedanon' => 'You have to [[{{ns:special}}:Userlogin|log in]] to edit pages.',
+'editemailconfirm' => 'You have to confirm your e-mail address through the [[{{ns:special}}:Preferences|edit preferences]] to edit pages.',
+'editemailconfirmanon' => 'You have to [[{{ns:special}}:Userlogin|log in]] and confirm your e-mail address through the [[{{ns:special}}:Preferences|edit preferences]] to edit pages.',
+'createrestricted' => 'You are not allowed to create new pages in this site.',
+'createrestrictedanon' => 'You have to [[{{ns:special}}:Userlogin|log in]] to create new pages.',
+'viewsourcetext' => 'You can view and copy the source of this page:',
+
# History pages
#
'revhistory' => 'Revision history',
Index: languages/MessagesHe.php
===================================================================
--- languages/MessagesHe.php (revision 13688)
+++ languages/MessagesHe.php (working copy)
@@ -316,11 +316,6 @@
"wrong_wfQuery_params" => "הפרמטרים שהוזנו ל־wfQuery() אינם נכונים:<br />
פונקציה: $1<br />
שאילתה: $2",
-"viewsource" => "הצג מקור",
-"viewsourcefor" => "לדף $1",
-"protectedtext" => "דף זה הינו '''דף מוגן''' ולא ניתן לערוך אותו. ישנן מספר סיבות אפשריות להגנה כזו.
-
-באפשרותכם לצפות בטקסט המקור של הדף, ואף להעתיקו:",
'sqlhidden' => "(שאילת ה־SQL מוסתרת)",
# Login and logout pages
@@ -450,14 +445,10 @@
** [[{{ns:special}}:Emailuser/$4|שלחו דואר אלקטרוני ל$4]] או גשו לדף המשתמש של אחד ממפעילי המערכת האחרים ובחרו ב"שלח דואר אלקטרוני למשתמש זה" מתוך תיבת הכלים שבצד ימין.
כתובת ה-IP שלך כרגע היא \'\'\'$3\'\'\', ויש לציין עובדה זו בכל פנייה למפעילי המערכת.',
-"whitelistedittitle" => "כניסה לחשבון נדרשת לעריכה",
-"whitelistedittext" => "עליכם [[{{ns:special}}:Userlogin|להיכנס לחשבון]] כדי לערוך דפים.",
"whitelistreadtitle" => "כניסה לחשבון נדרשת לקריאה",
"whitelistreadtext" => "עליכם [[{{ns:special}}:Userlogin|להיכנס לחשבון]] כדי לקרוא דפים.",
"whitelistacctitle" => "אינכם מורשים ליצור חשבון",
"whitelistacctext" => "עליכם [[{{ns:special}}:Userlogin|להיכנס לחשבון]] שיש לו את ההרשאה ליצור חשבונות כדי ליצור חשבון.",
-"confirmedittitle" => 'הנכם חייבים לאמת את כתובת הדוא"ל שלכם כדי לערוך',
-"confirmedittext" => 'עליכם לאמת את כתובת הדוא"ל שלכם לפני שתוכלו לערוך דפים. אנא הגדירו ואמתו את כתובת הדוא"ל שלכם באמצעות [[{{ns:special}}:Preferences|העדפות המשתמש]] לשכם.',
"loginreqtitle" => "כניסה לחשבון נדרשת",
"loginreqlink" => "כניסה לחשבון",
"loginreqpagetext" => "עליכם לבצע $1 כדי לצפות בדפים אחרים.",
@@ -518,9 +509,20 @@
"semiprotectedpagewarning" => "'''הערה:''' דף זה ננעל כך שרק משתמשים רשומים יכולים לערוך אותו.",
"templatesused" => "תבניות המופיעות בדף זה:",
"edittools" => "<!-- הטקסט הנכתב כאן יוצג מתחת לטפסי עריכת דפים והעלאת קבצים, ולפיכך ניתן לכתוב להציג בו תווים קשים לכתיבה, קטעים מוכנים של טקסט ועוד. -->",
-"nocreatetitle" => "יצירת הדפים הוגבלה",
-"nocreatetext" => "אתר זה מגביל את האפשרות ליצור דפים חדשים. באפשרותכם לחזור אחורה ולערוך דף קיים, או [[{{ns:special}}:Userlogin|להיכנס לחשבון]].",
+# Read-only pages
+"viewsource" => "הצג מקור",
+"viewsourcefor" => "לדף $1",
+"protectedtext" => "דף זה הינו '''דף מוגן''' ולא ניתן לערוך אותו. ישנן מספר סיבות אפשריות להגנה כזו.",
+"protectedtextanon" => "{{int:protectedtext}}",
+"editrestricted" => "אינכם מורשים לערוך דפים באתר זה.",
+"editrestrictedanon" => "עליכם [[{{ns:special}}:Userlogin|להיכנס לחשבון]] כדי לערוך דפים.",
+"editemailconfirm" => 'עליכם לאמת את כתובת הדוא"ל שלכם ב[[{{ns:special}}:Preferences|העדפות המשתמש]] כדי לערוך דפים.',
+"editemailconfirmanon" => 'עליכם [[{{ns:special}}:Userlogin|להיכנס לחשבון]] ולאמת את כתובת הדוא"ל שלכם ב[[{{ns:special}}:Preferences|העדפות המשתמש]] כדי לערוך דפים.',
+"createrestricted" => "אינכם מורשים ליצור דפים חדשים באתר זה.",
+"createrestrictedanon" => "עליכם [[{{ns:special}}:Userlogin|להיכנס לחשבון]] כדי ליצור דפים חדשים.",
+"viewsourcetext" => "באפשרותכם לצפות בטקסט המקור של הדף, ואף להעתיקו:",
+
# History pages
"revhistory" => "היסטוריית שינויים",
"nohistory" => "אין היסטוריית שינויים עבור דף זה",

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1469
Default Alt Text
1.patch (15 KB)

Event Timeline