r60304 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60303‎ | r60304 | r60305 >
Date:05:22, 23 December 2009
Author:aaron
Status:ok
Tags:
Comment:
* Cleanup up getLevelTier()
* Removed some code duplication
* Comment tweaks
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -1213,41 +1213,52 @@
12141214
12151215 /**
12161216 * @param Array $flags
1217 - * @return bool, is this revision at quality condition?
 1217+ * @return bool, is this revision at basic review condition?
12181218 */
 1219+ public static function isSighted( $flags ) {
 1220+ return self::tagsAtLevel( $flags, self::$minSL );
 1221+ }
 1222+
 1223+ /**
 1224+ * @param Array $flags
 1225+ * @return bool, is this revision at quality review condition?
 1226+ */
12191227 public static function isQuality( $flags ) {
1220 - if( empty($flags) ) return false;
1221 - foreach( self::$dimensions as $f => $x ) {
1222 - if( !isset($flags[$f]) || self::$minQL[$f] > $flags[$f] )
1223 - return false;
1224 - }
1225 - return true;
 1228+ return self::tagsAtLevel( $flags, self::$minQL );
12261229 }
12271230
12281231 /**
12291232 * @param Array $flags
1230 - * @return bool, is this revision at optimal condition?
 1233+ * @return bool, is this revision at pristine review condition?
12311234 */
12321235 public static function isPristine( $flags ) {
 1236+ return self::tagsAtLevel( $flags, self::$minPL );
 1237+ }
 1238+
 1239+ // Checks if $flags meets $reqFlagLevels
 1240+ protected static function tagsAtLevel( $flags, $reqFlagLevels ) {
12331241 if( empty($flags) ) return false;
12341242 foreach( self::$dimensions as $f => $x ) {
1235 - if( !isset($flags[$f]) || self::$minPL[$f] > $flags[$f] )
 1243+ if( !isset($flags[$f]) || $reqFlagLevels[$f] > $flags[$f] )
12361244 return false;
12371245 }
12381246 return true;
12391247 }
12401248
12411249 /**
 1250+ * Get the quality tier of review flags
12421251 * @param Array $flags
1243 - * @return int, flagging tier
 1252+ * @return int, flagging tier (-1 for non-sighted)
12441253 */
12451254 public static function getLevelTier( $flags ) {
1246 - if( self::isPristine($flags ) )
 1255+ if( self::isPristine( $flags ) )
12471256 return FR_PRISTINE;
1248 - elseif( self::isQuality($flags ) )
 1257+ elseif( self::isQuality( $flags ) )
12491258 return FR_QUALITY;
 1259+ elseif( self::isSighted( $flags ) )
 1260+ return FR_SIGHTED;
12501261 else
1251 - return 0;
 1262+ return -1;
12521263 }
12531264
12541265 /**

Status & tagging log