From 90093c2b5523c36009abf00a45e4365359b3a7c1 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sun, 13 Jun 2010 20:52:37 +0500 Subject: MUC: Added a 'Make Room Members-Only?' field to the room config dialog. --- plugins/muc/muc.lib.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua index cf8946eb..2f7800b4 100644 --- a/plugins/muc/muc.lib.lua +++ b/plugins/muc/muc.lib.lua @@ -491,6 +491,9 @@ function room_mt:send_form(origin, stanza) :tag("field", {type='boolean', label='Make Room Moderated?', var='muc#roomconfig_moderatedroom'}) :tag("value"):text(self:is_moderated() and "1" or "0"):up() :up() + :tag("field", {type='boolean', label='Make Room Members-Only?', var='muc#roomconfig_membersonly'}) + :tag("value"):text(self:is_members_only() and "1" or "0"):up() + :up() ); end @@ -529,6 +532,12 @@ function room_mt:process_form(origin, stanza) dirty = dirty or (self:is_moderated() ~= moderated) module:log("debug", "moderated=%s", tostring(moderated)); + local membersonly = fields['muc#roomconfig_membersonly']; + if membersonly == "0" or membersonly == "false" then membersonly = nil; elseif membersonly == "1" or membersonly == "true" then membersonly = true; + else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end + dirty = dirty or (self:is_members_only() ~= membersonly) + module:log("debug", "membersonly=%s", tostring(membersonly)); + local public = fields['muc#roomconfig_publicroom']; if public == "0" or public == "false" then public = nil; elseif public == "1" or public == "true" then public = true; else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end @@ -549,6 +558,7 @@ function room_mt:process_form(origin, stanza) self:set_password(password); end self:set_moderated(moderated); + self:set_members_only(membersonly); if self.save then self:save(true); end origin.send(st.reply(stanza)); -- cgit v1.2.3