Index: trunk/extensions/Contest/Contest.i18n.php |
— | — | @@ -192,6 +192,8 @@ |
193 | 193 | 'contest-mycontests-header-contest' => 'Contest', |
194 | 194 | 'contest-mycontests-header-challenge' => 'Challenge', |
195 | 195 | 'contest-mycontests-signup-success' => 'You have successfully signed up for this contest.', |
| 196 | + 'contest-mycontests-addition-success' => 'Your submission has been added.', |
| 197 | + 'contest-mycontests-updated-success' => 'Your submission has been updated.', |
196 | 198 | 'contest-mycontests-sessionfail' => 'Your submission could not be saved due to loss of session data. Please try again.', |
197 | 199 | |
198 | 200 | 'contest-submission-submit' => 'Submit', |
Index: trunk/extensions/Contest/specials/SpecialMyContests.php |
— | — | @@ -13,6 +13,8 @@ |
14 | 14 | */ |
15 | 15 | class SpecialMyContests extends SpecialContestPage { |
16 | 16 | |
| 17 | + protected $submissionState = null; |
| 18 | + |
17 | 19 | /** |
18 | 20 | * Constructor. |
19 | 21 | * |
— | — | @@ -238,6 +240,12 @@ |
239 | 241 | if ( $this->getRequest()->getCheck( 'new' ) ) { |
240 | 242 | $this->showSuccess( 'contest-mycontests-signup-success' ); |
241 | 243 | } |
| 244 | + else if ( $this->getRequest()->getCheck( 'added' ) ) { |
| 245 | + $this->showSuccess( 'contest-mycontests-addition-success' ); |
| 246 | + } |
| 247 | + else if ( $this->getRequest()->getCheck( 'updated' ) ) { |
| 248 | + $this->showSuccess( 'contest-mycontests-updated-success' ); |
| 249 | + } |
242 | 250 | else if ( $this->getRequest()->wasPosted() |
243 | 251 | && !$this->getUser()->matchEditToken( $this->getRequest()->getVal( 'wpEditToken' ) ) ) { |
244 | 252 | $this->showError( 'contest-mycontests-sessionfail' ); |
— | — | @@ -253,8 +261,9 @@ |
254 | 262 | $form->setSubmitCallback( array( $this, 'handleSubmission' ) ); |
255 | 263 | $form->setSubmitText( wfMsg( 'contest-submission-submit' ) ); |
256 | 264 | |
257 | | - if( $form->show() ){ |
258 | | - $this->getOutput()->redirect( $this->getTitle( $contestant->getContest()->getField( 'name' ) )->getLocalURL() ); |
| 265 | + if( $form->show() ) { |
| 266 | + $query = is_null( $this->submissionState ) ? '' : $this->submissionState; |
| 267 | + $this->getOutput()->redirect( $this->getTitle( $contestant->getContest()->getField( 'name' ) )->getLocalURL( $query ) ); |
259 | 268 | } |
260 | 269 | else { |
261 | 270 | $this->getOutput()->addModules( 'contest.special.submission' ); |
— | — | @@ -289,7 +298,18 @@ |
290 | 299 | 'submission' => trim( $data['contestant-submission'] ), |
291 | 300 | ) ); |
292 | 301 | |
293 | | - return $contestant->writeToDB(); |
| 302 | + $success = $contestant->writeToDB(); |
| 303 | + |
| 304 | + if ( $success ) { |
| 305 | + if ( trim( $data['contestant-previous-submission'] ) === '' && trim( $data['contestant-submission'] ) !== '' ) { |
| 306 | + $this->submissionState = 'added'; |
| 307 | + } |
| 308 | + else { |
| 309 | + $this->submissionState = 'updated'; |
| 310 | + } |
| 311 | + } |
| 312 | + |
| 313 | + return $success; |
294 | 314 | } |
295 | 315 | |
296 | 316 | /** |
— | — | @@ -310,6 +330,11 @@ |
311 | 331 | 'id' => 'contest-id', |
312 | 332 | ); |
313 | 333 | |
| 334 | + $fields['contestant-previous-submission'] = array( |
| 335 | + 'type' => 'hidden', |
| 336 | + 'default' => $contestant->getField( 'submission' ), |
| 337 | + ); |
| 338 | + |
314 | 339 | $fields['contestant-submission'] = array( |
315 | 340 | 'class' => 'ContestSubmissionField', |
316 | 341 | 'label-message' => 'contest-submission-submission', |