/**@{{
* @private
*/
- var $mComment; //!<
- var $mContent; //!<
- var $mContentLoaded; //!<
- var $mCounter; //!<
- var $mForUpdate; //!<
- var $mGoodAdjustment; //!<
- var $mLatest; //!<
- var $mMinorEdit; //!<
- var $mOldId; //!<
- var $mRedirectedFrom; //!<
- var $mRedirectUrl; //!<
- var $mRevIdFetched; //!<
- var $mRevision; //!<
- var $mTimestamp; //!<
- var $mTitle; //!<
- var $mTotalAdjustment; //!<
- var $mTouched; //!<
- var $mUser; //!<
- var $mUserText; //!<
- var $mRedirectTarget; //!<
+ var $mComment; //!<
+ var $mContent; //!<
+ var $mContentLoaded; //!<
+ var $mCounter; //!<
+ var $mForUpdate; //!<
+ var $mGoodAdjustment; //!<
+ var $mLatest; //!<
+ var $mMinorEdit; //!<
+ var $mOldId; //!<
+ var $mRedirectedFrom; //!<
+ var $mRedirectUrl; //!<
+ var $mRevIdFetched; //!<
+ var $mRevision; //!<
+ var $mTimestamp; //!<
+ var $mTitle; //!<
+ var $mTotalAdjustment; //!<
+ var $mTouched; //!<
+ var $mUser; //!<
+ var $mUserText; //!<
+ var $mRedirectTarget; //!<
var $mIsRedirect;
/**@}}*/
*/
function isRedirect( $text = false ) {
if ( $text === false ) {
- if ( $this->mDataLoaded )
+ if ( $this->mDataLoaded )
return $this->mIsRedirect;
-
+
// Apparently loadPageData was never called
$this->loadContent();
$titleObj = Title::newFromRedirect( $this->fetchContent() );
$this->viewUpdates();
wfProfileOut( __METHOD__ );
}
-
+
protected function viewRedirect( $target, $overwriteSubtitle = true, $forceKnown = false ) {
global $wgParser, $wgOut, $wgContLang, $wgStylePath, $wgUser;
-
+
# Display redirect
$imageDir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
$imageUrl = $wgStylePath.'/common/images/redirect' . $imageDir . '.png';
-
+
if( $overwriteSubtitle ) {
$wgOut->setSubtitle( wfMsgHtml( 'redirectpagesub' ) );
}
$wgOut->addHTML( '<img src="'.$imageUrl.'" alt="#REDIRECT " />' .
'<span class="redirectText">'.$link.'</span>' );
-
+
}
function addTrackbacks() {
# Update page
$ok = $this->updateRevisionOn( $dbw, $revision, $lastRevision );
-
+
wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, $baseRevId) );
if( !$ok ) {
# Update the page record with revision data
$this->updateRevisionOn( $dbw, $revision, 0 );
-
+
wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, false) );
if( !( $flags & EDIT_SUPPRESS_RC ) ) {
}
$comment = $wgContLang->ucfirst( wfMsgForContent( $comment_type, $this->mTitle->getPrefixedText() ) );
+ # Check if all groups that have required right to edit also can protect pages
+ # Otherwise, people who cannot normally protect can "protect" pages via transclusion
foreach( $limit as $action => $restrictions ) {
- # Check if the group level required to edit also can protect pages
- # Otherwise, people who cannot normally protect can "protect" pages via transclusion
- $cascade = ( $cascade && isset($wgGroupPermissions[$restrictions]['protect']) &&
- $wgGroupPermissions[$restrictions]['protect'] );
+ # 'sysop' is checked as 'protect', so it is always allowed
+ if ($cascade && ( $restrictions != 'sysop' ) ){
+ foreach( $wgGroupPermissions as $group => $rights ){
+ if( isset( $rights[$restrictions] ) && $rights[$restrictions] && !( isset( $rights['protect'] ) && $rights['protect'] ) ){
+ $cascade = false;
+ break( 2 );
+ }
+ }
+ }
}
$cascade_description = '';
'page_latest' => $nullRevId
), array( /* WHERE */
'page_id' => $id
- ), 'Article::protect'
+ ), __METHOD__
);
-
+
wfRunHooks( 'NewRevisionFromEditComplete', array($this, $nullRevision, false) );
wfRunHooks( 'ArticleProtectComplete', array( &$this, &$wgUser, $limit, $reason ) );
function doDelete( $reason, $suppress = false ) {
global $wgOut, $wgUser;
wfDebug( __METHOD__."\n" );
-
+
$id = $this->getId();
if (wfRunHooks('ArticleDelete', array(&$this, &$wgUser, &$reason))) {
if( empty( $summary ) ){
$summary = wfMsgForContent( 'revertpage' );
}
-
+
# Allow the custom summary to use the same args as the default message
$args = array(
$target->getUserText(), $from, $s->rev_id,
$wgLang->timeanddate(wfTimestamp(TS_MW, $s->rev_timestamp), true),
$current->getId(), $wgLang->timeanddate($current->getTimestamp())
);
- $summary = wfMsgReplaceArgs( $summary, $args );
+ $summary = wfMsgReplaceArgs( $summary, $args );
# Save
$flags = EDIT_UPDATE;
. $wgUser->getSkin()->userToolLinks( $target->getUser(), $target->getUserText() );
$wgOut->addHtml( wfMsgExt( 'rollback-success', array( 'parse', 'replaceafter' ), $old, $new ) );
$wgOut->returnToMain( false, $this->mTitle );
-
+
if( !$wgRequest->getBool( 'hidediff', false ) ) {
$de = new DifferenceEngine( $this->mTitle, $current->getId(), 'next', false, true );
$de->showDiff( '', '' );
$revision->insertOn( $dbw );
$this->updateRevisionOn( $dbw, $revision );
$dbw->commit();
-
+
wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, false) );
wfProfileOut( __METHOD__ );
global $wgRequest, $wgOut;
if( $wgRequest->wasPosted() ) {
if( $this->save() ) {
- $article = new Article( $this->mTitle );
- $q = $article->isRedirect() ? 'redirect=no' : '';
+ $q = $this->mArticle->isRedirect() ? 'redirect=no' : '';
$wgOut->redirect( $this->mTitle->getFullUrl( $q ) );
}
} else {
}
- # They shouldn't be able to do this anyway, but just to make sure, ensure that cascading restrictions aren't being applied
- # to a semi-protected page.
- global $wgGroupPermissions;
+ # NOTE : verification of cascading protection in semi-protection mode
+ # is in Article::updateRestriction()
- $edit_restriction = $this->mRestrictions['edit'];
-
- if ($this->mCascade && ($edit_restriction != 'protect') &&
- !(isset($wgGroupPermissions[$edit_restriction]['protect']) && $wgGroupPermissions[$edit_restriction]['protect'] ) )
- $this->mCascade = false;
-
- if ($this->mTitle->exists()) {
+ if( $this->mTitle->exists() ){
$ok = $this->mArticle->updateRestrictions( $this->mRestrictions, $this->mReason, $this->mCascade, $expiry );
} else {
$ok = $this->mTitle->updateTitleProtection( $this->mRestrictions['create'], $this->mReason, $expiry );
$script = 'var wgCascadeableLevels=';
$CascadeableLevels = array();
foreach( $wgRestrictionLevels as $key ) {
- if ( (isset($wgGroupPermissions[$key]['protect']) && $wgGroupPermissions[$key]['protect']) || $key == 'protect' ) {
+ $canCascade = true;
+ $check = $key == 'sysop' ? 'protect' : $key;
+ foreach( $wgGroupPermissions as $group => $rights ){
+ if( isset( $rights[$check] ) && $rights[$check] && !( isset( $rights['protect'] ) && $rights['protect'] ) ){
+ $canCascade = false;
+ break;
+ }
+ }
+ if( $key != '' && $canCascade ) {
$CascadeableLevels[] = "'" . Xml::escapeJsString( $key ) . "'";
}
}
$right = 'protect';
}
if( '' != $right && !$user->isAllowed( $right ) ) {
- //Users with 'editprotected' permission can edit protected pages
- if( $action=='edit' && $user->isAllowed( 'editprotected' ) ) {
- //Users with 'editprotected' permission cannot edit protected pages
- //with cascading option turned on.
- if($this->mCascadeRestriction) {
- $errors[] = array( 'protectedpagetext', $right );
- } else {
- //Nothing, user can edit!
- }
+ // Users with 'editprotected' permission can edit protected
+ // pages if protection is not with cascading option turned on.
+ if( $action=='edit' && $user->isAllowed( 'editprotected' ) && !$this->areRestrictionsCascading() ) {
+ // Nothing, user can edit!
} else {
$errors[] = array( 'protectedpagetext', $right );
}
wfProfileIn( __METHOD__ );
- $dbr = wfGetDb( DB_SLAVE );
+ $dbr = wfGetDB( DB_SLAVE );
if ( $this->getNamespace() == NS_IMAGE ) {
$tables = array ('imagelinks', 'page_restrictions');
if ($this->mLatestID !== false)
return $this->mLatestID;
- $db = ($flags & GAID_FOR_UPDATE) ? wfGetDB(DB_MASTER) : wfGetDB(DB_SLAVE);
+ $db = ($flags & GAID_FOR_UPDATE) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
return $this->mLatestID = $db->selectField( 'revision',
"max(rev_id)",
array('rev_page' => $this->getArticleID($flags)),