Index: trunk/extensions/CodeReview/CodeRevisionView.php |
— | — | @@ -51,16 +51,7 @@ |
52 | 52 | ); |
53 | 53 | $special = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName().'/'.$this->mRev->getId() ); |
54 | 54 | |
55 | | - $html = Xml::openElement( 'form', array( 'action' => $special->getLocalUrl(), 'method' => 'post' ) ); |
56 | | - $html .= '<div>' . |
57 | | - Xml::submitButton( wfMsg( 'code-rev-submit' ), array( 'name' => 'wpSave' ) ) . |
58 | | - ' ' . |
59 | | - Xml::submitButton( wfMsg( 'code-rev-submit-next' ), array( 'name' => 'wpSaveAndNext' ) ) . |
60 | | - ' ' . |
61 | | - Xml::submitButton( wfMsg( 'code-rev-comment-preview' ), array( 'name' => 'wpPreview' ) ) . |
62 | | - '</div>'; |
63 | | - |
64 | | - $html .= $this->formatMetaData( $fields ); |
| 55 | + $html = $this->formatMetaData( $fields ); |
65 | 56 | |
66 | 57 | if( $this->mRev->isDiffable() ) { |
67 | 58 | $diffHtml = $this->formatDiff(); |
— | — | @@ -70,10 +61,8 @@ |
71 | 62 | wfMsg('code-rev-purge-link'), 'action=purge' ) . ']</small></h2>' . |
72 | 63 | "<div class='mw-codereview-diff' id='mw-codereview-diff'>" . $diffHtml . "</div>\n"; |
73 | 64 | } |
74 | | - $comments = $this->formatComments(); |
75 | | - if( $comments ) { |
76 | | - $html .= "<h2 id='code-comments'>". wfMsgHtml( 'code-comments' ) ."</h2>\n" . $comments; |
77 | | - } |
| 65 | + |
| 66 | + $html .= $this->formatComments(); |
78 | 67 | |
79 | 68 | if( $this->mReplyTarget ) { |
80 | 69 | global $wgJsMimeType; |
— | — | @@ -82,14 +71,11 @@ |
83 | 72 | "document.getElementById('wpReplyTo$id').focus();" . |
84 | 73 | "});</script>\n"; |
85 | 74 | } |
86 | | - $html .= '<div>' . |
87 | | - Xml::submitButton( wfMsg( 'code-rev-submit' ), array( 'name' => 'wpSave' ) ) . |
88 | | - ' ' . |
89 | | - Xml::submitButton( wfMsg( 'code-rev-submit-next' ), array( 'name' => 'wpSaveAndNext' ) ) . |
90 | | - ' ' . |
91 | | - Xml::submitButton( wfMsg( 'code-rev-comment-preview' ), array( 'name' => 'wpPreview' ) ) . |
92 | | - '</div>' . |
93 | | - '</form>'; |
| 75 | + |
| 76 | + if ($wgUser->isAllowed( 'codereview-post-comment' ) ) { |
| 77 | + $html = Xml::tags( 'form', array( 'action' => $special->getLocalUrl(), 'method' => 'post' ), |
| 78 | + $this->submitButtons() . $html . $this->submitButtons() ); |
| 79 | + } |
94 | 80 | |
95 | 81 | $wgOut->addHtml( $html ); |
96 | 82 | } |
— | — | @@ -268,13 +254,19 @@ |
269 | 255 | } |
270 | 256 | |
271 | 257 | function formatComments() { |
272 | | - return "<div class='mw-codereview-comments'>" . |
273 | | - implode( "\n", |
274 | | - array_map( |
275 | | - array( $this, 'formatCommentInline' ), |
276 | | - $this->mRev->getComments() ) ) . |
277 | | - $this->postCommentForm() . |
278 | | - "</div>"; |
| 258 | + $comments = implode( "\n", |
| 259 | + array_map( |
| 260 | + array( $this, 'formatCommentInline' ), |
| 261 | + $this->mRev->getComments() |
| 262 | + ) ) . |
| 263 | + $this->postCommentForm(); |
| 264 | + |
| 265 | + if( $comments ) { |
| 266 | + //Can be empty if : no comments && no postCommentForm |
| 267 | + $comments = "<h2 id='code-comments'>". wfMsgHtml( 'code-comments' ) ."</h2>\n" . |
| 268 | + Xml::tags( 'div', array( 'class' => 'mw-codereview-comments' ), $comments ) . "\n"; |
| 269 | + } |
| 270 | + return $comments; |
279 | 271 | } |
280 | 272 | |
281 | 273 | function formatCommentInline( $comment ) { |
— | — | @@ -358,6 +350,11 @@ |
359 | 351 | |
360 | 352 | function postCommentForm( $parent=null ) { |
361 | 353 | global $wgUser; |
| 354 | + |
| 355 | + if( !$wgUser->isAllowed('codereview-post-comment') ) { |
| 356 | + return ''; |
| 357 | + } |
| 358 | + |
362 | 359 | if( $this->mPreviewText != false && $parent === $this->mReplyTarget ) { |
363 | 360 | $preview = $this->previewComment( $this->mPreviewText ); |
364 | 361 | $text = htmlspecialchars( $this->mPreviewText ); |
— | — | @@ -367,9 +364,6 @@ |
368 | 365 | } |
369 | 366 | $repo = $this->mRepo->getName(); |
370 | 367 | $rev = $this->mRev->getId(); |
371 | | - if( !$wgUser->isAllowed('codereview-post-comment') ) { |
372 | | - return ''; |
373 | | - } |
374 | 368 | return '<div class="mw-codereview-post-comment">' . |
375 | 369 | $preview . |
376 | 370 | Xml::hidden( 'wpEditToken', $wgUser->editToken() ) . |
— | — | @@ -385,4 +379,15 @@ |
386 | 380 | '</div>' . |
387 | 381 | '</div>'; |
388 | 382 | } |
| 383 | + |
| 384 | + function submitButtons() { |
| 385 | + return |
| 386 | + '<div>' . |
| 387 | + Xml::submitButton( wfMsg( 'code-rev-submit' ), array( 'name' => 'wpSave' ) ) . |
| 388 | + ' ' . |
| 389 | + Xml::submitButton( wfMsg( 'code-rev-submit-next' ), array( 'name' => 'wpSaveAndNext' ) ) . |
| 390 | + ' ' . |
| 391 | + Xml::submitButton( wfMsg( 'code-rev-comment-preview' ), array( 'name' => 'wpPreview' ) ) . |
| 392 | + "</div>\n"; |
| 393 | + } |
389 | 394 | } |