mod_muc_webchat_url: Fix default url
[prosody-modules.git] / mod_muc_config_restrict / mod_muc_config_restrict.lua
blob840af07dbd5ba9dd14057a19f3399cca5c27380f
1 local is_admin = require "core.usermanager".is_admin;
2 local t_remove = table.remove;
4 local restricted_options = module:get_option_set("muc_config_restricted", {})._items;
6 function handle_config_submit(event)
7 local stanza = event.stanza;
8 if is_admin(stanza.attr.from, module.host) then return; end -- Don't restrict admins
9 local fields = event.fields;
10 for option in restricted_options do
11 fields[option] = nil; -- Like it was never there
12 end
13 end
15 function handle_config_request(event)
16 if is_admin(event.actor, module.host) then return; end -- Don't restrict admins
17 local form = event.form;
18 for i = #form, 1, -1 do
19 if restricted_options[form[i].name] then
20 t_remove(form, i);
21 end
22 end
23 end
25 module:hook("muc-config-submitted", handle_config_submit);
26 module:hook("muc-config-form", handle_config_request);