r32879 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r32878‎ | r32879 | r32880 >
Date:21:57, 6 April 2008
Author:aaron
Status:old
Tags:
Comment:
* Add preference for users to show the stable version by default
* Use more direct check than isAnon()
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsPage.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -278,6 +278,11 @@
279279 $wgHooks['LogLine'][] = 'FlaggedRevs::reviewLogLine';
280280 # Disable auto-promotion
281281 $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';
282287 #########
283288 }
284289
@@ -1747,6 +1752,51 @@
17481753 }
17491754 return true;
17501755 }
 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+ }
17511801
17521802 /**
17531803 * Get a selector of reviewable namespaces
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -23,6 +23,9 @@
2424 # for a certain stable version will be handled elsewhere.
2525 if( $wgRequest->getVal('oldid') || $wgRequest->getVal('diff') || $wgRequest->getVal('stableid') )
2626 return false;
 27+ # Check user preferences
 28+ if( $wgUser->getOption('flaggedrevsstable') )
 29+ return !( $wgRequest->getIntOrNull('stable') === 0 );
2730 # Get page configuration
2831 $config = $this->getVisibilitySettings();
2932 # Does the stable version override the current one?
@@ -31,8 +34,9 @@
3235 # Viewer sees current by default (editors, insiders, ect...) ?
3336 foreach( $wgFlaggedRevsExceptions as $group ) {
3437 if( $group == 'user' ) {
35 - if( !$wgUser->isAnon() )
 38+ if( $wgUser->getID() ) {
3639 return ( $wgRequest->getIntOrNull('stable') === 1 );
 40+ }
3741 } else if( in_array( $group, $wgUser->getGroups() ) ) {
3842 return ( $wgRequest->getIntOrNull('stable') === 1 );
3943 }
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.i18n.php
@@ -215,8 +215,11 @@
216216 'stablepages-none' => 'There are no pages in this list',
217217 'stablepages-config' => 'Configuration',
218218
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)',
221224 );
222225
223226 /** Aragonese (Aragonés)

Status & tagging log