Index: trunk/extensions/LiquidThreads/api/ApiThreadAction.php |
— | — | @@ -48,6 +48,8 @@ |
49 | 49 | return array( |
50 | 50 | array( 'sessionfailure' ), |
51 | 51 | array( 'missingparam', 'action' ), |
| 52 | + array( 'missingparam', 'talkpage' ), |
| 53 | + array( 'missingparam', 'subject' ), |
52 | 54 | array( 'code' => 'too-many-threads', 'info' => 'You may only split one thread at a time' ), |
53 | 55 | array( 'code' => 'no-specified-threads', 'info' => 'You must specify a thread to split' ), |
54 | 56 | array( 'code' => 'already-top-level', 'info' => 'This thread is already a top-level thread.' ), |
— | — | @@ -55,10 +57,8 @@ |
56 | 58 | array( 'code' => 'no-specified-threads', 'info' => 'You must specify a thread to merge' ), |
57 | 59 | array( 'code' => 'no-parent-thread', 'info' => 'You must specify a new parent thread to merge beneath' ), |
58 | 60 | array( 'code' => 'invalid-parent-thread', 'info' => 'The parent thread you specified was neither the title of a thread, nor a thread ID.' ), |
59 | | - array( 'code' => 'missing-param', 'info' => 'You must specify a talk-page to post the thread to' ), |
60 | 61 | array( 'code' => 'invalid-talkpage', 'info' => 'The talkpage you specified is invalid, or does not have discussion threading enabled.' ), |
61 | 62 | array( 'code' => 'talkpage-protected', 'info' => 'You cannot post to the specified talkpage, because it is protected from new posts' ), |
62 | | - array( 'code' => 'missing-param', 'info' => 'You must specify a thread subject' ), |
63 | 63 | array( 'code' => 'invalid-subject', 'info' => 'The subject you specified is not valid' ), |
64 | 64 | array( 'code' => 'no-text', 'info' => 'You must include text in your post' ), |
65 | 65 | array( 'code' => 'too-many-threads', 'info' => 'You may only edit one thread at a time' ), |
— | — | @@ -67,7 +67,6 @@ |
68 | 68 | array( 'code' => 'perm_result-protected', 'info' => 'You cannot reply to this thread, because the perm_result is protected from replies.' ), |
69 | 69 | array( 'code' => 'too-many-threads', 'info' => 'You may only change the subject of one thread at a time' ), |
70 | 70 | array( 'code' => 'no-specified-threads', 'info' => 'You must specify a thread to change the subject of' ), |
71 | | - array( 'code' => 'missing-param', 'info' => 'You must specify a thread subject' ), |
72 | 71 | array( 'code' => 'no-specified-threads', 'info' => 'You must specify a thread to set the sortkey of' ), |
73 | 72 | array( 'code' => 'invalid-sortkey', 'info' => 'You must specify a valid timestamp for the sortkey parameter. It should be in the form YYYYMMddhhmmss, a unix timestamp or "now".' ), |
74 | 73 | ); |
— | — | @@ -207,11 +206,9 @@ |
208 | 207 | if ( count( $threads ) > 1 ) { |
209 | 208 | $this->dieUsage( 'You may only split one thread at a time', |
210 | 209 | 'too-many-threads' ); |
211 | | - return; |
212 | 210 | } elseif ( count( $threads ) < 1 ) { |
213 | 211 | $this->dieUsage( 'You must specify a thread to split', |
214 | 212 | 'no-specified-threads' ); |
215 | | - return; |
216 | 213 | } |
217 | 214 | |
218 | 215 | $thread = array_pop( $threads ); |
— | — | @@ -269,13 +266,11 @@ |
270 | 267 | if ( count( $threads ) < 1 ) { |
271 | 268 | $this->dieUsage( 'You must specify a thread to merge', |
272 | 269 | 'no-specified-threads' ); |
273 | | - return; |
274 | 270 | } |
275 | 271 | |
276 | 272 | if ( empty( $params['newparent'] ) ) { |
277 | 273 | $this->dieUsage( 'You must specify a new parent thread to merge beneath', |
278 | 274 | 'no-parent-thread' ); |
279 | | - return; |
280 | 275 | } |
281 | 276 | |
282 | 277 | $newParent = $params['newparent']; |
— | — | @@ -290,7 +285,6 @@ |
291 | 286 | if ( !$newParent ) { |
292 | 287 | $this->dieUsage( 'The parent thread you specified was neither the title ' . |
293 | 288 | 'of a thread, nor a thread ID.', 'invalid-parent-thread' ); |
294 | | - return; |
295 | 289 | } |
296 | 290 | |
297 | 291 | // Pull a reason, if applicable. |
— | — | @@ -324,10 +318,7 @@ |
325 | 319 | |
326 | 320 | // Validate talkpage parameters |
327 | 321 | if ( empty( $params['talkpage'] ) ) { |
328 | | - $this->dieUsage( 'You must specify a talk-page to post the thread to', |
329 | | - 'missing-param' ); |
330 | | - |
331 | | - return; |
| 322 | + $this->dieUsageMsg( array( 'missingparam', 'talkpage' ) ); |
332 | 323 | } |
333 | 324 | |
334 | 325 | $talkpageTitle = Title::newFromText( $params['talkpage'] ); |
— | — | @@ -335,7 +326,6 @@ |
336 | 327 | if ( !$talkpageTitle || !LqtDispatch::isLqtPage( $talkpageTitle ) ) { |
337 | 328 | $this->dieUsage( 'The talkpage you specified is invalid, or does not ' . |
338 | 329 | 'have discussion threading enabled.', 'invalid-talkpage' ); |
339 | | - return; |
340 | 330 | } |
341 | 331 | $talkpage = new Article( $talkpageTitle ); |
342 | 332 | |
— | — | @@ -343,14 +333,11 @@ |
344 | 334 | if ( Thread::canUserPost( $wgUser, $talkpage ) !== true ) { |
345 | 335 | $this->dieUsage( 'You cannot post to the specified talkpage, ' . |
346 | 336 | 'because it is protected from new posts', 'talkpage-protected' ); |
347 | | - return; |
348 | 337 | } |
349 | 338 | |
350 | 339 | // Validate subject, generate a title |
351 | 340 | if ( empty( $params['subject'] ) ) { |
352 | | - $this->dieUsage( 'You must specify a thread subject', |
353 | | - 'missing-param' ); |
354 | | - return; |
| 341 | + $this->dieUsageMsg( array( 'missingparam', 'subject' ) ); |
355 | 342 | } |
356 | 343 | |
357 | 344 | $bump = isset( $params['bump'] ) ? $params['bump'] : null; |
— | — | @@ -362,15 +349,12 @@ |
363 | 350 | if ( !$subjectOk ) { |
364 | 351 | $this->dieUsage( 'The subject you specified is not valid', |
365 | 352 | 'invalid-subject' ); |
366 | | - |
367 | | - return; |
368 | 353 | } |
369 | 354 | $article = new Article( $title ); |
370 | 355 | |
371 | 356 | // Check for text |
372 | 357 | if ( empty( $params['text'] ) ) { |
373 | 358 | $this->dieUsage( 'You must include text in your post', 'no-text' ); |
374 | | - return; |
375 | 359 | } |
376 | 360 | $text = $params['text']; |
377 | 361 | |
— | — | @@ -452,11 +436,9 @@ |
453 | 437 | if ( count($threads) > 1 ) { |
454 | 438 | $this->dieUsage( 'You may only edit one thread at a time', |
455 | 439 | 'too-many-threads' ); |
456 | | - return; |
457 | 440 | } elseif ( count($threads) < 1 ) { |
458 | 441 | $this->dieUsage( 'You must specify a thread to edit', |
459 | 442 | 'no-specified-threads' ); |
460 | | - return; |
461 | 443 | } |
462 | 444 | |
463 | 445 | $thread = array_pop( $threads ); |
— | — | @@ -478,14 +460,11 @@ |
479 | 461 | if ( !$subjectOk ) { |
480 | 462 | $this->dieUsage( 'The subject you specified is not valid', |
481 | 463 | 'invalid-subject' ); |
482 | | - |
483 | | - return; |
484 | 464 | } |
485 | 465 | |
486 | 466 | // Check for text |
487 | 467 | if ( empty( $params['text'] ) ) { |
488 | 468 | $this->dieUsage( 'You must include text in your post', 'no-text' ); |
489 | | - return; |
490 | 469 | } |
491 | 470 | $text = $params['text']; |
492 | 471 | |
— | — | @@ -567,11 +546,9 @@ |
568 | 547 | if ( count( $threads ) > 1 ) { |
569 | 548 | $this->dieUsage( 'You may only reply to one thread at a time', |
570 | 549 | 'too-many-threads' ); |
571 | | - return; |
572 | 550 | } elseif ( count( $threads ) < 1 ) { |
573 | 551 | $this->dieUsage( 'You must specify a thread to reply to', |
574 | 552 | 'no-specified-threads' ); |
575 | | - return; |
576 | 553 | } |
577 | 554 | $replyTo = array_pop( $threads ); |
578 | 555 | |
— | — | @@ -581,13 +558,11 @@ |
582 | 559 | $this->dieUsage( "You cannot reply to this thread, because the " . |
583 | 560 | $perm_result . " is protected from replies.", |
584 | 561 | $perm_result . '-protected' ); |
585 | | - return; |
586 | 562 | } |
587 | 563 | |
588 | 564 | // Validate text parameter |
589 | 565 | if ( empty( $params['text'] ) ) { |
590 | 566 | $this->dieUsage( 'You must include text in your post', 'no-text' ); |
591 | | - return; |
592 | 567 | } |
593 | 568 | |
594 | 569 | $text = $params['text']; |
— | — | @@ -710,19 +685,15 @@ |
711 | 686 | if ( count( $threads ) > 1 ) { |
712 | 687 | $this->dieUsage( 'You may only change the subject of one thread at a time', |
713 | 688 | 'too-many-threads' ); |
714 | | - return; |
715 | 689 | } elseif ( count( $threads ) < 1 ) { |
716 | 690 | $this->dieUsage( 'You must specify a thread to change the subject of', |
717 | 691 | 'no-specified-threads' ); |
718 | | - return; |
719 | 692 | } |
720 | 693 | $thread = array_pop( $threads ); |
721 | 694 | |
722 | 695 | // Validate subject |
723 | 696 | if ( empty( $params['subject'] ) ) { |
724 | | - $this->dieUsage( 'You must specify a thread subject', |
725 | | - 'missing-param' ); |
726 | | - return; |
| 697 | + $this->dieUsageMsg( array( 'missingparam', 'subject' ) ); |
727 | 698 | } |
728 | 699 | |
729 | 700 | $talkpage = $thread->article(); |
— | — | @@ -734,8 +705,6 @@ |
735 | 706 | if ( !$subjectOk ) { |
736 | 707 | $this->dieUsage( 'The subject you specified is not valid', |
737 | 708 | 'invalid-subject' ); |
738 | | - |
739 | | - return; |
740 | 709 | } |
741 | 710 | |
742 | 711 | $reason = null; |
— | — | @@ -765,7 +734,6 @@ |
766 | 735 | if ( !count( $threads ) ) { |
767 | 736 | $this->dieUsage( 'You must specify a thread to set the sortkey of', |
768 | 737 | 'no-specified-threads' ); |
769 | | - return; |
770 | 738 | } |
771 | 739 | |
772 | 740 | // Validate timestamp |
— | — | @@ -773,7 +741,6 @@ |
774 | 742 | $this->dieUsage( 'You must specify a valid timestamp for the sortkey ' . |
775 | 743 | 'parameter. It should be in the form YYYYMMddhhmmss, a ' . |
776 | 744 | 'unix timestamp or "now".', 'invalid-sortkey' ); |
777 | | - return; |
778 | 745 | } |
779 | 746 | |
780 | 747 | $ts = $params['sortkey']; |
— | — | @@ -786,7 +753,6 @@ |
787 | 754 | $this->dieUsage( 'You must specify a valid timestamp for the sortkey' . |
788 | 755 | 'parameter. It should be in the form YYYYMMddhhmmss, a ' . |
789 | 756 | 'unix timestamp or "now".', 'invalid-sortkey' ); |
790 | | - return; |
791 | 757 | } |
792 | 758 | |
793 | 759 | $reason = null; |
— | — | @@ -815,4 +781,4 @@ |
816 | 782 | public function getVersion() { |
817 | 783 | return __CLASS__ . ': $Id: $'; |
818 | 784 | } |
819 | | -} |
| 785 | +} |
\ No newline at end of file |