diff --git a/config/vanilla/bootstrap.early.php b/config/vanilla/bootstrap.early.php index 62dcc72..bce936c 100644 --- a/config/vanilla/bootstrap.early.php +++ b/config/vanilla/bootstrap.early.php @@ -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'); + } \ No newline at end of file diff --git a/vanilla/applications/vanilla/js/autosave.js b/vanilla/applications/vanilla/js/autosave.js new file mode 100644 index 0000000..147a2d0 --- /dev/null +++ b/vanilla/applications/vanilla/js/autosave.js @@ -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; + } +}); diff --git a/vanilla/applications/vanilla/views/discussion/discussion.php b/vanilla/applications/vanilla/views/discussion/discussion.php index 7e020ae..9ece006 100644 --- a/vanilla/applications/vanilla/views/discussion/discussion.php +++ b/vanilla/applications/vanilla/views/discussion/discussion.php @@ -4,6 +4,8 @@ * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 */ +use Vanilla\Formatting\DateTimeFormatter; + if (!defined('APPLICATION')) { exit(); } @@ -51,7 +53,8 @@