Index: trunk/extensions/Contest/Contest.i18n.php |
— | — | @@ -154,10 +154,17 @@ |
155 | 155 | 'contest-contest-reminder-page' => 'The content for the reminder e-mail comes from [[$1|this page]].', |
156 | 156 | 'contest-contest-send-reminder' => 'Send reminder', |
157 | 157 | |
| 158 | + // Special:Contest, reminder email JS |
158 | 159 | 'contest-contest-reminder-preview' => 'Preview of the reminder e-mail:', |
159 | 160 | 'contest-contest-reminder-title' => 'Reminder e-mail', |
160 | 161 | 'contest-contest-reminder-send' => 'Send reminder', |
161 | 162 | 'contest-contest-reminder-cancel' => 'Cancel', |
| 163 | + 'contest-contest-reminder-sending' => 'Sending...', |
| 164 | + // We really want // {{PLURAL:$1|contestant|contestants}} here, but the JS i18n shizzle does not support it yet :/ |
| 165 | + 'contest-contest-reminder-success' => 'Successfully send the reminder email to $1 contestants', |
| 166 | + 'contest-contest-reminder-close' => 'Close', |
| 167 | + 'contest-contest-reminder-retry' => 'Retry sending', |
| 168 | + 'contest-contest-reminder-failed' => 'Could not send the reminder emails.', |
162 | 169 | |
163 | 170 | // Contestant pager |
164 | 171 | 'contest-contestant-id' => 'ID', |
— | — | @@ -258,14 +265,10 @@ |
259 | 266 | 'contest-contest-name' => 'Table row header', |
260 | 267 | 'contest-contest-status' => 'Table row header', |
261 | 268 | 'contest-contest-submissioncount' => 'Table row header', |
| 269 | + 'contest-contest-end' => 'Table row header', |
262 | 270 | 'contest-contest-contestants' => 'Page section header', |
263 | | - 'contest-contest-reminder-mail' => 'Reminder email', |
264 | | - 'contest-contest-reminder-page' => 'Text explaining the email content is pulled from a page, $1 is the page name.', |
265 | | - 'contest-contest-send-reminder' => 'Send reminder button text', |
266 | | - 'contest-contest-reminder-preview' => 'Text indicating that the following content is the preview for the reminder email.', |
267 | | - 'contest-contest-reminder-title' => 'Dialog title', |
268 | | - 'contest-contest-reminder-send' => 'Send button text', |
269 | | - 'contest-contest-reminder-cancel' => 'Cancel button text', |
| 271 | + 'contest-contest-days-ago' => '$1 is a date, $2 is an integer, the amount of days', |
| 272 | + 'contest-contest-days-left' => '$1 is a date, $2 is an integer, the amount of days', |
270 | 273 | 'contest-contestant-id' => 'Table column header', |
271 | 274 | 'contest-contestant-volunteer' => 'Table column header', |
272 | 275 | 'contest-contestant-wmf' => 'Table column header', |
— | — | @@ -293,6 +296,22 @@ |
294 | 297 | 'contest-contestant-permalink' => 'Hover-text for comment permalinks', |
295 | 298 | 'contest-email-signup-title' => 'Title for signup e-mails', |
296 | 299 | 'contest-email-reminder-title' => 'Title for reminder e-mails', |
| 300 | + |
| 301 | + // Special:Contest, reminder email |
| 302 | + 'contest-contest-reminder-mail' => 'Reminder email', |
| 303 | + 'contest-contest-reminder-page' => 'Text explaining the email content is pulled from a page, $1 is the page name.', |
| 304 | + 'contest-contest-send-reminder' => 'Send reminder button text', |
| 305 | + 'contest-contest-reminder-preview' => 'Text indicating that the following content is the preview for the reminder email.', |
| 306 | + 'contest-contest-reminder-title' => 'Dialog title', |
| 307 | + 'contest-contest-reminder-send' => 'Send button text', |
| 308 | + 'contest-contest-reminder-cancel' => 'Cancel button text', |
| 309 | + 'contest-contest-reminder-sending' => 'Send button text after clicking it', |
| 310 | + '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.', |
| 311 | + 'contest-contest-reminder-close' => 'Close button text', |
| 312 | + 'contest-contest-reminder-retry' => 'Retry button text', |
| 313 | + 'contest-contest-reminder-failed' => 'Failiure message, displayed in an alert box', |
| 314 | + |
| 315 | + // Special:MyContests |
297 | 316 | 'contest-mycontests-toplink' => 'Text for link in the user menu (i.e. where watchlist and preferences are linked)', |
298 | 317 | 'contest-mycontests-no-contests' => 'Message indicating there are no contests for the user, displayed instead of a list.', |
299 | 318 | 'contest-mycontests-active-header' => 'Page header (h2)', |
Index: trunk/extensions/Contest/specials/SpecialContest.php |
— | — | @@ -140,6 +140,8 @@ |
141 | 141 | 'button', |
142 | 142 | array( |
143 | 143 | 'id' => 'send-reminder', |
| 144 | + 'data-token' => $this->getUser()->editToken(), |
| 145 | + 'data-contest-id' => $contest->getId() |
144 | 146 | ), |
145 | 147 | wfMsg( 'contest-contest-send-reminder' ) |
146 | 148 | ) ); |
Index: trunk/extensions/Contest/Contest.php |
— | — | @@ -163,7 +163,12 @@ |
164 | 164 | 'contest-contest-reminder-title', |
165 | 165 | 'contest-contest-reminder-cancel', |
166 | 166 | 'contest-contest-reminder-send', |
167 | | - 'contest-contest-reminder-preview' |
| 167 | + 'contest-contest-reminder-preview', |
| 168 | + 'contest-contest-reminder-sending', |
| 169 | + 'contest-contest-reminder-success', |
| 170 | + 'contest-contest-reminder-close', |
| 171 | + 'contest-contest-reminder-retry', |
| 172 | + 'contest-contest-reminder-failed', |
168 | 173 | ), |
169 | 174 | 'dependencies' => array( |
170 | 175 | 'jquery.ui.button', 'jquery.ui.dialog', |
Index: trunk/extensions/Contest/api/ApiMailContestants.php |
— | — | @@ -18,7 +18,6 @@ |
19 | 19 | parent::__construct( $main, $action ); |
20 | 20 | } |
21 | 21 | |
22 | | - // TODO |
23 | 22 | public function execute() { |
24 | 23 | global $wgUser; |
25 | 24 | |
— | — | @@ -71,11 +70,11 @@ |
72 | 71 | $conditions['id'] = $params['ids']; |
73 | 72 | } |
74 | 73 | |
75 | | - $contestants = ContestContestant::s()->select( 'email', $conditions ); |
| 74 | + $contestants = ContestContestant::s()->select( array( 'contest_id', 'email' ), $conditions ); |
76 | 75 | |
77 | 76 | if ( $contestants !== false && count( $contestants ) > 0 ) { |
78 | 77 | $setSize = ContestSettings::get( 'reminderJobSize' ); |
79 | | - $limit = count( $contestants ) - $setSize; |
| 78 | + $limit = count( $contestants ); |
80 | 79 | |
81 | 80 | for ( $i = 0; $i <= $limit; $i += $setSize ) { |
82 | 81 | $this->createReminderJob( array_splice( $contestants, $i, $setSize ) ); |
Index: trunk/extensions/Contest/resources/contest.special.contest.js |
— | — | @@ -10,22 +10,59 @@ |
11 | 11 | |
12 | 12 | var _this = this; |
13 | 13 | |
14 | | - this.sendReminder = function() { |
| 14 | + this.sendReminder = function( callback ) { |
| 15 | + var requestArgs = { |
| 16 | + 'action': 'mailcontestants', |
| 17 | + 'format': 'json', |
| 18 | + 'token': $( '#send-reminder' ).attr( 'data-token' ), |
| 19 | + 'contestids': $( '#send-reminder' ).attr( 'data-contest-id' ) |
| 20 | + }; |
15 | 21 | |
| 22 | + $.post( |
| 23 | + wgScriptPath + '/api.php', |
| 24 | + requestArgs, |
| 25 | + function( data ) { |
| 26 | + callback( data ); |
| 27 | + } |
| 28 | + ); |
16 | 29 | }; |
17 | 30 | |
18 | 31 | this.showReminderDialog = function() { |
| 32 | + var $dialog = null; |
| 33 | + |
19 | 34 | $dialog = $( '<div />' ).html( '' ).dialog( { |
20 | 35 | 'title': mw.msg( 'contest-contest-reminder-title' ), |
21 | 36 | 'buttons': [ |
22 | 37 | { |
23 | 38 | 'text': mw.msg( 'contest-contest-reminder-send' ), |
24 | | - 'click': function() { _this.sendReminder(); } |
| 39 | + 'id': 'reminder-send-button', |
| 40 | + 'click': function() { |
| 41 | + var $send = $( '#reminder-send-button' ); |
| 42 | + var $cancel = $( '#reminder-cancel-button' ); |
| 43 | + |
| 44 | + $send.button( 'option', 'disabled', true ); |
| 45 | + $send.button( 'option', 'label', mw.msg( 'contest-contest-reminder-sending' ) ); |
| 46 | + |
| 47 | + _this.sendReminder( function( data ) { |
| 48 | + if ( data.success ) { |
| 49 | + $dialog.text( mw.msg( 'contest-contest-reminder-success', data.contestantcount ) ); |
| 50 | + $send.remove(); |
| 51 | + $cancel.button( 'option', 'label', mw.msg( 'contest-contest-reminder-close' ) ); |
| 52 | + } |
| 53 | + else { |
| 54 | + $send.button( 'option', 'label', mw.msg( 'contest-contest-reminder-retry' ) ); |
| 55 | + $send.button( 'option', 'disabled', false ); |
| 56 | + |
| 57 | + alert( mw.msg( 'contest-contest-reminder-failed' ) ); |
| 58 | + } |
| 59 | + } ); |
| 60 | + } |
25 | 61 | }, |
26 | 62 | { |
27 | 63 | 'text': mw.msg( 'contest-contest-reminder-cancel' ), |
| 64 | + 'id': 'reminder-cancel-button', |
28 | 65 | 'click': function() { |
29 | | - $( this ).dialog( 'close' ); |
| 66 | + $dialog.dialog( 'close' ); |
30 | 67 | } |
31 | 68 | } |
32 | 69 | ] |