Add sofia global settings
This commit is contained in:
parent
d92797f82a
commit
11fd9ed86b
|
|
@ -1,310 +1,316 @@
|
|||
-- xml_handler.lua
|
||||
-- Part of FusionPBX
|
||||
-- Copyright (C) 2013 - 2018 Mark J Crane <markjcrane@fusionpbx.com>
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- Redistribution and use in source and binary forms, with or without
|
||||
-- modification, are permitted provided that the following conditions are met:
|
||||
--
|
||||
-- 1. Redistributions of source code must retain the above copyright notice,
|
||||
-- this list of conditions and the following disclaimer.
|
||||
--
|
||||
-- 2. Redistributions in binary form must reproduce the above copyright
|
||||
-- notice, this list of conditions and the following disclaimer in the
|
||||
-- documentation and/or other materials provided with the distribution.
|
||||
--
|
||||
-- THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
-- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
-- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
-- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
-- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
-- POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
--get the cache
|
||||
local cache = require "resources.functions.cache"
|
||||
local hostname = trim(api:execute("switchname", ""))
|
||||
local sofia_cache_key = "configuration:sofia.conf:" .. hostname
|
||||
XML_STRING, err = cache.get(sofia_cache_key)
|
||||
|
||||
--set the cache
|
||||
if not XML_STRING then
|
||||
--log cache error
|
||||
if (debug["cache"]) then
|
||||
freeswitch.consoleLog("warning", "[xml_handler] " .. sofia_cache_key .. " can not be get from the cache: " .. tostring(err) .. "\n");
|
||||
end
|
||||
|
||||
--set a default value
|
||||
if (expire["sofia"] == nil) then
|
||||
expire["sofia"]= "3600";
|
||||
end
|
||||
|
||||
--connect to the database
|
||||
local Database = require "resources.functions.database";
|
||||
dbh = Database.new('system');
|
||||
|
||||
--include json library
|
||||
local json
|
||||
if (debug["sql"]) then
|
||||
json = require "resources.functions.lunajson"
|
||||
end
|
||||
|
||||
--exits the script if we didn't connect properly
|
||||
assert(dbh:connected());
|
||||
|
||||
--get the variables
|
||||
vars = trim(api:execute("global_getvar", ""));
|
||||
|
||||
--start the xml array
|
||||
local xml = {}
|
||||
table.insert(xml, [[<?xml version="1.0" encoding="UTF-8" standalone="no"?>]]);
|
||||
table.insert(xml, [[<document type="freeswitch/xml">]]);
|
||||
table.insert(xml, [[ <section name="configuration">]]);
|
||||
table.insert(xml, [[ <configuration name="sofia.conf" description="sofia Endpoint">]]);
|
||||
table.insert(xml, [[ <global_settings>]]);
|
||||
table.insert(xml, [[ <param name="log-level" value="0"/>]]);
|
||||
--table.insert(xml, [[ <param name="auto-restart" value="false"/>]]);
|
||||
table.insert(xml, [[ <param name="debug-presence" value="0"/>]]);
|
||||
--table.insert(xml, [[ <param name="capture-server" value="udp:homer.domain.com:5060"/>]]);
|
||||
table.insert(xml, [[ </global_settings>]]);
|
||||
table.insert(xml, [[ <profiles>]]);
|
||||
|
||||
--set defaults
|
||||
previous_sip_profile_name = "";
|
||||
profile_tag_status = "closed";
|
||||
|
||||
--run the query
|
||||
sql = "select p.sip_profile_uuid, p.sip_profile_name, p.sip_profile_description, s.sip_profile_setting_name, s.sip_profile_setting_value ";
|
||||
sql = sql .. "from v_sip_profiles as p, v_sip_profile_settings as s ";
|
||||
sql = sql .. "where s.sip_profile_setting_enabled = 'true' ";
|
||||
sql = sql .. "and p.sip_profile_enabled = 'true' ";
|
||||
sql = sql .. "and (p.sip_profile_hostname = :hostname or p.sip_profile_hostname is null or p.sip_profile_hostname = '') ";
|
||||
sql = sql .. "and p.sip_profile_uuid = s.sip_profile_uuid ";
|
||||
sql = sql .. "order by p.sip_profile_name asc ";
|
||||
local params = {hostname = hostname};
|
||||
if (debug["sql"]) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "; params: " .. json.encode(params) .. "\n");
|
||||
end
|
||||
x = 0;
|
||||
dbh:query(sql, params, function(row)
|
||||
--set as variables
|
||||
sip_profile_uuid = row.sip_profile_uuid;
|
||||
sip_profile_name = row.sip_profile_name;
|
||||
--sip_profile_description = row.sip_profile_description;
|
||||
sip_profile_setting_name = row.sip_profile_setting_name;
|
||||
sip_profile_setting_value = row.sip_profile_setting_value;
|
||||
|
||||
--open xml tag
|
||||
if (sip_profile_name ~= previous_sip_profile_name) then
|
||||
if (x > 1) then
|
||||
table.insert(xml, [[ </settings>]]);
|
||||
table.insert(xml, [[ </profile>]]);
|
||||
end
|
||||
table.insert(xml, [[ <profile name="]]..sip_profile_name..[[">]]);
|
||||
table.insert(xml, [[ <aliases>]]);
|
||||
table.insert(xml, [[ </aliases>]]);
|
||||
table.insert(xml, [[ <gateways>]]);
|
||||
--table.insert(xml, [[ <X-PRE-PROCESS cmd="include" data="]]..sip_profile_name..[[/*.xml"/>]]);
|
||||
|
||||
--get the gateways
|
||||
sql = "select * from v_gateways ";
|
||||
sql = sql .. "where profile = :profile ";
|
||||
sql = sql .. "and enabled = 'true' ";
|
||||
sql = sql .. "and (hostname = :hostname or hostname is null or hostname = '') ";
|
||||
local params = {profile = sip_profile_name, hostname = hostname};
|
||||
if (debug["sql"]) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||
end
|
||||
x = 0;
|
||||
dbh:query(sql, params, function(field)
|
||||
table.insert(xml, [[ <gateway name="]] .. string.lower(field.gateway_uuid) .. [[">]]);
|
||||
|
||||
if (string.len(field.username) > 0) then
|
||||
table.insert(xml, [[ <param name="username" value="]] .. field.username .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.distinct_to) > 0) then
|
||||
table.insert(xml, [[ <param name="distinct-to" value="]] .. field.distinct_to .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.auth_username) > 0) then
|
||||
table.insert(xml, [[ <param name="auth-username" value="]] .. field.auth_username .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.password) > 0) then
|
||||
table.insert(xml, [[ <param name="password" value="]] .. field.password .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.realm) > 0) then
|
||||
table.insert(xml, [[ <param name="realm" value="]] .. field.realm .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.from_user) > 0) then
|
||||
table.insert(xml, [[ <param name="from-user" value="]] .. field.from_user .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.from_domain) > 0) then
|
||||
table.insert(xml, [[ <param name="from-domain" value="]] .. field.from_domain .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.proxy) > 0) then
|
||||
table.insert(xml, [[ <param name="proxy" value="]] .. field.proxy .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.register_proxy) > 0) then
|
||||
table.insert(xml, [[ <param name="register-proxy" value="]] .. field.register_proxy .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.outbound_proxy) > 0) then
|
||||
table.insert(xml, [[ <param name="outbound-proxy" value="]] .. field.outbound_proxy .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.expire_seconds) > 0) then
|
||||
table.insert(xml, [[ <param name="expire-seconds" value="]] .. field.expire_seconds .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.register) > 0) then
|
||||
table.insert(xml, [[ <param name="register" value="]] .. field.register .. [["/>]]);
|
||||
end
|
||||
|
||||
if (field.register_transport) then
|
||||
if (field.register_transport == "udp") then
|
||||
table.insert(xml, [[ <param name="register-transport" value="udp"/>]]);
|
||||
elseif (field.register_transport == "tcp") then
|
||||
table.insert(xml, [[ <param name="register-transport" value="tcp"/>]]);
|
||||
elseif (field.register_transport == "tls") then
|
||||
table.insert(xml, [[ <param name="register-transport" value="tls"/>]]);
|
||||
table.insert(xml, [[ <param name="contact-params" value="transport=tls"/>]]);
|
||||
else
|
||||
table.insert(xml, [[ <param name="register-transport" value="udp"/>]]);
|
||||
end
|
||||
end
|
||||
|
||||
if (string.len(field.retry_seconds) > 0) then
|
||||
table.insert(xml, [[ <param name="retry-seconds" value="]] .. field.retry_seconds .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.extension) > 0) then
|
||||
table.insert(xml, [[ <param name="extension" value="]] .. field.extension .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.ping) > 0) then
|
||||
table.insert(xml, [[ <param name="ping" value="]] .. field.ping .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.ping_min) > 0) then
|
||||
table.insert(xml, [[ <param name="ping-min" value="]] .. field.ping_min .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.ping_max) > 0) then
|
||||
table.insert(xml, [[ <param name="ping-max" value="]] .. field.ping_max .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.context) > 0) then
|
||||
table.insert(xml, [[ <param name="context" value="]] .. field.context .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.caller_id_in_from) > 0) then
|
||||
table.insert(xml, [[ <param name="caller-id-in-from" value="]] .. field.caller_id_in_from .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.supress_cng) > 0) then
|
||||
table.insert(xml, [[ <param name="supress-cng" value="]] .. field.supress_cng .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.extension_in_contact) > 0) then
|
||||
table.insert(xml, [[ <param name="extension-in-contact" value="]] .. field.extension_in_contact .. [["/>]]);
|
||||
end
|
||||
table.insert(xml, [[ <variables>]]);
|
||||
if (string.len(field.sip_cid_type) > 0) then
|
||||
table.insert(xml, [[ <variable name="sip_cid_type" value="]] .. field.sip_cid_type .. [["/>]]);
|
||||
end
|
||||
table.insert(xml, [[ </variables>]]);
|
||||
table.insert(xml, [[ </gateway>]]);
|
||||
end)
|
||||
|
||||
table.insert(xml, [[ </gateways>]]);
|
||||
table.insert(xml, [[ <domains>]]);
|
||||
|
||||
--add sip profile domain: name, alias, and parse
|
||||
table.insert(xml, [[ <!-- indicator to parse the directory for domains with parse="true" to get gateways-->]]);
|
||||
table.insert(xml, [[ <!--<domain name="$${domain}" parse="true"/>-->]]);
|
||||
table.insert(xml, [[ <!-- indicator to parse the directory for domains with parse="true" to get gateways and alias every domain to this profile -->]]);
|
||||
table.insert(xml, [[ <!--<domain name="all" alias="true" parse="true"/>-->]]);
|
||||
sql = "SELECT sip_profile_domain_name, sip_profile_domain_alias, sip_profile_domain_parse FROM v_sip_profile_domains ";
|
||||
sql = sql .. "WHERE sip_profile_uuid = :sip_profile_uuid";
|
||||
local params = {sip_profile_uuid = sip_profile_uuid};
|
||||
if (debug["sql"]) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "; sip_profile_uuid:" .. sip_profile_uuid .. "\n");
|
||||
end
|
||||
dbh:query(sql, params, function(row)
|
||||
name = row.sip_profile_domain_name;
|
||||
alias = row.sip_profile_domain_alias;
|
||||
parse = row.sip_profile_domain_parse;
|
||||
if (name == nil or name == '') then name = 'false'; end
|
||||
if (alias == nil or alias == '') then alias = 'false'; end
|
||||
if (parse == nil or parse == '') then parse = 'false'; end
|
||||
table.insert(xml, [[ <domain name="]] .. name .. [[" alias="]] .. alias .. [[" parse="]] .. parse .. [["/>]]);
|
||||
end);
|
||||
|
||||
table.insert(xml, [[ </domains>]]);
|
||||
table.insert(xml, [[ <settings>]]);
|
||||
profile_tag_status = "open";
|
||||
end
|
||||
|
||||
--loop through the var array
|
||||
for line in (vars.."\n"):gmatch"(.-)\n" do
|
||||
if (line) then
|
||||
pos = string.find(line, "=", 0, true);
|
||||
--name = string.sub( line, 0, pos-1);
|
||||
--value = string.sub( line, pos+1);
|
||||
sip_profile_setting_value = sip_profile_setting_value:gsub("%$%${"..string.sub( line, 0, pos-1).."}", string.sub( line, pos+1));
|
||||
end
|
||||
end
|
||||
|
||||
--remove $ and replace with ""
|
||||
--if (sip_profile_setting_value) then
|
||||
-- sip_profile_setting_value = sip_profile_setting_value:gsub("%$", "");
|
||||
--end
|
||||
|
||||
--set the parameters
|
||||
if (sip_profile_setting_name) then
|
||||
table.insert(xml, [[ <param name="]]..sip_profile_setting_name..[[" value="]]..sip_profile_setting_value..[["/>]]);
|
||||
end
|
||||
|
||||
--set the previous value
|
||||
previous_sip_profile_name = sip_profile_name;
|
||||
|
||||
--increment the value of x
|
||||
x = x + 1;
|
||||
end)
|
||||
|
||||
--close the extension tag if it was left open
|
||||
if (profile_tag_status == "open") then
|
||||
table.insert(xml, [[ </settings>]]);
|
||||
table.insert(xml, [[ </profile>]]);
|
||||
profile_tag_status = "close";
|
||||
end
|
||||
table.insert(xml, [[ </profiles>]]);
|
||||
table.insert(xml, [[ </configuration>]]);
|
||||
table.insert(xml, [[ </section>]]);
|
||||
table.insert(xml, [[</document>]]);
|
||||
XML_STRING = table.concat(xml, "\n");
|
||||
if (debug["xml_string"]) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] XML_STRING: " .. XML_STRING .. "\n");
|
||||
end
|
||||
|
||||
--close the database connection
|
||||
dbh:release();
|
||||
|
||||
--set the cache
|
||||
local ok, err = cache.set(sofia_cache_key, XML_STRING, expire["sofia"])
|
||||
if debug["cache"] then
|
||||
if ok then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] " .. sofia_cache_key .. " stored in the cache\n");
|
||||
else
|
||||
freeswitch.consoleLog("warning", "[xml_handler] " .. sofia_cache_key .. " can not be stored in the cache: " .. tostring(err) .. "\n");
|
||||
end
|
||||
end
|
||||
|
||||
--send to the console
|
||||
if (debug["cache"]) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] " .. sofia_cache_key .. " source: database\n");
|
||||
end
|
||||
else
|
||||
--send to the console
|
||||
if (debug["cache"]) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] " .. sofia_cache_key .. " source: cache\n");
|
||||
end
|
||||
end --if XML_STRING
|
||||
|
||||
--send the xml to the console
|
||||
if (debug["xml_string"]) then
|
||||
local file = assert(io.open(temp_dir .. "/sofia.conf.xml", "w"));
|
||||
file:write(XML_STRING);
|
||||
file:close();
|
||||
end
|
||||
-- xml_handler.lua
|
||||
-- Part of FusionPBX
|
||||
-- Copyright (C) 2013 - 2018 Mark J Crane <markjcrane@fusionpbx.com>
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- Redistribution and use in source and binary forms, with or without
|
||||
-- modification, are permitted provided that the following conditions are met:
|
||||
--
|
||||
-- 1. Redistributions of source code must retain the above copyright notice,
|
||||
-- this list of conditions and the following disclaimer.
|
||||
--
|
||||
-- 2. Redistributions in binary form must reproduce the above copyright
|
||||
-- notice, this list of conditions and the following disclaimer in the
|
||||
-- documentation and/or other materials provided with the distribution.
|
||||
--
|
||||
-- THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
-- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
-- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
-- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
-- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
-- POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
--get the cache
|
||||
local cache = require "resources.functions.cache"
|
||||
local hostname = trim(api:execute("switchname", ""))
|
||||
local sofia_cache_key = "configuration:sofia.conf:" .. hostname
|
||||
XML_STRING, err = cache.get(sofia_cache_key)
|
||||
|
||||
--set the cache
|
||||
if not XML_STRING then
|
||||
--log cache error
|
||||
if (debug["cache"]) then
|
||||
freeswitch.consoleLog("warning", "[xml_handler] " .. sofia_cache_key .. " can not be get from the cache: " .. tostring(err) .. "\n");
|
||||
end
|
||||
|
||||
--set a default value
|
||||
if (expire["sofia"] == nil) then
|
||||
expire["sofia"]= "3600";
|
||||
end
|
||||
|
||||
--connect to the database
|
||||
local Database = require "resources.functions.database";
|
||||
dbh = Database.new('system');
|
||||
|
||||
--include json library
|
||||
local json
|
||||
if (debug["sql"]) then
|
||||
json = require "resources.functions.lunajson"
|
||||
end
|
||||
|
||||
--exits the script if we didn't connect properly
|
||||
assert(dbh:connected());
|
||||
|
||||
--get the variables
|
||||
vars = trim(api:execute("global_getvar", ""));
|
||||
|
||||
--start the xml array
|
||||
local xml = {}
|
||||
table.insert(xml, [[<?xml version="1.0" encoding="UTF-8" standalone="no"?>]]);
|
||||
table.insert(xml, [[<document type="freeswitch/xml">]]);
|
||||
table.insert(xml, [[ <section name="configuration">]]);
|
||||
table.insert(xml, [[ <configuration name="sofia.conf" description="sofia Endpoint">]]);
|
||||
|
||||
--gt the global settings
|
||||
sql = "select * from v_sofia_global_settings ";
|
||||
sql = sql .. "where global_setting_enabled = 'true' ";
|
||||
sql = sql .. "order by global_setting_name asc ";
|
||||
local params = {};
|
||||
x = 0;
|
||||
table.insert(xml, [[ <global_settings>]]);
|
||||
dbh:query(sql, params, function(row)
|
||||
table.insert(xml, [[ <param name="]]..row.global_setting_name..[[" value="]]..row.global_setting_value..[["/>]]);
|
||||
end)
|
||||
table.insert(xml, [[ </global_settings>]]);
|
||||
|
||||
--set defaults
|
||||
previous_sip_profile_name = "";
|
||||
profile_tag_status = "closed";
|
||||
|
||||
--run the query
|
||||
sql = "select p.sip_profile_uuid, p.sip_profile_name, p.sip_profile_description, s.sip_profile_setting_name, s.sip_profile_setting_value ";
|
||||
sql = sql .. "from v_sip_profiles as p, v_sip_profile_settings as s ";
|
||||
sql = sql .. "where s.sip_profile_setting_enabled = 'true' ";
|
||||
sql = sql .. "and p.sip_profile_enabled = 'true' ";
|
||||
sql = sql .. "and (p.sip_profile_hostname = :hostname or p.sip_profile_hostname is null or p.sip_profile_hostname = '') ";
|
||||
sql = sql .. "and p.sip_profile_uuid = s.sip_profile_uuid ";
|
||||
sql = sql .. "order by p.sip_profile_name asc ";
|
||||
local params = {hostname = hostname};
|
||||
if (debug["sql"]) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "; params: " .. json.encode(params) .. "\n");
|
||||
end
|
||||
x = 0;
|
||||
table.insert(xml, [[ <profiles>]]);
|
||||
dbh:query(sql, params, function(row)
|
||||
--set as variables
|
||||
sip_profile_uuid = row.sip_profile_uuid;
|
||||
sip_profile_name = row.sip_profile_name;
|
||||
--sip_profile_description = row.sip_profile_description;
|
||||
sip_profile_setting_name = row.sip_profile_setting_name;
|
||||
sip_profile_setting_value = row.sip_profile_setting_value;
|
||||
|
||||
--open xml tag
|
||||
if (sip_profile_name ~= previous_sip_profile_name) then
|
||||
if (x > 1) then
|
||||
table.insert(xml, [[ </settings>]]);
|
||||
table.insert(xml, [[ </profile>]]);
|
||||
end
|
||||
table.insert(xml, [[ <profile name="]]..sip_profile_name..[[">]]);
|
||||
table.insert(xml, [[ <aliases>]]);
|
||||
table.insert(xml, [[ </aliases>]]);
|
||||
table.insert(xml, [[ <gateways>]]);
|
||||
--table.insert(xml, [[ <X-PRE-PROCESS cmd="include" data="]]..sip_profile_name..[[/*.xml"/>]]);
|
||||
|
||||
--get the gateways
|
||||
sql = "select * from v_gateways ";
|
||||
sql = sql .. "where profile = :profile ";
|
||||
sql = sql .. "and enabled = 'true' ";
|
||||
sql = sql .. "and (hostname = :hostname or hostname is null or hostname = '') ";
|
||||
local params = {profile = sip_profile_name, hostname = hostname};
|
||||
if (debug["sql"]) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||
end
|
||||
x = 0;
|
||||
dbh:query(sql, params, function(field)
|
||||
table.insert(xml, [[ <gateway name="]] .. string.lower(field.gateway_uuid) .. [[">]]);
|
||||
|
||||
if (string.len(field.username) > 0) then
|
||||
table.insert(xml, [[ <param name="username" value="]] .. field.username .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.distinct_to) > 0) then
|
||||
table.insert(xml, [[ <param name="distinct-to" value="]] .. field.distinct_to .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.auth_username) > 0) then
|
||||
table.insert(xml, [[ <param name="auth-username" value="]] .. field.auth_username .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.password) > 0) then
|
||||
table.insert(xml, [[ <param name="password" value="]] .. field.password .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.realm) > 0) then
|
||||
table.insert(xml, [[ <param name="realm" value="]] .. field.realm .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.from_user) > 0) then
|
||||
table.insert(xml, [[ <param name="from-user" value="]] .. field.from_user .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.from_domain) > 0) then
|
||||
table.insert(xml, [[ <param name="from-domain" value="]] .. field.from_domain .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.proxy) > 0) then
|
||||
table.insert(xml, [[ <param name="proxy" value="]] .. field.proxy .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.register_proxy) > 0) then
|
||||
table.insert(xml, [[ <param name="register-proxy" value="]] .. field.register_proxy .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.outbound_proxy) > 0) then
|
||||
table.insert(xml, [[ <param name="outbound-proxy" value="]] .. field.outbound_proxy .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.expire_seconds) > 0) then
|
||||
table.insert(xml, [[ <param name="expire-seconds" value="]] .. field.expire_seconds .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.register) > 0) then
|
||||
table.insert(xml, [[ <param name="register" value="]] .. field.register .. [["/>]]);
|
||||
end
|
||||
|
||||
if (field.register_transport) then
|
||||
if (field.register_transport == "udp") then
|
||||
table.insert(xml, [[ <param name="register-transport" value="udp"/>]]);
|
||||
elseif (field.register_transport == "tcp") then
|
||||
table.insert(xml, [[ <param name="register-transport" value="tcp"/>]]);
|
||||
elseif (field.register_transport == "tls") then
|
||||
table.insert(xml, [[ <param name="register-transport" value="tls"/>]]);
|
||||
table.insert(xml, [[ <param name="contact-params" value="transport=tls"/>]]);
|
||||
else
|
||||
table.insert(xml, [[ <param name="register-transport" value="udp"/>]]);
|
||||
end
|
||||
end
|
||||
|
||||
if (string.len(field.retry_seconds) > 0) then
|
||||
table.insert(xml, [[ <param name="retry-seconds" value="]] .. field.retry_seconds .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.extension) > 0) then
|
||||
table.insert(xml, [[ <param name="extension" value="]] .. field.extension .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.ping) > 0) then
|
||||
table.insert(xml, [[ <param name="ping" value="]] .. field.ping .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.ping_min) > 0) then
|
||||
table.insert(xml, [[ <param name="ping-min" value="]] .. field.ping_min .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.ping_max) > 0) then
|
||||
table.insert(xml, [[ <param name="ping-max" value="]] .. field.ping_max .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.context) > 0) then
|
||||
table.insert(xml, [[ <param name="context" value="]] .. field.context .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.caller_id_in_from) > 0) then
|
||||
table.insert(xml, [[ <param name="caller-id-in-from" value="]] .. field.caller_id_in_from .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.supress_cng) > 0) then
|
||||
table.insert(xml, [[ <param name="supress-cng" value="]] .. field.supress_cng .. [["/>]]);
|
||||
end
|
||||
if (string.len(field.extension_in_contact) > 0) then
|
||||
table.insert(xml, [[ <param name="extension-in-contact" value="]] .. field.extension_in_contact .. [["/>]]);
|
||||
end
|
||||
table.insert(xml, [[ <variables>]]);
|
||||
if (string.len(field.sip_cid_type) > 0) then
|
||||
table.insert(xml, [[ <variable name="sip_cid_type" value="]] .. field.sip_cid_type .. [["/>]]);
|
||||
end
|
||||
table.insert(xml, [[ </variables>]]);
|
||||
table.insert(xml, [[ </gateway>]]);
|
||||
end)
|
||||
|
||||
table.insert(xml, [[ </gateways>]]);
|
||||
table.insert(xml, [[ <domains>]]);
|
||||
|
||||
--add sip profile domain: name, alias, and parse
|
||||
table.insert(xml, [[ <!-- indicator to parse the directory for domains with parse="true" to get gateways-->]]);
|
||||
table.insert(xml, [[ <!--<domain name="$${domain}" parse="true"/>-->]]);
|
||||
table.insert(xml, [[ <!-- indicator to parse the directory for domains with parse="true" to get gateways and alias every domain to this profile -->]]);
|
||||
table.insert(xml, [[ <!--<domain name="all" alias="true" parse="true"/>-->]]);
|
||||
sql = "SELECT sip_profile_domain_name, sip_profile_domain_alias, sip_profile_domain_parse FROM v_sip_profile_domains ";
|
||||
sql = sql .. "WHERE sip_profile_uuid = :sip_profile_uuid";
|
||||
local params = {sip_profile_uuid = sip_profile_uuid};
|
||||
if (debug["sql"]) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "; sip_profile_uuid:" .. sip_profile_uuid .. "\n");
|
||||
end
|
||||
dbh:query(sql, params, function(row)
|
||||
name = row.sip_profile_domain_name;
|
||||
alias = row.sip_profile_domain_alias;
|
||||
parse = row.sip_profile_domain_parse;
|
||||
if (name == nil or name == '') then name = 'false'; end
|
||||
if (alias == nil or alias == '') then alias = 'false'; end
|
||||
if (parse == nil or parse == '') then parse = 'false'; end
|
||||
table.insert(xml, [[ <domain name="]] .. name .. [[" alias="]] .. alias .. [[" parse="]] .. parse .. [["/>]]);
|
||||
end);
|
||||
|
||||
table.insert(xml, [[ </domains>]]);
|
||||
table.insert(xml, [[ <settings>]]);
|
||||
profile_tag_status = "open";
|
||||
end
|
||||
|
||||
--loop through the var array
|
||||
for line in (vars.."\n"):gmatch"(.-)\n" do
|
||||
if (line) then
|
||||
pos = string.find(line, "=", 0, true);
|
||||
--name = string.sub( line, 0, pos-1);
|
||||
--value = string.sub( line, pos+1);
|
||||
sip_profile_setting_value = sip_profile_setting_value:gsub("%$%${"..string.sub( line, 0, pos-1).."}", string.sub( line, pos+1));
|
||||
end
|
||||
end
|
||||
|
||||
--remove $ and replace with ""
|
||||
--if (sip_profile_setting_value) then
|
||||
-- sip_profile_setting_value = sip_profile_setting_value:gsub("%$", "");
|
||||
--end
|
||||
|
||||
--set the parameters
|
||||
if (sip_profile_setting_name) then
|
||||
table.insert(xml, [[ <param name="]]..sip_profile_setting_name..[[" value="]]..sip_profile_setting_value..[["/>]]);
|
||||
end
|
||||
|
||||
--set the previous value
|
||||
previous_sip_profile_name = sip_profile_name;
|
||||
|
||||
--increment the value of x
|
||||
x = x + 1;
|
||||
end)
|
||||
|
||||
--close the extension tag if it was left open
|
||||
if (profile_tag_status == "open") then
|
||||
table.insert(xml, [[ </settings>]]);
|
||||
table.insert(xml, [[ </profile>]]);
|
||||
profile_tag_status = "close";
|
||||
end
|
||||
table.insert(xml, [[ </profiles>]]);
|
||||
table.insert(xml, [[ </configuration>]]);
|
||||
table.insert(xml, [[ </section>]]);
|
||||
table.insert(xml, [[</document>]]);
|
||||
XML_STRING = table.concat(xml, "\n");
|
||||
if (debug["xml_string"]) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] XML_STRING: " .. XML_STRING .. "\n");
|
||||
end
|
||||
|
||||
--close the database connection
|
||||
dbh:release();
|
||||
|
||||
--set the cache
|
||||
local ok, err = cache.set(sofia_cache_key, XML_STRING, expire["sofia"])
|
||||
if debug["cache"] then
|
||||
if ok then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] " .. sofia_cache_key .. " stored in the cache\n");
|
||||
else
|
||||
freeswitch.consoleLog("warning", "[xml_handler] " .. sofia_cache_key .. " can not be stored in the cache: " .. tostring(err) .. "\n");
|
||||
end
|
||||
end
|
||||
|
||||
--send to the console
|
||||
if (debug["cache"]) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] " .. sofia_cache_key .. " source: database\n");
|
||||
end
|
||||
else
|
||||
--send to the console
|
||||
if (debug["cache"]) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] " .. sofia_cache_key .. " source: cache\n");
|
||||
end
|
||||
end --if XML_STRING
|
||||
|
||||
--send the xml to the console
|
||||
if (debug["xml_string"]) then
|
||||
local file = assert(io.open(temp_dir .. "/sofia.conf.xml", "w"));
|
||||
file:write(XML_STRING);
|
||||
file:close();
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
//application details
|
||||
$apps[$x]['name'] = 'sofia_global_settings';
|
||||
$apps[$x]['uuid'] = '240c25a3-a2cf-44ea-a300-0626eca5b945';
|
||||
$apps[$x]['category'] = '';
|
||||
$apps[$x]['subcategory'] = '';
|
||||
$apps[$x]['version'] = '';
|
||||
$apps[$x]['license'] = 'Mozilla Public License 1.1';
|
||||
$apps[$x]['url'] = 'http://www.fusionpbx.com';
|
||||
$apps[$x]['description']['en-us'] = '';
|
||||
|
||||
//permission details
|
||||
$y = 0;
|
||||
$apps[$x]['permissions'][$y]['name'] = 'sofia_global_setting_view';
|
||||
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
|
||||
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
|
||||
$y++;
|
||||
$apps[$x]['permissions'][$y]['name'] = 'sofia_global_setting_add';
|
||||
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
|
||||
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
|
||||
$y++;
|
||||
$apps[$x]['permissions'][$y]['name'] = 'sofia_global_setting_edit';
|
||||
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
|
||||
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
|
||||
$y++;
|
||||
$apps[$x]['permissions'][$y]['name'] = 'sofia_global_setting_delete';
|
||||
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
|
||||
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
|
||||
$y++;
|
||||
$apps[$x]['permissions'][$y]['name'] = 'sofia_global_setting_all';
|
||||
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
|
||||
$y++;
|
||||
|
||||
//sofia_global_settings
|
||||
$y = 0;
|
||||
$apps[$x]['db'][$y]['table']['name'] = 'v_sofia_global_settings';
|
||||
$apps[$x]['db'][$y]['table']['parent'] = '';
|
||||
$z = 0;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'sofia_global_setting_uuid';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'primary';
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'global_setting_name';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the global setting name.';
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'global_setting_value';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the global setting value.';
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'global_setting_enabled';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'boolean';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['toggle'] = ['true','false'];
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the global setting enabled.';
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'global_setting_description';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the global setting description.';
|
||||
$z++;
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
if ($domains_processed == 1) {
|
||||
|
||||
//build array
|
||||
$x = 0;
|
||||
$array['sofia_global_settings'][$x]['sofia_global_setting_uuid'] = '9a0e83b3-e71c-4a9a-9f1c-680d32f756f8';
|
||||
$array['sofia_global_settings'][$x]['global_setting_name'] = 'log-level';
|
||||
$array['sofia_global_settings'][$x]['global_setting_value'] = '0';
|
||||
$array['sofia_global_settings'][$x]['global_setting_enabled'] = 'true';
|
||||
$array['sofia_global_settings'][$x]['global_setting_description'] = '';
|
||||
$x++;
|
||||
$array['sofia_global_settings'][$x]['sofia_global_setting_uuid'] = 'c2aa551a-b6d2-49a6-b633-21b5b1ddd5df';
|
||||
$array['sofia_global_settings'][$x]['global_setting_name'] = 'auto-restart';
|
||||
$array['sofia_global_settings'][$x]['global_setting_value'] = 'true';
|
||||
$array['sofia_global_settings'][$x]['global_setting_enabled'] = 'true';
|
||||
$array['sofia_global_settings'][$x]['global_setting_description'] = '';
|
||||
$x++;
|
||||
$array['sofia_global_settings'][$x]['sofia_global_setting_uuid'] = 'a9901c0c-efd8-4e66-9648-239566af576e';
|
||||
$array['sofia_global_settings'][$x]['global_setting_name'] = 'debug-presence';
|
||||
$array['sofia_global_settings'][$x]['global_setting_value'] = '0';
|
||||
$array['sofia_global_settings'][$x]['global_setting_enabled'] = 'true';
|
||||
$array['sofia_global_settings'][$x]['global_setting_description'] = '';
|
||||
$x++;
|
||||
$array['sofia_global_settings'][$x]['sofia_global_setting_uuid'] = '31054912-3b07-422d-a109-b995fd8d67f7';
|
||||
$array['sofia_global_settings'][$x]['global_setting_name'] = 'capture-server';
|
||||
$array['sofia_global_settings'][$x]['global_setting_value'] = 'udp:127.0.0.1:9060';
|
||||
$array['sofia_global_settings'][$x]['global_setting_enabled'] = 'false';
|
||||
$array['sofia_global_settings'][$x]['global_setting_description'] = '';
|
||||
|
||||
//grant temporary permissions
|
||||
$p = new permissions;
|
||||
$p->add('sofia_global_setting_add', 'temp');
|
||||
|
||||
//execute insert
|
||||
$database = new database;
|
||||
$database->app_name = 'sofia_global_settings';
|
||||
$database->app_uuid = '240c25a3-a2cf-44ea-a300-0626eca5b945';
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
//revoke temporary permissions
|
||||
$p->delete('sofia_global_setting_add', 'temp');
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,224 @@
|
|||
<?php
|
||||
|
||||
//Sofia Global Settings
|
||||
$text['title-sofia_global_settings']['en-us'] = 'Sofia Global Settings';
|
||||
$text['title-sofia_global_settings']['ar-eg'] = '';
|
||||
$text['title-sofia_global_settings']['de-at'] = '';
|
||||
$text['title-sofia_global_settings']['de-ch'] = '';
|
||||
$text['title-sofia_global_settings']['de-de'] = '';
|
||||
$text['title-sofia_global_settings']['es-cl'] = '';
|
||||
$text['title-sofia_global_settings']['es-mx'] = '';
|
||||
$text['title-sofia_global_settings']['fr-ca'] = '';
|
||||
$text['title-sofia_global_settings']['fr-fr'] = '';
|
||||
$text['title-sofia_global_settings']['he-il'] = '';
|
||||
$text['title-sofia_global_settings']['it-it'] = '';
|
||||
$text['title-sofia_global_settings']['nl-nl'] = '';
|
||||
$text['title-sofia_global_settings']['pl-pl'] = '';
|
||||
$text['title-sofia_global_settings']['pt-br'] = '';
|
||||
$text['title-sofia_global_settings']['pt-pt'] = '';
|
||||
$text['title-sofia_global_settings']['ro-ro'] = '';
|
||||
$text['title-sofia_global_settings']['ru-ru'] = '';
|
||||
$text['title-sofia_global_settings']['sv-se'] = '';
|
||||
$text['title-sofia_global_settings']['uk-ua'] = '';
|
||||
|
||||
$text['title-sofia_global_setting']['en-us'] = 'Sofia Global Setting';
|
||||
$text['title-sofia_global_setting']['ar-eg'] = '';
|
||||
$text['title-sofia_global_setting']['de-at'] = '';
|
||||
$text['title-sofia_global_setting']['de-ch'] = '';
|
||||
$text['title-sofia_global_setting']['de-de'] = '';
|
||||
$text['title-sofia_global_setting']['es-cl'] = '';
|
||||
$text['title-sofia_global_setting']['es-mx'] = '';
|
||||
$text['title-sofia_global_setting']['fr-ca'] = '';
|
||||
$text['title-sofia_global_setting']['fr-fr'] = '';
|
||||
$text['title-sofia_global_setting']['he-il'] = '';
|
||||
$text['title-sofia_global_setting']['it-it'] = '';
|
||||
$text['title-sofia_global_setting']['nl-nl'] = '';
|
||||
$text['title-sofia_global_setting']['pl-pl'] = '';
|
||||
$text['title-sofia_global_setting']['pt-br'] = '';
|
||||
$text['title-sofia_global_setting']['pt-pt'] = '';
|
||||
$text['title-sofia_global_setting']['ro-ro'] = '';
|
||||
$text['title-sofia_global_setting']['ru-ru'] = '';
|
||||
$text['title-sofia_global_setting']['sv-se'] = '';
|
||||
$text['title-sofia_global_setting']['uk-ua'] = '';
|
||||
|
||||
$text['title_description-sofia_global_settings']['en-us'] = 'Used to define sofia global settings.';
|
||||
$text['title_description-sofia_global_settings']['ar-eg'] = '';
|
||||
$text['title_description-sofia_global_settings']['de-at'] = '';
|
||||
$text['title_description-sofia_global_settings']['de-ch'] = '';
|
||||
$text['title_description-sofia_global_settings']['de-de'] = '';
|
||||
$text['title_description-sofia_global_settings']['es-cl'] = '';
|
||||
$text['title_description-sofia_global_settings']['es-mx'] = '';
|
||||
$text['title_description-sofia_global_settings']['fr-ca'] = '';
|
||||
$text['title_description-sofia_global_settings']['fr-fr'] = '';
|
||||
$text['title_description-sofia_global_settings']['he-il'] = '';
|
||||
$text['title_description-sofia_global_settings']['it-it'] = '';
|
||||
$text['title_description-sofia_global_settings']['nl-nl'] = '';
|
||||
$text['title_description-sofia_global_settings']['pl-pl'] = '';
|
||||
$text['title_description-sofia_global_settings']['pt-br'] = '';
|
||||
$text['title_description-sofia_global_settings']['pt-pt'] = '';
|
||||
$text['title_description-sofia_global_settings']['ro-ro'] = '';
|
||||
$text['title_description-sofia_global_settings']['ru-ru'] = '';
|
||||
$text['title_description-sofia_global_settings']['sv-se'] = '';
|
||||
$text['title_description-sofia_global_settings']['uk-ua'] = '';
|
||||
|
||||
$text['label-global_setting_name']['en-us'] = 'Name';
|
||||
$text['label-global_setting_name']['ar-eg'] = '';
|
||||
$text['label-global_setting_name']['de-at'] = '';
|
||||
$text['label-global_setting_name']['de-ch'] = '';
|
||||
$text['label-global_setting_name']['de-de'] = '';
|
||||
$text['label-global_setting_name']['es-cl'] = '';
|
||||
$text['label-global_setting_name']['es-mx'] = '';
|
||||
$text['label-global_setting_name']['fr-ca'] = '';
|
||||
$text['label-global_setting_name']['fr-fr'] = '';
|
||||
$text['label-global_setting_name']['he-il'] = '';
|
||||
$text['label-global_setting_name']['it-it'] = '';
|
||||
$text['label-global_setting_name']['nl-nl'] = '';
|
||||
$text['label-global_setting_name']['pl-pl'] = '';
|
||||
$text['label-global_setting_name']['pt-br'] = '';
|
||||
$text['label-global_setting_name']['pt-pt'] = '';
|
||||
$text['label-global_setting_name']['ro-ro'] = '';
|
||||
$text['label-global_setting_name']['ru-ru'] = '';
|
||||
$text['label-global_setting_name']['sv-se'] = '';
|
||||
$text['label-global_setting_name']['uk-ua'] = '';
|
||||
|
||||
$text['description-global_setting_name']['en-us'] = 'Enter the global setting name.';
|
||||
$text['description-global_setting_name']['ar-eg'] = '';
|
||||
$text['description-global_setting_name']['de-at'] = '';
|
||||
$text['description-global_setting_name']['de-ch'] = '';
|
||||
$text['description-global_setting_name']['de-de'] = '';
|
||||
$text['description-global_setting_name']['es-cl'] = '';
|
||||
$text['description-global_setting_name']['es-mx'] = '';
|
||||
$text['description-global_setting_name']['fr-ca'] = '';
|
||||
$text['description-global_setting_name']['fr-fr'] = '';
|
||||
$text['description-global_setting_name']['he-il'] = '';
|
||||
$text['description-global_setting_name']['it-it'] = '';
|
||||
$text['description-global_setting_name']['nl-nl'] = '';
|
||||
$text['description-global_setting_name']['pl-pl'] = '';
|
||||
$text['description-global_setting_name']['pt-br'] = '';
|
||||
$text['description-global_setting_name']['pt-pt'] = '';
|
||||
$text['description-global_setting_name']['ro-ro'] = '';
|
||||
$text['description-global_setting_name']['ru-ru'] = '';
|
||||
$text['description-global_setting_name']['sv-se'] = '';
|
||||
$text['description-global_setting_name']['uk-ua'] = '';
|
||||
|
||||
$text['label-global_setting_value']['en-us'] = 'Value';
|
||||
$text['label-global_setting_value']['ar-eg'] = '';
|
||||
$text['label-global_setting_value']['de-at'] = '';
|
||||
$text['label-global_setting_value']['de-ch'] = '';
|
||||
$text['label-global_setting_value']['de-de'] = '';
|
||||
$text['label-global_setting_value']['es-cl'] = '';
|
||||
$text['label-global_setting_value']['es-mx'] = '';
|
||||
$text['label-global_setting_value']['fr-ca'] = '';
|
||||
$text['label-global_setting_value']['fr-fr'] = '';
|
||||
$text['label-global_setting_value']['he-il'] = '';
|
||||
$text['label-global_setting_value']['it-it'] = '';
|
||||
$text['label-global_setting_value']['nl-nl'] = '';
|
||||
$text['label-global_setting_value']['pl-pl'] = '';
|
||||
$text['label-global_setting_value']['pt-br'] = '';
|
||||
$text['label-global_setting_value']['pt-pt'] = '';
|
||||
$text['label-global_setting_value']['ro-ro'] = '';
|
||||
$text['label-global_setting_value']['ru-ru'] = '';
|
||||
$text['label-global_setting_value']['sv-se'] = '';
|
||||
$text['label-global_setting_value']['uk-ua'] = '';
|
||||
|
||||
$text['description-global_setting_value']['en-us'] = 'Enter the global setting value.';
|
||||
$text['description-global_setting_value']['ar-eg'] = '';
|
||||
$text['description-global_setting_value']['de-at'] = '';
|
||||
$text['description-global_setting_value']['de-ch'] = '';
|
||||
$text['description-global_setting_value']['de-de'] = '';
|
||||
$text['description-global_setting_value']['es-cl'] = '';
|
||||
$text['description-global_setting_value']['es-mx'] = '';
|
||||
$text['description-global_setting_value']['fr-ca'] = '';
|
||||
$text['description-global_setting_value']['fr-fr'] = '';
|
||||
$text['description-global_setting_value']['he-il'] = '';
|
||||
$text['description-global_setting_value']['it-it'] = '';
|
||||
$text['description-global_setting_value']['nl-nl'] = '';
|
||||
$text['description-global_setting_value']['pl-pl'] = '';
|
||||
$text['description-global_setting_value']['pt-br'] = '';
|
||||
$text['description-global_setting_value']['pt-pt'] = '';
|
||||
$text['description-global_setting_value']['ro-ro'] = '';
|
||||
$text['description-global_setting_value']['ru-ru'] = '';
|
||||
$text['description-global_setting_value']['sv-se'] = '';
|
||||
$text['description-global_setting_value']['uk-ua'] = '';
|
||||
|
||||
$text['label-global_setting_enabled']['en-us'] = 'Enabled';
|
||||
$text['label-global_setting_enabled']['ar-eg'] = '';
|
||||
$text['label-global_setting_enabled']['de-at'] = '';
|
||||
$text['label-global_setting_enabled']['de-ch'] = '';
|
||||
$text['label-global_setting_enabled']['de-de'] = '';
|
||||
$text['label-global_setting_enabled']['es-cl'] = '';
|
||||
$text['label-global_setting_enabled']['es-mx'] = '';
|
||||
$text['label-global_setting_enabled']['fr-ca'] = '';
|
||||
$text['label-global_setting_enabled']['fr-fr'] = '';
|
||||
$text['label-global_setting_enabled']['he-il'] = '';
|
||||
$text['label-global_setting_enabled']['it-it'] = '';
|
||||
$text['label-global_setting_enabled']['nl-nl'] = '';
|
||||
$text['label-global_setting_enabled']['pl-pl'] = '';
|
||||
$text['label-global_setting_enabled']['pt-br'] = '';
|
||||
$text['label-global_setting_enabled']['pt-pt'] = '';
|
||||
$text['label-global_setting_enabled']['ro-ro'] = '';
|
||||
$text['label-global_setting_enabled']['ru-ru'] = '';
|
||||
$text['label-global_setting_enabled']['sv-se'] = '';
|
||||
$text['label-global_setting_enabled']['uk-ua'] = '';
|
||||
|
||||
$text['description-global_setting_enabled']['en-us'] = 'Enter the global setting enabled.';
|
||||
$text['description-global_setting_enabled']['ar-eg'] = '';
|
||||
$text['description-global_setting_enabled']['de-at'] = '';
|
||||
$text['description-global_setting_enabled']['de-ch'] = '';
|
||||
$text['description-global_setting_enabled']['de-de'] = '';
|
||||
$text['description-global_setting_enabled']['es-cl'] = '';
|
||||
$text['description-global_setting_enabled']['es-mx'] = '';
|
||||
$text['description-global_setting_enabled']['fr-ca'] = '';
|
||||
$text['description-global_setting_enabled']['fr-fr'] = '';
|
||||
$text['description-global_setting_enabled']['he-il'] = '';
|
||||
$text['description-global_setting_enabled']['it-it'] = '';
|
||||
$text['description-global_setting_enabled']['nl-nl'] = '';
|
||||
$text['description-global_setting_enabled']['pl-pl'] = '';
|
||||
$text['description-global_setting_enabled']['pt-br'] = '';
|
||||
$text['description-global_setting_enabled']['pt-pt'] = '';
|
||||
$text['description-global_setting_enabled']['ro-ro'] = '';
|
||||
$text['description-global_setting_enabled']['ru-ru'] = '';
|
||||
$text['description-global_setting_enabled']['sv-se'] = '';
|
||||
$text['description-global_setting_enabled']['uk-ua'] = '';
|
||||
|
||||
$text['label-global_setting_description']['en-us'] = 'Description';
|
||||
$text['label-global_setting_description']['ar-eg'] = '';
|
||||
$text['label-global_setting_description']['de-at'] = '';
|
||||
$text['label-global_setting_description']['de-ch'] = '';
|
||||
$text['label-global_setting_description']['de-de'] = '';
|
||||
$text['label-global_setting_description']['es-cl'] = '';
|
||||
$text['label-global_setting_description']['es-mx'] = '';
|
||||
$text['label-global_setting_description']['fr-ca'] = '';
|
||||
$text['label-global_setting_description']['fr-fr'] = '';
|
||||
$text['label-global_setting_description']['he-il'] = '';
|
||||
$text['label-global_setting_description']['it-it'] = '';
|
||||
$text['label-global_setting_description']['nl-nl'] = '';
|
||||
$text['label-global_setting_description']['pl-pl'] = '';
|
||||
$text['label-global_setting_description']['pt-br'] = '';
|
||||
$text['label-global_setting_description']['pt-pt'] = '';
|
||||
$text['label-global_setting_description']['ro-ro'] = '';
|
||||
$text['label-global_setting_description']['ru-ru'] = '';
|
||||
$text['label-global_setting_description']['sv-se'] = '';
|
||||
$text['label-global_setting_description']['uk-ua'] = '';
|
||||
|
||||
$text['description-global_setting_description']['en-us'] = 'Enter the global setting description.';
|
||||
$text['description-global_setting_description']['ar-eg'] = '';
|
||||
$text['description-global_setting_description']['de-at'] = '';
|
||||
$text['description-global_setting_description']['de-ch'] = '';
|
||||
$text['description-global_setting_description']['de-de'] = '';
|
||||
$text['description-global_setting_description']['es-cl'] = '';
|
||||
$text['description-global_setting_description']['es-mx'] = '';
|
||||
$text['description-global_setting_description']['fr-ca'] = '';
|
||||
$text['description-global_setting_description']['fr-fr'] = '';
|
||||
$text['description-global_setting_description']['he-il'] = '';
|
||||
$text['description-global_setting_description']['it-it'] = '';
|
||||
$text['description-global_setting_description']['nl-nl'] = '';
|
||||
$text['description-global_setting_description']['pl-pl'] = '';
|
||||
$text['description-global_setting_description']['pt-br'] = '';
|
||||
$text['description-global_setting_description']['pt-pt'] = '';
|
||||
$text['description-global_setting_description']['ro-ro'] = '';
|
||||
$text['description-global_setting_description']['ru-ru'] = '';
|
||||
$text['description-global_setting_description']['sv-se'] = '';
|
||||
$text['description-global_setting_description']['uk-ua'] = '';
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,261 @@
|
|||
<?php
|
||||
/*
|
||||
FusionPBX
|
||||
Version: MPL 1.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is FusionPBX
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2019 - 2021
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* sofia_global_settings class
|
||||
*
|
||||
* @method null delete
|
||||
* @method null toggle
|
||||
* @method null copy
|
||||
*/
|
||||
if (!class_exists('sofia_global_settings')) {
|
||||
class sofia_global_settings {
|
||||
|
||||
/**
|
||||
* declare the variables
|
||||
*/
|
||||
private $app_name;
|
||||
private $app_uuid;
|
||||
private $name;
|
||||
private $table;
|
||||
private $toggle_field;
|
||||
private $toggle_values;
|
||||
private $description_field;
|
||||
private $location;
|
||||
|
||||
/**
|
||||
* called when the object is created
|
||||
*/
|
||||
public function __construct() {
|
||||
//assign the variables
|
||||
$this->app_name = 'sofia_global_settings';
|
||||
$this->app_uuid = '240c25a3-a2cf-44ea-a300-0626eca5b945';
|
||||
$this->name = 'sofia_global_setting';
|
||||
$this->table = 'sofia_global_settings';
|
||||
$this->toggle_field = 'global_setting_enabled';
|
||||
$this->toggle_values = ['true','false'];
|
||||
$this->description_field = 'global_setting_description';
|
||||
$this->location = 'sofia_global_settings.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* called when there are no references to a particular object
|
||||
* unset the variables used in the class
|
||||
*/
|
||||
public function __destruct() {
|
||||
foreach ($this as $key => $value) {
|
||||
unset($this->$key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* delete rows from the database
|
||||
*/
|
||||
public function delete($records) {
|
||||
if (permission_exists($this->name.'_delete')) {
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//validate the token
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('Location: '.$this->location);
|
||||
exit;
|
||||
}
|
||||
|
||||
//delete multiple records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
//build the delete array
|
||||
$x = 0;
|
||||
foreach ($records as $record) {
|
||||
//add to the array
|
||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
$array[$this->table][$x]['sofia_global_setting_uuid'] = $record['sofia_global_setting_uuid'];
|
||||
}
|
||||
|
||||
//increment the id
|
||||
$x++;
|
||||
}
|
||||
|
||||
//delete the checked rows
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
//execute delete
|
||||
$database = new database;
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->delete($array);
|
||||
unset($array);
|
||||
|
||||
//set message
|
||||
message::add($text['message-delete']);
|
||||
}
|
||||
unset($records);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* toggle a field between two values
|
||||
*/
|
||||
public function toggle($records) {
|
||||
if (permission_exists($this->name.'_edit')) {
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//validate the token
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('Location: '.$this->location);
|
||||
exit;
|
||||
}
|
||||
|
||||
//toggle the checked records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
//get current toggle state
|
||||
foreach($records as $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid($record['sofia_global_setting_uuid'])) {
|
||||
$uuids[] = "'".$record['sofia_global_setting_uuid']."'";
|
||||
}
|
||||
}
|
||||
if (is_array($uuids) && @sizeof($uuids) != 0) {
|
||||
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
|
||||
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
|
||||
$database = new database;
|
||||
$rows = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||
foreach ($rows as $row) {
|
||||
$states[$row['uuid']] = $row['toggle'];
|
||||
}
|
||||
}
|
||||
unset($sql, $parameters, $rows, $row);
|
||||
}
|
||||
|
||||
//build update array
|
||||
$x = 0;
|
||||
foreach($states as $uuid => $state) {
|
||||
//create the array
|
||||
$array[$this->table][$x][$this->name.'_uuid'] = $uuid;
|
||||
$array[$this->table][$x][$this->toggle_field] = $state == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0];
|
||||
|
||||
//increment the id
|
||||
$x++;
|
||||
}
|
||||
|
||||
//save the changes
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
//save the array
|
||||
$database = new database;
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
//set message
|
||||
message::add($text['message-toggle']);
|
||||
}
|
||||
unset($records, $states);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* copy rows from the database
|
||||
*/
|
||||
public function copy($records) {
|
||||
if (permission_exists($this->name.'_add')) {
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//validate the token
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('Location: '.$this->location);
|
||||
exit;
|
||||
}
|
||||
|
||||
//copy the checked records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
|
||||
//get checked records
|
||||
foreach($records as $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid(sofia_global_setting_uuid')) {
|
||||
$uuids[] = "'".$record['sofia_global_setting_uuid']."'";
|
||||
}
|
||||
}
|
||||
|
||||
//create the array from existing data
|
||||
if (is_array($uuids) && @sizeof($uuids) != 0) {
|
||||
$sql = "select * from v_".$this->table." ";
|
||||
$sql .= "where sofia_global_setting_uuid in (".implode(', ', $uuids).") ";
|
||||
$database = new database;
|
||||
$rows = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||
$x = 0;
|
||||
foreach ($rows as $row) {
|
||||
//copy data
|
||||
$array[$this->table][$x] = $row;
|
||||
|
||||
//add copy to the description
|
||||
$array[$this->table][$x][sofia_global_setting.'_uuid'] = uuid();
|
||||
$array[$this->table][$x][$this->description_field] = trim($row[$this->description_field]).' ('.$text['label-copy'].')';
|
||||
|
||||
//increment the id
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
unset($sql, $parameters, $rows, $row);
|
||||
}
|
||||
|
||||
//save the changes and set the message
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
//save the array
|
||||
$database = new database;
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
//set message
|
||||
message::add($text['message-copy']);
|
||||
}
|
||||
unset($records);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
/*
|
||||
FusionPBX
|
||||
Version: MPL 1.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is FusionPBX
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2012
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
|
||||
// make sure the PATH_SEPARATOR is defined
|
||||
umask(2);
|
||||
if (!defined("PATH_SEPARATOR")) {
|
||||
if (strpos($_ENV["OS"], "Win") !== false) {
|
||||
define("PATH_SEPARATOR", ";");
|
||||
} else {
|
||||
define("PATH_SEPARATOR", ":");
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
|
||||
|
||||
// make sure the document_root is set
|
||||
$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
|
||||
if(PHP_SAPI == 'cli'){
|
||||
chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
|
||||
$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
|
||||
$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
|
||||
if (file_exists('/project_root.php')) {
|
||||
$path = '/';
|
||||
} else {
|
||||
$i = 1;
|
||||
$path = '';
|
||||
while ($i < count($dirs)) {
|
||||
$path .= '/' . $dirs[$i];
|
||||
if (file_exists($path. '/project_root.php')) {
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$_SERVER["DOCUMENT_ROOT"] = $path;
|
||||
}else{
|
||||
$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
|
||||
}
|
||||
$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
|
||||
// try to detect if a project path is being used
|
||||
if (!defined('PROJECT_PATH')) {
|
||||
if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) {
|
||||
define('PROJECT_PATH', '/fusionpbx');
|
||||
} elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) {
|
||||
define('PROJECT_PATH', '');
|
||||
} else {
|
||||
$dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME)));
|
||||
$i = 1;
|
||||
$path = $_SERVER["DOCUMENT_ROOT"];
|
||||
while ($i < count($dirs)) {
|
||||
$path .= '/' . $dirs[$i];
|
||||
if (file_exists($path. '/project_root.php')) {
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
if(!file_exists($path. '/project_root.php')){
|
||||
die("Failed to locate the Project Root by searching for project_root.php please contact support for assistance");
|
||||
}
|
||||
$project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path);
|
||||
define('PROJECT_PATH', $project_path);
|
||||
}
|
||||
$_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH);
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,267 @@
|
|||
<?php
|
||||
|
||||
//includes
|
||||
require_once "root.php";
|
||||
require_once "resources/require.php";
|
||||
require_once "resources/check_auth.php";
|
||||
|
||||
//check permissions
|
||||
if (permission_exists('sofia_global_setting_add') || permission_exists('sofia_global_setting_edit')) {
|
||||
//access granted
|
||||
}
|
||||
else {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//action add or update
|
||||
if (is_uuid($_REQUEST["id"])) {
|
||||
$action = "update";
|
||||
$sofia_global_setting_uuid = $_REQUEST["id"];
|
||||
$id = $_REQUEST["id"];
|
||||
}
|
||||
else {
|
||||
$action = "add";
|
||||
}
|
||||
|
||||
//get http post variables and set them to php variables
|
||||
if (is_array($_POST)) {
|
||||
$global_setting_name = $_POST["global_setting_name"];
|
||||
$global_setting_value = $_POST["global_setting_value"];
|
||||
$global_setting_enabled = $_POST["global_setting_enabled"];
|
||||
$global_setting_description = $_POST["global_setting_description"];
|
||||
}
|
||||
|
||||
//process the user data and save it to the database
|
||||
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
|
||||
//validate the token
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('Location: sofia_global_settings.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
//process the http post data by submitted action
|
||||
if ($_POST['action'] != '' && strlen($_POST['action']) > 0) {
|
||||
|
||||
//prepare the array(s)
|
||||
//send the array to the database class
|
||||
switch ($_POST['action']) {
|
||||
case 'copy':
|
||||
if (permission_exists('sofia_global_setting_add')) {
|
||||
$obj = new database;
|
||||
$obj->copy($array);
|
||||
}
|
||||
break;
|
||||
case 'delete':
|
||||
if (permission_exists('sofia_global_setting_delete')) {
|
||||
$obj = new database;
|
||||
$obj->delete($array);
|
||||
}
|
||||
break;
|
||||
case 'toggle':
|
||||
if (permission_exists('sofia_global_setting_update')) {
|
||||
$obj = new database;
|
||||
$obj->toggle($array);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//redirect the user
|
||||
if (in_array($_POST['action'], array('copy', 'delete', 'toggle'))) {
|
||||
header('Location: sofia_global_setting_edit.php?id='.$id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
//check for all required data
|
||||
$msg = '';
|
||||
if (strlen($global_setting_name) == 0) { $msg .= $text['message-required']." ".$text['label-global_setting_name']."<br>\n"; }
|
||||
if (strlen($global_setting_value) == 0) { $msg .= $text['message-required']." ".$text['label-global_setting_value']."<br>\n"; }
|
||||
if (strlen($global_setting_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-global_setting_enabled']."<br>\n"; }
|
||||
//if (strlen($global_setting_description) == 0) { $msg .= $text['message-required']." ".$text['label-global_setting_description']."<br>\n"; }
|
||||
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
require_once "resources/header.php";
|
||||
require_once "resources/persist_form_var.php";
|
||||
echo "<div align='center'>\n";
|
||||
echo "<table><tr><td>\n";
|
||||
echo $msg."<br />";
|
||||
echo "</td></tr></table>\n";
|
||||
persistformvar($_POST);
|
||||
echo "</div>\n";
|
||||
require_once "resources/footer.php";
|
||||
return;
|
||||
}
|
||||
|
||||
//add the sofia_global_setting_uuid
|
||||
if (!is_uuid($_POST["sofia_global_setting_uuid"])) {
|
||||
$sofia_global_setting_uuid = uuid();
|
||||
}
|
||||
|
||||
//prepare the array
|
||||
$array['sofia_global_settings'][0]['sofia_global_setting_uuid'] = $sofia_global_setting_uuid;
|
||||
$array['sofia_global_settings'][0]['global_setting_name'] = $global_setting_name;
|
||||
$array['sofia_global_settings'][0]['global_setting_value'] = $global_setting_value;
|
||||
$array['sofia_global_settings'][0]['global_setting_enabled'] = $global_setting_enabled;
|
||||
$array['sofia_global_settings'][0]['global_setting_description'] = $global_setting_description;
|
||||
|
||||
//save the data
|
||||
$database = new database;
|
||||
$database->app_name = 'sofia_global_settings';
|
||||
$database->app_uuid = '240c25a3-a2cf-44ea-a300-0626eca5b945';
|
||||
$database->save($array);
|
||||
|
||||
//redirect the user
|
||||
if (isset($action)) {
|
||||
if ($action == "add") {
|
||||
$_SESSION["message"] = $text['message-add'];
|
||||
}
|
||||
if ($action == "update") {
|
||||
$_SESSION["message"] = $text['message-update'];
|
||||
}
|
||||
//header('Location: sofia_global_settings.php');
|
||||
header('Location: sofia_global_setting_edit.php?id='.urlencode($sofia_global_setting_uuid));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//pre-populate the form
|
||||
if (is_array($_GET) && $_POST["persistformvar"] != "true") {
|
||||
$sql = "select ";
|
||||
$sql .= " sofia_global_setting_uuid, ";
|
||||
$sql .= " global_setting_name, ";
|
||||
$sql .= " global_setting_value, ";
|
||||
$sql .= " cast(global_setting_enabled as text), ";
|
||||
$sql .= " global_setting_description ";
|
||||
$sql .= "from v_sofia_global_settings ";
|
||||
$sql .= "where sofia_global_setting_uuid = :sofia_global_setting_uuid ";
|
||||
$parameters['sofia_global_setting_uuid'] = $sofia_global_setting_uuid;
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
if (is_array($row) && @sizeof($row) != 0) {
|
||||
$global_setting_name = $row["global_setting_name"];
|
||||
$global_setting_value = $row["global_setting_value"];
|
||||
$global_setting_enabled = $row["global_setting_enabled"];
|
||||
$global_setting_description = $row["global_setting_description"];
|
||||
}
|
||||
unset($sql, $parameters, $row);
|
||||
}
|
||||
|
||||
//create token
|
||||
$object = new token;
|
||||
$token = $object->create($_SERVER['PHP_SELF']);
|
||||
|
||||
//show the header
|
||||
$document['title'] = $text['title-sofia_global_setting'];
|
||||
require_once "resources/header.php";
|
||||
|
||||
//show the content
|
||||
echo "<form name='frm' id='frm' method='post' action=''>\n";
|
||||
echo "<input class='formfld' type='hidden' name='sofia_global_setting_uuid' value='".escape($sofia_global_setting_uuid)."'>\n";
|
||||
|
||||
echo "<div class='action_bar' id='action_bar'>\n";
|
||||
echo " <div class='heading'><b>".$text['title-sofia_global_setting']."</b></div>\n";
|
||||
echo " <div class='actions'>\n";
|
||||
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'sofia_global_settings.php']);
|
||||
if ($action == 'update') {
|
||||
if (permission_exists('_add')) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
|
||||
}
|
||||
if (permission_exists('_delete')) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; margin-right: 15px;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
|
||||
}
|
||||
}
|
||||
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','collapse'=>'hide-xs']);
|
||||
echo " </div>\n";
|
||||
echo " <div style='clear: both;'></div>\n";
|
||||
echo "</div>\n";
|
||||
|
||||
echo $text['title_description-sofia_global_settings']."\n";
|
||||
echo "<br /><br />\n";
|
||||
|
||||
if ($action == 'update') {
|
||||
if (permission_exists('sofia_global_setting_add')) {
|
||||
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'copy','onclick'=>"modal_close();"])]);
|
||||
}
|
||||
if (permission_exists('sofia_global_setting_delete')) {
|
||||
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'delete','onclick'=>"modal_close();"])]);
|
||||
}
|
||||
}
|
||||
|
||||
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
|
||||
echo "<tr>\n";
|
||||
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
|
||||
echo " ".$text['label-global_setting_name']."\n";
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable' style='position: relative;' align='left'>\n";
|
||||
echo " <input class='formfld' type='text' name='global_setting_name' maxlength='255' value='".escape($global_setting_name)."'>\n";
|
||||
echo "<br />\n";
|
||||
echo $text['description-global_setting_name']."\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "<tr>\n";
|
||||
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
|
||||
echo " ".$text['label-global_setting_value']."\n";
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable' style='position: relative;' align='left'>\n";
|
||||
echo " <input class='formfld' type='text' name='global_setting_value' maxlength='255' value='".escape($global_setting_value)."'>\n";
|
||||
echo "<br />\n";
|
||||
echo $text['description-global_setting_value']."\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "<tr>\n";
|
||||
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
|
||||
echo " ".$text['label-global_setting_enabled']."\n";
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable' style='position: relative;' align='left'>\n";
|
||||
echo " <select class='formfld' name='global_setting_enabled'>\n";
|
||||
echo " <option value=''></option>\n";
|
||||
if ($global_setting_enabled == "true") {
|
||||
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
|
||||
}
|
||||
else {
|
||||
echo " <option value='true'>".$text['label-true']."</option>\n";
|
||||
}
|
||||
if ($global_setting_enabled == "false") {
|
||||
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
|
||||
}
|
||||
else {
|
||||
echo " <option value='false'>".$text['label-false']."</option>\n";
|
||||
}
|
||||
echo " </select>\n";
|
||||
echo "<br />\n";
|
||||
echo $text['description-global_setting_enabled']."\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "<tr>\n";
|
||||
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
||||
echo " ".$text['label-global_setting_description']."\n";
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable' style='position: relative;' align='left'>\n";
|
||||
echo " <input class='formfld' type='text' name='global_setting_description' maxlength='255' value='".escape($global_setting_description)."'>\n";
|
||||
echo "<br />\n";
|
||||
echo $text['description-global_setting_description']."\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "</table>";
|
||||
echo "<br /><br />";
|
||||
|
||||
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
|
||||
|
||||
echo "</form>";
|
||||
|
||||
//include the footer
|
||||
require_once "resources/footer.php";
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,249 @@
|
|||
<?php
|
||||
/*
|
||||
FusionPBX
|
||||
Version: MPL 1.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is FusionPBX
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2018 - 2021
|
||||
the Initial Developer. All Rights Reserved.
|
||||
*/
|
||||
|
||||
//includes
|
||||
require_once "root.php";
|
||||
require_once "resources/require.php";
|
||||
require_once "resources/check_auth.php";
|
||||
require_once "resources/paging.php";
|
||||
|
||||
//check permissions
|
||||
if (permission_exists('sofia_global_setting_view')) {
|
||||
//access granted
|
||||
}
|
||||
else {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//get the http post data
|
||||
if (is_array($_POST['sofia_global_settings'])) {
|
||||
$action = $_POST['action'];
|
||||
$search = $_POST['search'];
|
||||
$sofia_global_settings = $_POST['sofia_global_settings'];
|
||||
}
|
||||
|
||||
//process the http post data by action
|
||||
if ($action != '' && is_array($sofia_global_settings) && @sizeof($sofia_global_settings) != 0) {
|
||||
|
||||
switch ($action) {
|
||||
case 'copy':
|
||||
if (permission_exists('sofia_global_setting_add')) {
|
||||
$obj = new sofia_global_settings;
|
||||
$obj->copy($sofia_global_settings);
|
||||
}
|
||||
break;
|
||||
case 'toggle':
|
||||
if (permission_exists('sofia_global_setting_edit')) {
|
||||
$obj = new sofia_global_settings;
|
||||
$obj->toggle($sofia_global_settings);
|
||||
}
|
||||
break;
|
||||
case 'delete':
|
||||
if (permission_exists('sofia_global_setting_delete')) {
|
||||
$obj = new sofia_global_settings;
|
||||
$obj->delete($sofia_global_settings);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//redirect the user
|
||||
header('Location: sofia_global_settings.php'.($search != '' ? '?search='.urlencode($search) : null));
|
||||
exit;
|
||||
}
|
||||
|
||||
//get order and order by
|
||||
$order_by = $_GET["order_by"];
|
||||
$order = $_GET["order"];
|
||||
|
||||
//add the search
|
||||
if (isset($_GET["search"])) {
|
||||
$search = strtolower($_GET["search"]);
|
||||
}
|
||||
|
||||
//get the count
|
||||
$sql = "select count(sofia_global_setting_uuid) ";
|
||||
$sql .= "from v_sofia_global_settings ";
|
||||
if (isset($search)) {
|
||||
$sql .= "where (";
|
||||
$sql .= ") ";
|
||||
$parameters['search'] = '%'.$search.'%';
|
||||
}
|
||||
$database = new database;
|
||||
$num_rows = $database->select($sql, $parameters, 'column');
|
||||
unset($sql, $parameters);
|
||||
|
||||
//prepare to page the results
|
||||
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
|
||||
$param = $search ? "&search=".$search : null;
|
||||
$page = is_numeric($_GET['page']) ? $_GET['page'] : 0;
|
||||
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
|
||||
list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true);
|
||||
$offset = $rows_per_page * $page;
|
||||
|
||||
//get the list
|
||||
$sql = "select ";
|
||||
$sql .= "sofia_global_setting_uuid, ";
|
||||
$sql .= "global_setting_name, ";
|
||||
$sql .= "global_setting_value, ";
|
||||
$sql .= "cast(global_setting_enabled as text), ";
|
||||
$sql .= "global_setting_description ";
|
||||
$sql .= "from v_sofia_global_settings ";
|
||||
if (isset($_GET["search"])) {
|
||||
$sql .= "where (";
|
||||
$sql .= ") ";
|
||||
$parameters['search'] = '%'.$search.'%';
|
||||
}
|
||||
$sql .= order_by($order_by, $order, 'global_setting_name', 'asc');
|
||||
$sql .= limit_offset($rows_per_page, $offset);
|
||||
$database = new database;
|
||||
$sofia_global_settings = $database->select($sql, $parameters, 'all');
|
||||
unset($sql, $parameters);
|
||||
|
||||
//create token
|
||||
$object = new token;
|
||||
$token = $object->create($_SERVER['PHP_SELF']);
|
||||
|
||||
//additional includes
|
||||
$document['title'] = $text['title-sofia_global_settings'];
|
||||
require_once "resources/header.php";
|
||||
|
||||
//show the content
|
||||
echo "<div class='action_bar' id='action_bar'>\n";
|
||||
echo " <div class='heading'><b>".$text['title-sofia_global_settings']." (".$num_rows.")</b></div>\n";
|
||||
echo " <div class='actions'>\n";
|
||||
if (permission_exists('sofia_global_setting_add')) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','name'=>'btn_add','link'=>'sofia_global_setting_edit.php']);
|
||||
}
|
||||
if (permission_exists('sofia_global_setting_add') && $sofia_global_settings) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display:none;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
|
||||
}
|
||||
if (permission_exists('sofia_global_setting_edit') && $sofia_global_settings) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'id'=>'btn_toggle','name'=>'btn_toggle','style'=>'display:none;','onclick'=>"modal_open('modal-toggle','btn_toggle');"]);
|
||||
}
|
||||
if (permission_exists('sofia_global_setting_delete') && $sofia_global_settings) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display:none;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
|
||||
}
|
||||
echo "<form id='form_search' class='inline' method='get'>\n";
|
||||
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown='list_search_reset();'>";
|
||||
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]);
|
||||
echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'sofia_global_settings.php','style'=>($search == '' ? 'display: none;' : null)]);
|
||||
if ($paging_controls_mini != '') {
|
||||
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
|
||||
}
|
||||
echo " </form>\n";
|
||||
echo " </div>\n";
|
||||
echo " <div style='clear: both;'></div>\n";
|
||||
echo "</div>\n";
|
||||
|
||||
if (permission_exists('sofia_global_setting_add') && $sofia_global_settings) {
|
||||
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('copy'); list_form_submit('form_list');"])]);
|
||||
}
|
||||
if (permission_exists('sofia_global_setting_edit') && $sofia_global_settings) {
|
||||
echo modal::create(['id'=>'modal-toggle','type'=>'toggle','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_toggle','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('toggle'); list_form_submit('form_list');"])]);
|
||||
}
|
||||
if (permission_exists('sofia_global_setting_delete') && $sofia_global_settings) {
|
||||
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
|
||||
}
|
||||
|
||||
echo $text['title_description-sofia_global_settings']."\n";
|
||||
echo "<br /><br />\n";
|
||||
|
||||
echo "<form id='form_list' method='post'>\n";
|
||||
echo "<input type='hidden' id='action' name='action' value=''>\n";
|
||||
echo "<input type='hidden' name='search' value=\"".escape($search)."\">\n";
|
||||
|
||||
echo "<table class='list'>\n";
|
||||
echo "<tr class='list-header'>\n";
|
||||
if (permission_exists('sofia_global_setting_add') || permission_exists('sofia_global_setting_edit') || permission_exists('sofia_global_setting_delete')) {
|
||||
echo " <th class='checkbox'>\n";
|
||||
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".($sofia_global_settings ?: "style='visibility: hidden;'").">\n";
|
||||
echo " </th>\n";
|
||||
}
|
||||
echo th_order_by('global_setting_name', $text['label-global_setting_name'], $order_by, $order);
|
||||
echo th_order_by('global_setting_value', $text['label-global_setting_value'], $order_by, $order);
|
||||
echo th_order_by('global_setting_enabled', $text['label-global_setting_enabled'], $order_by, $order, null, "class='center'");
|
||||
echo " <th class='hide-sm-dn'>".$text['label-global_setting_description']."</th>\n";
|
||||
if (permission_exists('sofia_global_setting_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
|
||||
echo " <td class='action-button'> </td>\n";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
|
||||
if (is_array($sofia_global_settings) && @sizeof($sofia_global_settings) != 0) {
|
||||
$x = 0;
|
||||
foreach ($sofia_global_settings as $row) {
|
||||
if (permission_exists('sofia_global_setting_edit')) {
|
||||
$list_row_url = "sofia_global_setting_edit.php?id=".urlencode($row['sofia_global_setting_uuid']);
|
||||
}
|
||||
echo "<tr class='list-row' href='".$list_row_url."'>\n";
|
||||
if (permission_exists('sofia_global_setting_add') || permission_exists('sofia_global_setting_edit') || permission_exists('sofia_global_setting_delete')) {
|
||||
echo " <td class='checkbox'>\n";
|
||||
echo " <input type='checkbox' name='sofia_global_settings[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
|
||||
echo " <input type='hidden' name='sofia_global_settings[$x][sofia_global_setting_uuid]' value='".escape($row['sofia_global_setting_uuid'])."' />\n";
|
||||
echo " </td>\n";
|
||||
}
|
||||
echo " <td>\n";
|
||||
if (permission_exists('sofia_global_setting_edit')) {
|
||||
echo " <a href='".$list_row_url."' title=\"".$text['button-edit']."\">".escape($row['global_setting_name'])."</a>\n";
|
||||
}
|
||||
else {
|
||||
echo " ".escape($row['global_setting_name']);
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo " <td>".escape($row['global_setting_value'])."</td>\n";
|
||||
if (permission_exists('sofia_global_setting_edit')) {
|
||||
echo " <td class='no-link center'>\n";
|
||||
echo " <input type='hidden' name='number_translations[$x][global_setting_enabled]' value='".escape($row['global_setting_enabled'])."' />\n";
|
||||
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['global_setting_enabled']],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);
|
||||
}
|
||||
else {
|
||||
echo " <td class='center'>\n";
|
||||
echo $text['label-'.$row['global_setting_enabled']];
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo " <td class='description overflow hide-sm-dn'>".escape($row['global_setting_description'])."</td>\n";
|
||||
if (permission_exists('sofia_global_setting_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
|
||||
echo " <td class='action-button'>\n";
|
||||
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
|
||||
echo " </td>\n";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
$x++;
|
||||
}
|
||||
unset($sofia_global_settings);
|
||||
}
|
||||
|
||||
echo "</table>\n";
|
||||
echo "<br />\n";
|
||||
echo "<div align='center'>".$paging_controls."</div>\n";
|
||||
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
|
||||
echo "</form>\n";
|
||||
|
||||
//include the footer
|
||||
require_once "resources/footer.php";
|
||||
|
||||
?>
|
||||
Loading…
Reference in New Issue