r59146 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59145‎ | r59146 | r59147 >
Date:21:05, 16 November 2009
Author:catrope
Status:ok
Tags:
Comment:
* OptIn: (bug 21508) Trying to opt in as an already opted-in user displays the Leave Beta survey
* (bug 21509) Don't point people to Special:Userlogout in returnto-type links
* (bug 21529) Edits not saving with magic iframe enabled
Modified paths:
  • /trunk/extensions/UsabilityInitiative/OptIn/SpecialOptIn.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/OptIn/SpecialOptIn.php
@@ -66,6 +66,12 @@
6767
6868 $par = $wgRequest->getVal( 'from', $par );
6969 $this->mOriginTitle = Title::newFromText( $par );
 70+
 71+ // Verify that $this->mOriginTitle is not Special:Userlogout
 72+ if ( $this->mOriginTitle && $this->mOriginTitle->getNamespace() == NS_SPECIAL &&
 73+ SpecialPage::resolveAlias( $this->mOriginTitle->getText() ) == 'Userlogout' ) {
 74+ $this->mOriginTitle = null;
 75+ }
7076 if ( $this->mOriginTitle ) {
7177 $this->mOrigin = $this->mOriginTitle->getPrefixedDBKey();
7278 $this->mOriginQuery = $wgRequest->getVal( 'fromquery' );
@@ -93,17 +99,17 @@
94100 }
95101 else
96102 {
97 - if ( $wgRequest->getVal( 'opt' ) == 'in' )
98 - // Just opted in
 103+ if ( $wgRequest->getVal( 'opt' ) == 'in' && $wgUser->isLoggedIn() )
 104+ // Will be opted in in this request
99105 $wgOut->setPageTitle( wfMsg( 'optin-title-justoptedin' ) );
100106 else
101107 // About to opt in
102108 $wgOut->setPageTitle( wfMsg( 'optin-title-optedout' ) );
103109 }
104110
105 - if ( $wgRequest->getCheck( 'opt' ) ) {
 111+ if ( $wgRequest->getCheck( 'opt' ) && $wgUser->isLoggedIn() ) {
106112 if ( $wgRequest->getVal( 'opt' ) === 'in' ) {
107 - if ( self::checkToken() ) {
 113+ if ( self::checkToken() && !self::isOptedIn( $wgUser ) ) {
108114 self::optIn( $wgUser );
109115 $wgOut->addWikiMsg( 'optin-success-in' );
110116
@@ -117,21 +123,28 @@
118124 array( 'type' => $wgJsMimeType ),
119125 'js2AddOnloadHook( function() { $j.post( "' . $url . '", optInGetPOSTData() ); } );'
120126 ) );
 127+ } else if ( self::isOptedIn( $wgUser ) ) {
 128+ // User is already opted in but
 129+ // reloaded the page or tried to opt in
 130+ // again. Fake success
 131+ $wgOut->addWikiMsg( 'optin-success-in' );
121132 } else
 133+ // Token didn't match
122134 $this->showForm( self::isOptedIn( $wgUser ) ?
123135 'out' : 'in' );
124 - } else if ( $wgRequest->getVal( 'opt' ) == 'feedback' ) {
 136+ } else if ( $wgRequest->getVal( 'opt' ) == 'feedback' && self::isOptedIn( $wgUser ) ) {
125137 if ( $wgRequest->wasPosted() ) {
126138 $this->saveSurvey( $wgOptInFeedBackSurvey,
127139 'feedback' );
128140 $wgOut->addWikiMsg( 'optin-success-feedback' );
129141 } else
130142 $this->showForm( 'feedback' );
131 - } else if ( $wgRequest->getVal( 'opt' ) == 'browser' ) {
 143+ } else if ( $wgRequest->getVal( 'opt' ) == 'browser' && self::isOptedIn( $wgUser ) ) {
132144 $this->saveSurvey( $wgOptInBrowserSurvey, 'in' );
133145 $wgOut->disable();
134146 } else {
135 - if ( self::checkToken() ) {
 147+ // Opt out
 148+ if ( self::checkToken() && self::isOptedIn( $wgUser ) ) {
136149 self::optOut( $wgUser );
137150 $this->saveSurvey( $wgOptInSurvey, 'out' );
138151 $wgOut->addWikiMsg( 'optin-success-out' );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
@@ -195,7 +195,7 @@
196196 // copied over to the textarea
197197 context.$textarea.closest( 'form' ).submit( function() {
198198 context.$textarea.attr( 'disabled', false );
199 - context.$textarea.val( context.$textarea.getSelection( 'getContents' ) );
 199+ context.$textarea.val( context.$textarea.textSelection( 'getContents' ) );
200200 } );
201201
202202 /* This is probably only a textarea issue, thus no longer needed

Follow-up revisions

RevisionCommit summaryAuthorDate
r59147Recombine, bump style versions for r59146catrope21:06, 16 November 2009
r59149usability: Merge r59048 (ClickTracking fix) and r59146 (partial; OptIn fix) f...catrope21:34, 16 November 2009
r59204wmf-deployment: Merging usability changes from trunk...catrope18:53, 18 November 2009

Status & tagging log