Index: branches/wmf/1.18wmf1/extensions/Contest/specials/SpecialMyContests.php |
— | — | @@ -348,6 +348,7 @@ |
349 | 349 | |
350 | 350 | $contestant = new ContestContestant( array( |
351 | 351 | 'id' => $data['contestant-id'], |
| 352 | + 'challenge_id' => $data['contestant-challengeid'], |
352 | 353 | |
353 | 354 | 'full_name' => $data['contestant-realname'], |
354 | 355 | 'email' => $data['contestant-email'], |
— | — | @@ -431,6 +432,15 @@ |
432 | 433 | 'options' => ContestContestant::getCountriesForInput() |
433 | 434 | ); |
434 | 435 | |
| 436 | + $fields['contestant-challengeid'] = array( |
| 437 | + 'type' => 'radio', |
| 438 | + 'label-message' => 'contest-signup-challenge', |
| 439 | + 'options' => $this->getChallengesList( $contestant ), |
| 440 | + 'default' => $contestant->getField( 'challenge_id' ), |
| 441 | + 'required' => true, |
| 442 | + 'validation-callback' => array( __CLASS__, 'validateChallengeField' ) |
| 443 | + ); |
| 444 | + |
435 | 445 | $fields['contestant-volunteer'] = array( |
436 | 446 | 'type' => 'check', |
437 | 447 | 'default' => $contestant->getField( 'volunteer' ), |
— | — | @@ -454,7 +464,33 @@ |
455 | 465 | |
456 | 466 | return $fields; |
457 | 467 | } |
| 468 | + |
| 469 | + /** |
| 470 | + * Gets a list of contests that can be fed directly to the options field of |
| 471 | + * an HTMLForm radio input. |
| 472 | + * challenge title => challenge id |
| 473 | + * |
| 474 | + * @since 0.1 |
| 475 | + * |
| 476 | + * @param ContestContestant $contestant |
| 477 | + * |
| 478 | + * @return array |
| 479 | + */ |
| 480 | + protected function getChallengesList( ContestContestant $contestant ) { |
| 481 | + $list = array(); |
458 | 482 | |
| 483 | + $challenges = ContestChallenge::s()->select( |
| 484 | + array( 'id', 'title' ), |
| 485 | + array( 'contest_id' => $contestant->getField( 'contest_id' ) ) |
| 486 | + ); |
| 487 | + |
| 488 | + foreach ( $challenges as /* ContestChallenge */ $challenge ) { |
| 489 | + $list[$challenge->getField( 'title' )] = $challenge->getId(); |
| 490 | + } |
| 491 | + |
| 492 | + return $list; |
| 493 | + } |
| 494 | + |
459 | 495 | /** |
460 | 496 | * HTMLForm field validation-callback for name field. |
461 | 497 | * |
— | — | @@ -544,7 +580,25 @@ |
545 | 581 | |
546 | 582 | return wfMsg( 'contest-submission-invalid-url' ); |
547 | 583 | } |
| 584 | + |
| 585 | + /** |
| 586 | + * HTMLForm field validation-callback for challenge field. |
| 587 | + * |
| 588 | + * @since 0.1 |
| 589 | + * |
| 590 | + * @param $value String |
| 591 | + * @param $alldata Array |
| 592 | + * |
| 593 | + * @return true|string |
| 594 | + */ |
| 595 | + public static function validateChallengeField( $value, $alldata = null ) { |
| 596 | + if ( is_null( $value ) ) { |
| 597 | + return wfMsg( 'contest-signup-require-challenge' ); |
| 598 | + } |
548 | 599 | |
| 600 | + return true; |
| 601 | + } |
| 602 | + |
549 | 603 | } |
550 | 604 | |
551 | 605 | class ContestSubmissionField extends HTMLFormField { |
Index: branches/wmf/1.18wmf1/extensions/Contest/Contest.php |
— | — | @@ -275,3 +275,6 @@ |
276 | 276 | $egContestSettings = array(); |
277 | 277 | |
278 | 278 | $wgContestEmailParse = false; |
| 279 | + |
| 280 | +$wgContestMailSender = $wgPasswordSender; |
| 281 | +$wgContestMailSenderName = $wgPasswordSenderName; |
Index: branches/wmf/1.18wmf1/extensions/Contest/includes/ContestContestant.php |
— | — | @@ -489,13 +489,13 @@ |
490 | 490 | * @return Status |
491 | 491 | */ |
492 | 492 | public function sendSignupEmail() { |
493 | | - global $wgPasswordSender, $wgPasswordSenderName; |
| 493 | + global $wgContestMailSender, $wgContestMailSenderName; |
494 | 494 | |
495 | 495 | $title = wfMsg( 'contest-email-signup-title' ); |
496 | 496 | $emailText = ContestUtils::getParsedArticleContent( $this->getContest()->getField( 'signup_email' ) ); |
497 | 497 | $user = $this->getUser(); |
498 | | - $sender = $wgPasswordSender; |
499 | | - $senderName = $wgPasswordSenderName; |
| 498 | + $sender = $wgContestMailSender; |
| 499 | + $senderName = $wgContestMailSenderName; |
500 | 500 | |
501 | 501 | wfRunHooks( 'ContestBeforeSignupEmail', array( &$this, &$title, &$emailText, &$user, &$sender, &$senderName ) ); |
502 | 502 | |
— | — | @@ -517,7 +517,7 @@ |
518 | 518 | * @return Status |
519 | 519 | */ |
520 | 520 | public function sendReminderEmail( $emailText, array $params = array() ) { |
521 | | - global $wgPasswordSender, $wgPasswordSenderName; |
| 521 | + global $wgContestMailSender, $wgContestMailSenderName; |
522 | 522 | |
523 | 523 | if ( !array_key_exists( 'daysLeft', $params ) ) { |
524 | 524 | $params['daysLeft'] = $this->getContest()->getDaysLeft(); |
— | — | @@ -525,8 +525,8 @@ |
526 | 526 | |
527 | 527 | $title = wfMsgExt( 'contest-email-reminder-title', 'parsemag', $params['daysLeft'] ); |
528 | 528 | $user = $this->getUser(); |
529 | | - $sender = $wgPasswordSender; |
530 | | - $senderName = $wgPasswordSenderName; |
| 529 | + $sender = $wgContestMailSender; |
| 530 | + $senderName = $wgContestMailSenderName; |
531 | 531 | |
532 | 532 | wfRunHooks( 'ContestBeforeReminderEmail', array( &$this, &$title, &$emailText, &$user, &$sender, &$senderName ) ); |
533 | 533 | |
Property changes on: branches/wmf/1.18wmf1/extensions/Contest |
___________________________________________________________________ |
Modified: svn:mergeinfo |
534 | 534 | Merged /trunk/extensions/Contest:r100287,100292 |