Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -291,7 +291,7 @@ |
292 | 292 | $wgAvailableRights[] = 'stablesettings'; |
293 | 293 | |
294 | 294 | # Bump this number every time you change flaggedrevs.css/flaggedrevs.js |
295 | | -$wgFlaggedRevStyleVersion = 60; |
| 295 | +$wgFlaggedRevStyleVersion = 61; |
296 | 296 | |
297 | 297 | $wgExtensionFunctions[] = 'efLoadFlaggedRevs'; |
298 | 298 | |
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -1563,7 +1563,8 @@ |
1564 | 1564 | } else { |
1565 | 1565 | # If disable, use the current flags; if none, then use the min flag. |
1566 | 1566 | $i = $disabled ? $selected : $minLevel; |
1567 | | - $attribs = array( 'class' => "fr-rating-option-$i", 'onchange' => "updateRatingForm()" ) + $toggle; |
| 1567 | + $attribs = array( 'class' => "fr-rating-option-$i", 'onchange' => "updateRatingForm()" ); |
| 1568 | + $attribs = $attribs + $toggle + array('value' => $minLevel); |
1568 | 1569 | $form .= Xml::checkLabel( wfMsg( "revreview-$label[$i]" ), "wp$quality", "wp$quality", |
1569 | 1570 | ($selected == $i), $attribs ) . "\n"; |
1570 | 1571 | } |
Index: trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php |
— | — | @@ -759,16 +759,19 @@ |
760 | 760 | } |
761 | 761 | |
762 | 762 | /** |
763 | | - * Returns true if a user can do something |
| 763 | + * Returns true if a user can set $tag to $value. |
764 | 764 | * @param string $tag |
765 | 765 | * @param int $value |
| 766 | + * @param array $config (optional page config) |
766 | 767 | * @returns bool |
767 | 768 | */ |
768 | | - public static function userCan( $tag, $value, $config = array() ) { |
| 769 | + public static function userCan( $tag, $value, $config = null ) { |
769 | 770 | global $wgFlagRestrictions, $wgUser; |
770 | | - # Levels may not apply for some pages |
771 | | - if( $value > 0 && !self::levelAvailable( $tag, $value, $config ) ) |
| 771 | + # Levels may not apply for some pages. |
| 772 | + # Skip this check if $config is not given. |
| 773 | + if( !is_null($config) && !self::levelAvailable($tag,$value,$config) ) { |
772 | 774 | return false; |
| 775 | + } |
773 | 776 | # No restrictions -> full access |
774 | 777 | if( !isset($wgFlagRestrictions[$tag]) ) |
775 | 778 | return true; |
— | — | @@ -794,30 +797,33 @@ |
795 | 798 | * @param array $config, visibility settings |
796 | 799 | * @returns bool |
797 | 800 | */ |
798 | | - public static function userCanSetFlags( $flags, $oldflags = array(), $config = array() ) { |
| 801 | + public static function userCanSetFlags( $flags, $oldflags = array(), $config = null ) { |
799 | 802 | global $wgUser; |
800 | | - if( !$wgUser->isAllowed('review') ) { |
801 | | - return false; |
802 | | - } |
| 803 | + if( !$wgUser->isAllowed('review') ) |
| 804 | + return false; // User is not able to review pages |
803 | 805 | # Check if all of the required site flags have a valid value |
804 | 806 | # that the user is allowed to set. |
805 | 807 | foreach( FlaggedRevs::getDimensions() as $qal => $levels ) { |
806 | 808 | $level = isset($flags[$qal]) ? $flags[$qal] : 0; |
807 | 809 | $highest = count($levels) - 1; // highest valid level |
808 | 810 | if( !self::userCan($qal,$level,$config) ) { |
809 | | - return false; |
| 811 | + return false; // user cannot set proposed flag |
810 | 812 | } elseif( isset($oldflags[$qal]) && !self::userCan($qal,$oldflags[$qal]) ) { |
811 | | - return false; |
| 813 | + return false; // user cannot change old flag |
812 | 814 | } elseif( $level < 0 || $level > $highest ) { |
813 | | - return false; |
| 815 | + return false; // flag range is invalid |
814 | 816 | } |
815 | 817 | } |
816 | 818 | return true; |
817 | 819 | } |
818 | 820 | |
| 821 | + // Check if a given level for a tag is available in $config |
819 | 822 | public static function levelAvailable( $tag, $val, $config ) { |
820 | 823 | global $wgFlagAvailability; |
821 | | - if( !array_key_exists('select',$config) ) return true; |
| 824 | + if( $val == 0 ) |
| 825 | + return true; // unreviewed is always applicable |
| 826 | + if( !array_key_exists('select',$config) ) |
| 827 | + return true; // missing config |
822 | 828 | if( isset($wgFlagAvailability[$tag]) && isset($wgFlagAvailability[$tag][$val]) ) { |
823 | 829 | $precedence = $wgFlagAvailability[$tag][$val]; |
824 | 830 | return ( $config['select'] === $precedence ); |
Index: trunk/extensions/FlaggedRevs/flaggedrevs.js |
— | — | @@ -144,7 +144,7 @@ |
145 | 145 | } else if( inputs[i].type == "submit" ) { |
146 | 146 | inputs[i].value = wgAjaxReview.sendingMsg; |
147 | 147 | } else if( inputs[i].type == "checkbox" ) { |
148 | | - args.push( inputs[i].name + "|" + (inputs[i].checked ? 1 : 0) ); |
| 148 | + args.push( inputs[i].name + "|" + (inputs[i].checked ? inputs[i].value : 0) ); |
149 | 149 | } else if( inputs[i].type != "radio" || inputs[i].checked ) { |
150 | 150 | args.push( inputs[i].name + "|" + inputs[i].value ); |
151 | 151 | } |