| Index: trunk/extensions/Comments/Comments_AjaxFunctions.php |
| — | — | @@ -131,4 +131,20 @@ |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | return 'ok'; |
| 135 | | -} |
| \ No newline at end of file |
| | 135 | +} |
| | 136 | + |
| | 137 | +$wgAjaxExportList[] = 'wfDeleteComment'; |
| | 138 | +function wfDeleteComment( $pageId, $commentId ) { |
| | 139 | + global $wgUser; |
| | 140 | + |
| | 141 | + // Blocked users cannot delete comments, and neither can unprivileged ones |
| | 142 | + if( $wgUser->isBlocked() || !$wgUser->isAllowed( 'commentadmin' ) ) { |
| | 143 | + return ''; |
| | 144 | + } |
| | 145 | + |
| | 146 | + $comment = new Comment( $pageId ); |
| | 147 | + $comment->setCommentID( $commentId ); |
| | 148 | + $comment->delete(); |
| | 149 | + |
| | 150 | + return 'ok'; |
| | 151 | +} |
| Index: trunk/extensions/Comments/Comment.php |
| — | — | @@ -4,7 +4,7 @@ |
| 5 | 5 | * |
| 6 | 6 | * @file |
| 7 | 7 | * @ingroup Extensions |
| 8 | | - * @version 2.5 |
| | 8 | + * @version 2.7 |
| 9 | 9 | * @author David Pean <david.pean@gmail.com> |
| 10 | 10 | * @author Misza <misza@shoutwiki.com> |
| 11 | 11 | * @author Jack Phoenix <jack@countervandalism.net> |
| — | — | @@ -24,7 +24,7 @@ |
| 25 | 25 | // Extension credits that will show up on Special:Version |
| 26 | 26 | $wgExtensionCredits['parserhook'][] = array( |
| 27 | 27 | 'name' => 'Comments', |
| 28 | | - 'version' => '2.6', |
| | 28 | + 'version' => '2.7', |
| 29 | 29 | 'author' => array( 'David Pean', 'Misza', 'Jack Phoenix' ), |
| 30 | 30 | 'description' => 'Adds <tt><comments></tt> parser hook that allows commenting on articles', |
| 31 | 31 | 'url' => 'https://www.mediawiki.org/wiki/Extension:Comments' |
| — | — | @@ -38,7 +38,7 @@ |
| 39 | 39 | 'comment-voted-label', 'comment-loading', |
| 40 | 40 | 'comment-auto-refresher-pause', 'comment-auto-refresher-enable', |
| 41 | 41 | 'comment-cancel-reply', 'comment-reply-to', 'comment-block-warning', |
| 42 | | - 'comment-block-anon', 'comment-block-user' |
| | 42 | + 'comment-block-anon', 'comment-block-user', 'comment-delete-warning' |
| 43 | 43 | ), |
| 44 | 44 | 'localBasePath' => dirname( __FILE__ ), |
| 45 | 45 | 'remoteExtPath' => 'Comments', |
| — | — | @@ -136,10 +136,6 @@ |
| 137 | 137 | $comment->setAllow( $allow ); |
| 138 | 138 | $comment->setVoting( $voting ); |
| 139 | 139 | |
| 140 | | - if( isset( $_POST['commentid'] ) ) { // isset added by misza |
| 141 | | - $comment->setCommentID( $_POST['commentid'] ); |
| 142 | | - $comment->delete(); |
| 143 | | - } |
| 144 | 140 | // This was originally commented out, I don't know why. |
| 145 | 141 | // Uncommented to prevent E_NOTICE. |
| 146 | 142 | $output = $comment->displayOrderForm(); |
| Index: trunk/extensions/Comments/Comments.i18n.php |
| — | — | @@ -21,6 +21,7 @@ |
| 22 | 22 | 'comment-reply-to' => 'Reply to', |
| 23 | 23 | 'comment-cancel-reply' => 'Cancel', |
| 24 | 24 | 'comment-block-warning' => 'Are you sure you want to permanently ignore all comments from', |
| | 25 | + 'comment-delete-warning' => 'Are you sure you want delete this comment?', |
| 25 | 26 | 'comment-block-anon' => 'this Anonymous user (via their IP address)', |
| 26 | 27 | 'comment-block-user' => 'user', |
| 27 | 28 | 'comment-sort-by-date' => 'Sort by Date', |
| — | — | @@ -78,6 +79,7 @@ |
| 79 | 80 | 'comment-auto-refresher-enable' => 'Ota käyttöön kommenttien automaattinen päivitys', |
| 80 | 81 | 'comment-reply-to' => 'Vastaa käyttäjälle', |
| 81 | 82 | 'comment-cancel-reply' => 'Peruuta', |
| | 83 | + 'comment-delete-warning' => 'Oletko varma, että haluat poistaa tämän kommentin?', |
| 82 | 84 | 'comment-block-warning' => 'Oletko varma, että haluat lopullisesti jättää kaikki kommentit huomiotta', |
| 83 | 85 | 'comment-block-anon' => 'tältä anonyymiltä käyttäjältä (IP-osoitteensa perusteella)', |
| 84 | 86 | 'comment-block-user' => 'käyttäjältä', |
| Index: trunk/extensions/Comments/Comment.js |
| — | — | @@ -4,7 +4,7 @@ |
| 5 | 5 | * object-oriented. |
| 6 | 6 | * |
| 7 | 7 | * @file |
| 8 | | - * @date 7 January 2012 |
| | 8 | + * @date 4 May 2012 |
| 9 | 9 | */ |
| 10 | 10 | var Comment = { |
| 11 | 11 | submitted: 0, |
| — | — | @@ -51,6 +51,22 @@ |
| 52 | 52 | }, |
| 53 | 53 | |
| 54 | 54 | /** |
| | 55 | + * This function is called whenever a user clicks on the "Delete Comment" |
| | 56 | + * link to delete a comment. |
| | 57 | + * |
| | 58 | + * @param c_id Integer: comment ID number |
| | 59 | + */ |
| | 60 | + deleteComment: function( c_id ) { |
| | 61 | + var pageId = document.commentform.pid.value; |
| | 62 | + if( confirm( mw.msg( 'comment-delete-warning' ) ) ) { |
| | 63 | + sajax_request_type = 'POST'; |
| | 64 | + sajax_do_call( 'wfDeleteComment', [ pageId, c_id ], function( response ) { |
| | 65 | + window.location.href = window.location; |
| | 66 | + }); |
| | 67 | + } |
| | 68 | + }, |
| | 69 | + |
| | 70 | + /** |
| 55 | 71 | * Vote for a comment. |
| 56 | 72 | * Formerly called "cv" |
| 57 | 73 | * |
| — | — | @@ -270,6 +286,16 @@ |
| 271 | 287 | } ); |
| 272 | 288 | } ); |
| 273 | 289 | |
| | 290 | + // "Delete Comment" links |
| | 291 | + jQuery( 'a.comment-delete-link' ).each( function( index ) { |
| | 292 | + var that = jQuery( this ); |
| | 293 | + that.click( function() { |
| | 294 | + Comment.deleteComment( |
| | 295 | + that.data( 'comment-id' ) |
| | 296 | + ); |
| | 297 | + } ); |
| | 298 | + } ); |
| | 299 | + |
| 274 | 300 | // "Show this hidden comment" -- comments made by people on the user's |
| 275 | 301 | // personal block list |
| 276 | 302 | jQuery( 'div.c-ignored-links a' ).each( function( index ) { |
| Index: trunk/extensions/Comments/CommentClass.php |
| — | — | @@ -501,6 +501,7 @@ |
| 502 | 502 | array( 'Comment_Vote_ID' => $this->CommentID ), |
| 503 | 503 | __METHOD__ |
| 504 | 504 | ); |
| | 505 | + $dbw->commit(); |
| 505 | 506 | $this->clearCommentListCache(); |
| 506 | 507 | wfRunHooks( 'Comment::delete', array( $this, $this->CommentID, $this->PageID ) ); |
| 507 | 508 | } |
| — | — | @@ -675,7 +676,7 @@ |
| 676 | 677 | if( $wgUser->isBlocked() ) { |
| 677 | 678 | return ''; |
| 678 | 679 | } |
| 679 | | - if ( ! $wgUser->isAllowed( 'comment' ) ) { |
| | 680 | + if ( !$wgUser->isAllowed( 'comment' ) ) { |
| 680 | 681 | return ''; |
| 681 | 682 | } |
| 682 | 683 | |
| — | — | @@ -778,9 +779,13 @@ |
| 779 | 780 | |
| 780 | 781 | // Comment delete button for privileged users |
| 781 | 782 | $dlt = ''; |
| | 783 | + |
| 782 | 784 | if( $wgUser->isAllowed( 'commentadmin' ) ) { |
| 783 | | - $dlt = " | <span class=\"c-delete\"><a href=\"javascript:document.commentform.commentid.value={$comment['CommentID']};document.commentform.submit();\">" . |
| 784 | | - wfMsg( 'comment-delete-link' ) . '</a></span>'; |
| | 785 | + //$dlt = " | <span class=\"c-delete\"><a href=\"javascript:document.commentform.commentid.value={$comment['CommentID']};document.commentform.submit();\">" . |
| | 786 | + $dlt = ' | <span class="c-delete">' . |
| | 787 | + '<a href="javascript:void(0);" rel="nofollow" class="comment-delete-link" data-comment-id="' . |
| | 788 | + $comment['CommentID'] . '">' . |
| | 789 | + wfMsg( 'comment-delete-link' ) . '</a></span>'; |
| 785 | 790 | } |
| 786 | 791 | |
| 787 | 792 | // Reply Link (does not appear on child comments) |