http://www.mediawiki.org/wiki/Special:Code/MediaWiki/66575
Revision: 66575 Author: aaron Date: 2010-05-17 18:48:37 +0000 (Mon, 17 May 2010) Log Message: ----------- * Renamed protect level element * Cleaned up protection hooks * Fixed code comments Modified Paths: -------------- trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php trunk/extensions/FlaggedRevs/FlaggedRevs.php trunk/extensions/FlaggedRevs/forms/FlaggedRevsConfigForm.php trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php Modified: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php =================================================================== --- trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php 2010-05-17 18:37:49 UTC (rev 66574) +++ trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php 2010-05-17 18:48:37 UTC (rev 66575) @@ -2076,7 +2076,7 @@ // Code stolen from Stabilization (which was stolen from ProtectionForm) public static function onProtectionForm( $article, &$output ) { global $wgUser, $wgRequest, $wgLang; - if ( !FlaggedRevs::useProtectionLevels() || !$article->exists() ) { + if ( !$article->exists() ) { return true; // nothing to do } elseif ( !FlaggedRevs::inReviewNamespace( $article->getTitle() ) ) { return true; // not a reviewable page @@ -2091,7 +2091,7 @@ $oldExpirySelect = ( $config['expiry'] == 'infinity' ) ? 'infinite' : 'existing'; # Load requested restriction level, default to current level... - $restriction = $wgRequest->getVal( 'mwStabilityConfig', + $restriction = $wgRequest->getVal( 'mwStabilityLevel', FlaggedRevs::getProtectionLevel( $config ) ); # Load the requested expiry time (dropdown) $expirySelect = $wgRequest->getVal( 'mwStabilizeExpirySelection', $oldExpirySelect ); @@ -2110,8 +2110,8 @@ array_unshift( $effectiveLevels, "none" ); # Show all restriction levels in a <select>... $attribs = array( - 'id' => 'mwStabilityConfig', - 'name' => 'mwStabilityConfig', + 'id' => 'mwStabilityLevel', + 'name' => 'mwStabilityLevel', 'size' => count( $effectiveLevels ), ) + $disabledAttrib; $output .= Xml::openElement( 'select', $attribs ); @@ -2203,7 +2203,7 @@ // Add stability log extract to protection form public static function insertStabilityLog( $article, $out ) { - if ( !FlaggedRevs::useProtectionLevels() || !$article->exists() ) { + if ( !$article->exists() ) { return true; // nothing to do } else if ( !FlaggedRevs::inReviewNamespace( $article->getTitle() ) ) { return true; // not a reviewable page @@ -2217,7 +2217,7 @@ // Update stability config from request public static function onProtectionSave( $article, &$errorMsg ) { global $wgUser, $wgRequest; - if ( !FlaggedRevs::useProtectionLevels() || !$article->exists() ) { + if ( !$article->exists() ) { return true; // simple custom levels set for action=protect } elseif ( !FlaggedRevs::inReviewNamespace( $article->getTitle() ) ) { return true; // not a reviewable page @@ -2226,17 +2226,16 @@ } $form = new PageStabilityProtectForm(); $form->setTarget( $article->getTitle() ); // target page + $permission = $wgRequest->getVal( 'mwStabilityLevel' ); + if ( $permission == "none" ) { + $permission = ''; // 'none' => '' + } + $form->setAutoreview( $permission ); // protection level (autoreview restriction) $form->setWatchThis( null ); // protection form already has a watch check $form->setReason( $wgRequest->getText( 'mwProtect-reason' ) ); // manual $form->setReasonSelection( $wgRequest->getVal( 'wpProtectReasonSelection' ) ); // dropdown $form->setExpiry( $wgRequest->getVal( 'mwStabilizeExpiryOther' ) ); // manual $form->setExpirySelection( $wgRequest->getVal( 'mwStabilizeExpirySelection' ) ); // dropdown - # Fill in config from the protection level... - $permission = $wgRequest->getVal( 'mwStabilityConfig' ); - if ( $permission == "none" ) { - $permission = ''; // 'none' => '' - } - $form->setAutoreview( $permission ); // autoreview restriction $form->setWasPosted( $wgRequest->wasPosted() ); // double-check $status = $form->handleParams(); if ( $status === true ) { Modified: trunk/extensions/FlaggedRevs/FlaggedRevs.php =================================================================== --- trunk/extensions/FlaggedRevs/FlaggedRevs.php 2010-05-17 18:37:49 UTC (rev 66574) +++ trunk/extensions/FlaggedRevs/FlaggedRevs.php 2010-05-17 18:48:37 UTC (rev 66575) @@ -421,9 +421,6 @@ $wgHooks['PageHistoryBeforeList'][] = 'FlaggedRevsHooks::addToHistView'; # Add review form and visiblity settings link $wgHooks['SkinAfterContent'][] = 'FlaggedRevsHooks::onSkinAfterContent'; -# Add protection form field -$wgHooks['ProtectionForm::buildForm'][] = 'FlaggedRevsHooks::onProtectionForm'; -$wgHooks['ProtectionForm::showLogExtract'][] = 'FlaggedRevsHooks::insertStabilityLog'; # Mark items in page history $wgHooks['PageHistoryPager::getQueryInfo'][] = 'FlaggedRevsHooks::addToHistQuery'; $wgHooks['PageHistoryLineEnding'][] = 'FlaggedRevsHooks::addToHistLine'; @@ -485,8 +482,6 @@ # User edit tallies $wgHooks['ArticleRollbackComplete'][] = 'FlaggedRevsHooks::incrementRollbacks'; $wgHooks['NewRevisionFromEditComplete'][] = 'FlaggedRevsHooks::incrementReverts'; -# Save stability settings -$wgHooks['ProtectionForm::save'][] = 'FlaggedRevsHooks::onProtectionSave'; # Extra cache updates for stable versions $wgHooks['HTMLCacheUpdate::doUpdate'][] = 'FlaggedRevsHooks::doCacheUpdate'; # Updates stable version tracking data @@ -533,6 +528,13 @@ if ( !empty( $wgFlaggedRevsVisible ) ) { $wgHooks['getUserPermissionsErrors'][] = 'FlaggedRevsHooks::userCanView'; } + if ( FlaggedRevs::useProtectionLevels() ) { + # Add protection form field + $wgHooks['ProtectionForm::buildForm'][] = 'FlaggedRevsHooks::onProtectionForm'; + $wgHooks['ProtectionForm::showLogExtract'][] = 'FlaggedRevsHooks::insertStabilityLog'; + # Save stability settings + $wgHooks['ProtectionForm::save'][] = 'FlaggedRevsHooks::onProtectionSave'; + } } # ####### END HOOK TRIGGERED FUNCTIONS ######### Modified: trunk/extensions/FlaggedRevs/forms/FlaggedRevsConfigForm.php =================================================================== --- trunk/extensions/FlaggedRevs/forms/FlaggedRevsConfigForm.php 2010-05-17 18:37:49 UTC (rev 66574) +++ trunk/extensions/FlaggedRevs/forms/FlaggedRevsConfigForm.php 2010-05-17 18:48:37 UTC (rev 66575) @@ -130,7 +130,7 @@ $ok = $this->handlePostedParams(); } if ( $ok === true && $this->wasPosted ) { - $this->submitLock = 0; + $this->submitLock = 0; // allow calling of submit() } return $ok; } @@ -163,7 +163,7 @@ } /* - * Gets the current config expiry in GTM (or 'infinite') + * Gets the current config expiry in GMT (or 'infinite') * @return string */ public function getOldExpiryGMT() { @@ -598,7 +598,7 @@ // Checks if new config is different than the existing row protected function configIsDifferent( $oldRow, $override, $autoreview, $dbExpiry ) { - if( !$oldRow ) { + if ( !$oldRow ) { return true; // no previous config } # For protection config, just ignore the fpc_select column Modified: trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php =================================================================== --- trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php 2010-05-17 18:37:49 UTC (rev 66574) +++ trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php 2010-05-17 18:48:37 UTC (rev 66575) @@ -57,7 +57,7 @@ # Param for sites with binary flagging $this->approve = $wgRequest->getCheck( 'wpApprove' ); $this->unapprove = $wgRequest->getCheck( 'wpUnapprove' ); - # Patrol the edit if requested... + # Review the edit if requested... $this->markReviewed(); } _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs