http://www.mediawiki.org/wiki/Special:Code/MediaWiki/96173
Revision: 96173
Author: hashar
Date: 2011-09-03 09:12:36 +0000 (Sat, 03 Sep 2011)
Log Message:
-----------
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
trunk/extensions/CodeReview/modules/ext.codereview.linecomment.js
Modified: trunk/extensions/CodeReview/api/ApiRevisionUpdate.php
===================================================================
--- trunk/extensions/CodeReview/api/ApiRevisionUpdate.php 2011-09-03
07:09:39 UTC (rev 96172)
+++ trunk/extensions/CodeReview/api/ApiRevisionUpdate.php 2011-09-03
09:12:36 UTC (rev 96173)
@@ -32,6 +32,11 @@
$params = $this->extractRequestParams();
+ if( $params['comment']
+ && !$wgUser->isAllowed( 'codereview-post-comment' ) ) {
+ $this->dieUsage( 'You do not have permission to post
comment', 'permissiondenied' );
+ }
+
$repo = CodeRepository::newFromName( $params['repo'] );
if ( !$repo ) {
$this->dieUsage( "Invalid repo ``{$params['repo']}''",
'invalidrepo' );
Modified: trunk/extensions/CodeReview/modules/ext.codereview.linecomment.js
===================================================================
--- trunk/extensions/CodeReview/modules/ext.codereview.linecomment.js
2011-09-03 07:09:39 UTC (rev 96172)
+++ trunk/extensions/CodeReview/modules/ext.codereview.linecomment.js
2011-09-03 09:12:36 UTC (rev 96173)
@@ -68,9 +68,15 @@
dataType: 'json',
type: 'POST',
success: function( data ) {
- // FIXME
- console.log( data.coderevisionupdate );
- //data.coderevisionupdate.commentid;
+ // our API return usage error as a success!
+ if( data.error !== undefined ) {
+ console.log( lineComment.find( 'input'
) );
+ lineComment.find( 'input' ).after(
+ $('<span
class="errorbox"></span>')
+ .text( data.error.info )
+ );
+ return;
+ }
var text = data.coderevisionupdate.HTML
lineComment.fadeOut( 200 ).remove();
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs