Skip to content

Issues-523, Issues-529, Issues-528 #534

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 4, 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
17 changes: 9 additions & 8 deletions config/vanilla/bootstrap.early.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,17 @@
->column('CountWatchedCategories', 'int', null)
->set(false, false);

// Set count of WatchedCategories for users
// Set count of Watched Categories 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)', 'update');

select count(c.CategoryID) from GDN_Category c, (select distinct SUBSTRING_INDEX(um.Name, ".", -1) as CategoryID from GDN_UserMeta um
where um.Name LIKE "Preferences.%" AND um.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');
// Re-calculate count of Watched Categories if CountWatchedCategories is null
// Remove it later. It should be executed only once when the column is added
Gdn::sql()->query('update GDN_User u set u.CountWatchedCategories = (
select count(c.CategoryID) from GDN_Category c, (select distinct SUBSTRING_INDEX(um.Name, ".", -1) as CategoryID from GDN_UserMeta um
where um.Name LIKE "Preferences.%" AND um.UserID = u.UserID and Value = 1) ws where ws.CategoryID = c.CategoryID) where CountWatchedCategories is null', 'update');

}
33 changes: 33 additions & 0 deletions vanilla/applications/vanilla/js/autosave.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
jQuery(document).ready(function($) {
/* Autosave functionality for comment & discussion drafts */
$.fn.autosave = function(opts) {
// Interval - 15 secs
var options = $.extend({interval: 15000, button: false}, opts);
var textarea = this;
if (!options.button)
return false;

var lastVal = $(textarea).val();

var save = function() {
var currentVal = $(textarea).val();
var defaultValues = [
undefined,
null,
'',
'[{\"insert\":\"\\n\"}]',
lastVal
];
if (!defaultValues.includes(currentVal)) {
lastVal = currentVal;
$(options.button).click();
}
};

if (options.interval > 0) {
setInterval(save, options.interval);
}

return this;
}
});
5 changes: 4 additions & 1 deletion vanilla/applications/vanilla/views/discussion/discussion.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
*/

use Vanilla\Formatting\DateTimeFormatter;

if (!defined('APPLICATION')) {
exit();
}
Expand Down Expand Up @@ -51,7 +53,8 @@
</div>
<div class="Meta DiscussionMeta">
<span class="MItem DateCreated">
<?php echo Gdn_Format::date($Discussion->DateInserted, 'html'); ?>
<?php echo Gdn::getContainer()->get(DateTimeFormatter::class)->formatDate($Discussion->DateInserted, true,
DateTimeFormatter::FORCE_FULL_FORMAT); ?>
</span>
<?php
echo dateUpdated($Discussion, ['<span class="MItem">', '</span>']);
Expand Down