Skip to content

Issues-511: Replay placement, Issues-523, Issues-518 #531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion config/vanilla/bootstrap.early.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 24 additions & 6 deletions vanilla/applications/vanilla/js/discussion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 != '') {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand All @@ -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');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
?>
<li class="<?php echo $cssClass; ?>" id="<?php echo 'Comment_'.$comment->CommentID; ?>">
<div class="Comment">
Expand Down
24 changes: 19 additions & 5 deletions vanilla/applications/vanilla/views/modules/discussionfilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,28 @@
<ul role="nav" class="FilterMenu">
<?php
$Controller->fireEvent('BeforeDiscussionFilters');
// if (c('Vanilla.Categories.ShowTabs')) {
if (c('Vanilla.Categories.Use')) {
$menuOptions = [];

$CssClass = 'AllCategories';
if ((strtolower($Controller->ControllerName) == 'categoriescontroller' && in_array(strtolower($Controller->RequestMethod),['index', 'all']))
|| strpos(strtolower($Controller->Request->path()) , 'categories') === 0) {
$CssClass .= ' Active';
$isActive = false;
if($Controller instanceof CategoriesController || $Controller instanceof DiscussionController
|| $Controller instanceof PostController) {
$isActive = true;
}

$menuOptions['AllCategories']['Url'] = anchor('Public Forums', '/categories');
$menuOptions['AllCategories']['IsActive'] = $isActive;
$menuOptions['AllCategories']['CssClass'] = $CssClass;

$Controller->EventArguments['Menu'] = &$menuOptions;
$Controller->fireEvent('BeforeRenderDiscussionFilters');
foreach($menuOptions as $key => $value) {
if($menuOptions[$key]['IsActive'] === true) {
$menuOptions[$key]['CssClass'] .= ' Active';
}
echo '<li class="' . $menuOptions[$key]['CssClass'] . '">' . $menuOptions[$key]['Url'] . '</li> ';
}
echo '<li class="'.$CssClass.'">'.anchor('Public Forums', '/categories').'</li> ';
}
/*
<li id="RecentDiscussions" class="Discussions<?php echo strtolower($Controller->ControllerName) == 'discussionscontroller' && strtolower($Controller->RequestMethod) == 'index' && strpos(strtolower($Controller->Request->path()) , 'discussions') === 0? ' Active' : ''; ?>">
Expand Down
8 changes: 8 additions & 0 deletions vanilla/js/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,14 @@ jQuery(document).ready(function($) {
return urlFormat.replace("{Path}", path);
};

// Get query param from url
gdn.urlQueryParam = function (url, name) {
var results = new RegExp('[\?&]' + name + '=([^&#]*)')
.exec(url);

return (results !== null) ? results[1] || 0 : false;
};

// Fill in placeholders.
if (!gdn.elementSupports('input', 'placeholder')) {
$('input:text,textarea').not('.NoIE').each(function() {
Expand Down