$this->summary = '';
$this->textbox1 = $this->getContent();
if ( !$this->mArticle->exists() && $this->mArticle->mTitle->getNamespace() == NS_MEDIAWIKI )
- $this->textbox1 = wfMsgWeirdKey( $this->mArticle->mTitle->getText() ) ;
+ $this->textbox1 = wfMsgWeirdKey( $this->mArticle->mTitle->getText() );
wfProxyCheck();
}
}
}
}
-
+
+ $cascadeSource = $this->mTitle->getCascadeProtectionSource();
+
if( $this->mTitle->isProtected( 'edit' ) ) {
# Is the protection due to the namespace, e.g. interface text?
if( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
if( wfEmptyMsg( 'semiprotectedpagewarning', $notice ) || $notice == '-' ) {
$notice = '';
}
+ } elseif ($cascadeSource) {
+ # Cascaded protection: warn the user.
+ $cascadeSourceTitle = Title::newFromId($cascadeSource);
+ $cascadeSourceText = $cascadeSourceTitle->getPrefixedText();
+
+ $notice = wfMsgForContent( 'cascadeprotectedwarning', $cascadeSourceText );
} else {
# No; regular protection
$notice = wfMsg( 'protectedpagewarning' );
var $mLatestID; # ID of most recent revision
var $mRestrictions; # Array of groups allowed to edit this article
var $mCascadeRestriction;
+ var $mCascadeRestrictionSource;
var $mRestrictionsLoaded; # Boolean for initialisation on demand
var $mPrefixedText; # Text form including namespace/interwiki, initialised on demand
var $mDefaultNamespace; # Namespace index when there is no namespace
*/
function isProtected( $action = '' ) {
global $wgRestrictionLevels;
+
if ( NS_SPECIAL == $this->mNamespace ) { return true; }
+
+ if ( $this->getCascadeProtectionSource() ) { return true; }
if( $action == 'edit' || $action == '' ) {
$r = $this->getRestrictions( 'edit' );
return false;
}
- if ( ( $this->isCascadeProtectedPage() ) ||
- ($this->getNamespace() == NS_IMAGE && $this->isCascadeProtectedImage() ) ) {
+ if ( $this->getCascadeProtectionSource() ) {
# We /could/ use the protection level on the source page, but it's fairly ugly
# as we have to establish a precedence hierarchy for pages included by multiple
# cascade-protected pages. So just restrict it to people with 'protect' permission,
}
/**
- * Cascading protects: Check if the current image is protected due to a cascading restriction
- *
- * @return bool If the current page is protected due to a cascading restriction.
- * @access public
- */
- function isCascadeProtectedImage() {
+ * Cascading protection: Get the source of any cascading restrictions on this page.
+ *
+ * @return int The page_id of the page from which cascading restrictions have come, or false for none.
+ * @access public
+ */
+ function getCascadeProtectionSource() {
+
+ if ( isset( $this->mCascadeSource ) ) {
+ return $this->mCascadeSource;
+ }
+
+ $source = NULL;
+
+ if ( $this->getNamespace() == NS_IMAGE ) {
+ $source = $this->getCascadeProtectedImageSource();
+ } else {
+ $source = $this->getCascadeProtectedPageSource();
+ }
+
+ $this->mCascadeSource = $source;
+
+ return $source;
+ }
+
+ /**
+ * Cascading protects: Check if the current image is protected due to a cascading restriction
+ *
+ * @return int The page_id of the page from which cascading restrictions have come, or false for none.
+ * @access public
+ */
+ function getCascadeProtectedImageSource() {
global $wgEnableCascadingProtection;
if (!$wgEnableCascadingProtection)
return false;
$dbr =& wfGetDb( DB_SLAVE );
- $cols = array( 'il_to' );
+ $cols = array( 'pr_page' );
$tables = array ('imagelinks', 'page_restrictions');
$where_clauses = array( 'il_to' => $this->getDBkey(), 'il_from=pr_page', 'pr_cascade' => 1 );
$res = $dbr->select( $tables, $cols, $where_clauses, __METHOD__);
if ($dbr->numRows($res)) {
+ $row = $dbr->fetchObject($res);
+ $culprit = $row->pr_page;
wfProfileOut(__METHOD__);
- return true;
+ return $culprit;
} else {
wfProfileOut(__METHOD__);
return false;
}
/**
- * Cascading protects: Check if the current page is protected due to a cascading restriction.
- *
- * @return bool if the current page is protected due to a cascading restriction
- * @access public
- */
- function isCascadeProtectedPage() {
+ * Cascading protects: Check if the current page is protected due to a cascading restriction.
+ *
+ * @return int The page_id of the page from which cascading restrictions have come, or false for none.
+ * @access public
+ */
+ function getCascadeProtectedPageSource() {
global $wgEnableCascadingProtection;
if (!$wgEnableCascadingProtection)
return false;
$dbr =& wfGetDb( DB_SLAVE );
- $cols = array( 'tl_namespace', 'tl_title' );
+ $cols = array( 'pr_page' );
$tables = array ('templatelinks', 'page_restrictions');
$where_clauses = array( 'tl_namespace' => $this->getNamespace(), 'tl_title' => $this->getDBkey(), 'tl_from=pr_page', 'pr_cascade' => 1 );
$res = $dbr->select( $tables, $cols, $where_clauses, __METHOD__);
if ($dbr->numRows($res)) {
+ $row = $dbr->fetchObject($res);
+ $culprit = $row->pr_page;
wfProfileOut(__METHOD__);
- return true;
+ return $culprit;
} else {
wfProfileOut(__METHOD__);
return false;
'protectedinterface' => 'This page provides interface text for the software, and is locked to prevent abuse.',
'editinginterface' => "'''Warning:''' You are editing a page which is used to provide interface text for the software. Changes to this page will affect the appearance of the user interface for other users.",
'sqlhidden' => '(SQL query hidden)',
+'cascadeprotected' => 'This page has been protected from editing, because it is included in [[$1]], which has been protected with the "cascading" option turned on.',
# Login and logout pages
#
the text into a text file and save it for later.</strong>',
'protectedpagewarning' => "<strong>WARNING: This page has been locked so that only users with sysop privileges can edit it.</strong>",
'semiprotectedpagewarning' => "'''Note:''' This page has been locked so that only registered users can edit it.",
+'cascadeprotectedwarning' => "<strong>WARNING: This page has been locked so that only users with sysop privileges can edit it, because it is included on [[$1]], which is protected with the 'cascading protection' option turned on.</strong>",
'templatesused' => 'Templates used on this page:',
'templatesusedpreview' => 'Templates used in this preview:',
'templatesusedsection' => 'Templates used in this section:',
'protect-text' => 'You may view and change the protection level here for the page <strong>$1</strong>.',
'protect-viewtext' => 'Your account does not have permission to change
page protection levels. Here are the current settings for the page <strong>$1</strong>:',
+'protect-cascadeon' => 'This page is currently subject to cascading protection, because it is included in [[$1]], which has been protected with the "cascading protection" option turned on. You can change the protection level for this page here, but it will not affect the cascading protection.',
'protect-default' => '(default)',
'protect-level-autoconfirmed' => 'Block unregistered users',
'protect-level-sysop' => 'Sysops only',