From eebc308d2ac07887275b156296a3484a6f5cb8c2 Mon Sep 17 00:00:00 2001 From: aritas1 Date: Tue, 14 Feb 2012 18:02:17 +0400 Subject: [PATCH] add delete group form groups --- node/db/GroupManager.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/node/db/GroupManager.js b/node/db/GroupManager.js index d6f9717b4..13620c2e5 100644 --- a/node/db/GroupManager.js +++ b/node/db/GroupManager.js @@ -101,8 +101,33 @@ exports.deleteGroup = function(groupID, callback) //remove group and group2sessions entry function(callback) { + // remove group from groups entry + db.get("groups", function (err, groups) + { + if(ERR(err, callback)) return; + + if(ERR(err, callback)) return; + + existingGroups = []; + + if(groups != undefined) + { + for(var key in groups['groups']) + { + if(groupID != groups['groups'][key]) + { + existingGroups.push(groups['groups'][key]); + } + } + } + + db.set("groups", {groups: existingGroups}); + }); + db.remove("group2sessions:" + groupID); db.remove("group:" + groupID); + + callback(); } ], function(err)