Software /
code /
prosody-modules
Changeset
207:1ae653712e37
mod_adhoc: Add capability to pass data to forms
mod_adhoc_cmd_modules: Update to use afforementioned functionality
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Sat, 10 Jul 2010 01:26:41 +0200 |
parents | 206:d3498f115fcd |
children | 208:214cb85cdfbf |
files | mod_adhoc/adhoc/adhoc.lib.lua mod_adhoc/adhoc/mod_adhoc.lua mod_adhoc_cmd_modules/mod_adhoc_cmd_modules.lua |
diffstat | 3 files changed, 10 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_adhoc/adhoc/adhoc.lib.lua Fri Jul 09 22:38:05 2010 +0200 +++ b/mod_adhoc/adhoc/adhoc.lib.lua Sat Jul 10 01:26:41 2010 +0200 @@ -69,9 +69,9 @@ end cmdtag:add_child(actions); elseif name == "form" then - cmdtag:add_child(content:form()); + cmdtag:add_child((content.layout or content):form(content.data)); elseif name == "result" then - cmdtag:add_child(content.layout:form(content.data, "result")); + cmdtag:add_child((content.layout or content):form(content.data, "result")); elseif name == "other" then cmdtag:add_child(content); end
--- a/mod_adhoc/adhoc/mod_adhoc.lua Fri Jul 09 22:38:05 2010 +0200 +++ b/mod_adhoc/adhoc/mod_adhoc.lua Sat Jul 10 01:26:41 2010 +0200 @@ -16,7 +16,7 @@ module:hook("iq/host/"..xmlns_disco.."#items:query", function (event) local origin, stanza = event.origin, event.stanza; - -- TODO: Is this correct, or should is_admin be changed? + -- Required for Prosody <= 0.7 local privileged = is_admin(stanza.attr.from) or is_admin(stanza.attr.from, stanza.attr.to); if stanza.attr.type == "get" and stanza.tags[1].attr.node @@ -42,7 +42,7 @@ if stanza.attr.type == "set" and stanza.tags[1] and stanza.tags[1].name == "command" then local node = stanza.tags[1].attr.node - -- TODO: Is this correct, or should is_admin be changed? + -- Required for Prosody <= 0.7 local privileged = is_admin(event.stanza.attr.from) or is_admin(stanza.attr.from, stanza.attr.to); if commands[node] then
--- a/mod_adhoc_cmd_modules/mod_adhoc_cmd_modules.lua Fri Jul 09 22:38:05 2010 +0200 +++ b/mod_adhoc_cmd_modules/mod_adhoc_cmd_modules.lua Sat Jul 10 01:26:41 2010 +0200 @@ -30,13 +30,12 @@ -- TODO: Allow reloading multiple modules (depends on list-multi) function reload_modules_handler(self, data, state) - local modules = {}; local layout = dataforms_new { title = "Reload module"; instructions = "Select the module to be reloaded"; { name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/modules#reload" }; - { name = "module", type = "list-single", value = modules, label = "Module to be reloaded:"}; + { name = "module", type = "list-single", label = "Module to be reloaded:"}; }; if state then if data.action == "cancel" then @@ -51,23 +50,19 @@ '". Error was: "'..tostring(err)..'"' }; end else - local modules2 = array.collect(keys(hosts[data.to].modules)):sort(); - for i, val in ipairs(modules2) do - modules[i] = val; - end - return { status = "executing", form = layout }, "executing"; + local modules = array.collect(keys(hosts[data.to].modules)):sort(); + return { status = "executing", form = { layout = layout; data = { module = modules } } }, "executing"; end end -- TODO: Allow unloading multiple modules (depends on list-multi) function unload_modules_handler(self, data, state) - local modules = {}; local layout = dataforms_new { title = "Unload module"; instructions = "Select the module to be unloaded"; { name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/modules#unload" }; - { name = "module", type = "list-single", value = modules, label = "Module to be unloaded:"}; + { name = "module", type = "list-single", label = "Module to be unloaded:"}; }; if state then if data.action == "cancel" then @@ -82,11 +77,8 @@ '". Error was: "'..tostring(err)..'"' }; end else - local modules2 = array.collect(keys(hosts[data.to].modules)):sort(); - for i, val in ipairs(modules2) do - modules[i] = val; - end - return { status = "executing", form = layout }, "executing"; + local modules = array.collect(keys(hosts[data.to].modules)):sort(); + return { status = "executing", form = { layout = layout; data = { module = modules } } }, "executing"; end end