diff --git a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua index 6274ab2e4c..d4bfce5a02 100644 --- a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua +++ b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua @@ -1,310 +1,316 @@ --- xml_handler.lua --- Part of FusionPBX --- Copyright (C) 2013 - 2018 Mark J Crane --- 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, [[]]); - table.insert(xml, [[]]); - table.insert(xml, [[
]]); - table.insert(xml, [[ ]]); - table.insert(xml, [[ ]]); - table.insert(xml, [[ ]]); - --table.insert(xml, [[ ]]); - table.insert(xml, [[ ]]); - --table.insert(xml, [[ ]]); - table.insert(xml, [[ ]]); - table.insert(xml, [[ ]]); - - --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, [[ ]]); - table.insert(xml, [[ ]]); - end - table.insert(xml, [[ ]]); - table.insert(xml, [[ ]]); - table.insert(xml, [[ ]]); - table.insert(xml, [[ ]]); - --table.insert(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, [[ ]]); - - if (string.len(field.username) > 0) then - table.insert(xml, [[ ]]); - end - if (string.len(field.distinct_to) > 0) then - table.insert(xml, [[ ]]); - end - if (string.len(field.auth_username) > 0) then - table.insert(xml, [[ ]]); - end - if (string.len(field.password) > 0) then - table.insert(xml, [[ ]]); - end - if (string.len(field.realm) > 0) then - table.insert(xml, [[ ]]); - end - if (string.len(field.from_user) > 0) then - table.insert(xml, [[ ]]); - end - if (string.len(field.from_domain) > 0) then - table.insert(xml, [[ ]]); - end - if (string.len(field.proxy) > 0) then - table.insert(xml, [[ ]]); - end - if (string.len(field.register_proxy) > 0) then - table.insert(xml, [[ ]]); - end - if (string.len(field.outbound_proxy) > 0) then - table.insert(xml, [[ ]]); - end - if (string.len(field.expire_seconds) > 0) then - table.insert(xml, [[ ]]); - end - if (string.len(field.register) > 0) then - table.insert(xml, [[ ]]); - end - - if (field.register_transport) then - if (field.register_transport == "udp") then - table.insert(xml, [[ ]]); - elseif (field.register_transport == "tcp") then - table.insert(xml, [[ ]]); - elseif (field.register_transport == "tls") then - table.insert(xml, [[ ]]); - table.insert(xml, [[ ]]); - else - table.insert(xml, [[ ]]); - end - end - - if (string.len(field.retry_seconds) > 0) then - table.insert(xml, [[ ]]); - end - if (string.len(field.extension) > 0) then - table.insert(xml, [[ ]]); - end - if (string.len(field.ping) > 0) then - table.insert(xml, [[ ]]); - end - if (string.len(field.ping_min) > 0) then - table.insert(xml, [[ ]]); - end - if (string.len(field.ping_max) > 0) then - table.insert(xml, [[ ]]); - end - if (string.len(field.context) > 0) then - table.insert(xml, [[ ]]); - end - if (string.len(field.caller_id_in_from) > 0) then - table.insert(xml, [[ ]]); - end - if (string.len(field.supress_cng) > 0) then - table.insert(xml, [[ ]]); - end - if (string.len(field.extension_in_contact) > 0) then - table.insert(xml, [[ ]]); - end - table.insert(xml, [[ ]]); - if (string.len(field.sip_cid_type) > 0) then - table.insert(xml, [[ ]]); - end - table.insert(xml, [[ ]]); - table.insert(xml, [[ ]]); - end) - - table.insert(xml, [[ ]]); - table.insert(xml, [[ ]]); - - --add sip profile domain: name, alias, and parse - table.insert(xml, [[ ]]); - table.insert(xml, [[ ]]); - table.insert(xml, [[ ]]); - table.insert(xml, [[ ]]); - 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, [[ ]]); - end); - - table.insert(xml, [[ ]]); - table.insert(xml, [[ ]]); - 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, [[ ]]); - 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, [[ ]]); - table.insert(xml, [[ ]]); - profile_tag_status = "close"; - end - table.insert(xml, [[ ]]); - table.insert(xml, [[ ]]); - table.insert(xml, [[
]]); - table.insert(xml, [[
]]); - 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 +-- 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, [[]]); + table.insert(xml, [[]]); + table.insert(xml, [[
]]); + table.insert(xml, [[ ]]); + + --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, [[ ]]); + dbh:query(sql, params, function(row) + table.insert(xml, [[ ]]); + end) + table.insert(xml, [[ ]]); + + --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, [[ ]]); + 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, [[ ]]); + table.insert(xml, [[ ]]); + end + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + --table.insert(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, [[ ]]); + + if (string.len(field.username) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(field.distinct_to) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(field.auth_username) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(field.password) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(field.realm) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(field.from_user) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(field.from_domain) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(field.proxy) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(field.register_proxy) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(field.outbound_proxy) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(field.expire_seconds) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(field.register) > 0) then + table.insert(xml, [[ ]]); + end + + if (field.register_transport) then + if (field.register_transport == "udp") then + table.insert(xml, [[ ]]); + elseif (field.register_transport == "tcp") then + table.insert(xml, [[ ]]); + elseif (field.register_transport == "tls") then + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + else + table.insert(xml, [[ ]]); + end + end + + if (string.len(field.retry_seconds) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(field.extension) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(field.ping) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(field.ping_min) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(field.ping_max) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(field.context) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(field.caller_id_in_from) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(field.supress_cng) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(field.extension_in_contact) > 0) then + table.insert(xml, [[ ]]); + end + table.insert(xml, [[ ]]); + if (string.len(field.sip_cid_type) > 0) then + table.insert(xml, [[ ]]); + end + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + end) + + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + + --add sip profile domain: name, alias, and parse + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + 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, [[ ]]); + end); + + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + 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, [[ ]]); + 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, [[ ]]); + table.insert(xml, [[ ]]); + profile_tag_status = "close"; + end + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[
]]); + table.insert(xml, [[
]]); + 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 diff --git a/app/sofia_global_settings/app_config.php b/app/sofia_global_settings/app_config.php new file mode 100644 index 0000000000..2d5cd5a096 --- /dev/null +++ b/app/sofia_global_settings/app_config.php @@ -0,0 +1,67 @@ + \ No newline at end of file diff --git a/app/sofia_global_settings/app_defaults.php b/app/sofia_global_settings/app_defaults.php new file mode 100644 index 0000000000..536031bb7f --- /dev/null +++ b/app/sofia_global_settings/app_defaults.php @@ -0,0 +1,46 @@ +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'); +} + +?> diff --git a/app/sofia_global_settings/app_languages.php b/app/sofia_global_settings/app_languages.php new file mode 100644 index 0000000000..32f4ef7a44 --- /dev/null +++ b/app/sofia_global_settings/app_languages.php @@ -0,0 +1,224 @@ + \ No newline at end of file diff --git a/app/sofia_global_settings/resources/classes/sofia_global_settings.php b/app/sofia_global_settings/resources/classes/sofia_global_settings.php new file mode 100644 index 0000000000..3f9d16c334 --- /dev/null +++ b/app/sofia_global_settings/resources/classes/sofia_global_settings.php @@ -0,0 +1,261 @@ + + Portions created by the Initial Developer are Copyright (C) 2019 - 2021 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +/** + * 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); + } + } + } + + } +} + +?> \ No newline at end of file diff --git a/app/sofia_global_settings/root.php b/app/sofia_global_settings/root.php new file mode 100644 index 0000000000..6fdf32f37b --- /dev/null +++ b/app/sofia_global_settings/root.php @@ -0,0 +1,90 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// 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"]); + } + +?> \ No newline at end of file diff --git a/app/sofia_global_settings/sofia_global_setting_edit.php b/app/sofia_global_settings/sofia_global_setting_edit.php new file mode 100644 index 0000000000..089625fb97 --- /dev/null +++ b/app/sofia_global_settings/sofia_global_setting_edit.php @@ -0,0 +1,267 @@ +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']."
\n"; } + if (strlen($global_setting_value) == 0) { $msg .= $text['message-required']." ".$text['label-global_setting_value']."
\n"; } + if (strlen($global_setting_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-global_setting_enabled']."
\n"; } + //if (strlen($global_setting_description) == 0) { $msg .= $text['message-required']." ".$text['label-global_setting_description']."
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "resources/header.php"; + require_once "resources/persist_form_var.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\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 "
\n"; + echo "\n"; + + echo "
\n"; + echo "
".$text['title-sofia_global_setting']."
\n"; + echo "
\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 "
\n"; + echo "
\n"; + echo "
\n"; + + echo $text['title_description-sofia_global_settings']."\n"; + echo "

