From 9bca777320c2cabe04c0de0a6a5da3e09fbe1e17 Mon Sep 17 00:00:00 2001
From: barisusakli
Date: Thu, 5 Feb 2015 19:38:51 -0500
Subject: [PATCH] closes #2700 allowGroupCreation setting
---
src/controllers/groups.js | 4 +++-
src/socket.io/groups.js | 5 ++++-
src/views/admin/settings/group.tpl | 9 +++++++++
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/controllers/groups.js b/src/controllers/groups.js
index c20993a7df..c5d430b28d 100644
--- a/src/controllers/groups.js
+++ b/src/controllers/groups.js
@@ -2,6 +2,7 @@
var async = require('async'),
nconf = require('nconf'),
+ meta = require('../meta'),
groups = require('../groups'),
user = require('../user'),
helpers = require('./helpers'),
@@ -17,7 +18,8 @@ groupsController.list = function(req, res, next) {
return next(err);
}
res.render('groups/list', {
- groups: groups
+ groups: groups,
+ allowGroupCreation: parseInt(meta.config.allowGroupCreation, 10) === 1
});
});
};
diff --git a/src/socket.io/groups.js b/src/socket.io/groups.js
index b2b1b244ed..a99112eded 100644
--- a/src/socket.io/groups.js
+++ b/src/socket.io/groups.js
@@ -116,12 +116,15 @@ SocketGroups.update = function(socket, data, callback) {
};
SocketGroups.create = function(socket, data, callback) {
- if(!data) {
+ if (!data) {
return callback(new Error('[[error:invalid-data]]'));
} else if (socket.uid === 0) {
return callback(new Error('[[error:no-privileges]]'));
+ } else if (parseInt(meta.config.allowGroupCreation, 10) !== 1) {
+ return callback(new Error('[[error:group-creation-disabled]]'));
}
+
data.ownerUid = socket.uid;
groups.create(data, callback);
};
diff --git a/src/views/admin/settings/group.tpl b/src/views/admin/settings/group.tpl
index 7da62689ce..11a3c41f72 100644
--- a/src/views/admin/settings/group.tpl
+++ b/src/views/admin/settings/group.tpl
@@ -15,6 +15,15 @@
+
+
+
+