r42014 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r42013‎ | r42014 | r42015 >
Date:03:05, 13 October 2008
Author:nicdumz
Status:old (Comments)
Tags:
Comment:
* Do not show the submit buttons when user cannot post comments
* Do not show an empty 'Comments' header when there's no comments & user's not allowed to post
Modified paths:
  • /trunk/extensions/CodeReview/CodeRevisionView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeRevisionView.php
@@ -51,16 +51,7 @@
5252 );
5353 $special = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName().'/'.$this->mRev->getId() );
5454
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 );
6556
6657 if( $this->mRev->isDiffable() ) {
6758 $diffHtml = $this->formatDiff();
@@ -70,10 +61,8 @@
7162 wfMsg('code-rev-purge-link'), 'action=purge' ) . ']</small></h2>' .
7263 "<div class='mw-codereview-diff' id='mw-codereview-diff'>" . $diffHtml . "</div>\n";
7364 }
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();
7867
7968 if( $this->mReplyTarget ) {
8069 global $wgJsMimeType;
@@ -82,14 +71,11 @@
8372 "document.getElementById('wpReplyTo$id').focus();" .
8473 "});</script>\n";
8574 }
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+ }
9480
9581 $wgOut->addHtml( $html );
9682 }
@@ -268,13 +254,19 @@
269255 }
270256
271257 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;
279271 }
280272
281273 function formatCommentInline( $comment ) {
@@ -358,6 +350,11 @@
359351
360352 function postCommentForm( $parent=null ) {
361353 global $wgUser;
 354+
 355+ if( !$wgUser->isAllowed('codereview-post-comment') ) {
 356+ return '';
 357+ }
 358+
362359 if( $this->mPreviewText != false && $parent === $this->mReplyTarget ) {
363360 $preview = $this->previewComment( $this->mPreviewText );
364361 $text = htmlspecialchars( $this->mPreviewText );
@@ -367,9 +364,6 @@
368365 }
369366 $repo = $this->mRepo->getName();
370367 $rev = $this->mRev->getId();
371 - if( !$wgUser->isAllowed('codereview-post-comment') ) {
372 - return '';
373 - }
374368 return '<div class="mw-codereview-post-comment">' .
375369 $preview .
376370 Xml::hidden( 'wpEditToken', $wgUser->editToken() ) .
@@ -385,4 +379,15 @@
386380 '</div>' .
387381 '</div>';
388382 }
 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+ }
389394 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r42018Revert r42014 per comments by brionaaron06:06, 13 October 2008

Comments

#Comment by Brion VIBBER (talk | contribs)   04:47, 13 October 2008

Tag, status, and comment permissions are all separate; hypothetically one could have permission to update status or tag but not comment, in which case not having any buttons would kind of suck.

#Comment by Voice of All (talk | contribs)   06:06, 13 October 2008

Reverted in r42018

Status & tagging log