-
Notifications
You must be signed in to change notification settings - Fork 43
/
library.js
executable file
·65 lines (52 loc) · 1.55 KB
/
library.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
'use strict';
const NodeBB = require('./lib/nodebb');
const Config = require('./lib/config');
const Sockets = require('./lib/sockets');
const Hooks = require('./lib/hooks');
const Scheduler = require('./lib/scheduler');
const Plugin = module.exports;
Plugin.hooks = Hooks;
Plugin.load = async function (params) {
const routeHelpers = require.main.require('./src/routes/helpers');
const { router } = params;
routeHelpers.setupAdminPageRoute(router, `/admin/plugins/${Config.plugin.id}`, (req, res) => {
res.render(`admin/plugins/${Config.plugin.id}`, {
title: 'Poll',
});
});
NodeBB.PluginSockets[Config.plugin.id] = Sockets;
NodeBB.AdminSockets[Config.plugin.id] = Config.adminSockets;
NodeBB.app = params.app;
Scheduler.start();
await Config.init();
};
Plugin.addAdminNavigation = function (adminHeader) {
adminHeader.plugins.push({
route: `/plugins/${Config.plugin.id}`,
icon: Config.plugin.icon,
name: Config.plugin.name,
});
return adminHeader;
};
Plugin.registerFormatting = function (payload) {
payload.options.push({
name: 'poll',
className: `fa ${Config.plugin.icon}`,
title: '[[poll:creator_title]]',
});
return payload;
};
Plugin.addPrivilege = function (hookData) {
hookData.privileges.set(
'poll:create', { label: '[[poll:admin.create-poll]]' },
);
};
Plugin.copyPrivilegesFrom = function (data) {
if (data.privileges.indexOf('poll:create') === -1) {
data.privileges.push('poll:create');
}
if (data.privileges.indexOf('groups:poll:create') === -1) {
data.privileges.push('groups:poll:create');
}
return data;
};