Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -144,6 +144,14 @@ |
145 | 145 | 'depth' => array( 'review' => 2 ), |
146 | 146 | 'style' => array( 'review' => 3 ), |
147 | 147 | ); |
| 148 | +# Use this to make levels of flags only appear if the page configured to |
| 149 | +# select the stable version in a certain way. Array of tags=>level=>config. |
| 150 | +$wgFlagAvailability = array(); |
| 151 | +/* (example usage) |
| 152 | +$wgFlagAvailability = array( |
| 153 | + 'style' => array( 1=>FLAGGED_VIS_LATEST, 2=>FLAGGED_VIS_QUALITY ) |
| 154 | +); |
| 155 | +*/ |
148 | 156 | |
149 | 157 | # Restriction levels for auto-review right at Stabilization page |
150 | 158 | $wgFlaggedRevsRestrictionLevels = array( '', 'sysop' ); |
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -1300,6 +1300,7 @@ |
1301 | 1301 | } |
1302 | 1302 | $skin = $wgUser->getSkin(); |
1303 | 1303 | |
| 1304 | + $config = $this->getVisibilitySettings(); |
1304 | 1305 | # Variable for sites with no flags, otherwise discarded |
1305 | 1306 | $approve = $wgRequest->getBool('wpApprove'); |
1306 | 1307 | # See if the version being displayed is flagged... |
— | — | @@ -1357,8 +1358,8 @@ |
1358 | 1359 | # else collect all quality levels of a flag current user can set |
1359 | 1360 | } else { |
1360 | 1361 | foreach( $levels as $i => $name ) { |
1361 | | - if( !RevisionReview::userCan($quality, $i) ) { |
1362 | | - break; |
| 1362 | + if( !RevisionReview::userCan($quality,$i,$config) ) { |
| 1363 | + continue; // skip this level |
1363 | 1364 | } |
1364 | 1365 | $label[$i] = $name; |
1365 | 1366 | } |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -922,7 +922,7 @@ |
923 | 923 | return array( 'select' => $select, 'override' => $override, |
924 | 924 | 'autoreview' => '', 'expiry' => 'infinity' ); |
925 | 925 | } |
926 | | - return array('select' => intval($row->fpc_select), 'override' => $row->fpc_override, |
| 926 | + return array( 'select' => intval($row->fpc_select), 'override' => $row->fpc_override, |
927 | 927 | 'autoreview' => $row->fpc_level, 'expiry' => $row->fpc_expiry ); |
928 | 928 | } |
929 | 929 | |
Index: trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php |
— | — | @@ -64,6 +64,7 @@ |
65 | 65 | $wgOut->addHTML( wfMsgExt('revreview-main',array('parse')) ); |
66 | 66 | return; |
67 | 67 | } |
| 68 | + # Get revision ID |
68 | 69 | $this->oldid = $wgRequest->getIntOrNull( 'oldid' ); |
69 | 70 | if( !$this->oldid ) { |
70 | 71 | $wgOut->showErrorPage( 'internalerror', 'revreview-revnotfound' ); |
— | — | @@ -104,8 +105,10 @@ |
105 | 106 | $this->dims[$tag] = 0; |
106 | 107 | } |
107 | 108 | } |
| 109 | + $fa = FlaggedArticle::getTitleInstance( $this->page ); |
| 110 | + $this->config = $fa->getVisibilitySettings(); |
108 | 111 | # Check permissions and validate |
109 | | - if( !$this->userCanSetFlags( $this->dims, $this->oflags ) ) { |
| 112 | + if( !self::userCanSetFlags( $this->dims, $this->oflags, $this->config ) ) { |
110 | 113 | $wgOut->permissionRequired( 'badaccess-group0' ); |
111 | 114 | return; |
112 | 115 | } |
— | — | @@ -247,10 +250,16 @@ |
248 | 251 | if( $form->validatedParams !== $k ) { |
249 | 252 | return '<err#>'; |
250 | 253 | } |
| 254 | + // User must be able to edit this page |
| 255 | + if( !$form->page->quickUserCan('edit') ) { |
| 256 | + return '<err#>'; |
| 257 | + } |
| 258 | + $fa = FlaggedArticle::getTitleInstance( $form->page ); |
| 259 | + $form->config = $fa->getVisibilitySettings(); |
251 | 260 | # Get the revision's current flags, if any |
252 | 261 | $form->oflags = FlaggedRevs::getRevisionTags( $form->page, $form->oldid ); |
253 | | - # Check permissions |
254 | | - if( !$form->page->quickUserCan('edit') || !$form->userCanSetFlags($form->dims,$form->oflags) ) { |
| 262 | + # Check tag permissions |
| 263 | + if( !self::userCanSetFlags($form->dims,$form->oflags,$form->config) ) { |
255 | 264 | return '<err#>'; |
256 | 265 | } |
257 | 266 | list($approved,$status) = $form->submit(); |
— | — | @@ -382,7 +391,7 @@ |
383 | 392 | } |
384 | 393 | } |
385 | 394 | # Double-check permissions |
386 | | - if( !$this->page->quickUserCan('edit') || !$this->userCanSetFlags($this->dims,$this->oflags) ) { |
| 395 | + if( !$this->page->quickUserCan('edit') || !self::userCanSetFlags($this->dims,$this->oflags,$this->config) ) { |
387 | 396 | return array($approved,false); |
388 | 397 | } |
389 | 398 | # We can only approve actual revisions... |
— | — | @@ -750,8 +759,11 @@ |
751 | 760 | * @param int $value |
752 | 761 | * @returns bool |
753 | 762 | */ |
754 | | - public static function userCan( $tag, $value ) { |
| 763 | + public static function userCan( $tag, $value, $config = array() ) { |
755 | 764 | global $wgFlagRestrictions, $wgUser; |
| 765 | + # Levels may not apply for some pages |
| 766 | + if( !self::levelAvailable( $tag, $value, $config ) ) |
| 767 | + return false; |
756 | 768 | # No restrictions -> full access |
757 | 769 | if( !isset($wgFlagRestrictions[$tag]) ) |
758 | 770 | return true; |
— | — | @@ -774,9 +786,10 @@ |
775 | 787 | * to the given levels for each tag. |
776 | 788 | * @param array $flags, suggested flags |
777 | 789 | * @param array $oldflags, pre-existing flags |
| 790 | + * @param array $config, visibility settings |
778 | 791 | * @returns bool |
779 | 792 | */ |
780 | | - public static function userCanSetFlags( $flags, $oldflags = array() ) { |
| 793 | + public static function userCanSetFlags( $flags, $oldflags = array(), $config = array() ) { |
781 | 794 | global $wgUser; |
782 | 795 | if( !$wgUser->isAllowed('review') ) { |
783 | 796 | return false; |
— | — | @@ -786,7 +799,7 @@ |
787 | 800 | foreach( FlaggedRevs::getDimensions() as $qal => $levels ) { |
788 | 801 | $level = isset($flags[$qal]) ? $flags[$qal] : 0; |
789 | 802 | $highest = count($levels) - 1; // highest valid level |
790 | | - if( !self::userCan($qal,$level) ) { |
| 803 | + if( !self::userCan($qal,$level,$config) ) { |
791 | 804 | return false; |
792 | 805 | } else if( isset($oldflags[$qal]) && !self::userCan($qal,$oldflags[$qal]) ) { |
793 | 806 | return false; |
— | — | @@ -797,6 +810,15 @@ |
798 | 811 | return true; |
799 | 812 | } |
800 | 813 | |
| 814 | + public static function levelAvailable( $tag, $val, $config ) { |
| 815 | + global $wgFlagAvailability; |
| 816 | + if( isset($wgFlagAvailability[$tag]) && isset($wgFlagAvailability[$tag][$val]) ) { |
| 817 | + $precedence = $wgFlagAvailability[$tag][$val]; |
| 818 | + return ( $config['select'] === $precedence ); |
| 819 | + } |
| 820 | + return true; |
| 821 | + } |
| 822 | + |
801 | 823 | public static function updateRecentChanges( $title, $revId, $rcId=false, $patrol=true ) { |
802 | 824 | wfProfileIn( __METHOD__ ); |
803 | 825 | $revId = intval($revId); |
Index: trunk/extensions/FlaggedRevs/api/ApiReview.php |
— | — | @@ -78,7 +78,9 @@ |
79 | 79 | |
80 | 80 | // Check if user is even allowed to set the flags |
81 | 81 | $form->oflags = FlaggedRevs::getRevisionTags( $title, $form->oldid ); |
82 | | - if( !$title->quickUserCan('edit') || !$form->userCanSetFlags( $form->dims, $form->oflags ) ) |
| 82 | + $fa = FlaggedArticle::getTitleInstance( $form->page ); |
| 83 | + $form->config = $fa->getVisibilitySettings(); |
| 84 | + if( !$title->quickUserCan('edit') || !RevisionReview::userCanSetFlags($form->dims,$form->oflags,$form->config) ) |
83 | 85 | $this->dieUsage( "You don't have the necessary rights to set the specified flags.", 'permissiondenied' ); |
84 | 86 | |
85 | 87 | // Now get the template and image parameters needed |