/**@{{
* @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
+ # Only restrictions with the 'protect' right can cascade...
# Otherwise, people who cannot normally protect can "protect" pages via transclusion
- foreach( $limit as $action => $restrictions ) {
- # '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 );
- }
- }
+ foreach( $limit as $action => $restriction ) {
+ # FIXME: can $restriction be an array or what? (same as fixme above)
+ if( $restriction != 'protect' && $restriction != 'sysop' ) {
+ $cascade = false;
+ break;
}
}
'page_latest' => $nullRevId
), array( /* WHERE */
'page_id' => $id
- ), __METHOD__
+ ), 'Article::protect'
);
-
+
wfRunHooks( 'NewRevisionFromEditComplete', array($this, $nullRevision, false) );
wfRunHooks( 'ArticleProtectComplete', array( &$this, &$wgUser, $limit, $reason ) );
# Update the protection log
$log = new LogPage( 'protect' );
if( $protect ) {
- $log->addEntry( $modified ? 'modify' : 'protect', $this->mTitle, trim( $reason . " [$updated]$cascade_description$expiry_description" ) );
+ $log->addEntry( $modified ? 'modify' : 'protect', $this->mTitle,
+ trim( $reason . " [$updated]$cascade_description$expiry_description" ) );
} else {
$log->addEntry( 'unprotect', $this->mTitle, $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() ) {
- $q = $this->mArticle->isRedirect() ? 'redirect=no' : '';
+ $article = new Article( $this->mTitle );
+ $q = $article->isRedirect() ? 'redirect=no' : '';
$wgOut->redirect( $this->mTitle->getFullUrl( $q ) );
}
} else {
}
- # NOTE : verification of cascading protection in semi-protection mode
- # is in Article::updateRestriction()
+ # 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;
- if( $this->mTitle->exists() ){
+ $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()) {
$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 ) {
- $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 ) {
+ if ( (isset($wgGroupPermissions[$key]['protect']) && $wgGroupPermissions[$key]['protect']) || $key == 'protect' ) {
$CascadeableLevels[] = "'" . Xml::escapeJsString( $key ) . "'";
}
}
$right = 'protect';
}
if( '' != $right && !$user->isAllowed( $right ) ) {
- // 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!
+ //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!
+ }
} 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)),