http://www.mediawiki.org/wiki/Special:Code/MediaWiki/100274
Revision: 100274
Author: jeroendedauw
Date: 2011-10-19 20:46:39 +0000 (Wed, 19 Oct 2011)
Log Message:
-----------
created basic reminder email functionality
Modified Paths:
--------------
trunk/extensions/Contest/Contest.i18n.php
trunk/extensions/Contest/Contest.php
trunk/extensions/Contest/api/ApiMailContestants.php
trunk/extensions/Contest/resources/contest.special.contest.js
trunk/extensions/Contest/specials/SpecialContest.php
Modified: trunk/extensions/Contest/Contest.i18n.php
===================================================================
--- trunk/extensions/Contest/Contest.i18n.php 2011-10-19 20:32:27 UTC (rev
100273)
+++ trunk/extensions/Contest/Contest.i18n.php 2011-10-19 20:46:39 UTC (rev
100274)
@@ -154,10 +154,17 @@
'contest-contest-reminder-page' => 'The content for the reminder e-mail
comes from [[$1|this page]].',
'contest-contest-send-reminder' => 'Send reminder',
+ // Special:Contest, reminder email JS
'contest-contest-reminder-preview' => 'Preview of the reminder e-mail:',
'contest-contest-reminder-title' => 'Reminder e-mail',
'contest-contest-reminder-send' => 'Send reminder',
'contest-contest-reminder-cancel' => 'Cancel',
+ 'contest-contest-reminder-sending' => 'Sending...',
+ // We really want // {{PLURAL:$1|contestant|contestants}} here, but the
JS i18n shizzle does not support it yet :/
+ 'contest-contest-reminder-success' => 'Successfully send the reminder
email to $1 contestants',
+ 'contest-contest-reminder-close' => 'Close',
+ 'contest-contest-reminder-retry' => 'Retry sending',
+ 'contest-contest-reminder-failed' => 'Could not send the reminder
emails.',
// Contestant pager
'contest-contestant-id' => 'ID',
@@ -258,14 +265,10 @@
'contest-contest-name' => 'Table row header',
'contest-contest-status' => 'Table row header',
'contest-contest-submissioncount' => 'Table row header',
+ 'contest-contest-end' => 'Table row header',
'contest-contest-contestants' => 'Page section header',
- 'contest-contest-reminder-mail' => 'Reminder email',
- 'contest-contest-reminder-page' => 'Text explaining the email content
is pulled from a page, $1 is the page name.',
- 'contest-contest-send-reminder' => 'Send reminder button text',
- 'contest-contest-reminder-preview' => 'Text indicating that the
following content is the preview for the reminder email.',
- 'contest-contest-reminder-title' => 'Dialog title',
- 'contest-contest-reminder-send' => 'Send button text',
- 'contest-contest-reminder-cancel' => 'Cancel button text',
+ 'contest-contest-days-ago' => '$1 is a date, $2 is an integer, the
amount of days',
+ 'contest-contest-days-left' => '$1 is a date, $2 is an integer, the
amount of days',
'contest-contestant-id' => 'Table column header',
'contest-contestant-volunteer' => 'Table column header',
'contest-contestant-wmf' => 'Table column header',
@@ -293,6 +296,22 @@
'contest-contestant-permalink' => 'Hover-text for comment permalinks',
'contest-email-signup-title' => 'Title for signup e-mails',
'contest-email-reminder-title' => 'Title for reminder e-mails',
+
+ // Special:Contest, reminder email
+ 'contest-contest-reminder-mail' => 'Reminder email',
+ 'contest-contest-reminder-page' => 'Text explaining the email content
is pulled from a page, $1 is the page name.',
+ 'contest-contest-send-reminder' => 'Send reminder button text',
+ 'contest-contest-reminder-preview' => 'Text indicating that the
following content is the preview for the reminder email.',
+ 'contest-contest-reminder-title' => 'Dialog title',
+ 'contest-contest-reminder-send' => 'Send button text',
+ 'contest-contest-reminder-cancel' => 'Cancel button text',
+ 'contest-contest-reminder-sending' => 'Send button text after clicking
it',
+ 'contest-contest-reminder-success' => 'Success message, $1 is the
amount of contesnats. No PLURAL for now, just assume there are multiple untill
MWs JS supports plural.',
+ 'contest-contest-reminder-close' => 'Close button text',
+ 'contest-contest-reminder-retry' => 'Retry button text',
+ 'contest-contest-reminder-failed' => 'Failiure message, displayed in an
alert box',
+
+ // Special:MyContests
'contest-mycontests-toplink' => 'Text for link in the user menu (i.e.
where watchlist and preferences are linked)',
'contest-mycontests-no-contests' => 'Message indicating there are no
contests for the user, displayed instead of a list.',
'contest-mycontests-active-header' => 'Page header (h2)',
Modified: trunk/extensions/Contest/Contest.php
===================================================================
--- trunk/extensions/Contest/Contest.php 2011-10-19 20:32:27 UTC (rev
100273)
+++ trunk/extensions/Contest/Contest.php 2011-10-19 20:46:39 UTC (rev
100274)
@@ -163,7 +163,12 @@
'contest-contest-reminder-title',
'contest-contest-reminder-cancel',
'contest-contest-reminder-send',
- 'contest-contest-reminder-preview'
+ 'contest-contest-reminder-preview',
+ 'contest-contest-reminder-sending',
+ 'contest-contest-reminder-success',
+ 'contest-contest-reminder-close',
+ 'contest-contest-reminder-retry',
+ 'contest-contest-reminder-failed',
),
'dependencies' => array(
'jquery.ui.button', 'jquery.ui.dialog',
Modified: trunk/extensions/Contest/api/ApiMailContestants.php
===================================================================
--- trunk/extensions/Contest/api/ApiMailContestants.php 2011-10-19 20:32:27 UTC
(rev 100273)
+++ trunk/extensions/Contest/api/ApiMailContestants.php 2011-10-19 20:46:39 UTC
(rev 100274)
@@ -18,7 +18,6 @@
parent::__construct( $main, $action );
}
- // TODO
public function execute() {
global $wgUser;
@@ -71,11 +70,11 @@
$conditions['id'] = $params['ids'];
}
- $contestants = ContestContestant::s()->select( 'email',
$conditions );
+ $contestants = ContestContestant::s()->select( array(
'contest_id', 'email' ), $conditions );
if ( $contestants !== false && count( $contestants ) > 0 ) {
$setSize = ContestSettings::get( 'reminderJobSize' );
- $limit = count( $contestants ) - $setSize;
+ $limit = count( $contestants );
for ( $i = 0; $i <= $limit; $i += $setSize ) {
$this->createReminderJob( array_splice(
$contestants, $i, $setSize ) );
Modified: trunk/extensions/Contest/resources/contest.special.contest.js
===================================================================
--- trunk/extensions/Contest/resources/contest.special.contest.js
2011-10-19 20:32:27 UTC (rev 100273)
+++ trunk/extensions/Contest/resources/contest.special.contest.js
2011-10-19 20:46:39 UTC (rev 100274)
@@ -10,22 +10,59 @@
var _this = this;
- this.sendReminder = function() {
+ this.sendReminder = function( callback ) {
+ var requestArgs = {
+ 'action': 'mailcontestants',
+ 'format': 'json',
+ 'token': $( '#send-reminder' ).attr( 'data-token' ),
+ 'contestids': $( '#send-reminder' ).attr(
'data-contest-id' )
+ };
+ $.post(
+ wgScriptPath + '/api.php',
+ requestArgs,
+ function( data ) {
+ callback( data );
+ }
+ );
};
this.showReminderDialog = function() {
+ var $dialog = null;
+
$dialog = $( '<div />' ).html( '' ).dialog( {
'title': mw.msg( 'contest-contest-reminder-title' ),
'buttons': [
{
'text': mw.msg(
'contest-contest-reminder-send' ),
- 'click': function() {
_this.sendReminder(); }
+ 'id': 'reminder-send-button',
+ 'click': function() {
+ var $send = $(
'#reminder-send-button' );
+ var $cancel = $(
'#reminder-cancel-button' );
+
+ $send.button( 'option',
'disabled', true );
+ $send.button( 'option',
'label', mw.msg( 'contest-contest-reminder-sending' ) );
+
+ _this.sendReminder( function(
data ) {
+ if ( data.success ) {
+ $dialog.text(
mw.msg( 'contest-contest-reminder-success', data.contestantcount ) );
+ $send.remove();
+ $cancel.button(
'option', 'label', mw.msg( 'contest-contest-reminder-close' ) );
+ }
+ else {
+ $send.button(
'option', 'label', mw.msg( 'contest-contest-reminder-retry' ) );
+ $send.button(
'option', 'disabled', false );
+
+ alert( mw.msg(
'contest-contest-reminder-failed' ) );
+ }
+ } );
+ }
},
{
'text': mw.msg(
'contest-contest-reminder-cancel' ),
+ 'id': 'reminder-cancel-button',
'click': function() {
- $( this ).dialog( 'close' );
+ $dialog.dialog( 'close' );
}
}
]
Modified: trunk/extensions/Contest/specials/SpecialContest.php
===================================================================
--- trunk/extensions/Contest/specials/SpecialContest.php 2011-10-19
20:32:27 UTC (rev 100273)
+++ trunk/extensions/Contest/specials/SpecialContest.php 2011-10-19
20:46:39 UTC (rev 100274)
@@ -140,6 +140,8 @@
'button',
array(
'id' => 'send-reminder',
+ 'data-token' => $this->getUser()->editToken(),
+ 'data-contest-id' => $contest->getId()
),
wfMsg( 'contest-contest-send-reminder' )
) );
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs