r99430 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99429‎ | r99430 | r99431 >
Date:21:26, 10 October 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on email stuff
Modified paths:
  • /trunk/extensions/Contest/Contest.i18n.php (modified) (history)
  • /trunk/extensions/Contest/includes/Contest.class.php (modified) (history)
  • /trunk/extensions/Contest/includes/ContestContestant.php (modified) (history)
  • /trunk/extensions/Contest/includes/ContestUtils.php (modified) (history)
  • /trunk/extensions/Contest/test/ContestParseTests.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Contest/test/ContestParseTests.php
@@ -14,7 +14,7 @@
1515 /**
1616 * Tests @see ContestUtils::replaceRelativeLinks
1717 */
18 - public function testObjectSelectCount() {
 18+ public function testLinkReplacing() {
1919 $tests = array(
2020 '[[Foo|Bar]]' => '[' . Title::newFromText( 'Foo' )->getFullUrl() . ' Bar]',
2121 '[[Foo|Foo]]' => '[' . Title::newFromText( 'Foo' )->getFullUrl() . ' Foo]',
Index: trunk/extensions/Contest/Contest.i18n.php
@@ -178,6 +178,7 @@
179179
180180 // Emails
181181 '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!',
182183 );
183184
184185 /** Message documentation (Message documentation)
Index: trunk/extensions/Contest/includes/ContestUtils.php
@@ -58,7 +58,7 @@
5959 self::replaceRelativeLinks( $article->fetchContent() ),
6060 $article->getTitle(),
6161 $article->getParserOptions()
62 - )->getText(); // TODO: have full urls instead of relative ones
 62+ )->getText();
6363 }
6464
6565 /**
Index: trunk/extensions/Contest/includes/ContestContestant.php
@@ -468,9 +468,7 @@
469469 }
470470
471471 /**
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.
475473 *
476474 * @since 0.1
477475 *
@@ -498,6 +496,34 @@
499497 }
500498
501499 /**
 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+ /**
502528 * Update the vote count and avarage vote fields.
503529 * This does not write the changes to the database,
504530 * if this is required, call writeToDB.
Index: trunk/extensions/Contest/includes/Contest.class.php
@@ -430,4 +430,26 @@
431431 // TODO
432432 }
433433
 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+
434456 }

Status & tagging log