diff --git a/install/data/defaults.json b/install/data/defaults.json index 3babb24f61..8f1bc88115 100644 --- a/install/data/defaults.json +++ b/install/data/defaults.json @@ -11,10 +11,6 @@ "field": "minimumPostLength", "value": 8 }, - { - "field": "allowGuestPosting", - "value": 0 - }, { "field": "allowGuestSearching", "value": 0 diff --git a/public/src/modules/composer.js b/public/src/modules/composer.js index ebe720c44c..f3a8ed716d 100644 --- a/public/src/modules/composer.js +++ b/public/src/modules/composer.js @@ -41,22 +41,22 @@ define(['taskbar'], function(taskbar) { $el.unwrap(); } - function allowed() { - if(!(parseInt(app.uid, 10) > 0 || config.allowGuestPosting)) { - app.alert({ - type: 'danger', - timeout: 5000, - alert_id: 'post_error', - title: '[[global:please_log_in]]', - message: '[[global:posting_restriction_info]]', - clickfn: function() { - ajaxify.go('login'); - } - }); - return false; - } - return true; - } + // function allowed() { + // if(!(parseInt(app.uid, 10) > 0 || config.allowGuestPosting)) { + // app.alert({ + // type: 'danger', + // timeout: 5000, + // alert_id: 'post_error', + // title: '[[global:please_log_in]]', + // message: '[[global:posting_restriction_info]]', + // clickfn: function() { + // ajaxify.go('login'); + // } + // }); + // return false; + // } + // return true; + // } function alreadyOpen(post) { // If a composer for the same cid/tid/pid is already open, return the uuid, else return bool false @@ -484,9 +484,9 @@ define(['taskbar'], function(taskbar) { }; composer.newTopic = function(cid) { - if(!allowed()) { - return; - } + // if(!allowed()) { + // return; + // } push({ cid: cid, @@ -498,9 +498,9 @@ define(['taskbar'], function(taskbar) { }; composer.addQuote = function(tid, pid, title, username, text){ - if (!allowed()) { - return; - } + // if (!allowed()) { + // return; + // } var uuid = composer.active; @@ -521,9 +521,9 @@ define(['taskbar'], function(taskbar) { }; composer.newReply = function(tid, pid, title, text) { - if(!allowed()) { - return; - } + // if(!allowed()) { + // return; + // } push({ tid: tid, @@ -536,9 +536,9 @@ define(['taskbar'], function(taskbar) { }; composer.editPost = function(pid) { - if(!allowed()) { - return; - } + // if(!allowed()) { + // return; + // } socket.emit('modules.composer.push', pid, function(err, threadData) { if(err) { @@ -610,7 +610,7 @@ define(['taskbar'], function(taskbar) { thumbToggleBtnEl.removeClass('hide'); } }; - + postData.title = $('
').html(postData.title).text(); if (parseInt(postData.tid, 10) > 0) { diff --git a/src/controllers/api.js b/src/controllers/api.js index 648a5a70c6..501cf0fe60 100644 --- a/src/controllers/api.js +++ b/src/controllers/api.js @@ -24,8 +24,7 @@ apiController.getConfig = function(req, res, next) { config.minimumPasswordLength = meta.config.minimumPasswordLength; config.maximumSignatureLength = meta.config.maximumSignatureLength; config.useOutgoingLinksPage = parseInt(meta.config.useOutgoingLinksPage, 10) === 1; - config.allowGuestPosting = parseInt(meta.config.allowGuestPosting, 10) === 1; - config.allowGuestSearching = parseInt(meta.config.allowGuestPosting, 10) === 1; + config.allowGuestSearching = parseInt(meta.config.allowGuestSearching, 10) === 1; config.allowFileUploads = parseInt(meta.config.allowFileUploads, 10) === 1; config.allowTopicsThumbnail = parseInt(meta.config.allowTopicsThumbnail, 10) === 1; config.privateUserInfo = parseInt(meta.config.privateUserInfo, 10) === 1; diff --git a/src/groups.js b/src/groups.js index 030df7d0a4..72864c47a9 100644 --- a/src/groups.js +++ b/src/groups.js @@ -38,6 +38,16 @@ }); } }); + }, + removeEphemeralGroups: function(groups) { + var x = groups.length; + while(x--) { + if (ephemeralGroups.indexOf(groups[x]) !== -1) { + groups.splice(x, 1); + } + } + + return groups; } }; @@ -137,9 +147,14 @@ }; Groups.isMemberOfGroupList = function(uid, groupListKey, callback) { - db.getSetMembers('group:' + groupListKey + ':members', function(err, gids) { - async.some(gids, function(gid, next) { - Groups.isMember(uid, gid, function(err, isMember) { + db.getSetMembers('group:' + groupListKey + ':members', function(err, groupNames) { + groupNames = internals.removeEphemeralGroups(groupNames); + if (groupNames.length === 0) { + return callback(null, null); + } + + async.some(groupNames, function(groupName, next) { + Groups.isMember(uid, groupName, function(err, isMember) { if (!err && isMember) { next(true); } else { diff --git a/src/privileges/helpers.js b/src/privileges/helpers.js index 2c043fd6ac..9c4ec535a0 100644 --- a/src/privileges/helpers.js +++ b/src/privileges/helpers.js @@ -40,11 +40,11 @@ helpers.allowedTo = function(privilege, uid, cid, callback) { }, function(next) { helpers.isMember(groups.isMember, 'cid:' + cid + ':privileges:groups:' + privilege, 'guests', function(err, isMember) { - next(err, privilege !== 'find' ? isMember : isMember !== false); + next(err, privilege !== 'find' && privilege !== 'read' ? isMember === true : isMember !== false); }); } ], function(err, results) { - callback(err, results[0] && results[1]); + callback(err, results[0] && (results[1] || results[1] === null)); }); } diff --git a/src/privileges/topics.js b/src/privileges/topics.js index 7c82452f93..621baf45ca 100644 --- a/src/privileges/topics.js +++ b/src/privileges/topics.js @@ -55,6 +55,16 @@ module.exports = function(privileges) { }); }; + privileges.topics.can = function(privilege, tid, uid, callback) { + topics.getTopicField(tid, 'cid', function(err, cid) { + if (err) { + return callback(err); + } + + privileges.categories.can(privilege, cid, uid, callback); + }); + }; + privileges.topics.canRead = function(tid, uid, callback) { topics.getTopicField(tid, 'cid', function(err, cid) { if (err) { diff --git a/src/socket.io/modules.js b/src/socket.io/modules.js index 2a7159b0da..ce24c362ea 100644 --- a/src/socket.io/modules.js +++ b/src/socket.io/modules.js @@ -49,10 +49,6 @@ var stopTracking = function(replyObj) { }; SocketModules.composer.push = function(socket, pid, callback) { - if(!socket.uid && parseInt(meta.config.allowGuestPosting, 10) !== 1) { - return callback(new Error('[[error:not-logged-in]]')); - } - posts.getPostFields(pid, ['content'], function(err, postData) { if(err || (!postData && !postData.content)) { return callback(err || new Error('[[error:invalid-pid]]')); diff --git a/src/socket.io/posts.js b/src/socket.io/posts.js index 1d240140f6..f2c77678b2 100644 --- a/src/socket.io/posts.js +++ b/src/socket.io/posts.js @@ -19,11 +19,6 @@ var async = require('async'), SocketPosts.reply = function(socket, data, callback) { - - if (!socket.uid && !parseInt(meta.config.allowGuestPosting, 10)) { - return callback(new Error('[[error:not-logged-in]]')); - } - if(!data || !data.tid || !data.content) { return callback(new Error('[[error:invalid-data]]')); } diff --git a/src/socket.io/topics.js b/src/socket.io/topics.js index d0cf8e716e..7323a225e3 100644 --- a/src/socket.io/topics.js +++ b/src/socket.io/topics.js @@ -21,10 +21,6 @@ SocketTopics.post = function(socket, data, callback) { return callback(new Error('[[error:invalid-data]]')); } - if (!socket.uid && !parseInt(meta.config.allowGuestPosting, 10)) { - return callback(new Error('[[error:not-logged-in]]')); - } - topics.post({ uid: socket.uid, title: data.title, diff --git a/src/user.js b/src/user.js index 43d30b353c..6bbd6e0f6b 100644 --- a/src/user.js +++ b/src/user.js @@ -154,10 +154,6 @@ var bcrypt = require('bcryptjs'), }; User.isReadyToPost = function(uid, callback) { - if (meta.config.allowGuestPosting && parseInt(uid, 10) === 0) { - return callback(); - } - async.parallel({ banned: function(next) { User.getUserField(uid, 'banned', next);