# HG changeset patch # User Waqas Hussain # Date 1276442695 -18000 # Node ID 22062c50eabe67a9166d5c7cd19ad4e82e255ceb # Parent f2f9fe088f6e52546a8932f3cf0880472ffdffbf MUC: Added a 'Make Room Moderated?' field to the room config dialog. diff -r f2f9fe088f6e -r 22062c50eabe plugins/muc/muc.lib.lua --- a/plugins/muc/muc.lib.lua Sun Jun 13 20:10:42 2010 +0500 +++ b/plugins/muc/muc.lib.lua Sun Jun 13 20:24:55 2010 +0500 @@ -253,7 +253,7 @@ 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 @@ :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 @@ 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 @@ 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));