From 6d947ad59f0cd9ac0f7ba3bfd50476fc1325c5f1 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sun, 13 Jun 2010 20:24:55 +0500 Subject: MUC: Added a 'Make Room Moderated?' field to the room config dialog. --- plugins/muc/muc.lib.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua index 50100557..9ca54ad6 100644 --- a/plugins/muc/muc.lib.lua +++ b/plugins/muc/muc.lib.lua @@ -253,7 +253,7 @@ end function room_mt:set_moderated(moderated) moderated = moderated and true or nil; if self._data.moderated ~= moderated then - self._data.moderated = + self._data.moderated = moderated; if self.save then self:save(true); end end end @@ -475,6 +475,9 @@ function room_mt:send_form(origin, stanza) :tag("field", {type='text-private', label='Password', var='muc#roomconfig_roomsecret'}) :tag("value"):text(self:get_password() or ""):up() :up() + :tag("field", {type='boolean', label='Make Room Moderated?', var='muc#roomconfig_moderatedroom'}) + :tag("value"):text(self:is_moderated() and "1" or "0"):up() + :up() ); end @@ -507,6 +510,12 @@ function room_mt:process_form(origin, stanza) self._data.persistent = persistent; module:log("debug", "persistent=%s", tostring(persistent)); + local moderated = fields['muc#roomconfig_moderatedroom']; + if moderated == "0" or moderated == "false" then moderated = nil; elseif moderated == "1" or moderated == "true" then moderated = true; + else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end + dirty = dirty or (self:is_moderated() ~= moderated) + module:log("debug", "moderated=%s", tostring(moderated)); + 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 @@ -526,6 +535,7 @@ function room_mt:process_form(origin, stanza) if password then self:set_password(password); end + self:set_moderated(moderated); if self.save then self:save(true); end origin.send(st.reply(stanza)); -- cgit v1.2.3