proper handling of post editing, integration with ACP toggle, #2569

v1.18.x
Julian Lam 10 years ago
parent 325815a78d
commit 9befa6aca7

@ -154,6 +154,7 @@ define('composer', [
push({ push({
pid: pid, pid: pid,
uid: threadData.uid,
title: $('<div/>').html(threadData.title).text(), title: $('<div/>').html(threadData.title).text(),
body: threadData.body, body: threadData.body,
modified: false, modified: false,
@ -213,9 +214,11 @@ define('composer', [
} }
function createNewComposer(post_uuid) { function createNewComposer(post_uuid) {
var allowTopicsThumbnail = config.allowTopicsThumbnail && composer.posts[post_uuid].isMain && (config.hasImageUploadPlugin || config.allowFileUploads); var allowTopicsThumbnail = config.allowTopicsThumbnail && composer.posts[post_uuid].isMain && (config.hasImageUploadPlugin || config.allowFileUploads),
var isTopic = composer.posts[post_uuid] ? !!composer.posts[post_uuid].cid : false; isTopic = composer.posts[post_uuid] ? !!composer.posts[post_uuid].cid : false,
var isMain = composer.posts[post_uuid] ? !!composer.posts[post_uuid].isMain : false; isMain = composer.posts[post_uuid] ? !!composer.posts[post_uuid].isMain : false,
isEditing = composer.posts[post_uuid] ? !!composer.posts[post_uuid].pid : false,
isGuestPost = composer.posts[post_uuid] ? composer.posts[post_uuid].uid === '0' : null;
composer.bsEnvironment = utils.findBootstrapEnvironment(); composer.bsEnvironment = utils.findBootstrapEnvironment();
@ -225,7 +228,7 @@ define('composer', [
allowTopicsThumbnail: allowTopicsThumbnail, allowTopicsThumbnail: allowTopicsThumbnail,
showTags: isTopic || isMain, showTags: isTopic || isMain,
isTopic: isTopic, isTopic: isTopic,
allowGuestHandles: config.allowGuestHandles showHandleInput: (app.user.uid === 0 || (isEditing && isGuestPost && app.user.isAdmin)) && config.allowGuestHandles
}; };
parseAndTranslate(template, data, function(composerTemplate) { parseAndTranslate(template, data, function(composerTemplate) {

@ -35,7 +35,7 @@ SocketModules.composer.push = function(socket, pid, callback) {
if (err || !canRead) { if (err || !canRead) {
return callback(err || new Error('[[error:no-privileges]]')); return callback(err || new Error('[[error:no-privileges]]'));
} }
posts.getPostFields(pid, ['content', 'tid'], function(err, postData) { posts.getPostFields(pid, ['content', 'tid', 'uid'], function(err, postData) {
if(err || (!postData && !postData.content)) { if(err || (!postData && !postData.content)) {
return callback(err || new Error('[[error:invalid-pid]]')); return callback(err || new Error('[[error:invalid-pid]]'));
} }
@ -61,6 +61,7 @@ SocketModules.composer.push = function(socket, pid, callback) {
callback(null, { callback(null, {
pid: pid, pid: pid,
uid: postData.uid,
body: postData.content, body: postData.content,
title: results.topic.title, title: results.topic.title,
topic_thumb: results.topic.thumb, topic_thumb: results.topic.thumb,

@ -10,7 +10,8 @@ var async = require('async'),
user = require('../user'), user = require('../user'),
favourites = require('../favourites'), favourites = require('../favourites'),
posts = require('../posts'), posts = require('../posts'),
privileges = require('../privileges'); privileges = require('../privileges'),
meta = require('../meta');
module.exports = function(Topics) { module.exports = function(Topics) {
@ -130,7 +131,7 @@ module.exports = function(Topics) {
} }
// Username override for guests, if enabled // Username override for guests, if enabled
if (parseInt(postObj.uid, 10) === 0 && postObj.handle) { if (parseInt(meta.config.allowGuestHandles, 10) === 1 && parseInt(postObj.uid, 10) === 0 && postObj.handle) {
postObj.user.username = postObj.handle; postObj.user.username = postObj.handle;
} }
} }

Loading…
Cancel
Save