mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-31 19:15:58 +01:00
closes #1398
This commit is contained in:
@@ -48,6 +48,7 @@
|
||||
"thread_tools.lock": "Lock Topic",
|
||||
"thread_tools.unlock": "Unlock Topic",
|
||||
"thread_tools.move": "Move Topic",
|
||||
"thread_tools.move_all": "Move All",
|
||||
"thread_tools.fork": "Fork Topic",
|
||||
"thread_tools.delete": "Delete Topic",
|
||||
"thread_tools.delete_confirm": "Are you sure you want to delete this thread?",
|
||||
|
||||
@@ -68,13 +68,19 @@ define(['forum/topic/move', 'topicSelect'], function(move, topicSelect) {
|
||||
|
||||
$('.move_thread').on('click', function() {
|
||||
var tids = topicSelect.getSelectedTids();
|
||||
console.log(tids);
|
||||
|
||||
if (tids.length) {
|
||||
move.init(tids, cid, onCommandComplete);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.move_all_threads').on('click', function() {
|
||||
move.init(null, cid, function(err) {
|
||||
ajaxify.refresh();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
socket.on('event:topic_deleted', setDeleteState);
|
||||
socket.on('event:topic_restored', setDeleteState);
|
||||
@@ -151,7 +157,7 @@ define(['forum/topic/move', 'topicSelect'], function(move, topicSelect) {
|
||||
var topic = getTopicEl(data.tid);
|
||||
topic.toggleClass('pinned', data.isPinned);
|
||||
topic.find('.fa-thumb-tack').toggleClass('hide', !data.isPinned);
|
||||
ajaxify.go('category/' + CategoryTools.cid);
|
||||
ajaxify.refresh();
|
||||
}
|
||||
|
||||
function setLockedState(data) {
|
||||
|
||||
@@ -15,11 +15,11 @@ define(function() {
|
||||
Move.tids = tids;
|
||||
Move.currentCid = currentCid;
|
||||
Move.onComplete = onComplete;
|
||||
Move.moveAll = tids ? false : true;
|
||||
|
||||
modal.on('shown.bs.modal', onMoveModalShown);
|
||||
$('#move-confirm').hide();
|
||||
modal.modal('show');
|
||||
|
||||
};
|
||||
|
||||
function onMoveModalShown() {
|
||||
@@ -60,14 +60,15 @@ define(function() {
|
||||
if (!commitEl.prop('disabled') && targetCid) {
|
||||
commitEl.prop('disabled', true);
|
||||
|
||||
moveTopic();
|
||||
moveTopics();
|
||||
}
|
||||
}
|
||||
|
||||
function moveTopic() {
|
||||
socket.emit('topics.move', {
|
||||
function moveTopics() {
|
||||
socket.emit(Move.moveAll ? 'topics.moveAll' : 'topics.move', {
|
||||
tids: Move.tids,
|
||||
cid: targetCid
|
||||
cid: targetCid,
|
||||
currentCid: Move.currentCid
|
||||
}, function(err) {
|
||||
modal.modal('hide');
|
||||
$('#move_thread_commit').prop('disabled', false);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
var topics = require('../topics'),
|
||||
categories = require('../categories'),
|
||||
threadTools = require('../threadTools'),
|
||||
categoryTools = require('../categoryTools'),
|
||||
index = require('./index'),
|
||||
user = require('../user'),
|
||||
db = require('./../database'),
|
||||
@@ -265,6 +266,39 @@ SocketTopics.move = function(socket, data, callback) {
|
||||
}, callback);
|
||||
};
|
||||
|
||||
SocketTopics.moveAll = function(socket, data, callback) {
|
||||
if(!data || !data.cid || !data.currentCid) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
}
|
||||
|
||||
async.parallel({
|
||||
from: function(next) {
|
||||
categoryTools.privileges(data.currentCid, socket.uid, next);
|
||||
},
|
||||
to: function(next) {
|
||||
categoryTools.privileges(data.cid, socket.uid, next);
|
||||
}
|
||||
}, function(err, results) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (!results.from.admin && (!results.from.moderator || !results.to.moderator)) {
|
||||
return callback(new Error('[[error:no-privileges]]'));
|
||||
}
|
||||
|
||||
categories.getTopicIds(data.currentCid, 0, -1, function(err, tids) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
async.each(tids, function(tid, next) {
|
||||
threadTools.move(tid, data.cid, next);
|
||||
}, callback);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
SocketTopics.followCheck = function(socket, tid, callback) {
|
||||
threadTools.isFollowing(tid, socket.uid, callback);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user