diff --git a/config/vanilla/bootstrap.early.php b/config/vanilla/bootstrap.early.php index af21e5a..06b250f 100644 --- a/config/vanilla/bootstrap.early.php +++ b/config/vanilla/bootstrap.early.php @@ -162,7 +162,13 @@ // Set count of WatchedCategories for users Gdn::sql()->query('update GDN_User u set u.CountWatchedCategories = ( select count(c.CategoryID) from GDN_Category c, (select distinct CAST(SUBSTRING_INDEX(um.Name, ".", -1) as UNSIGNED) as CategoryID from GDN_UserMeta um - where um.Name LIKE "Preferences.%" AND UserID = u.UserID and Value = 1) ws where ws.CategoryID = c.CategoryID)'); + where um.Name LIKE "Preferences.%" AND UserID = u.UserID and Value = 1) ws where ws.CategoryID = c.CategoryID)', 'update'); } + + // FIX: https://github.com/topcoder-platform/forums/issues/479 + // Re-calculate count of WatchedCategories if WatchedCategories is null + Gdn::sql()->query('update GDN_User u set u.CountWatchedCategories = ( + select count(c.CategoryID) from GDN_Category c, (select distinct CAST(SUBSTRING_INDEX(um.Name, ".", -1) as UNSIGNED) as CategoryID from GDN_UserMeta um + where um.Name LIKE "Preferences.%" AND UserID = u.UserID and Value = 1) ws where ws.CategoryID = c.CategoryID) where CountWatchedCategories is null', 'update'); } \ No newline at end of file diff --git a/vanilla/applications/vanilla/controllers/class.discussioncontroller.php b/vanilla/applications/vanilla/controllers/class.discussioncontroller.php index 666047e..177aa68 100644 --- a/vanilla/applications/vanilla/controllers/class.discussioncontroller.php +++ b/vanilla/applications/vanilla/controllers/class.discussioncontroller.php @@ -796,7 +796,7 @@ public function deleteComment($commentID = '', $transientKey = '') { if ($comment && $discussion) { $defaultTarget = discussionUrl($discussion); - + $this->json('DiscussionID', $discussionID); // Make sure comment is this user's or they have Delete permission. if ($comment->InsertUserID != $session->UserID || !c('Vanilla.Comments.AllowSelfDelete')) { $this->categoryPermission($discussion->CategoryID, 'Vanilla.Comments.Delete'); @@ -811,6 +811,12 @@ public function deleteComment($commentID = '', $transientKey = '') { // Delete the comment. if (!$this->CommentModel->deleteID($commentID)) { $this->Form->addError('Failed to delete comment'); + } else { + // FIX: https://github.com/topcoder-platform/forums/issues/511 + // Allow plugins to handle it + $this->EventArguments['DiscussionID'] = $discussionID; + $this->EventArguments['CommentID'] = $commentID; + $this->fireEvent('AfterCommentDeleted'); } } else { $this->Form->addError('Invalid comment'); diff --git a/vanilla/applications/vanilla/controllers/class.postcontroller.php b/vanilla/applications/vanilla/controllers/class.postcontroller.php index 3803e90..5ffd811 100644 --- a/vanilla/applications/vanilla/controllers/class.postcontroller.php +++ b/vanilla/applications/vanilla/controllers/class.postcontroller.php @@ -395,10 +395,12 @@ public function discussion($categoryUrlCode = '', $announce = '') { $this->EventArguments['Discussion'] = $discussion; $this->fireEvent('AfterDiscussionSave'); + // FIX: https://github.com/topcoder-platform/forums/issues/511 + // if /discussion/{discussionID}/p{Page} is used then view mode is flat if ($this->_DeliveryType == DELIVERY_TYPE_ALL) { - redirectTo(discussionUrl($discussion, 1).'?new=1'); + redirectTo(discussionUrl($discussion).'?new=1'); } else { - $this->setRedirectTo(discussionUrl($discussion, 1, true).'?new=1'); + $this->setRedirectTo(discussionUrl($discussion).'?new=1'); } } else { // If this was a draft save, notify the user about the save diff --git a/vanilla/applications/vanilla/js/discussion.js b/vanilla/applications/vanilla/js/discussion.js index 1ad3720..fd5ebfd 100755 --- a/vanilla/applications/vanilla/js/discussion.js +++ b/vanilla/applications/vanilla/js/discussion.js @@ -135,6 +135,7 @@ jQuery(document).ready(function($) { $('div.Popup,.Overlay').remove(); var commentID = json.CommentID; + var parentCommentID = json.ParentCommentID; // Assign the comment id to the form if it was defined if (commentID != null && commentID != '') { @@ -194,11 +195,19 @@ jQuery(document).ready(function($) { $(json.Data).prependTo('ul.Comments,.DiscussionTable'); $('ul.Comments li:first').effect("highlight", {}, "slow"); } else { - $(json.Data) - .appendTo('ul.Comments,.DiscussionTable') - .effect("highlight", {}, "slow") - .trigger('contentLoad'); -// $('ul.Comments li:last,.DiscussionTable li:last').effect("highlight", {}, "slow"); + var viewMode = json['ReplyTo.ViewMode']; + if(viewMode === 'threaded') { + item = $('ul.Comments'); + $('ul.Comments li').remove(); + $(item).append(json.Data) + //.effect("highlight", {}, "slow") + .trigger('contentLoad'); + } else { + $(json.Data) + .appendTo('ul.Comments,.DiscussionTable') + //.effect("highlight", {}, "slow") + .trigger('contentLoad'); + } } } // Remove any "More" pager links (because it is typically replaced with the latest comment by this function) @@ -367,7 +376,7 @@ jQuery(document).ready(function($) { confirmHeading: gdn.definition('ConfirmDeleteCommentHeading', 'Delete Comment'), confirmText: gdn.definition('ConfirmDeleteCommentText', 'Are you sure you want to delete this comment?'), followConfirm: false, - deliveryType: 'BOOL', // DELIVERY_TYPE_BOOL + deliveryType: gdn.urlQueryParam( $('a.DeleteComment').attr('href'), 'deliveryType'), //'VIEW' - threaded, 'BOOL' - flat afterConfirm: function(json, sender) { var row = $(sender).parents('li.ItemComment'); if (json.ErrorMessage) { @@ -378,6 +387,15 @@ jQuery(document).ready(function($) { $(this).remove(); }); gdn.processTargets(json.Targets); + + var viewMode = json['ReplyTo.ViewMode']; + if(viewMode === 'threaded') { + item = $('ul.Comments'); + $('ul.Comments li').remove(); + $(item).append(json.Data); + //.effect("highlight", {}, "slow"); + } + // Let listeners know that the comment was deleted. $(document).trigger('CommentDeleted'); } diff --git a/vanilla/applications/vanilla/views/discussion/helper_functions.php b/vanilla/applications/vanilla/views/discussion/helper_functions.php index c666ba0..8d29f50 100644 --- a/vanilla/applications/vanilla/views/discussion/helper_functions.php +++ b/vanilla/applications/vanilla/views/discussion/helper_functions.php @@ -114,7 +114,7 @@ function writeComment($comment, $sender, $session, $currentOffset) { // FIX: https://github.com/topcoder-platform/forums/issues/488: // ViewMode should be set before displaying comment - $viewMode = $sender->data('ViewMode'); + $viewMode = $sender->data('ReplyTo.ViewMode'); ?>
  • diff --git a/vanilla/applications/vanilla/views/modules/discussionfilter.php b/vanilla/applications/vanilla/views/modules/discussionfilter.php index 1839692..b08456b 100644 --- a/vanilla/applications/vanilla/views/modules/discussionfilter.php +++ b/vanilla/applications/vanilla/views/modules/discussionfilter.php @@ -40,14 +40,28 @@