r42018 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r42017‎ | r42018 | r42019 >
Date:06:06, 13 October 2008
Author:aaron
Status:old (Comments)
Tags:
Comment:
Revert r42014 per comments by brion
Modified paths:
  • /trunk/extensions/CodeReview/CodeRevisionView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeRevisionView.php
@@ -51,7 +51,16 @@
5252 );
5353 $special = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName().'/'.$this->mRev->getId() );
5454
55 - $html = $this->formatMetaData( $fields );
 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 );
5665
5766 if( $this->mRev->isDiffable() ) {
5867 $diffHtml = $this->formatDiff();
@@ -61,8 +70,10 @@
6271 wfMsg('code-rev-purge-link'), 'action=purge' ) . ']</small></h2>' .
6372 "<div class='mw-codereview-diff' id='mw-codereview-diff'>" . $diffHtml . "</div>\n";
6473 }
65 -
66 - $html .= $this->formatComments();
 74+ $comments = $this->formatComments();
 75+ if( $comments ) {
 76+ $html .= "<h2 id='code-comments'>". wfMsgHtml( 'code-comments' ) ."</h2>\n" . $comments;
 77+ }
6778
6879 if( $this->mReplyTarget ) {
6980 global $wgJsMimeType;
@@ -71,11 +82,14 @@
7283 "document.getElementById('wpReplyTo$id').focus();" .
7384 "});</script>\n";
7485 }
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 - }
 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>';
8094
8195 $wgOut->addHtml( $html );
8296 }
@@ -254,19 +268,13 @@
255269 }
256270
257271 function formatComments() {
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;
 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>";
271279 }
272280
273281 function formatCommentInline( $comment ) {
@@ -350,11 +358,6 @@
351359
352360 function postCommentForm( $parent=null ) {
353361 global $wgUser;
354 -
355 - if( !$wgUser->isAllowed('codereview-post-comment') ) {
356 - return '';
357 - }
358 -
359362 if( $this->mPreviewText != false && $parent === $this->mReplyTarget ) {
360363 $preview = $this->previewComment( $this->mPreviewText );
361364 $text = htmlspecialchars( $this->mPreviewText );
@@ -364,6 +367,9 @@
365368 }
366369 $repo = $this->mRepo->getName();
367370 $rev = $this->mRev->getId();
 371+ if( !$wgUser->isAllowed('codereview-post-comment') ) {
 372+ return '';
 373+ }
368374 return '<div class="mw-codereview-post-comment">' .
369375 $preview .
370376 Xml::hidden( 'wpEditToken', $wgUser->editToken() ) .
@@ -379,15 +385,4 @@
380386 '</div>' .
381387 '</div>';
382388 }
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 - }
394389 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r42014* Do not show the submit buttons when user cannot post comments...nicdumz03:05, 13 October 2008

Comments

#Comment by NicDumZ (talk | contribs)   07:57, 13 October 2008

quite drastic. Why reverting the other functionality of r42014 ? 'Do not show an empty 'Comments' header when there's no comments & user's not allowed to post' ?

What about just updating the r42014 userrights checks ? We don't really want to show these submit buttons if the user cannot do any change to the page, do we ? :)

Status & tagging log