r99805 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99804‎ | r99805 | r99806 >
Date:21:07, 14 October 2011
Author:jeroendedauw
Status:ok
Tags:
Comment:
added submission success notifications
Modified paths:
  • /trunk/extensions/Contest/Contest.i18n.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialMyContests.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Contest/Contest.i18n.php
@@ -192,6 +192,8 @@
193193 'contest-mycontests-header-contest' => 'Contest',
194194 'contest-mycontests-header-challenge' => 'Challenge',
195195 '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.',
196198 'contest-mycontests-sessionfail' => 'Your submission could not be saved due to loss of session data. Please try again.',
197199
198200 'contest-submission-submit' => 'Submit',
Index: trunk/extensions/Contest/specials/SpecialMyContests.php
@@ -13,6 +13,8 @@
1414 */
1515 class SpecialMyContests extends SpecialContestPage {
1616
 17+ protected $submissionState = null;
 18+
1719 /**
1820 * Constructor.
1921 *
@@ -238,6 +240,12 @@
239241 if ( $this->getRequest()->getCheck( 'new' ) ) {
240242 $this->showSuccess( 'contest-mycontests-signup-success' );
241243 }
 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+ }
242250 else if ( $this->getRequest()->wasPosted()
243251 && !$this->getUser()->matchEditToken( $this->getRequest()->getVal( 'wpEditToken' ) ) ) {
244252 $this->showError( 'contest-mycontests-sessionfail' );
@@ -253,8 +261,9 @@
254262 $form->setSubmitCallback( array( $this, 'handleSubmission' ) );
255263 $form->setSubmitText( wfMsg( 'contest-submission-submit' ) );
256264
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 ) );
259268 }
260269 else {
261270 $this->getOutput()->addModules( 'contest.special.submission' );
@@ -289,7 +298,18 @@
290299 'submission' => trim( $data['contestant-submission'] ),
291300 ) );
292301
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;
294314 }
295315
296316 /**
@@ -310,6 +330,11 @@
311331 'id' => 'contest-id',
312332 );
313333
 334+ $fields['contestant-previous-submission'] = array(
 335+ 'type' => 'hidden',
 336+ 'default' => $contestant->getField( 'submission' ),
 337+ );
 338+
314339 $fields['contestant-submission'] = array(
315340 'class' => 'ContestSubmissionField',
316341 'label-message' => 'contest-submission-submission',

Status & tagging log