Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -278,6 +278,11 @@ |
279 | 279 | $wgHooks['LogLine'][] = 'FlaggedRevs::reviewLogLine'; |
280 | 280 | # Disable auto-promotion |
281 | 281 | $wgHooks['UserRights'][] = 'FlaggedRevs::recordDemote'; |
| 282 | + # Local user account preference |
| 283 | + $wgHooks['RenderPreferencesForm'][] = 'FlaggedRevs::injectPreferences'; |
| 284 | + $wgHooks['InitPreferencesForm'][] = 'FlaggedRevs::injectFormPreferences'; |
| 285 | + $wgHooks['ResetPreferences'][] = 'FlaggedRevs::resetPreferences'; |
| 286 | + $wgHooks['SavePreferences'][] = 'FlaggedRevs::savePreferences'; |
282 | 287 | ######### |
283 | 288 | } |
284 | 289 | |
— | — | @@ -1747,6 +1752,51 @@ |
1748 | 1753 | } |
1749 | 1754 | return true; |
1750 | 1755 | } |
| 1756 | + |
| 1757 | + /** |
| 1758 | + * Add user preference to form HTML |
| 1759 | + */ |
| 1760 | + public static function injectPreferences( $form, $out ) { |
| 1761 | + $out->addHTML( |
| 1762 | + Xml::openElement( 'fieldset' ) . |
| 1763 | + Xml::element( 'legend', null, wfMsgHtml('flaggedrevs-prefs') ) . |
| 1764 | + Xml::openElement( 'table' ) . Xml::openElement( 'tr' ) . |
| 1765 | + '<td>'.wfCheck( 'wpFlaggedRevsStable', $form->mFlaggedRevsStable, |
| 1766 | + array('id' => 'wpFlaggedRevsStable') ) . '</td>' . |
| 1767 | + '<td>' . wfLabel( wfMsg( 'flaggedrevs-prefs-stable' ), 'wpFlaggedRevsStable' ) . '</td>' . |
| 1768 | + Xml::closeElement( 'tr' ) . Xml::closeElement( 'table' ) . |
| 1769 | + Xml::closeElement( 'fieldset' ) |
| 1770 | + ); |
| 1771 | + |
| 1772 | + return true; |
| 1773 | + } |
| 1774 | + |
| 1775 | + /** |
| 1776 | + * Add user preference to form object based on submission |
| 1777 | + */ |
| 1778 | + public static function injectFormPreferences( $form, $request ) { |
| 1779 | + $form->mFlaggedRevsStable = $request->getInt( 'wpFlaggedRevsStable' ); |
| 1780 | + |
| 1781 | + return true; |
| 1782 | + } |
| 1783 | + |
| 1784 | + /** |
| 1785 | + * Set preferences on form based on user settings |
| 1786 | + */ |
| 1787 | + public static function resetPreferences( $form, $user ) { |
| 1788 | + $form->mFlaggedRevsStable = $user->getOption( 'flaggedrevsstable' ); |
| 1789 | + |
| 1790 | + return true; |
| 1791 | + } |
| 1792 | + |
| 1793 | + /** |
| 1794 | + * Set user preferences into user object before it is applied to DB |
| 1795 | + */ |
| 1796 | + public static function savePreferences( $form, $user, &$msg ) { |
| 1797 | + $user->setOption( 'flaggedrevsstable', $form->validateInt( $form->mFlaggedRevsStable, 0, 1 ) ); |
| 1798 | + |
| 1799 | + return true; |
| 1800 | + } |
1751 | 1801 | |
1752 | 1802 | /** |
1753 | 1803 | * Get a selector of reviewable namespaces |
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -23,6 +23,9 @@ |
24 | 24 | # for a certain stable version will be handled elsewhere. |
25 | 25 | if( $wgRequest->getVal('oldid') || $wgRequest->getVal('diff') || $wgRequest->getVal('stableid') ) |
26 | 26 | return false; |
| 27 | + # Check user preferences |
| 28 | + if( $wgUser->getOption('flaggedrevsstable') ) |
| 29 | + return !( $wgRequest->getIntOrNull('stable') === 0 ); |
27 | 30 | # Get page configuration |
28 | 31 | $config = $this->getVisibilitySettings(); |
29 | 32 | # Does the stable version override the current one? |
— | — | @@ -31,8 +34,9 @@ |
32 | 35 | # Viewer sees current by default (editors, insiders, ect...) ? |
33 | 36 | foreach( $wgFlaggedRevsExceptions as $group ) { |
34 | 37 | if( $group == 'user' ) { |
35 | | - if( !$wgUser->isAnon() ) |
| 38 | + if( $wgUser->getID() ) { |
36 | 39 | return ( $wgRequest->getIntOrNull('stable') === 1 ); |
| 40 | + } |
37 | 41 | } else if( in_array( $group, $wgUser->getGroups() ) ) { |
38 | 42 | return ( $wgRequest->getIntOrNull('stable') === 1 ); |
39 | 43 | } |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.i18n.php |
— | — | @@ -215,8 +215,11 @@ |
216 | 216 | 'stablepages-none' => 'There are no pages in this list', |
217 | 217 | 'stablepages-config' => 'Configuration', |
218 | 218 | |
219 | | - 'rights-editor-autosum' => 'autopromoted', |
220 | | - 'rights-editor-revoke' => 'removed editor status from [[$1]]', |
| 219 | + 'rights-editor-autosum' => 'autopromoted', |
| 220 | + 'rights-editor-revoke' => 'removed editor status from [[$1]]', |
| 221 | + |
| 222 | + 'flaggedrevs-prefs' => 'Stability', |
| 223 | + 'flaggedrevs-prefs-stable' => 'Show the stable version of content pages by default (if there is one)', |
221 | 224 | ); |
222 | 225 | |
223 | 226 | /** Aragonese (Aragonés) |