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