Index: trunk/extensions/UsabilityInitiative/OptIn/SpecialOptIn.php |
— | — | @@ -66,6 +66,12 @@ |
67 | 67 | |
68 | 68 | $par = $wgRequest->getVal( 'from', $par ); |
69 | 69 | $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 | + } |
70 | 76 | if ( $this->mOriginTitle ) { |
71 | 77 | $this->mOrigin = $this->mOriginTitle->getPrefixedDBKey(); |
72 | 78 | $this->mOriginQuery = $wgRequest->getVal( 'fromquery' ); |
— | — | @@ -93,17 +99,17 @@ |
94 | 100 | } |
95 | 101 | else |
96 | 102 | { |
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 |
99 | 105 | $wgOut->setPageTitle( wfMsg( 'optin-title-justoptedin' ) ); |
100 | 106 | else |
101 | 107 | // About to opt in |
102 | 108 | $wgOut->setPageTitle( wfMsg( 'optin-title-optedout' ) ); |
103 | 109 | } |
104 | 110 | |
105 | | - if ( $wgRequest->getCheck( 'opt' ) ) { |
| 111 | + if ( $wgRequest->getCheck( 'opt' ) && $wgUser->isLoggedIn() ) { |
106 | 112 | if ( $wgRequest->getVal( 'opt' ) === 'in' ) { |
107 | | - if ( self::checkToken() ) { |
| 113 | + if ( self::checkToken() && !self::isOptedIn( $wgUser ) ) { |
108 | 114 | self::optIn( $wgUser ); |
109 | 115 | $wgOut->addWikiMsg( 'optin-success-in' ); |
110 | 116 | |
— | — | @@ -117,21 +123,28 @@ |
118 | 124 | array( 'type' => $wgJsMimeType ), |
119 | 125 | 'js2AddOnloadHook( function() { $j.post( "' . $url . '", optInGetPOSTData() ); } );' |
120 | 126 | ) ); |
| 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' ); |
121 | 132 | } else |
| 133 | + // Token didn't match |
122 | 134 | $this->showForm( self::isOptedIn( $wgUser ) ? |
123 | 135 | 'out' : 'in' ); |
124 | | - } else if ( $wgRequest->getVal( 'opt' ) == 'feedback' ) { |
| 136 | + } else if ( $wgRequest->getVal( 'opt' ) == 'feedback' && self::isOptedIn( $wgUser ) ) { |
125 | 137 | if ( $wgRequest->wasPosted() ) { |
126 | 138 | $this->saveSurvey( $wgOptInFeedBackSurvey, |
127 | 139 | 'feedback' ); |
128 | 140 | $wgOut->addWikiMsg( 'optin-success-feedback' ); |
129 | 141 | } else |
130 | 142 | $this->showForm( 'feedback' ); |
131 | | - } else if ( $wgRequest->getVal( 'opt' ) == 'browser' ) { |
| 143 | + } else if ( $wgRequest->getVal( 'opt' ) == 'browser' && self::isOptedIn( $wgUser ) ) { |
132 | 144 | $this->saveSurvey( $wgOptInBrowserSurvey, 'in' ); |
133 | 145 | $wgOut->disable(); |
134 | 146 | } else { |
135 | | - if ( self::checkToken() ) { |
| 147 | + // Opt out |
| 148 | + if ( self::checkToken() && self::isOptedIn( $wgUser ) ) { |
136 | 149 | self::optOut( $wgUser ); |
137 | 150 | $this->saveSurvey( $wgOptInSurvey, 'out' ); |
138 | 151 | $wgOut->addWikiMsg( 'optin-success-out' ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -195,7 +195,7 @@ |
196 | 196 | // copied over to the textarea |
197 | 197 | context.$textarea.closest( 'form' ).submit( function() { |
198 | 198 | context.$textarea.attr( 'disabled', false ); |
199 | | - context.$textarea.val( context.$textarea.getSelection( 'getContents' ) ); |
| 199 | + context.$textarea.val( context.$textarea.textSelection( 'getContents' ) ); |
200 | 200 | } ); |
201 | 201 | |
202 | 202 | /* This is probably only a textarea issue, thus no longer needed |