Node.js based forum software built for the modern web
added filter:topic.thread_tools for creating custom admin functionality in topics view
psychobunny2ec6dd1d141c
diff --git a/public/templates/topic.tpl b/public/templates/topic.tplindex 4666bc639e..20c8cb4b29 100644--- a/public/templates/topic.tpl+++ b/public/templates/topic.tpl@@ -181,6 +181,11 @@<li><a href="#" class="fork_thread"><i class="fa fa-fw fa-code-fork"></i> [[topic:thread_tools.fork]]</a></li><li class="divider"></li><li><a href="#" class="delete_thread"><span class="text-error"><i class="fa fa-fw fa-trash-o"></i> [[topic:thread_tools.delete]]</span></a></li>+ <!-- BEGIN thread_tools -->+ <li>+ <a href="#" class="{thread_tools.class}"><i class="fa fa-fw {thread_tools.icon}"></i> {thread_tools.title}</a>+ </li>+ <!-- END thread_tools --></ul></div></div>@@ -208,6 +213,11 @@<li><a href="#" class="fork_thread"><i class="fa fa-fw fa-code-fork"></i> [[topic:thread_tools.fork]]</a></li><li class="divider"></li><li><a href="#" class="delete_thread"><span class="text-error"><i class="fa fa-fw fa-trash-o"></i> [[topic:thread_tools.delete]]</span></a></li>+ <!-- BEGIN thread_tools -->+ <li>+ <a href="#" class="{thread_tools.class}"><i class="fa fa-fw {thread_tools.icon}"></i> {thread_tools.title}</a>+ </li>+ <!-- END thread_tools --></ul></div></div>diff --git a/src/topics.js b/src/topics.jsindex 6ad23bee70..046593e253 100644--- a/src/topics.js+++ b/src/topics.js@@ -826,7 +826,13 @@ var async = require('async'),Topics.getPageCount(tid, current_user, next);}- async.parallel([getTopicData, getTopicPosts, getPrivileges, getCategoryData, getPageCount], function(err, results) {+ function getThreadTools(next) {+ Plugins.fireHook('filter:topic.thread_tools', [], function(err, threadTools) {+ next(err, threadTools);+ });+ }++ async.parallel([getTopicData, getTopicPosts, getPrivileges, getCategoryData, getPageCount, getThreadTools], function(err, results) {if (err) {winston.error('[Topics.getTopicWithPosts] Could not retrieve topic data: ', err.message);return callback(err);@@ -835,7 +841,8 @@ var async = require('async'),var topicData = results[0],privileges = results[2],categoryData = results[3],- pageCount = results[4];+ pageCount = results[4],+ threadTools = results[5];callback(null, {'topic_name': topicData.title,@@ -852,6 +859,7 @@ var async = require('async'),'unreplied': parseInt(topicData.postcount, 10) === 1,'topic_id': tid,'expose_tools': privileges.editable ? 1 : 0,+ 'thread_tools': threadTools,'disableSocialButtons': meta.config.disableSocialButtons !== undefined ? parseInt(meta.config.disableSocialButtons, 10) !== 0 : false,'posts': results[1]});