mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-22 08:20:36 +01:00
interim commit to thread options
This commit is contained in:
@@ -40,7 +40,7 @@ var config = {
|
|||||||
|
|
||||||
// Privileged Actions Reputation Thresholds
|
// Privileged Actions Reputation Thresholds
|
||||||
"privilege_thresholds": {
|
"privilege_thresholds": {
|
||||||
"manage_thread": 2000
|
"manage_thread": 1000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ var ajaxify = {};
|
|||||||
jQuery('#content').fadeOut(100);
|
jQuery('#content').fadeOut(100);
|
||||||
|
|
||||||
load_template(function() {
|
load_template(function() {
|
||||||
|
|
||||||
exec_body_scripts(content);
|
exec_body_scripts(content);
|
||||||
|
|
||||||
ajaxify.enable();
|
ajaxify.enable();
|
||||||
|
|||||||
@@ -146,7 +146,6 @@ function load_template(callback) {
|
|||||||
url = (url === '' || url === '/') ? 'home' : url;
|
url = (url === '' || url === '/') ? 'home' : url;
|
||||||
|
|
||||||
jQuery.get(API_URL + url, function(data) {
|
jQuery.get(API_URL + url, function(data) {
|
||||||
console.log(data)
|
|
||||||
document.getElementById('content').innerHTML = templates[url.split('/')[0]].parse(JSON.parse(data));
|
document.getElementById('content').innerHTML = templates[url.split('/')[0]].parse(JSON.parse(data));
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -47,9 +47,8 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
(function() {
|
(function() {
|
||||||
var locked = '{locked}',
|
var locked = '{locked}',
|
||||||
expose_tools = '{expose_tools}';
|
expose_tools = '{expose_tools}',
|
||||||
|
tid = '{topic_id}';
|
||||||
console.log(expose_tools);
|
|
||||||
|
|
||||||
jQuery('document').ready(function() {
|
jQuery('document').ready(function() {
|
||||||
var room = 'topic_' + '{topic_id}',
|
var room = 'topic_' + '{topic_id}',
|
||||||
@@ -61,7 +60,7 @@
|
|||||||
if (locked === '1') set_locked_state(true);
|
if (locked === '1') set_locked_state(true);
|
||||||
|
|
||||||
if (expose_tools === '1') {
|
if (expose_tools === '1') {
|
||||||
var deleteThreadEl = document.getElementById('delete-thread');
|
var deleteThreadEl = document.getElementById('delete_thread');
|
||||||
|
|
||||||
adminTools.style.visibility = 'inherit';
|
adminTools.style.visibility = 'inherit';
|
||||||
|
|
||||||
@@ -69,14 +68,14 @@
|
|||||||
deleteThreadEl.addEventListener('click', function(e) {
|
deleteThreadEl.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (confirm('really delete thread? (THIS DIALOG TO BE REPLACED WITH BOOTBOX)')) {
|
if (confirm('really delete thread? (THIS DIALOG TO BE REPLACED WITH BOOTBOX)')) {
|
||||||
console.log('socket shiz');
|
socket.emit('api:topic.delete', { tid: tid });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
ajaxify.register_events(['event:rep_up', 'event:rep_down', 'event:new_post', 'api:get_users_in_room']);
|
ajaxify.register_events(['event:rep_up', 'event:rep_down', 'event:new_post', 'api:get_users_in_room', 'event:topic_deleted']);
|
||||||
socket.on('api:get_users_in_room', function(users) {
|
socket.on('api:get_users_in_room', function(users) {
|
||||||
var anonymous = users.anonymous,
|
var anonymous = users.anonymous,
|
||||||
usernames = users.usernames,
|
usernames = users.usernames,
|
||||||
@@ -106,7 +105,6 @@
|
|||||||
adjust_rep(-1, data.pid, data.uid);
|
adjust_rep(-1, data.pid, data.uid);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
socket.on('event:new_post', function(data) {
|
socket.on('event:new_post', function(data) {
|
||||||
var html = templates.prepare(templates['topic'].blocks['posts']).parse(data),
|
var html = templates.prepare(templates['topic'].blocks['posts']).parse(data),
|
||||||
uniqueid = new Date().getTime();
|
uniqueid = new Date().getTime();
|
||||||
@@ -115,7 +113,11 @@
|
|||||||
set_up_posts(uniqueid);
|
set_up_posts(uniqueid);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on('event:topic_deleted', function(data) {
|
||||||
|
if (data.tid === tid && data.status === 'ok') {
|
||||||
|
console.log('thread deleted!!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function adjust_rep(value, pid, uid) {
|
function adjust_rep(value, pid, uid) {
|
||||||
var post_rep = jQuery('.post_rep_' + pid),
|
var post_rep = jQuery('.post_rep_' + pid),
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
var RDB = require('./redis.js'),
|
var RDB = require('./redis.js'),
|
||||||
posts = require('./posts.js'),
|
posts = require('./posts.js'),
|
||||||
utils = require('./utils.js'),
|
utils = require('./utils.js'),
|
||||||
user = require('./user.js');
|
user = require('./user.js'),
|
||||||
|
configs = require('../config.js');
|
||||||
|
|
||||||
(function(Topics) {
|
(function(Topics) {
|
||||||
|
|
||||||
@@ -135,8 +136,71 @@ var RDB = require('./redis.js'),
|
|||||||
timeout: 2000
|
timeout: 2000
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Topics.lock = function(tid, uid, socket) {
|
||||||
|
user.getUserField(uid, 'reputation', function(rep) {
|
||||||
|
if (rep >= configs.privilege_thresholds.manage_thread) {
|
||||||
|
// Mark thread as locked
|
||||||
|
RDB.set('tid:' + tid + ':locked', 1);
|
||||||
|
|
||||||
|
if (socket) {
|
||||||
|
socket.emit('event:topic_locked', {
|
||||||
|
tid: tid,
|
||||||
|
status: 'ok'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Topics.unlock = function(tid, uid, socket) {
|
||||||
|
user.getUserField(uid, 'reputation', function(rep) {
|
||||||
|
if (rep >= configs.privilege_thresholds.manage_thread) {
|
||||||
|
// Mark thread as locked
|
||||||
|
RDB.set('tid:' + tid + ':locked', 0);
|
||||||
|
|
||||||
|
if (socket) {
|
||||||
|
socket.emit('event:topic_unlocked', {
|
||||||
|
tid: tid,
|
||||||
|
status: 'ok'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Topics.delete = function(tid, uid, socket) {
|
||||||
|
user.getUserField(uid, 'reputation', function(rep) {
|
||||||
|
if (rep >= configs.privilege_thresholds.manage_thread) {
|
||||||
|
// Mark thread as deleted
|
||||||
|
RDB.set('tid:' + tid + ':deleted', 1);
|
||||||
|
Topics.lock(tid, uid);
|
||||||
|
|
||||||
|
if (socket) {
|
||||||
|
socket.emit('event:topic_deleted', {
|
||||||
|
tid: tid,
|
||||||
|
status: 'ok'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Topics.restore = function(tid, uid, socket) {
|
||||||
|
user.getUserField(uid, 'reputation', function(rep) {
|
||||||
|
if (rep >= configs.privilege_thresholds.manage_thread) {
|
||||||
|
// Mark thread as deleted
|
||||||
|
RDB.set('tid:' + tid + ':deleted', 0);
|
||||||
|
Topics.lock(tid, uid);
|
||||||
|
|
||||||
|
if (socket) {
|
||||||
|
socket.emit('event:topic_restored', {
|
||||||
|
tid: tid,
|
||||||
|
status: 'ok'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}(exports));
|
}(exports));
|
||||||
@@ -356,9 +356,8 @@ passport.deserializeUser(function(uid, done) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.get('/test', function(req, res) {
|
app.get('/test', function(req, res) {
|
||||||
global.modules.posts.create(2, 2, 'test', function(pid) {
|
global.modules.topics.delete(1, 1);
|
||||||
res.send('<pre>' + pid + '</pre>');
|
res.send();
|
||||||
}, 1, 1);
|
|
||||||
});
|
});
|
||||||
}(WebServer));
|
}(WebServer));
|
||||||
|
|
||||||
|
|||||||
@@ -183,6 +183,22 @@ var SocketIO = require('socket.io').listen(global.server,{log:false}),
|
|||||||
socket.on('api:user.active.get_record', function() {
|
socket.on('api:user.active.get_record', function() {
|
||||||
modules.user.active.get_record(socket);
|
modules.user.active.get_record(socket);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on('api:topic.delete', function(data) {
|
||||||
|
modules.topics.delete(data.tid, uid, socket);
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('api:topic.restore', function(data) {
|
||||||
|
modules.topics.restore(data.tid, uid, socket);
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('api:topic.lock', function(data) {
|
||||||
|
modules.topics.lock(data.tid, uid, socket);
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('api:topic.unlock', function(data) {
|
||||||
|
modules.topics.unlock(data.tid, uid, socket);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}(SocketIO));
|
}(SocketIO));
|
||||||
|
|||||||
Reference in New Issue
Block a user