r98802 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98801‎ | r98802 | r98803 >
Date:20:39, 3 October 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
some work on contest class
Modified paths:
  • /trunk/extensions/Contest/includes/Contest.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Contest/includes/Contest.class.php
@@ -13,14 +13,39 @@
1414 */
1515 class Contest extends ContestDBObject {
1616
 17+ // Constants representing the states a contest can have.
1718 const STATUS_DRAFT = 0;
1819 const STATUS_ACTIVE = 1;
1920 const STATUS_FINISHED = 2;
2021
 22+ /**
 23+ * List of challanges for this contest.
 24+ * @see loadChallanges, setChallanges and writeChallangesToDB
 25+ *
 26+ * @since 0.1
 27+ * @var array of ContestChallange
 28+ */
2129 protected $challanges = null;
 30+
 31+ /**
 32+ * List of contestants for this contest.
 33+ * @see loadContestants, setContestants and writeContestantsToDB
 34+ *
 35+ * @since 0.1
 36+ * @var array of ContestContestant
 37+ */
2238 protected $contestants = null;
2339
2440 /**
 41+ * Indicates if the contest was set from non-finished to finished.
 42+ * This is used to take further action on save of the object.
 43+ *
 44+ * @since 0.1
 45+ * @var boolean
 46+ */
 47+ protected $wasSetToFinished = false;
 48+
 49+ /**
2550 * Method to get an instance so methods that ought to be static,
2651 * but can't be due to PHP 5.2 not having LSB, can be called on
2752 * it. This also allows easy identifying of code that needs to
@@ -240,6 +265,21 @@
241266 }
242267
243268 /**
 269+ * (non-PHPdoc)
 270+ * @see ContestDBObject::writeToDB()
 271+ */
 272+ public function writeToDB() {
 273+ $success = parent::writeToDB();
 274+
 275+ if ( $success && $this->wasSetToFinished ) {
 276+ $this->doFinishActions();
 277+ $this->wasSetToFinished = false;
 278+ }
 279+
 280+ return $success;
 281+ }
 282+
 283+ /**
244284 * Write the contest and all set challanges and participants to the database.
245285 *
246286 * @since 0.1
@@ -247,8 +287,8 @@
248288 * @return boolean Success indicator
249289 */
250290 public function writeAllToDB() {
251 - $success = parent::writeToDB();
252 -
 291+ $success = self::writeToDB();
 292+
253293 if ( $success ) {
254294 $success = $this->writeChallangesToDB();
255295 }
@@ -354,4 +394,24 @@
355395 return $success;
356396 }
357397
 398+ /**
 399+ * (non-PHPdoc)
 400+ * @see ContestDBObject::setField()
 401+ */
 402+ public function setField( $name, $value ) {
 403+ if ( $name == 'status' && $value == self::STATUS_FINISHED
 404+ && $this->hasField( $name ) && $this->getField( $name ) != self::STATUS_FINISHED ) {
 405+ $this->wasSetToFinished = true;
 406+ }
 407+ }
 408+
 409+ /**
 410+ * Do all actions that need to be done on contest finish.
 411+ *
 412+ * @since 0.1
 413+ */
 414+ public function doFinishActions() {
 415+ // TODO
 416+ }
 417+
358418 }

Status & tagging log