r57302 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57301‎ | r57302 | r57303 >
Date:19:03, 2 October 2009
Author:aaron
Status:ok
Tags:
Comment:
Follow up r57300: fixed preloaded of protection level
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -57,11 +57,12 @@
5858 self::$minSL[$tag] = 1;
5959 }
6060 global $wgFlaggedRevsProtectLevels;
61 - foreach( $wgFlaggedRevsProtectLevels as $level => $config ) {
 61+ foreach( $wgFlaggedRevsProtectLevels as $level => &$config ) {
6262 # Sanity checks
6363 if( !isset($config['select']) || !isset($config['override']) || !isset($config['autoreview']) ) {
6464 throw new MWException( 'FlaggedRevs given incomplete $wgFlaggedRevsProtectLevels value!' );
6565 }
 66+ $config['override'] = intval( $config['override'] ); // Type cleanup
6667 }
6768 self::$loaded = true;
6869 }
@@ -156,8 +157,24 @@
157158 */
158159 public static function getProtectionLevels() {
159160 global $wgFlaggedRevsProtectLevels;
 161+ self::load();
160162 return $wgFlaggedRevsProtectLevels;
161163 }
 164+
 165+ /**
 166+ * Find what protection level a config is in
 167+ * @param array $config
 168+ * @returns mixed (array/string)
 169+ */
 170+ public static function getProtectionLevel( $config ) {
 171+ global $wgFlaggedRevsProtectLevels;
 172+ self::load();
 173+ unset( $config['expiry'] );
 174+ foreach( $wgFlaggedRevsProtectLevels as $level => $settings ) {
 175+ if( $config == $settings ) return $level;
 176+ }
 177+ return "none";
 178+ }
162179
163180 /**
164181 * Should comments be allowed on pages and forms?
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -1815,14 +1815,14 @@
18161816 # Can the user actually do anything?
18171817 $isAllowed = $wgUser->isAllowed('stablesettings');
18181818 $disabledAttrib = !$isAllowed ? array( 'disabled' => 'disabled' ) : array();
1819 - # Load request params...
1820 - $selected = $wgRequest->getVal( 'wpStabilityConfig' );
1821 - $expiry = $wgRequest->getText( 'mwStabilize-expiry' );
1822 - $reviewThis = $wgRequest->getBool( 'wpReviewthis', true );
18231819 # Get the current config/expiry
18241820 $config = FlaggedRevs::getPageVisibilitySettings( $article->getTitle(), true );
18251821 $oldExpiry = $config['expiry'] !== 'infinity' ?
18261822 wfTimestamp( TS_RFC2822, $config['expiry'] ) : 'infinite';
 1823+ # Load request params...
 1824+ $selected = $wgRequest->getVal( 'wpStabilityConfig', FlaggedRevs::getProtectionLevel($config) );
 1825+ $expiry = $wgRequest->getText( 'mwStabilize-expiry' );
 1826+ $reviewThis = $wgRequest->getBool( 'wpReviewthis', true );
18271827 # Add some script for expiry dropdowns
18281828 $wgOut->addScript(
18291829 "<script type=\"text/javascript\">

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r57300* Added $wgFlaggedRevsProtectLevels to allow for site defined review "protect...aaron18:46, 2 October 2009

Status & tagging log