r100440 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100439‎ | r100440 | r100441 >
Date:19:22, 21 October 2011
Author:reedy
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/wmf/1.18wmf1/extensions/Contest (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Contest/Contest.i18n.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Contest/Contest.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Contest/Contest.settings.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Contest/api/ApiDeleteContest.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Contest/includes/Contest.class.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Contest/includes/ContestContestant.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Contest/includes/ContestDBObject.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Contest/resources/contest.contestant.pager.css (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Contest/resources/contest.contestant.pager.js (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Contest/resources/contest.special.editcontest.js (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Contest/specials/SpecialContest.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Contest/specials/SpecialContestWelcome.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Contest/specials/SpecialContestant.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Contest/specials/SpecialContests.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Contest/specials/SpecialEditContest.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/extensions/Contest/Contest.i18n.php
@@ -61,7 +61,7 @@
6262 'specialpages-group-contest' => 'Contests',
6363
6464 // Navigation links
65 - 'contest-nav-contests' => 'Contests list',
 65+ 'contest-nav-contests' => 'Contest list',
6666 'contest-nav-editcontest' => 'Edit contest',
6767 'contest-nav-contest' => 'Summary and participants',
6868 'contest-nav-contestwelcome' => 'Landing page',
@@ -122,7 +122,7 @@
123123 'contest-signup-header' => 'Please fill out the form to complete your registration for $1.',
124124 'contest-signup-email' => 'Your e-mail address',
125125 'contest-signup-realname' => 'Your real name',
126 - 'contest-signup-volunteer' => 'I am interested in receiving email about volunteer opportunities',
 126+ 'contest-signup-volunteer' => 'I am interested in receiving e-mail about volunteer opportunities',
127127 'contest-signup-wmf' => 'I am interested in being contacted about working for the Wikimedia Foundation',
128128 'contest-signup-cv' => 'Link to your CV',
129129 'contest-signup-readrules' => 'I confirm that I have read [[$1|the contest rules]] and agree to them',
@@ -160,10 +160,10 @@
161161 'contest-contest-reminder-cancel' => 'Cancel',
162162 'contest-contest-reminder-sending' => 'Sending...',
163163 // We really want // {{PLURAL:$1|contestant|contestants}} here, but the JS i18n shizzle does not support it yet :/
164 - 'contest-contest-reminder-success' => 'Successfully sent the reminder email to $1 contestants',
 164+ 'contest-contest-reminder-success' => 'Successfully sent the reminder e-mail to $1 contestants',
165165 'contest-contest-reminder-close' => 'Close',
166166 'contest-contest-reminder-retry' => 'Retry sending',
167 - 'contest-contest-reminder-failed' => 'Could not sent the reminder emails.',
 167+ 'contest-contest-reminder-failed' => 'Could not send the reminder e-mails.',
168168 'contest-contest-reminder-subject' => 'Subject:',
169169
170170 // Contestant pager
@@ -209,7 +209,7 @@
210210 'contest-mycontests-active-header' => 'Running contests',
211211 'contest-mycontests-finished-header' => 'Passed contests',
212212 'contest-mycontests-active-text' => 'You are currently participating in these contests:',
213 - 'contest-mycontests-finished-text' => 'You have have participated in these contests:',
 213+ 'contest-mycontests-finished-text' => 'You have participated in these contests:',
214214 'contest-mycontests-header-contest' => 'Contest',
215215 'contest-mycontests-header-challenge' => 'Challenge',
216216 'contest-mycontests-signup-success' => 'You have successfully signed up for the "$1" contest.',
@@ -270,6 +270,20 @@
271271 'contest-contest-contestants' => 'Page section header',
272272 'contest-contest-days-ago' => '$1 is a date, $2 is an integer, the amount of days',
273273 'contest-contest-days-left' => '$1 is a date, $2 is an integer, the amount of days',
 274+ 'contest-contest-contestants' => 'Page section header',
 275+ 'contest-contest-reminder-mail' => 'Reminder e-mail',
 276+ 'contest-contest-reminder-page' => 'Text explaining the e-mail content is pulled from a page, $1 is the page name.',
 277+ 'contest-contest-send-reminder' => 'Send reminder button text',
 278+ 'contest-contest-reminder-preview' => 'Text indicating that the following content is the preview for the reminder email.',
 279+ 'contest-contest-reminder-title' => 'Dialog title',
 280+ 'contest-contest-reminder-send' => 'Send button text',
 281+ 'contest-contest-reminder-cancel' => 'Cancel button text',
 282+ 'contest-contest-reminder-sending' => 'Send button text after clicking it',
 283+ '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.',
 284+ 'contest-contest-reminder-close' => 'Close button text',
 285+ 'contest-contest-reminder-retry' => 'Retry button text',
 286+ 'contest-contest-reminder-failed' => 'Failiure message, displayed in an alert box',
 287+ 'contest-contest-reminder-subject' => 'E-mail subject indicator',
274288 'contest-contestant-id' => 'Table column header',
275289 'contest-contestant-volunteer' => 'Table column header',
276290 'contest-contestant-wmf' => 'Table column header',
Index: branches/wmf/1.18wmf1/extensions/Contest/specials/SpecialContestWelcome.php
@@ -142,11 +142,11 @@
143143 $challenges[] = $data;
144144 }
145145
146 - $this->getOutput()->addScript(
 146+ $output->addScript(
147147 Skin::makeVariablesScript(
148148 array(
149149 'ContestChallenges' => $challenges,
150 - 'ContestConfig' => array()
 150+ 'ContestConfig' => array(),
151151 )
152152 )
153153 );
@@ -188,7 +188,7 @@
189189 */
190190 protected function showRules( Contest $contest ) {
191191 // TODO: we might want to have a pop-up with the content here, instead of a link to the page.
192 - $this->getOutput()->addWikiMsgArray( 'contest-welcome-rules', $contest->getField( 'rules_page' ) );
 192+ $this->getOutput()->addWikiMsgArray( 'contest-welcome-rules', $contest->getField( 'rules_page' ) );
193193 }
194194
195195 /**
Index: branches/wmf/1.18wmf1/extensions/Contest/specials/SpecialContest.php
@@ -56,7 +56,11 @@
5757
5858 $this->displayNavigation();
5959 $this->showGeneralInfo( $contest );
60 - $this->showMailFunctionality( $contest );
 60+
 61+ if ( $this->getUser()->isAllowed( 'contestadmin' ) ) {
 62+ $this->showMailFunctionality( $contest );
 63+ }
 64+
6165 $this->showContestants( $contest, $challengeTitle );
6266
6367 $out->addModules( 'contest.special.contest' );
Index: branches/wmf/1.18wmf1/extensions/Contest/specials/SpecialContestant.php
@@ -27,13 +27,16 @@
2828 *
2929 * @since 0.1
3030 *
31 - * @param string $arg
 31+ * @param string $subPage
3232 */
3333 public function execute( $subPage ) {
3434 if ( !parent::execute( $subPage ) ) {
3535 return;
3636 }
3737
 38+ /**
 39+ * @var $contestant ContestContestant
 40+ */
3841 $contestant = ContestContestant::s()->selectRow( 'id', array( 'id' => (int)$subPage ) );
3942
4043 if ( $contestant === false ) {
@@ -47,10 +50,12 @@
4851 }
4952
5053 if ( $this->getRequest()->wasPosted() ) {
51 - $contestant->setReadDb( DB_MASTER );
 54+ ContestContestant::s()->setReadDb( DB_MASTER );
5255 }
5356
5457 $contestant->loadFields();
 58+ ContestContestant::s()->setReadDb( DB_SLAVE );
 59+
5560 $this->showPage( $contestant );
5661 }
5762 }
@@ -293,7 +298,14 @@
294299
295300 $out->addHTML( '<div class="contestant-comments">' );
296301
297 - foreach ( $contestant->getComments() as /* ContestComment */ $comment ) {
 302+ if ( $this->getRequest()->wasPosted() ) {
 303+ ContestComment::s()->setReadDb( DB_MASTER );
 304+ }
 305+
 306+ $comments = $contestant->getComments();
 307+ ContestComment::s()->setReadDb( DB_SLAVE );
 308+
 309+ foreach ( $comments as /* ContestComment */ $comment ) {
298310 $out->addHTML( $this->getCommentHTML( $comment ) );
299311 }
300312
Index: branches/wmf/1.18wmf1/extensions/Contest/specials/SpecialContests.php
@@ -216,17 +216,19 @@
217217 ),
218218 wfMsg( 'contest-special-edit' )
219219 );
220 -
221 - $links[] = Html::element(
222 - 'a',
223 - array(
224 - 'href' => '#',
225 - 'class' => 'contest-delete',
226 - 'data-contest-id' => $contest->getId(),
227 - 'data-contest-token' => $this->getUser()->editToken( 'deletecontest' . $contest->getId() )
228 - ),
229 - wfMsg( 'contest-special-delete' )
230 - );
 220+
 221+ if ( ContestSettings::get( 'contestDeletionEnabled' ) ) {
 222+ $links[] = Html::element(
 223+ 'a',
 224+ array(
 225+ 'href' => '#',
 226+ 'class' => 'contest-delete',
 227+ 'data-contest-id' => $contest->getId(),
 228+ 'data-contest-token' => $this->getUser()->editToken( 'deletecontest' . $contest->getId() )
 229+ ),
 230+ wfMsg( 'contest-special-delete' )
 231+ );
 232+ }
231233 }
232234
233235 $links[] = Html::element(
Index: branches/wmf/1.18wmf1/extensions/Contest/specials/SpecialEditContest.php
@@ -95,6 +95,13 @@
9696 protected function showContent( $subPage ) {
9797 $isNew = $this->getRequest()->wasPosted() && $this->getUser()->matchEditToken( $this->getRequest()->getVal( 'newEditToken' ) );
9898
 99+ $this->getOutput()->addScript(
 100+ Skin::makeVariablesScript(
 101+ array(
 102+ 'ContestDeletionEnabled' => ContestSettings::get( 'contestDeletionEnabled' ),
 103+ )
 104+ )
 105+ );
99106 if ( $isNew ) {
100107 $data = array( 'name' => $this->getRequest()->getVal( 'newcontest' ) );
101108
@@ -312,7 +319,12 @@
313320 if ( $idString == '' ) {
314321 return true;
315322 }
316 -
 323+
 324+ if ( !ContestSettings::get( 'contestDeletionEnabled' ) ) {
 325+ // Shouldn't get here (UI should prevent it)
 326+ throw new MWException( 'Contest deletion is disabled', 'contestdeletiondisabled' );
 327+ }
 328+
317329 return ContestChallenge::s()->delete( array( 'id' => explode( '|', $idString ) ) );
318330 }
319331
Index: branches/wmf/1.18wmf1/extensions/Contest/Contest.settings.php
@@ -31,7 +31,10 @@
3232 'voteValues' => range( 0, 5 ),
3333 'enableTopLink' => true,
3434 'submissionDomains' => array( 'github.com', 'gitorious.org', 'mediawiki.org' ),
35 - 'reminderJobSize' => 50
 35+ 'reminderJobSize' => 50,
 36+ 'mailSender' => $GLOBALS['wgPasswordSender'],
 37+ 'mailSenderName' => $GLOBALS['wgPasswordSenderName'],
 38+ 'contestDeletionEnabled' => true
3639 );
3740 }
3841
Index: branches/wmf/1.18wmf1/extensions/Contest/Contest.php
@@ -296,6 +296,3 @@
297297 $egContestSettings = array();
298298
299299 $wgContestEmailParse = false;
300 -
301 -$wgContestMailSender = $wgPasswordSender;
302 -$wgContestMailSenderName = $wgPasswordSenderName;
Index: branches/wmf/1.18wmf1/extensions/Contest/includes/ContestDBObject.php
@@ -23,14 +23,14 @@
2424 * @var array
2525 */
2626 protected $fields = array( 'id' => null );
27 -
 27+
2828 /**
2929 * The database connection to use for read operations.
30 - *
 30+ *
3131 * @since 0.2
3232 * @var integer DB_ enum
3333 */
34 - protected $readDb = DB_SLAVE;
 34+ protected static $readDb = DB_SLAVE;
3535
3636 /**
3737 * Constructor.
@@ -281,29 +281,8 @@
282282 return $this->insertIntoDB();
283283 }
284284 }
285 -
 285+
286286 /**
287 - * Get the database type used for read operations.
288 - *
289 - * @since 0.2
290 - * @return integer DB_ enum
291 - */
292 - public function getReadDb() {
293 - return $this->readDb;
294 - }
295 -
296 - /**
297 - * Set the database type to use for read operations.
298 - *
299 - * @param integer $db
300 - *
301 - * @since 0.2
302 - */
303 - public function setReadDb( $db ) {
304 - $this->readDb = $db;
305 - }
306 -
307 - /**
308287 * Updates the object in the database.
309288 *
310289 * @since 0.1
@@ -351,13 +330,13 @@
352331 * @return boolean Success indicator
353332 */
354333 public function removeFromDB() {
355 - $sucecss = $this->delete( array( 'id' => $this->getId() ) );
 334+ $success = $this->delete( array( 'id' => $this->getId() ) );
356335
357 - if ( $sucecss ) {
 336+ if ( $success ) {
358337 $this->setField( 'id', null );
359338 }
360339
361 - return $sucecss;
 340+ return $success;
362341 }
363342
364343 /**
@@ -481,6 +460,27 @@
482461 //
483462
484463 /**
 464+ * Get the database type used for read operations.
 465+ *
 466+ * @since 0.2
 467+ * @return integer DB_ enum
 468+ */
 469+ public function getReadDb() {
 470+ return self::$readDb;
 471+ }
 472+
 473+ /**
 474+ * Set the database type to use for read operations.
 475+ *
 476+ * @param integer $db
 477+ *
 478+ * @since 0.2
 479+ */
 480+ public function setReadDb( $db ) {
 481+ self::$readDb = $db;
 482+ }
 483+
 484+ /**
485485 * Gets if the object can take a certain field.
486486 *
487487 * @since 0.1
Index: branches/wmf/1.18wmf1/extensions/Contest/includes/ContestContestant.php
@@ -489,13 +489,11 @@
490490 * @return Status
491491 */
492492 public function sendSignupEmail() {
493 - global $wgContestMailSender, $wgContestMailSenderName;
494 -
495493 $title = wfMsg( 'contest-email-signup-title' );
496494 $emailText = ContestUtils::getParsedArticleContent( $this->getContest()->getField( 'signup_email' ) );
497495 $user = $this->getUser();
498 - $sender = $wgContestMailSender;
499 - $senderName = $wgContestMailSenderName;
 496+ $sender = ContestSettings::get( 'wgPasswordSender' );
 497+ $senderName = ContestSettings::get( 'wgPasswordSenderName' );
500498
501499 wfRunHooks( 'ContestBeforeSignupEmail', array( &$this, &$title, &$emailText, &$user, &$sender, &$senderName ) );
502500
@@ -517,16 +515,14 @@
518516 * @return Status
519517 */
520518 public function sendReminderEmail( $emailText, array $params = array() ) {
521 - global $wgContestMailSender, $wgContestMailSenderName;
522 -
523519 if ( !array_key_exists( 'daysLeft', $params ) ) {
524520 $params['daysLeft'] = $this->getContest()->getDaysLeft();
525521 }
526522
527523 $title = wfMsgExt( 'contest-email-reminder-title', 'parsemag', $params['daysLeft'] );
528524 $user = $this->getUser();
529 - $sender = $wgContestMailSender;
530 - $senderName = $wgContestMailSenderName;
 525+ $sender = ContestSettings::get( 'wgPasswordSender' );
 526+ $senderName = ContestSettings::get( 'wgPasswordSenderName' );
531527
532528 wfRunHooks( 'ContestBeforeReminderEmail', array( &$this, &$title, &$emailText, &$user, &$sender, &$senderName ) );
533529
Index: branches/wmf/1.18wmf1/extensions/Contest/includes/Contest.class.php
@@ -412,6 +412,10 @@
413413 * @return boolean Success indicator
414414 */
415415 public function removeAllFromDB() {
 416+ if ( !ContestSettings::get( 'contestDeletionEnabled' ) ) {
 417+ // Shouldn't get here (UI should prevent it)
 418+ throw new MWException( 'Contest deletion is disabled', 'contestdeletiondisabled' );
 419+ }
416420 $condition = array( 'contest_id' => $this->getId() );
417421
418422 $success = ContestChallenge::s()->delete( $condition );
Index: branches/wmf/1.18wmf1/extensions/Contest/api/ApiDeleteContest.php
@@ -19,6 +19,9 @@
2020 }
2121
2222 public function execute() {
 23+ if ( !ContestSettings::get( 'contestDeletionEnabled' ) ) {
 24+ $this->dieUsage( 'Contest deletion is disabled', 'contestdeletiondisabled' );
 25+ }
2326 global $wgUser;
2427
2528 if ( !$wgUser->isAllowed( 'contestadmin' ) || $wgUser->isBlocked() ) {
@@ -80,7 +83,7 @@
8184
8285 public function getPossibleErrors() {
8386 return array_merge( parent::getPossibleErrors(), array(
84 - array( 'missingparam', 'ids' ),
 87+ array( 'code' => 'contestdeletiondisabled', 'info' => 'Contest deletion is disabled' ),
8588 ) );
8689 }
8790
Index: branches/wmf/1.18wmf1/extensions/Contest/resources/contest.contestant.pager.css
@@ -6,6 +6,6 @@
77 * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
88 */
99
10 -.contestant-row td:hover {
 10+/*.contestant-row td:hover {
1111 cursor: pointer;
12 -}
\ No newline at end of file
 12+}*/
\ No newline at end of file
Index: branches/wmf/1.18wmf1/extensions/Contest/resources/contest.special.editcontest.js
@@ -80,16 +80,17 @@
8181 ).append( '<br />' ).append( this.textInput )
8282 );
8383
84 - this.deleteButton = $( '<button />' )
85 - .button( { 'label': mw.msg( 'contest-edit-delete' ) } )
86 - .click( function() {
87 - if ( confirm( mw.msg( 'contest-edit-confirm-delete' ) ) ) {
88 - _this.remove();
89 - return false;
90 - }
91 - } );
92 -
93 - $this.append( this.deleteButton );
 84+ if ( mw.config.get( 'ContestDeletionEnabled' ) ) {
 85+ this.deleteButton = $( '<button />' )
 86+ .button( { 'label': mw.msg( 'contest-edit-delete' ) } )
 87+ .click( function() {
 88+ if ( confirm( mw.msg( 'contest-edit-confirm-delete' ) ) ) {
 89+ _this.remove();
 90+ return false;
 91+ }
 92+ } );
 93+ $this.append( this.deleteButton );
 94+ }
9495 };
9596
9697 this.init();
Index: branches/wmf/1.18wmf1/extensions/Contest/resources/contest.contestant.pager.js
@@ -8,12 +8,15 @@
99
1010 (function( $, mw ) {
1111
12 - $( document ).ready( function() {
 12+// $( document ).ready( function() {
 13+//
 14+// $( '.contestant-row' ).click( function( e ) {
 15+// window.open(
 16+// $( this ).attr( 'data-contestant-target' ),
 17+// e.metaKey ? '_blank' : '_self'
 18+// );
 19+// } );
 20+//
 21+// } );
1322
14 - $( '.contestant-row' ).click( function() {
15 - window.location = $( this ).attr( 'data-contestant-target' );
16 - } );
17 -
18 - } );
19 -
2023 })( window.jQuery, window.mediaWiki );
Property changes on: branches/wmf/1.18wmf1/extensions/Contest
___________________________________________________________________
Modified: svn:mergeinfo
2124 Merged /trunk/extensions/Contest:r100405,100419,100427,100432-100433,100435-100439

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r100402use master db after submission so results do not get omitted due to rep lagjeroendedauw01:53, 21 October 2011
r100405Tweak message...reedy03:14, 21 October 2011
r100419Fix r100302, r100255: remove duplicate "have", sent -> send, email -> e-mailrobin14:00, 21 October 2011
r100427Follow up to r100402;jeroendedauw16:22, 21 October 2011
r100428Fix for r100204 - name attribute is only set if it's the correct tag nameyaron16:40, 21 October 2011
r1004321st attempt at disabling deletion...reedy17:37, 21 October 2011
r100433* (bug 31860, bug 31861) Revert most of r99837: i18n construction regression,...brion18:07, 21 October 2011
r100435just forget about clikable rows; turns out to be very hard and not nice to ha...jeroendedauw18:33, 21 October 2011
r100436Followup r100432...reedy18:47, 21 October 2011
r100437Followup r100436, put the code in the right placereedy18:53, 21 October 2011
r100439only show mail stuff for adminsjeroendedauw19:08, 21 October 2011

Status & tagging log