r66610 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66609‎ | r66610 | r66611 >
Date:14:16, 18 May 2010
Author:aaron
Status:ok
Tags:
Comment:
Removed unused $config param
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsXML.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/api/ApiReview.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/forms/PageStabilityForm.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -399,10 +399,9 @@
400400 * Returns true if a user can set $tag to $value.
401401 * @param string $tag
402402 * @param int $value
403 - * @param array $config (optional page config)
404403 * @returns bool
405404 */
406 - public static function userCanSetTag( $tag, $value, $config = null ) {
 405+ public static function userCanSetTag( $tag, $value ) {
407406 global $wgUser;
408407 # Sanity check tag and value
409408 $levels = self::getTagLevels( $tag );
@@ -435,10 +434,9 @@
436435 * to the given levels for each tag.
437436 * @param array $flags, suggested flags
438437 * @param array $oldflags, pre-existing flags
439 - * @param array $config, visibility settings
440438 * @returns bool
441439 */
442 - public static function userCanSetFlags( $flags, $oldflags = array(), $config = null ) {
 440+ public static function userCanSetFlags( $flags, $oldflags = array() ) {
443441 global $wgUser;
444442 if ( !$wgUser->isAllowed( 'review' ) )
445443 return false; // User is not able to review pages
@@ -447,12 +445,12 @@
448446 foreach ( self::getDimensions() as $qal => $levels ) {
449447 $level = isset( $flags[$qal] ) ? $flags[$qal] : 0;
450448 $highest = count( $levels ) - 1; // highest valid level
451 - if ( !self::userCanSetTag( $qal, $level, $config ) ) {
 449+ if ( !self::userCanSetTag( $qal, $level ) ) {
452450 return false; // user cannot set proposed flag
453451 } elseif ( isset( $oldflags[$qal] )
454452 && !self::userCanSetTag( $qal, $oldflags[$qal] ) )
455453 {
456 - return false; // user cannot change old flag ($config is ignored here)
 454+ return false; // user cannot change old flag
457455 }
458456 }
459457 return true;
Index: trunk/extensions/FlaggedRevs/forms/PageStabilityForm.php
@@ -1,4 +1,5 @@
22 <?php
 3+# (c) Aaron Schulz 2010 GPL
34 if ( !defined( 'MEDIAWIKI' ) ) {
45 echo "FlaggedRevs extension\n";
56 exit( 1 );
@@ -209,7 +210,7 @@
210211
211212 /**
212213 * Submit the form parameters for the page config to the DB.
213 - * Note: caller is responsible for permission checks.
 214+ * Note: caller is responsible for basic permission checks.
214215 *
215216 * @return mixed (true on success, error string on failure)
216217 */
Index: trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php
@@ -128,10 +128,8 @@
129129 }
130130 }
131131 }
132 - $fa = FlaggedArticle::getTitleInstance( $this->page );
133 - $this->config = $fa->getVisibilitySettings();
134132 # Check permissions and validate
135 - if ( !FlaggedRevs::userCanSetFlags( $this->dims, $this->oflags, $this->config ) ) {
 133+ if ( !FlaggedRevs::userCanSetFlags( $this->dims, $this->oflags ) ) {
136134 $wgOut->permissionRequired( 'badaccess-group0' );
137135 return;
138136 }
@@ -288,12 +286,10 @@
289287 if ( $form->validatedParams !== $k ) {
290288 return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' );
291289 }
292 - $fa = FlaggedArticle::getTitleInstance( $form->page );
293 - $form->config = $fa->getVisibilitySettings();
294290 # Get the revision's current flags, if any
295291 $form->oflags = FlaggedRevs::getRevisionTags( $form->page, $form->oldid );
296292 # Check tag permissions
297 - if ( !FlaggedRevs::userCanSetFlags( $form->dims, $form->oflags, $form->config ) ) {
 293+ if ( !FlaggedRevs::userCanSetFlags( $form->dims, $form->oflags ) ) {
298294 return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' );
299295 }
300296 list( $approved, $status ) = $form->submit();
@@ -334,7 +330,7 @@
335331 }
336332 # Double-check permissions
337333 if ( !$this->page->quickUserCan( 'edit' )
338 - || !FlaggedRevs::userCanSetFlags( $this->dims, $this->oflags, $this->config ) )
 334+ || !FlaggedRevs::userCanSetFlags( $this->dims, $this->oflags ) )
339335 {
340336 return array( $approved, false );
341337 }
Index: trunk/extensions/FlaggedRevs/FlaggedRevsXML.php
@@ -378,16 +378,15 @@
379379
380380 /**
381381 * @param array $flags, selected flags
382 - * @param array $config, page config
383382 * @param bool $disabled, form disabled
384383 * @param bool $reviewed, rev already reviewed
385384 * @returns string
386385 * Generates a main tag inputs (checkboxes/radios/selects) for review form
387386 */
388 - public static function ratingInputs( $flags, $config, $disabled, $reviewed ) {
 387+ public static function ratingInputs( $flags, $disabled, $reviewed ) {
389388 $form = '';
390389 # Get all available tags for this page/user
391 - list( $labels, $minLevels ) = self::ratingFormTags( $flags, $config );
 390+ list( $labels, $minLevels ) = self::ratingFormTags( $flags );
392391 if ( $labels === false ) {
393392 $disabled = true; // a tag is unsettable
394393 }
@@ -462,13 +461,13 @@
463462 return $form;
464463 }
465464
466 - protected static function ratingFormTags( $selected, $config ) {
 465+ protected static function ratingFormTags( $selected ) {
467466 $labels = array();
468467 $minLevels = array();
469468 # Build up all levels available to user
470469 foreach ( FlaggedRevs::getDimensions() as $tag => $levels ) {
471470 if ( isset( $selected[$tag] ) &&
472 - !FlaggedRevs::userCanSetTag( $tag, $selected[$tag], $config ) )
 471+ !FlaggedRevs::userCanSetTag( $tag, $selected[$tag] ) )
473472 {
474473 return array( false, false ); // form will have to be disabled
475474 }
@@ -476,7 +475,7 @@
477476 $minLevels[$tag] = false; // first non-zero level number
478477 foreach ( $levels as $i => $msg ) {
479478 # Some levels may be restricted or not applicable...
480 - if ( !FlaggedRevs::userCanSetTag( $tag, $i, $config ) ) {
 479+ if ( !FlaggedRevs::userCanSetTag( $tag, $i ) ) {
481480 continue; // skip this level
482481 } else if ( $i > 0 && !$minLevels[$tag] ) {
483482 $minLevels[$tag] = $i; // first non-zero level number
@@ -634,7 +633,6 @@
635634 # Do we need to get inclusion IDs from parser output?
636635 $getPOut = ( $templateIDs && $imageSHA1Keys );
637636
638 - $config = $article->getVisibilitySettings();
639637 # Variable for sites with no flags, otherwise discarded
640638 $approve = $wgRequest->getBool( 'wpApprove' );
641639 # See if the version being displayed is flagged...
@@ -697,7 +695,7 @@
698696
699697 # Add main checkboxes/selects
700698 $form .= Xml::openElement( 'span', array( 'id' => 'mw-fr-ratingselects' ) );
701 - $form .= FlaggedRevsXML::ratingInputs( $flags, $config, $disabled, (bool)$frev );
 699+ $form .= FlaggedRevsXML::ratingInputs( $flags, $disabled, (bool)$frev );
702700 $form .= Xml::closeElement( 'span' );
703701 # Add review notes input
704702 if ( FlaggedRevs::allowComments() && $wgUser->isAllowed( 'validate' ) ) {
Index: trunk/extensions/FlaggedRevs/api/ApiReview.php
@@ -75,11 +75,9 @@
7676
7777 // Check if user is even allowed to set the flags
7878 $form->oflags = FlaggedRevs::getRevisionTags( $title, $form->oldid );
79 - $fa = FlaggedArticle::getTitleInstance( $form->page );
80 - $form->config = $fa->getVisibilitySettings();
8179
8280 if ( !$title->quickUserCan( 'edit' )
83 - || !FlaggedRevs::userCanSetFlags( $form->dims, $form->oflags, $form->config ) )
 81+ || !FlaggedRevs::userCanSetFlags( $form->dims, $form->oflags ) )
8482 {
8583 $this->dieUsage( "You don't have the necessary rights to set the specified flags.", 'permissiondenied' );
8684 }

Status & tagging log