comparison mod_mam_muc/mod_mam_muc.lua @ 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
comparison
equal deleted inserted replaced
1275:50c427295767 1276:01dfaf2f2782
29 local advertise_archive = module:get_option_boolean("muc_log_advertise", true); 29 local advertise_archive = module:get_option_boolean("muc_log_advertise", true);
30 30
31 local archive = module:open_store("archive2", "archive"); 31 local archive = module:open_store("archive2", "archive");
32 local rooms = hosts[module.host].modules.muc.rooms; 32 local rooms = hosts[module.host].modules.muc.rooms;
33 33
34 module:hook("muc-config-form", function(event) 34 if not log_all_rooms then
35 local room, form = event.room, event.form; 35 module:hook("muc-config-form", function(event)
36 local logging_enabled = room._data.logging; 36 local room, form = event.room, event.form;
37 if logging_enabled == nil then 37 local logging_enabled = room._data.logging;
38 logging_enabled = log_by_default; 38 if logging_enabled == nil then
39 end 39 logging_enabled = log_by_default;
40 table.insert(form, 40 end
41 { 41 table.insert(form,
42 name = muc_form_config_option, 42 {
43 type = "boolean", 43 name = muc_form_config_option,
44 label = "Enable Logging?", 44 type = "boolean",
45 value = logging_enabled, 45 label = "Enable Logging?",
46 } 46 value = logging_enabled,
47 ); 47 }
48 end); 48 );
49 end);
49 50
50 module:hook("muc-config-submitted", function(event) 51 module:hook("muc-config-submitted", function(event)
51 local room, fields, changed = event.room, event.fields, event.changed; 52 local room, fields, changed = event.room, event.fields, event.changed;
52 local new = fields[muc_form_config_option]; 53 local new = fields[muc_form_config_option];
53 if new ~= room._data.logging then 54 if new ~= room._data.logging then
54 room._data.logging = new; 55 room._data.logging = new;
55 if type(changed) == "table" then 56 if type(changed) == "table" then
56 changed[muc_form_config_option] = true; 57 changed[muc_form_config_option] = true;
57 else 58 else
58 event.changed = true; 59 event.changed = true;
60 end
59 end 61 end
60 end 62 end);
61 end); 63 end
62 64
63 65
64 -- Handle archive queries 66 -- Handle archive queries
65 module:hook("iq-get/bare/"..xmlns_mam..":query", function(event) 67 module:hook("iq-get/bare/"..xmlns_mam..":query", function(event)
66 local origin, stanza = event.origin, event.stanza; 68 local origin, stanza = event.origin, event.stanza;