r96173 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96172‎ | r96173 | r96174 >
Date:09:12, 3 September 2011
Author:hashar
Status:reverted (Comments)
Tags:
Comment:
API: check user can post comment

* Update the coderevisionupdate to check for user right when posting a
comment.
* Add up an error box when user try to submit an inline comment and is
not allowed to do so.

This is merely a work around bug 30615:
"Inline comments don't check permissions to display comment box"
Modified paths:
  • /trunk/extensions/CodeReview/api/ApiRevisionUpdate.php (modified) (history)
  • /trunk/extensions/CodeReview/modules/ext.codereview.linecomment.js (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/modules/ext.codereview.linecomment.js
@@ -68,9 +68,15 @@
6969 dataType: 'json',
7070 type: 'POST',
7171 success: function( data ) {
72 - // FIXME
73 - console.log( data.coderevisionupdate );
74 - //data.coderevisionupdate.commentid;
 72+ // our API return usage error as a success!
 73+ if( data.error !== undefined ) {
 74+ console.log( lineComment.find( 'input' ) );
 75+ lineComment.find( 'input' ).after(
 76+ $('<span class="errorbox"></span>')
 77+ .text( data.error.info )
 78+ );
 79+ return;
 80+ }
7581
7682 var text = data.coderevisionupdate.HTML
7783 lineComment.fadeOut( 200 ).remove();
Index: trunk/extensions/CodeReview/api/ApiRevisionUpdate.php
@@ -32,6 +32,11 @@
3333
3434 $params = $this->extractRequestParams();
3535
 36+ if( $params['comment']
 37+ && !$wgUser->isAllowed( 'codereview-post-comment' ) ) {
 38+ $this->dieUsage( 'You do not have permission to post comment', 'permissiondenied' );
 39+ }
 40+
3641 $repo = CodeRepository::newFromName( $params['repo'] );
3742 if ( !$repo ) {
3843 $this->dieUsage( "Invalid repo ``{$params['repo']}''", 'invalidrepo' );

Follow-up revisions

RevisionCommit summaryAuthorDate
r108350Reverting inline commenting from CodeReview...johnduhart06:55, 8 January 2012

Comments

#Comment by Johnduhart (talk | contribs)   19:51, 5 October 2011

Commenting to come back to later.

Status & tagging log