Skip to content

Commit 43d1350

Browse files
authored
Merge pull request #534 from topcoder-platform/issues-523
Issues-523, Issues-529, Issues-528
2 parents 2607a53 + 3863e14 commit 43d1350

File tree

3 files changed

+46
-9
lines changed

3 files changed

+46
-9
lines changed

config/vanilla/bootstrap.early.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,17 @@
159159
->column('CountWatchedCategories', 'int', null)
160160
->set(false, false);
161161

162-
// Set count of WatchedCategories for users
162+
// Set count of Watched Categories for users
163163
Gdn::sql()->query('update GDN_User u set u.CountWatchedCategories = (
164-
select count(c.CategoryID) from GDN_Category c, (select distinct CAST(SUBSTRING_INDEX(um.Name, ".", -1) as UNSIGNED) as CategoryID from GDN_UserMeta um
165-
where um.Name LIKE "Preferences.%" AND UserID = u.UserID and Value = 1) ws where ws.CategoryID = c.CategoryID)', 'update');
166-
164+
select count(c.CategoryID) from GDN_Category c, (select distinct SUBSTRING_INDEX(um.Name, ".", -1) as CategoryID from GDN_UserMeta um
165+
where um.Name LIKE "Preferences.%" AND um.UserID = u.UserID and Value = 1) ws where ws.CategoryID = c.CategoryID)', 'update');
167166
}
168167

169168
// FIX: https://github.com/topcoder-platform/forums/issues/479
170-
// Re-calculate count of WatchedCategories if WatchedCategories is null
171-
// Gdn::sql()->query('update GDN_User u set u.CountWatchedCategories = (
172-
// select count(c.CategoryID) from GDN_Category c, (select distinct CAST(SUBSTRING_INDEX(um.Name, ".", -1) as UNSIGNED) as CategoryID from GDN_UserMeta um
173-
// where um.Name LIKE "Preferences.%" AND UserID = u.UserID and Value = 1) ws where ws.CategoryID = c.CategoryID) where CountWatchedCategories is null', 'update');
169+
// Re-calculate count of Watched Categories if CountWatchedCategories is null
170+
// Remove it later. It should be executed only once when the column is added
171+
Gdn::sql()->query('update GDN_User u set u.CountWatchedCategories = (
172+
select count(c.CategoryID) from GDN_Category c, (select distinct SUBSTRING_INDEX(um.Name, ".", -1) as CategoryID from GDN_UserMeta um
173+
where um.Name LIKE "Preferences.%" AND um.UserID = u.UserID and Value = 1) ws where ws.CategoryID = c.CategoryID) where CountWatchedCategories is null', 'update');
174+
174175
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
jQuery(document).ready(function($) {
2+
/* Autosave functionality for comment & discussion drafts */
3+
$.fn.autosave = function(opts) {
4+
// Interval - 15 secs
5+
var options = $.extend({interval: 15000, button: false}, opts);
6+
var textarea = this;
7+
if (!options.button)
8+
return false;
9+
10+
var lastVal = $(textarea).val();
11+
12+
var save = function() {
13+
var currentVal = $(textarea).val();
14+
var defaultValues = [
15+
undefined,
16+
null,
17+
'',
18+
'[{\"insert\":\"\\n\"}]',
19+
lastVal
20+
];
21+
if (!defaultValues.includes(currentVal)) {
22+
lastVal = currentVal;
23+
$(options.button).click();
24+
}
25+
};
26+
27+
if (options.interval > 0) {
28+
setInterval(save, options.interval);
29+
}
30+
31+
return this;
32+
}
33+
});

vanilla/applications/vanilla/views/discussion/discussion.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
55
*/
66

7+
use Vanilla\Formatting\DateTimeFormatter;
8+
79
if (!defined('APPLICATION')) {
810
exit();
911
}
@@ -51,7 +53,8 @@
5153
</div>
5254
<div class="Meta DiscussionMeta">
5355
<span class="MItem DateCreated">
54-
<?php echo Gdn_Format::date($Discussion->DateInserted, 'html'); ?>
56+
<?php echo Gdn::getContainer()->get(DateTimeFormatter::class)->formatDate($Discussion->DateInserted, true,
57+
DateTimeFormatter::FORCE_FULL_FORMAT); ?>
5558
</span>
5659
<?php
5760
echo dateUpdated($Discussion, ['<span class="MItem">', '</span>']);

0 commit comments

Comments
 (0)