Index: trunk/extensions/Commentbox/SpecialAddComment_body.php |
— | — | @@ -20,12 +20,7 @@ |
21 | 21 | return; |
22 | 22 | } |
23 | 23 | $this->setHeaders(); |
24 | | - |
25 | 24 | |
26 | | - if ( !$this->userCanExecute( $wgUser ) ) { |
27 | | - $this->displayRestrictionError(); |
28 | | - return; |
29 | | - } |
30 | 25 | $Pagename = $wgRequest->getText( 'wpPageName' ); |
31 | 26 | $Author = $wgRequest->getText( 'wpAuthor', '' ); |
32 | 27 | $Comment = $wgRequest->getText( 'wpComment', '' ); |
— | — | @@ -75,14 +70,38 @@ |
76 | 71 | // Append <br /> after each newline, except if the user started a new paragraph |
77 | 72 | $Comment = preg_replace( '/(?<!\n)\n(?!\n)/', "<br />\n", $Comment ); |
78 | 73 | $text .= "\n\n" . $subject . $Comment . "\n<br />" . $sig; |
79 | | - $status = $article->doEdit( $text, wfMsgForContent( 'commentbox-log' ) ); |
80 | 74 | |
81 | | - if ( $status->isOK() ) { |
| 75 | + $reqArr = array( |
| 76 | + 'wpTextbox1' => $text, |
| 77 | + 'wpSummary' => wfMsgForContent( 'commentbox-log' ), |
| 78 | + 'wpEditToken' => $wgUser->editToken(), |
| 79 | + 'wpIgnoreBlankSummary' => '', |
| 80 | + 'wpStarttime' => wfTimestampNow(), |
| 81 | + 'wpEdittime' => $article->getTimestamp(), |
| 82 | + ); |
| 83 | + $request = new FauxRequest( $reqArr, true ); |
| 84 | + $ep = new EditPage( $article ); |
| 85 | + $ep->setContextTitle( $title ); |
| 86 | + $ep->importFormData( $request ); |
| 87 | + $details = array(); // Passed by ref |
| 88 | + $retval = $ep->internalAttemptSave( $details ); |
| 89 | + |
| 90 | + switch ( $retval ) { |
| 91 | + case EditPage::AS_SUCCESS_UPDATE: |
82 | 92 | $wgOut->redirect( $title->getFullURL() ); |
83 | | - } else { |
84 | | - $wgOut->setPageTitle( wfMsg( 'commentbox-errorpage-title' ) ); |
85 | | - $wgOut->addWikiText( $status->getWikiText() ); |
86 | | - $wgOut->returnToMain( false, $title ); |
| 93 | + break; |
| 94 | + case EditPage::AS_SPAM_ERROR: |
| 95 | + $ep->spamPageWithContent( $details['spam'] ); |
| 96 | + break; |
| 97 | + case EditPage::AS_BLOCKED_PAGE_FOR_USER: |
| 98 | + $wgOut->blockedPage(); |
| 99 | + break; |
| 100 | + case EditPage::AS_READ_ONLY_PAGE_ANON: |
| 101 | + case EditPage::AS_READ_ONLY_PAGE_LOGGED: |
| 102 | + $wgOut->permissionRequired( 'edit' ); |
| 103 | + break; |
| 104 | + case EditPage::AS_READ_ONLY_PAGE: |
| 105 | + $wgOut->readOnlyPage(); |
87 | 106 | } |
88 | 107 | } |
89 | 108 | |