Added a proof of concept of how a warning about no accounts having been configured can look.
This commit is contained in:
parent
6e632b7225
commit
dc6057a519
1 changed files with 54 additions and 6 deletions
|
@ -29,7 +29,9 @@ modulename = "pbx-calls"
|
||||||
voipmodulename = "pbx-voip"
|
voipmodulename = "pbx-voip"
|
||||||
googlemodulename = "pbx-google"
|
googlemodulename = "pbx-google"
|
||||||
usersmodulename = "pbx-users"
|
usersmodulename = "pbx-users"
|
||||||
|
allvalidaccounts = {}
|
||||||
validoutaccounts = {}
|
validoutaccounts = {}
|
||||||
|
validinaccounts = {}
|
||||||
allvalidusers = {}
|
allvalidusers = {}
|
||||||
|
|
||||||
-- Checks whether the entered extension is valid syntactically.
|
-- Checks whether the entered extension is valid syntactically.
|
||||||
|
@ -50,6 +52,44 @@ function m.on_after_commit(self)
|
||||||
luci.sys.call("/etc/init.d/" .. server .. " restart 1\>/dev/null 2\>/dev/null")
|
luci.sys.call("/etc/init.d/" .. server .. " restart 1\>/dev/null 2\>/dev/null")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Add Google accounts to all valid accounts, and accounts valid for incoming and outgoing calls.
|
||||||
|
m.uci:foreach(googlemodulename, "gtalk_jabber",
|
||||||
|
function(s1)
|
||||||
|
-- Add this provider to list of valid accounts.
|
||||||
|
if s1.username ~= nil and s1.name ~= nil then
|
||||||
|
allvalidaccounts[s1.name] = s1.username
|
||||||
|
|
||||||
|
if s1.make_outgoing_calls == "yes" then
|
||||||
|
-- Add provider to the associative array of valid outgoing accounts.
|
||||||
|
validoutaccounts[s1.name] = s1.username
|
||||||
|
end
|
||||||
|
|
||||||
|
if s1.register == "yes" then
|
||||||
|
-- Add provider to the associative array of valid outgoing accounts.
|
||||||
|
validinaccounts[s1.name] = s1.username
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Add SIP accounts to all valid accounts, and accounts valid for incoming and outgoing calls.
|
||||||
|
m.uci:foreach(voipmodulename, "voip_provider",
|
||||||
|
function(s1)
|
||||||
|
-- Add this provider to list of valid accounts.
|
||||||
|
if s1.defaultuser ~= nil and s1.host ~= nil and s1.name ~= nil then
|
||||||
|
allvalidaccounts[s1.name] = s1.defaultuser .. "@" .. s1.host
|
||||||
|
|
||||||
|
if s1.make_outgoing_calls == "yes" then
|
||||||
|
-- Add provider to the associative array of valid outgoing accounts.
|
||||||
|
validoutaccounts[s1.name] = s1.defaultuser .. "@" .. s1.host
|
||||||
|
end
|
||||||
|
|
||||||
|
if s1.register == "yes" then
|
||||||
|
-- Add provider to the associative array of valid outgoing accounts.
|
||||||
|
validinaccounts[s1.name] = s1.defaultuser .. "@" .. s1.host
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
----------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------
|
||||||
s = m:section(NamedSection, "outgoing_calls", "call_routing", translate("Outgoing Calls"),
|
s = m:section(NamedSection, "outgoing_calls", "call_routing", translate("Outgoing Calls"),
|
||||||
translate("If you have more than one account which can make outgoing calls, you \
|
translate("If you have more than one account which can make outgoing calls, you \
|
||||||
|
@ -67,15 +107,14 @@ s = m:section(NamedSection, "outgoing_calls", "call_routing", translate("Outgoin
|
||||||
list, and/or one per line by hitting enter after every one."))
|
list, and/or one per line by hitting enter after every one."))
|
||||||
s.anonymous = true
|
s.anonymous = true
|
||||||
|
|
||||||
|
|
||||||
m.uci:foreach(googlemodulename, "gtalk_jabber",
|
m.uci:foreach(googlemodulename, "gtalk_jabber",
|
||||||
function(s1)
|
function(s1)
|
||||||
|
-- If this provider is valid AND is enabled for outgoing calls, add it to the section.
|
||||||
if s1.username ~= nil and s1.name ~= nil and
|
if s1.username ~= nil and s1.name ~= nil and
|
||||||
s1.make_outgoing_calls == "yes" then
|
s1.make_outgoing_calls == "yes" then
|
||||||
patt = s:option(DynamicList, s1.name, s1.username)
|
patt = s:option(DynamicList, s1.name, s1.username)
|
||||||
|
|
||||||
-- Add provider to the associative array of valid accounts.
|
|
||||||
validoutaccounts[s1.name] = s1.username
|
|
||||||
|
|
||||||
-- If the saved field is empty, we return a string
|
-- If the saved field is empty, we return a string
|
||||||
-- telling the user that this account would dial any exten.
|
-- telling the user that this account would dial any exten.
|
||||||
function patt.cfgvalue(self, section)
|
function patt.cfgvalue(self, section)
|
||||||
|
@ -106,13 +145,12 @@ m.uci:foreach(googlemodulename, "gtalk_jabber",
|
||||||
|
|
||||||
m.uci:foreach(voipmodulename, "voip_provider",
|
m.uci:foreach(voipmodulename, "voip_provider",
|
||||||
function(s1)
|
function(s1)
|
||||||
|
|
||||||
|
-- If this provider is valid AND is enabled for outgoing calls, add it to the section.
|
||||||
if s1.defaultuser ~= nil and s1.host ~= nil and
|
if s1.defaultuser ~= nil and s1.host ~= nil and
|
||||||
s1.name ~= nil and s1.make_outgoing_calls == "yes" then
|
s1.name ~= nil and s1.make_outgoing_calls == "yes" then
|
||||||
patt = s:option(DynamicList, s1.name, s1.defaultuser .. "@" .. s1.host)
|
patt = s:option(DynamicList, s1.name, s1.defaultuser .. "@" .. s1.host)
|
||||||
|
|
||||||
-- Add provider to the associative array of valid accounts.
|
|
||||||
validoutaccounts[s1.name] = s1.defaultuser .. "@" .. s1.host
|
|
||||||
|
|
||||||
-- If the saved field is empty, we return a string
|
-- If the saved field is empty, we return a string
|
||||||
-- telling the user that this account would dial any exten.
|
-- telling the user that this account would dial any exten.
|
||||||
function patt.cfgvalue(self, section)
|
function patt.cfgvalue(self, section)
|
||||||
|
@ -141,6 +179,15 @@ m.uci:foreach(voipmodulename, "voip_provider",
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- If there are no accounts enabled for outgoing calls.
|
||||||
|
if # allvalidaccounts == 0 then
|
||||||
|
warn = s:option(DummyValue, "warn")
|
||||||
|
warn.default = "NOTE: There are no Google or SIP provider accounts configured."
|
||||||
|
elseif # validoutaccounts == 0 then
|
||||||
|
warn.s:option(DummyValue, "warn")
|
||||||
|
warn.default = "NOTE: There are no Google or SIP provider accounts enabled for outgoing calls."
|
||||||
|
end
|
||||||
|
|
||||||
----------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------
|
||||||
s = m:section(NamedSection, "incoming_calls", "call_routing", translate("Incoming Calls"),
|
s = m:section(NamedSection, "incoming_calls", "call_routing", translate("Incoming Calls"),
|
||||||
translate("For each provider that receives calls, here you can restrict which users to ring \
|
translate("For each provider that receives calls, here you can restrict which users to ring \
|
||||||
|
@ -221,6 +268,7 @@ m.uci:foreach(voipmodulename, "voip_provider",
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
----------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------
|
||||||
s = m:section(NamedSection, "providers_user_can_use", "call_routing",
|
s = m:section(NamedSection, "providers_user_can_use", "call_routing",
|
||||||
translate("Providers Used for Outgoing Calls"),
|
translate("Providers Used for Outgoing Calls"),
|
||||||
|
|
Loading…
Reference in a new issue