v1.18.x
Baris Usakli 7 years ago
parent 189008af75
commit 6a6dc7ef06

@ -63,11 +63,15 @@ define('forum/topic/move', ['categorySelector'], function (categorySelector) {
} }
function moveTopics() { function moveTopics() {
socket.emit(Move.moveAll ? 'topics.moveAll' : 'topics.move', { var data = {
tids: Move.tids, tids: Move.tids,
cid: selectedCategory.cid, cid: selectedCategory.cid,
currentCid: Move.currentCid, currentCid: Move.currentCid,
}, function (err) { };
$(window).trigger('action:topic.move', data);
socket.emit(Move.moveAll ? 'topics.moveAll' : 'topics.move', data, function (err) {
modal.modal('hide'); modal.modal('hide');
if (err) { if (err) {

@ -28,7 +28,8 @@ module.exports = function (SocketTopics) {
function (_topicData, next) { function (_topicData, next) {
topicData = _topicData; topicData = _topicData;
topicData.tid = tid; topicData.tid = tid;
topics.tools.move(tid, data.cid, socket.uid, next); data.uid = socket.uid;
topics.tools.move(tid, data, next);
}, },
function (next) { function (next) {
socketHelpers.emitToTopicAndCategory('event:topic_moved', topicData); socketHelpers.emitToTopicAndCategory('event:topic_moved', topicData);
@ -59,8 +60,9 @@ module.exports = function (SocketTopics) {
categories.getAllTopicIds(data.currentCid, 0, -1, next); categories.getAllTopicIds(data.currentCid, 0, -1, next);
}, },
function (tids, next) { function (tids, next) {
data.uid = socket.uid;
async.eachLimit(tids, 50, function (tid, next) { async.eachLimit(tids, 50, function (tid, next) {
topics.tools.move(tid, data.cid, socket.uid, next); topics.tools.move(tid, data, next);
}, next); }, next);
}, },
], callback); ], callback);

@ -243,9 +243,10 @@ module.exports = function (Topics) {
], callback); ], callback);
}; };
topicTools.move = function (tid, cid, uid, callback) { topicTools.move = function (tid, data, callback) {
var topic; var topic;
var oldCid; var oldCid;
var cid = data.cid;
async.waterfall([ async.waterfall([
function (next) { function (next) {
Topics.exists(tid, next); Topics.exists(tid, next);
@ -311,12 +312,11 @@ module.exports = function (Topics) {
}); });
}, },
function (next) { function (next) {
plugins.fireHook('action:topic.move', { var hookData = _.clone(data);
tid: tid, hookData.fromCid = oldCid;
fromCid: oldCid, hookData.toCid = cid;
toCid: cid, hookData.tid = tid;
uid: uid, plugins.fireHook('action:topic.move', hookData);
});
next(); next();
}, },
], callback); ], callback);

Loading…
Cancel
Save