\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 "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + echo " ".$text['label-global_setting_name']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-global_setting_name']."\n"; + echo "
\n"; + echo " ".$text['label-global_setting_value']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-global_setting_value']."\n"; + echo "
\n"; + echo " ".$text['label-global_setting_enabled']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-global_setting_enabled']."\n"; + echo "
\n"; + echo " ".$text['label-global_setting_description']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-global_setting_description']."\n"; + echo "
"; + echo "

"; + + echo "\n"; + + echo "
"; + +//include the footer + require_once "resources/footer.php"; + +?> \ No newline at end of file diff --git a/app/sofia_global_settings/sofia_global_settings.php b/app/sofia_global_settings/sofia_global_settings.php new file mode 100644 index 0000000000..ed52e208cb --- /dev/null +++ b/app/sofia_global_settings/sofia_global_settings.php @@ -0,0 +1,249 @@ + + 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 "
\n"; + echo "
".$text['title-sofia_global_settings']." (".$num_rows.")
\n"; + echo "
\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 "\n"; + echo "
\n"; + echo "
\n"; + echo "
\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 "

\n"; + + echo "
\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + if (permission_exists('sofia_global_setting_add') || permission_exists('sofia_global_setting_edit') || permission_exists('sofia_global_setting_delete')) { + echo " \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 " \n"; + if (permission_exists('sofia_global_setting_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { + echo " \n"; + } + echo "\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 "\n"; + if (permission_exists('sofia_global_setting_add') || permission_exists('sofia_global_setting_edit') || permission_exists('sofia_global_setting_delete')) { + echo " \n"; + } + echo " \n"; + echo " \n"; + if (permission_exists('sofia_global_setting_edit')) { + echo " \n"; + echo " \n"; + if (permission_exists('sofia_global_setting_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { + echo " \n"; + } + echo "\n"; + $x++; + } + unset($sofia_global_settings); + } + + echo "
\n"; + echo " \n"; + echo " ".$text['label-global_setting_description']." 
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + if (permission_exists('sofia_global_setting_edit')) { + echo " ".escape($row['global_setting_name'])."\n"; + } + else { + echo " ".escape($row['global_setting_name']); + } + echo " ".escape($row['global_setting_value'])."\n"; + echo $text['label-'.$row['global_setting_enabled']]; + } + echo " ".escape($row['global_setting_description'])."\n"; + echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]); + echo "
\n"; + echo "
\n"; + echo "
".$paging_controls."
\n"; + echo "\n"; + echo "
\n"; + +//include the footer + require_once "resources/footer.php"; + +?> \ No newline at end of file