gluon/package/gluon-config-mode-contact-info/files/lib/gluon/config-mode/wizard/0500-contact-info.lua
2015-03-19 21:14:41 +01:00

35 lines
1.0 KiB
Lua

local cbi = require "luci.cbi"
local i18n = require "luci.i18n"
local uci = luci.model.uci.cursor()
local M = {}
function M.section(form)
local s = form:section(cbi.SimpleSection, nil, i18n.translate(
'You can provide your contact information here to '
.. 'allow others to contact you. Please note that '
.. 'this information will be visible <em>publicly</em> '
.. 'on the internet together with your node\'s coordinates.'
)
)
local o = s:option(cbi.Value, "_contact", i18n.translate("Contact info"))
o.default = uci:get_first("gluon-node-info", "owner", "contact", "")
o.rmempty = true
o.datatype = "string"
o.description = i18n.translate("e.g. E-mail or phone number")
o.maxlen = 140
end
function M.handle(data)
if data._contact ~= nil then
uci:set("gluon-node-info", uci:get_first("gluon-node-info", "owner"), "contact", data._contact)
else
uci:delete("gluon-node-info", uci:get_first("gluon-node-info", "owner"), "contact")
end
uci:save("gluon-node-info")
uci:commit("gluon-node-info")
end
return M