diff --git a/public/src/app.js b/public/src/app.js
index 6002156e4c..451f73e493 100644
--- a/public/src/app.js
+++ b/public/src/app.js
@@ -109,8 +109,6 @@ var socket,
// timeout default = permanent
// location : alert_window (default) or content
app.alert = function(params) {
-
-
var alert_id = 'alert_button_' + ((params.alert_id) ? params.alert_id : new Date().getTime());
var alert = $('#'+alert_id);
@@ -121,7 +119,6 @@ var socket,
alert.attr('class', "alert toaster-alert " + ((params.type=='warning') ? '' : "alert-" + params.type));
}
else {
-
var div = document.createElement('div'),
button = document.createElement('button'),
strong = document.createElement('strong'),
diff --git a/public/src/forum/footer.js b/public/src/forum/footer.js
index 35a5aa6bc8..1273e29d4b 100644
--- a/public/src/forum/footer.js
+++ b/public/src/forum/footer.js
@@ -13,7 +13,7 @@
socket.emit('user.latest', {});
socket.on('user.latest', function(data) {
if (data.username == '') {
- latest_user.innerHTML = '';y
+ latest_user.innerHTML = '';
} else {
latest_user.innerHTML = "The most recent user to register is " + data.username + ".";
}
diff --git a/public/src/modules/composer.js b/public/src/modules/composer.js
index 158d22484d..217772fae8 100644
--- a/public/src/modules/composer.js
+++ b/public/src/modules/composer.js
@@ -41,21 +41,34 @@ define(function() {
document.body.insertBefore(composer.postContainer, composer.btnContainer);
socket.on('api:composer.push', function(threadData) {
- var uuid = utils.generateUUID(),
- btnEl = document.createElement('li');
- btnEl.innerHTML = '
' + (!threadData.cid ? (threadData.title || '') : 'New Topic') + '';
- btnEl.setAttribute('data-uuid', uuid);
- composer.listEl.appendChild(btnEl);
- composer.posts[uuid] = {
- tid: threadData.tid,
- cid: threadData.cid,
- pid: threadData.pid,
- title: threadData.title || '',
- body: threadData.body || ''
- };
- composer.active++;
- composer.update();
- composer.load(uuid);
+ if (!threadData.error) {
+ var uuid = utils.generateUUID(),
+ btnEl = document.createElement('li');
+ btnEl.innerHTML = '
' + (!threadData.cid ? (threadData.title || '') : 'New Topic') + '';
+ btnEl.setAttribute('data-uuid', uuid);
+ composer.listEl.appendChild(btnEl);
+ composer.posts[uuid] = {
+ tid: threadData.tid,
+ cid: threadData.cid,
+ pid: threadData.pid,
+ title: threadData.title || '',
+ body: threadData.body || ''
+ };
+ composer.active++;
+ composer.update();
+ composer.load(uuid);
+ } else {
+ app.alert({
+ type: 'error',
+ timeout: 5000,
+ alert_id: 'post_error',
+ title: 'Please Log In to Post',
+ message: 'Posting is currently restricted to registered members only, click here to log in',
+ clickfn: function() {
+ ajaxify.go('login');
+ }
+ });
+ }
});
socket.on('api:composer.editCheck', function(editCheck) {
diff --git a/src/websockets.js b/src/websockets.js
index c8e7017833..78283703f9 100644
--- a/src/websockets.js
+++ b/src/websockets.js
@@ -308,38 +308,44 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
});
socket.on('api:composer.push', function(data) {
- if (parseInt(data.tid) > 0) {
- topics.get_topic(data.tid, uid, function(topicData) {
- topicData.tid = data.tid;
- socket.emit('api:composer.push', topicData);
- });
- } else if (parseInt(data.cid) > 0) {
- user.getUserField(uid, 'username', function(username) {
- socket.emit('api:composer.push', {
- tid: 0,
- cid: data.cid,
- username: username,
- title: undefined
+ if (uid > 0) {
+ if (parseInt(data.tid) > 0) {
+ topics.get_topic(data.tid, uid, function(topicData) {
+ topicData.tid = data.tid;
+ socket.emit('api:composer.push', topicData);
});
- });
- } else if (parseInt(data.pid) > 0) {
- async.parallel([
- function(next) {
- posts.getRawContent(data.pid, function(raw) {
- next(null, raw);
+ } else if (parseInt(data.cid) > 0) {
+ user.getUserField(uid, 'username', function(username) {
+ socket.emit('api:composer.push', {
+ tid: 0,
+ cid: data.cid,
+ username: username,
+ title: undefined
});
- },
- function(next) {
- topics.getTitle(data.pid, function(title) {
- next(null, title);
- });
- }
- ], function(err, results) {
- socket.emit('api:composer.push', {
- title: results[1],
- pid: data.pid,
- body: results[0]
});
+ } else if (parseInt(data.pid) > 0) {
+ async.parallel([
+ function(next) {
+ posts.getRawContent(data.pid, function(raw) {
+ next(null, raw);
+ });
+ },
+ function(next) {
+ topics.getTitle(data.pid, function(title) {
+ next(null, title);
+ });
+ }
+ ], function(err, results) {
+ socket.emit('api:composer.push', {
+ title: results[1],
+ pid: data.pid,
+ body: results[0]
+ });
+ });
+ }
+ } else {
+ socket.emit('api:composer.push', {
+ error: 'no-uid'
});
}
});