# HG changeset patch # User Kim Alvefur # Date 1390075575 -3600 # Node ID 01dfaf2f2782502660e69f1bb8d4d0062f9387a1 # Parent 50c4272957674a15f69a3013857d3e13b9be79c8 mod_mam_muc: Hide logging option from room configuration if set to log all rooms diff -r 50c427295767 -r 01dfaf2f2782 mod_mam_muc/mod_mam_muc.lua --- a/mod_mam_muc/mod_mam_muc.lua Sat Jan 18 21:04:33 2014 +0100 +++ b/mod_mam_muc/mod_mam_muc.lua Sat Jan 18 21:06:15 2014 +0100 @@ -31,34 +31,36 @@ local archive = module:open_store("archive2", "archive"); local rooms = hosts[module.host].modules.muc.rooms; -module:hook("muc-config-form", function(event) - local room, form = event.room, event.form; - local logging_enabled = room._data.logging; - if logging_enabled == nil then - logging_enabled = log_by_default; - end - table.insert(form, - { - name = muc_form_config_option, - type = "boolean", - label = "Enable Logging?", - value = logging_enabled, - } - ); -end); +if not log_all_rooms then + module:hook("muc-config-form", function(event) + local room, form = event.room, event.form; + local logging_enabled = room._data.logging; + if logging_enabled == nil then + logging_enabled = log_by_default; + end + table.insert(form, + { + name = muc_form_config_option, + type = "boolean", + label = "Enable Logging?", + value = logging_enabled, + } + ); + end); -module:hook("muc-config-submitted", function(event) - local room, fields, changed = event.room, event.fields, event.changed; - local new = fields[muc_form_config_option]; - if new ~= room._data.logging then - room._data.logging = new; - if type(changed) == "table" then - changed[muc_form_config_option] = true; - else - event.changed = true; + module:hook("muc-config-submitted", function(event) + local room, fields, changed = event.room, event.fields, event.changed; + local new = fields[muc_form_config_option]; + if new ~= room._data.logging then + room._data.logging = new; + if type(changed) == "table" then + changed[muc_form_config_option] = true; + else + event.changed = true; + end end - end -end); + end); +end -- Handle archive queries