r100296 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100295‎ | r100296 | r100297 >
Date:23:40, 19 October 2011
Author:reedy
Status:old
Tags:
Comment:
1.18wmf1 MFT r100292, r100287
Modified paths:
  • /branches/wmf/1.18wmf1/extensions/Contest (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Contest/Contest.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Contest/includes/ContestContestant.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Contest/specials/SpecialMyContests.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/extensions/Contest/specials/SpecialMyContests.php
@@ -348,6 +348,7 @@
349349
350350 $contestant = new ContestContestant( array(
351351 'id' => $data['contestant-id'],
 352+ 'challenge_id' => $data['contestant-challengeid'],
352353
353354 'full_name' => $data['contestant-realname'],
354355 'email' => $data['contestant-email'],
@@ -431,6 +432,15 @@
432433 'options' => ContestContestant::getCountriesForInput()
433434 );
434435
 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+
435445 $fields['contestant-volunteer'] = array(
436446 'type' => 'check',
437447 'default' => $contestant->getField( 'volunteer' ),
@@ -454,7 +464,33 @@
455465
456466 return $fields;
457467 }
 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();
458482
 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+
459495 /**
460496 * HTMLForm field validation-callback for name field.
461497 *
@@ -544,7 +580,25 @@
545581
546582 return wfMsg( 'contest-submission-invalid-url' );
547583 }
 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+ }
548599
 600+ return true;
 601+ }
 602+
549603 }
550604
551605 class ContestSubmissionField extends HTMLFormField {
Index: branches/wmf/1.18wmf1/extensions/Contest/Contest.php
@@ -275,3 +275,6 @@
276276 $egContestSettings = array();
277277
278278 $wgContestEmailParse = false;
 279+
 280+$wgContestMailSender = $wgPasswordSender;
 281+$wgContestMailSenderName = $wgPasswordSenderName;
Index: branches/wmf/1.18wmf1/extensions/Contest/includes/ContestContestant.php
@@ -489,13 +489,13 @@
490490 * @return Status
491491 */
492492 public function sendSignupEmail() {
493 - global $wgPasswordSender, $wgPasswordSenderName;
 493+ global $wgContestMailSender, $wgContestMailSenderName;
494494
495495 $title = wfMsg( 'contest-email-signup-title' );
496496 $emailText = ContestUtils::getParsedArticleContent( $this->getContest()->getField( 'signup_email' ) );
497497 $user = $this->getUser();
498 - $sender = $wgPasswordSender;
499 - $senderName = $wgPasswordSenderName;
 498+ $sender = $wgContestMailSender;
 499+ $senderName = $wgContestMailSenderName;
500500
501501 wfRunHooks( 'ContestBeforeSignupEmail', array( &$this, &$title, &$emailText, &$user, &$sender, &$senderName ) );
502502
@@ -517,7 +517,7 @@
518518 * @return Status
519519 */
520520 public function sendReminderEmail( $emailText, array $params = array() ) {
521 - global $wgPasswordSender, $wgPasswordSenderName;
 521+ global $wgContestMailSender, $wgContestMailSenderName;
522522
523523 if ( !array_key_exists( 'daysLeft', $params ) ) {
524524 $params['daysLeft'] = $this->getContest()->getDaysLeft();
@@ -525,8 +525,8 @@
526526
527527 $title = wfMsgExt( 'contest-email-reminder-title', 'parsemag', $params['daysLeft'] );
528528 $user = $this->getUser();
529 - $sender = $wgPasswordSender;
530 - $senderName = $wgPasswordSenderName;
 529+ $sender = $wgContestMailSender;
 530+ $senderName = $wgContestMailSenderName;
531531
532532 wfRunHooks( 'ContestBeforeReminderEmail', array( &$this, &$title, &$emailText, &$user, &$sender, &$senderName ) );
533533
Property changes on: branches/wmf/1.18wmf1/extensions/Contest
___________________________________________________________________
Modified: svn:mergeinfo
534534 Merged /trunk/extensions/Contest:r100287,100292

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r100287let users modify the challenge they want to tacklejeroendedauw22:27, 19 October 2011
r100292Added new globals to override the email sender address/name, defaults to MW $...reedy23:30, 19 October 2011

Status & tagging log