Index: trunk/extensions/Contest/test/ContestParseTests.php |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | /** |
16 | 16 | * Tests @see ContestUtils::replaceRelativeLinks |
17 | 17 | */ |
18 | | - public function testObjectSelectCount() { |
| 18 | + public function testLinkReplacing() { |
19 | 19 | $tests = array( |
20 | 20 | '[[Foo|Bar]]' => '[' . Title::newFromText( 'Foo' )->getFullUrl() . ' Bar]', |
21 | 21 | '[[Foo|Foo]]' => '[' . Title::newFromText( 'Foo' )->getFullUrl() . ' Foo]', |
Index: trunk/extensions/Contest/Contest.i18n.php |
— | — | @@ -178,6 +178,7 @@ |
179 | 179 | |
180 | 180 | // Emails |
181 | 181 | 'contest-email-signup-title' => 'Thanks for joining the challenge!', |
| 182 | + 'contest-email-reminder-title' => 'Only $1 {{PLURAL:$1|day|days}} until the end of the challenge!', |
182 | 183 | ); |
183 | 184 | |
184 | 185 | /** Message documentation (Message documentation) |
Index: trunk/extensions/Contest/includes/ContestUtils.php |
— | — | @@ -58,7 +58,7 @@ |
59 | 59 | self::replaceRelativeLinks( $article->fetchContent() ), |
60 | 60 | $article->getTitle(), |
61 | 61 | $article->getParserOptions() |
62 | | - )->getText(); // TODO: have full urls instead of relative ones |
| 62 | + )->getText(); |
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
Index: trunk/extensions/Contest/includes/ContestContestant.php |
— | — | @@ -468,9 +468,7 @@ |
469 | 469 | } |
470 | 470 | |
471 | 471 | /** |
472 | | - * Send the ignup email. |
473 | | - * TODO: use actual config |
474 | | - * TODO: test code on machine that is properly configured for email sending |
| 472 | + * Send the signup email. |
475 | 473 | * |
476 | 474 | * @since 0.1 |
477 | 475 | * |
— | — | @@ -498,6 +496,34 @@ |
499 | 497 | } |
500 | 498 | |
501 | 499 | /** |
| 500 | + * Send a reminder email. |
| 501 | + * |
| 502 | + * @since 0.1 |
| 503 | + * |
| 504 | + * @return Status |
| 505 | + */ |
| 506 | + public function sendReminderEmail() { |
| 507 | + global $wgPasswordSender, $wgPasswordSenderName; |
| 508 | + |
| 509 | + $title = wfMsgExt( 'contest-email-reminder-title', 'parsemag', $this->getContest()->getDaysLeft() ); |
| 510 | + $emailText = ContestUtils::getParsedArticleContent( $this->getContest()->getField( 'reminder_email' ) ); |
| 511 | + $user = $this->getUser(); |
| 512 | + $sender = $wgPasswordSender; |
| 513 | + $senderName = $wgPasswordSenderName; |
| 514 | + |
| 515 | + wfRunHooks( 'ContestBeforeReminderEmail', array( &$this, &$title, &$emailText, &$user, &$sender, &$senderName ) ); |
| 516 | + |
| 517 | + return UserMailer::send( |
| 518 | + new MailAddress( $user ), |
| 519 | + new MailAddress( $sender, $senderName ), |
| 520 | + $title, |
| 521 | + $emailText, |
| 522 | + null, |
| 523 | + 'text/html; charset=ISO-8859-1' |
| 524 | + ); |
| 525 | + } |
| 526 | + |
| 527 | + /** |
502 | 528 | * Update the vote count and avarage vote fields. |
503 | 529 | * This does not write the changes to the database, |
504 | 530 | * if this is required, call writeToDB. |
Index: trunk/extensions/Contest/includes/Contest.class.php |
— | — | @@ -430,4 +430,26 @@ |
431 | 431 | // TODO |
432 | 432 | } |
433 | 433 | |
| 434 | + /** |
| 435 | + * Gets the amount of time left, in seconds. |
| 436 | + * |
| 437 | + * @since 0.1 |
| 438 | + * |
| 439 | + * @return integer |
| 440 | + */ |
| 441 | + public function getTimeLeft() { |
| 442 | + return wfTimestamp( TS_UNIX, $this->getField( 'end' ) ) - time(); |
| 443 | + } |
| 444 | + |
| 445 | + /** |
| 446 | + * Gets the amount of days left, rounded up to the nearest integer. |
| 447 | + * |
| 448 | + * @since 0.1 |
| 449 | + * |
| 450 | + * @return integer |
| 451 | + */ |
| 452 | + public function getDaysLeft() { |
| 453 | + return (int)ceil( $this->getTimeLeft() / ( 60 * 60 * 24 ) ); |
| 454 | + } |
| 455 | + |
434 | 456 | } |