Index: trunk/extensions/Contest/specials/SpecialContests.php |
— | — | @@ -216,17 +216,19 @@ |
217 | 217 | ), |
218 | 218 | wfMsg( 'contest-special-edit' ) |
219 | 219 | ); |
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 | + global $wgContestDeletionEnabled; |
| 221 | + if ( $wgContestDeletionEnabled ) { |
| 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 | + } |
231 | 233 | } |
232 | 234 | |
233 | 235 | $links[] = Html::element( |
Index: trunk/extensions/Contest/Contest.php |
— | — | @@ -301,3 +301,5 @@ |
302 | 302 | |
303 | 303 | $wgContestMailSender = $wgPasswordSender; |
304 | 304 | $wgContestMailSenderName = $wgPasswordSenderName; |
| 305 | + |
| 306 | +$wgContestDeletionEnabled = true; |
Index: trunk/extensions/Contest/includes/ContestDBObject.php |
— | — | @@ -23,15 +23,15 @@ |
24 | 24 | * @var array |
25 | 25 | */ |
26 | 26 | protected $fields = array( 'id' => null ); |
27 | | - |
| 27 | + |
28 | 28 | /** |
29 | 29 | * The database connection to use for read operations. |
30 | | - * |
| 30 | + * |
31 | 31 | * @since 0.2 |
32 | 32 | * @var integer DB_ enum |
33 | 33 | */ |
34 | 34 | protected static $readDb = DB_SLAVE; |
35 | | - |
| 35 | + |
36 | 36 | /** |
37 | 37 | * Constructor. |
38 | 38 | * |
— | — | @@ -281,7 +281,7 @@ |
282 | 282 | return $this->insertIntoDB(); |
283 | 283 | } |
284 | 284 | } |
285 | | - |
| 285 | + |
286 | 286 | /** |
287 | 287 | * Updates the object in the database. |
288 | 288 | * |
— | — | @@ -330,13 +330,13 @@ |
331 | 331 | * @return boolean Success indicator |
332 | 332 | */ |
333 | 333 | public function removeFromDB() { |
334 | | - $sucecss = $this->delete( array( 'id' => $this->getId() ) ); |
| 334 | + $success = $this->delete( array( 'id' => $this->getId() ) ); |
335 | 335 | |
336 | | - if ( $sucecss ) { |
| 336 | + if ( $success ) { |
337 | 337 | $this->setField( 'id', null ); |
338 | 338 | } |
339 | 339 | |
340 | | - return $sucecss; |
| 340 | + return $success; |
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
— | — | @@ -461,25 +461,25 @@ |
462 | 462 | |
463 | 463 | /** |
464 | 464 | * Get the database type used for read operations. |
465 | | - * |
| 465 | + * |
466 | 466 | * @since 0.2 |
467 | 467 | * @return integer DB_ enum |
468 | 468 | */ |
469 | 469 | public function getReadDb() { |
470 | 470 | return self::$readDb; |
471 | 471 | } |
472 | | - |
| 472 | + |
473 | 473 | /** |
474 | 474 | * Set the database type to use for read operations. |
475 | | - * |
| 475 | + * |
476 | 476 | * @param integer $db |
477 | | - * |
| 477 | + * |
478 | 478 | * @since 0.2 |
479 | 479 | */ |
480 | 480 | public function setReadDb( $db ) { |
481 | 481 | self::$readDb = $db; |
482 | 482 | } |
483 | | - |
| 483 | + |
484 | 484 | /** |
485 | 485 | * Gets if the object can take a certain field. |
486 | 486 | * |
Index: trunk/extensions/Contest/includes/Contest.class.php |
— | — | @@ -412,6 +412,11 @@ |
413 | 413 | * @return boolean Success indicator |
414 | 414 | */ |
415 | 415 | public function removeAllFromDB() { |
| 416 | + global $wgContestDeletionEnabled; |
| 417 | + if ( !$wgContestDeletionEnabled ) { |
| 418 | + // Shouldn't get here (UI should prevent it) |
| 419 | + throw new MWException( 'Contest deletion is disabled', 'contestdeletiondisabled' ); |
| 420 | + } |
416 | 421 | $condition = array( 'contest_id' => $this->getId() ); |
417 | 422 | |
418 | 423 | $success = ContestChallenge::s()->delete( $condition ); |
Index: trunk/extensions/Contest/api/ApiDeleteContest.php |
— | — | @@ -19,6 +19,10 @@ |
20 | 20 | } |
21 | 21 | |
22 | 22 | public function execute() { |
| 23 | + global $wgContestDeletionEnabled; |
| 24 | + if ( !$wgContestDeletionEnabled ) { |
| 25 | + $this->dieUsage( 'Contest deletion is disabled', 'contestdeletiondisabled' ); |
| 26 | + } |
23 | 27 | global $wgUser; |
24 | 28 | |
25 | 29 | if ( !$wgUser->isAllowed( 'contestadmin' ) || $wgUser->isBlocked() ) { |
— | — | @@ -80,7 +84,7 @@ |
81 | 85 | |
82 | 86 | public function getPossibleErrors() { |
83 | 87 | return array_merge( parent::getPossibleErrors(), array( |
84 | | - array( 'missingparam', 'ids' ), |
| 88 | + array( 'code' => 'contestdeletiondisabled', 'info' => 'Contest deletion is disabled' ), |
85 | 89 | ) ); |
86 | 90 | } |
87 | 91 | |