Mercurial > prosody-modules
changeset 1276:01dfaf2f2782
mod_mam_muc: Hide logging option from room configuration if set to log all rooms
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 18 Jan 2014 21:06:15 +0100 |
parents | 50c427295767 |
children | 999891a9ae5d |
files | mod_mam_muc/mod_mam_muc.lua |
diffstat | 1 files changed, 28 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- 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