Index: trunk/extensions/Contest/specials/SpecialContestSubmission.php |
— | — | @@ -67,9 +67,6 @@ |
68 | 68 | case Contest::STATUS_ACTIVE: |
69 | 69 | $this->handleEnabledPage( $contest ); |
70 | 70 | break; |
71 | | - case Contest::STATUS_DRAFT: |
72 | | - // TODO |
73 | | - break; |
74 | 71 | case Contest::STATUS_FINISHED: |
75 | 72 | $this->showWarning( 'contest-submission-finished' ); |
76 | 73 | $out->addHTML( '<br /><br /><br /><br />' ); |
Index: trunk/extensions/Contest/specials/SpecialContestSignup.php |
— | — | @@ -99,7 +99,9 @@ |
100 | 100 | $this->showEnabledPage( $contest, $challangeId ); |
101 | 101 | break; |
102 | 102 | case Contest::STATUS_DRAFT: |
103 | | - // TODO |
| 103 | + $this->showWarning( 'contest-signup-draft' ); |
| 104 | + $out->addHTML( '<br /><br /><br /><br />' ); |
| 105 | + $out->returnToMain(); |
104 | 106 | break; |
105 | 107 | case Contest::STATUS_FINISHED: |
106 | 108 | $this->showWarning( 'contest-signup-finished' ); |
Index: trunk/extensions/Contest/includes/Contest.class.php |
— | — | @@ -312,4 +312,38 @@ |
313 | 313 | return $success; |
314 | 314 | } |
315 | 315 | |
| 316 | + /** |
| 317 | + * Add an amount (can be negative) to the total submissions for this contest. |
| 318 | + * |
| 319 | + * @since 0.1 |
| 320 | + * |
| 321 | + * @param integer $amount |
| 322 | + * |
| 323 | + * @return boolean Success indicator |
| 324 | + */ |
| 325 | + public function addToSubmissionCount( $amount ) { |
| 326 | + if ( $amount == 0 ) { |
| 327 | + return true; |
| 328 | + } |
| 329 | + |
| 330 | + $absoluteAmount = abs( $amount ); |
| 331 | + $isNegative = $amount < 0; |
| 332 | + |
| 333 | + $dbw = wfGetDB( DB_MASTER ); |
| 334 | + |
| 335 | + $countField = $this->getPrefixedField( 'submission_count' ); |
| 336 | + |
| 337 | + $success = $dbw->update( |
| 338 | + $this->getDBTable(), |
| 339 | + array( "$countField=$countField" . ( $isNegative ? '-' : '+' ) . $absoluteAmount ), |
| 340 | + array( $this->getPrefixedField( 'id' ) => $this->getId() ) |
| 341 | + ); |
| 342 | + |
| 343 | + if ( $success && $this->hasField( 'submission_count' ) ) { |
| 344 | + $this->setField( 'submission_count', $this->getField( 'submission_count' ) + $amount ); |
| 345 | + } |
| 346 | + |
| 347 | + return $success; |
| 348 | + } |
| 349 | + |
316 | 350 | } |
\ No newline at end of file |
Index: trunk/extensions/Contest/includes/ContestContestant.php |
— | — | @@ -124,14 +124,22 @@ |
125 | 125 | * |
126 | 126 | * @since 0.1 |
127 | 127 | * |
| 128 | + * @param array|null $fields The fields to load, null for all fields. |
| 129 | + * |
128 | 130 | * @return Contest |
129 | 131 | */ |
130 | | - public function getContest() { |
131 | | - if ( is_null( $this->contest ) ) { |
132 | | - $this->contest = Contest::s()->selectRow( null, array( 'id' => $this->getField( 'contest_id' ) ) ); |
| 132 | + public function getContest( array $fields = null ) { |
| 133 | + if ( !is_null( $this->contest ) ) { |
| 134 | + return $this->contest; |
133 | 135 | } |
134 | 136 | |
135 | | - return $this->contest; |
| 137 | + $contest = Contest::s()->selectRow( $fields, array( 'id' => $this->getField( 'contest_id' ) ) ); |
| 138 | + |
| 139 | + if ( is_null( $this->contest ) && is_null( $fields ) ) { |
| 140 | + $this->contest = $contest; |
| 141 | + } |
| 142 | + |
| 143 | + return $contest; |
136 | 144 | } |
137 | 145 | |
138 | 146 | /** |
— | — | @@ -420,5 +428,18 @@ |
421 | 429 | ); |
422 | 430 | } |
423 | 431 | |
| 432 | + /** |
| 433 | + * (non-PHPdoc) |
| 434 | + * @see ContestDBObject::insertIntoDB() |
| 435 | + */ |
| 436 | + protected function insertIntoDB() { |
| 437 | + $success = parent::insertIntoDB(); |
| 438 | + |
| 439 | + if ( $success ) { |
| 440 | + $this->getContest( array( 'id' ) )->addToSubmissionCount( 1 ); |
| 441 | + } |
| 442 | + |
| 443 | + return $success; |
| 444 | + } |
424 | 445 | |
425 | 446 | } |
Index: trunk/extensions/Contest/Contest.i18n.php |
— | — | @@ -109,6 +109,7 @@ |
110 | 110 | 'contest-signup-readrules' => 'I confirm that I have read, and agree to, [[$1|the contest rules]]', |
111 | 111 | 'contest-signup-challange' => 'What challenge do you want to take on?', |
112 | 112 | 'contest-signup-finished' => 'This contest has ended.', |
| 113 | + 'contest-signup-draft' => 'This contest has not started yet. Please be patient.', |
113 | 114 | 'contest-signup-country' => 'Your country', |
114 | 115 | |
115 | 116 | // Special:ContestSubmission |