Add new extension_settings feature

This commit is contained in:
markjcrane
2021-02-09 13:09:32 -07:00
parent 38a9e1fae0
commit 682c632520
7 changed files with 1441 additions and 0 deletions

View File

@@ -0,0 +1,87 @@
<?php
//application details
$apps[$x]['name'] = 'Extension Settings';
$apps[$x]['uuid'] = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
$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'] = 'extension_setting_view';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'extension_setting_add';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'extension_setting_edit';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'extension_setting_delete';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'extension_setting_all';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
//Extension Settings
$y = 0;
$apps[$x]['db'][$y]['table']['name'] = 'v_extension_settings';
$apps[$x]['db'][$y]['table']['parent'] = '';
$z = 0;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'extension_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'] = 'domain_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'] = 'foreign';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_domains';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'domain_uuid';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'extension_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]['search_by'] = 'false';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'extension_setting_type';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the extension subcategory.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'extension_setting_name';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the extension name.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'extension_setting_value';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'false';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the extension value.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'extension_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 extension enabled.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'extension_setting_description';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the extension description.';
$z++;
?>

View File

@@ -0,0 +1,7 @@
<?php
if ($domains_processed == 1) {
}
?>

View File

@@ -0,0 +1,302 @@
<?php
//Extension Settings
$text['title-extension_settings']['en-us'] = 'Extension Settings';
$text['title-extension_settings']['ar-eg'] = '';
$text['title-extension_settings']['de-at'] = '';
$text['title-extension_settings']['de-ch'] = '';
$text['title-extension_settings']['de-de'] = '';
$text['title-extension_settings']['es-cl'] = '';
$text['title-extension_settings']['es-mx'] = '';
$text['title-extension_settings']['fr-ca'] = '';
$text['title-extension_settings']['fr-fr'] = '';
$text['title-extension_settings']['he-il'] = '';
$text['title-extension_settings']['it-it'] = '';
$text['title-extension_settings']['nl-nl'] = '';
$text['title-extension_settings']['pl-pl'] = '';
$text['title-extension_settings']['pt-br'] = '';
$text['title-extension_settings']['pt-pt'] = '';
$text['title-extension_settings']['ro-ro'] = '';
$text['title-extension_settings']['ru-ru'] = '';
$text['title-extension_settings']['sv-se'] = '';
$text['title-extension_settings']['uk-ua'] = '';
$text['title-extension_setting']['en-us'] = 'Extension Setting';
$text['title-extension_setting']['ar-eg'] = '';
$text['title-extension_setting']['de-at'] = '';
$text['title-extension_setting']['de-ch'] = '';
$text['title-extension_setting']['de-de'] = '';
$text['title-extension_setting']['es-cl'] = '';
$text['title-extension_setting']['es-mx'] = '';
$text['title-extension_setting']['fr-ca'] = '';
$text['title-extension_setting']['fr-fr'] = '';
$text['title-extension_setting']['he-il'] = '';
$text['title-extension_setting']['it-it'] = '';
$text['title-extension_setting']['nl-nl'] = '';
$text['title-extension_setting']['pl-pl'] = '';
$text['title-extension_setting']['pt-br'] = '';
$text['title-extension_setting']['pt-pt'] = '';
$text['title-extension_setting']['ro-ro'] = '';
$text['title-extension_setting']['ru-ru'] = '';
$text['title-extension_setting']['sv-se'] = '';
$text['title-extension_setting']['uk-ua'] = '';
$text['title_description-extension_settings']['en-us'] = 'Assign variables and parameters to this extension.';
$text['title_description-extension_settings']['ar-eg'] = '';
$text['title_description-extension_settings']['de-at'] = '';
$text['title_description-extension_settings']['de-ch'] = '';
$text['title_description-extension_settings']['de-de'] = '';
$text['title_description-extension_settings']['es-cl'] = '';
$text['title_description-extension_settings']['es-mx'] = '';
$text['title_description-extension_settings']['fr-ca'] = '';
$text['title_description-extension_settings']['fr-fr'] = '';
$text['title_description-extension_settings']['he-il'] = '';
$text['title_description-extension_settings']['it-it'] = '';
$text['title_description-extension_settings']['nl-nl'] = '';
$text['title_description-extension_settings']['pl-pl'] = '';
$text['title_description-extension_settings']['pt-br'] = '';
$text['title_description-extension_settings']['pt-pt'] = '';
$text['title_description-extension_settings']['ro-ro'] = '';
$text['title_description-extension_settings']['ru-ru'] = '';
$text['title_description-extension_settings']['sv-se'] = '';
$text['title_description-extension_settings']['uk-ua'] = '';
$text['label-extension_setting_type']['en-us'] = 'Type';
$text['label-extension_setting_type']['ar-eg'] = '';
$text['label-extension_setting_type']['de-at'] = '';
$text['label-extension_setting_type']['de-ch'] = '';
$text['label-extension_setting_type']['de-de'] = '';
$text['label-extension_setting_type']['es-cl'] = '';
$text['label-extension_setting_type']['es-mx'] = '';
$text['label-extension_setting_type']['fr-ca'] = '';
$text['label-extension_setting_type']['fr-fr'] = '';
$text['label-extension_setting_type']['he-il'] = '';
$text['label-extension_setting_type']['it-it'] = '';
$text['label-extension_setting_type']['nl-nl'] = '';
$text['label-extension_setting_type']['pl-pl'] = '';
$text['label-extension_setting_type']['pt-br'] = '';
$text['label-extension_setting_type']['pt-pt'] = '';
$text['label-extension_setting_type']['ro-ro'] = '';
$text['label-extension_setting_type']['ru-ru'] = '';
$text['label-extension_setting_type']['sv-se'] = '';
$text['label-extension_setting_type']['uk-ua'] = '';
$text['description-extension_setting_type']['en-us'] = 'Enter the extension subcategory.';
$text['description-extension_setting_type']['ar-eg'] = '';
$text['description-extension_setting_type']['de-at'] = '';
$text['description-extension_setting_type']['de-ch'] = '';
$text['description-extension_setting_type']['de-de'] = '';
$text['description-extension_setting_type']['es-cl'] = '';
$text['description-extension_setting_type']['es-mx'] = '';
$text['description-extension_setting_type']['fr-ca'] = '';
$text['description-extension_setting_type']['fr-fr'] = '';
$text['description-extension_setting_type']['he-il'] = '';
$text['description-extension_setting_type']['it-it'] = '';
$text['description-extension_setting_type']['nl-nl'] = '';
$text['description-extension_setting_type']['pl-pl'] = '';
$text['description-extension_setting_type']['pt-br'] = '';
$text['description-extension_setting_type']['pt-pt'] = '';
$text['description-extension_setting_type']['ro-ro'] = '';
$text['description-extension_setting_type']['ru-ru'] = '';
$text['description-extension_setting_type']['sv-se'] = '';
$text['description-extension_setting_type']['uk-ua'] = '';
$text['label-param']['en-us'] = 'param';
$text['label-param']['ar-eg'] = '';
$text['label-param']['de-at'] = '';
$text['label-param']['de-ch'] = '';
$text['label-param']['de-de'] = '';
$text['label-param']['es-mx'] = '';
$text['label-param']['fr-ca'] = '';
$text['label-param']['fr-fr'] = '';
$text['label-param']['he-il'] = '';
$text['label-param']['it-it'] = '';
$text['label-param']['nl-nl'] = '';
$text['label-param']['pl-pl'] = '';
$text['label-param']['pt-br'] = '';
$text['label-param']['pt-pt'] = '';
$text['label-param']['ro-ro'] = '';
$text['label-param']['ru-ru'] = '';
$text['label-param']['sv-se'] = '';
$text['label-param']['uk-ua'] = '';
$text['label-variable']['en-us'] = 'variable';
$text['label-variable']['ar-eg'] = '';
$text['label-variable']['de-at'] = '';
$text['label-variable']['de-ch'] = '';
$text['label-variable']['de-de'] = '';
$text['label-variable']['es-mx'] = '';
$text['label-variable']['fr-ca'] = '';
$text['label-variable']['fr-fr'] = '';
$text['label-variable']['he-il'] = '';
$text['label-variable']['it-it'] = '';
$text['label-variable']['nl-nl'] = '';
$text['label-variable']['pl-pl'] = '';
$text['label-variable']['pt-br'] = '';
$text['label-variable']['pt-pt'] = '';
$text['label-variable']['ro-ro'] = '';
$text['label-variable']['ru-ru'] = '';
$text['label-variable']['sv-se'] = '';
$text['label-variable']['uk-ua'] = '';
$text['label-extension_setting_name']['en-us'] = 'Name';
$text['label-extension_setting_name']['ar-eg'] = '';
$text['label-extension_setting_name']['de-at'] = '';
$text['label-extension_setting_name']['de-ch'] = '';
$text['label-extension_setting_name']['de-de'] = '';
$text['label-extension_setting_name']['es-cl'] = '';
$text['label-extension_setting_name']['es-mx'] = '';
$text['label-extension_setting_name']['fr-ca'] = '';
$text['label-extension_setting_name']['fr-fr'] = '';
$text['label-extension_setting_name']['he-il'] = '';
$text['label-extension_setting_name']['it-it'] = '';
$text['label-extension_setting_name']['nl-nl'] = '';
$text['label-extension_setting_name']['pl-pl'] = '';
$text['label-extension_setting_name']['pt-br'] = '';
$text['label-extension_setting_name']['pt-pt'] = '';
$text['label-extension_setting_name']['ro-ro'] = '';
$text['label-extension_setting_name']['ru-ru'] = '';
$text['label-extension_setting_name']['sv-se'] = '';
$text['label-extension_setting_name']['uk-ua'] = '';
$text['description-extension_setting_name']['en-us'] = 'Enter the extension name.';
$text['description-extension_setting_name']['ar-eg'] = '';
$text['description-extension_setting_name']['de-at'] = '';
$text['description-extension_setting_name']['de-ch'] = '';
$text['description-extension_setting_name']['de-de'] = '';
$text['description-extension_setting_name']['es-cl'] = '';
$text['description-extension_setting_name']['es-mx'] = '';
$text['description-extension_setting_name']['fr-ca'] = '';
$text['description-extension_setting_name']['fr-fr'] = '';
$text['description-extension_setting_name']['he-il'] = '';
$text['description-extension_setting_name']['it-it'] = '';
$text['description-extension_setting_name']['nl-nl'] = '';
$text['description-extension_setting_name']['pl-pl'] = '';
$text['description-extension_setting_name']['pt-br'] = '';
$text['description-extension_setting_name']['pt-pt'] = '';
$text['description-extension_setting_name']['ro-ro'] = '';
$text['description-extension_setting_name']['ru-ru'] = '';
$text['description-extension_setting_name']['sv-se'] = '';
$text['description-extension_setting_name']['uk-ua'] = '';
$text['label-extension_setting_value']['en-us'] = 'Value';
$text['label-extension_setting_value']['ar-eg'] = '';
$text['label-extension_setting_value']['de-at'] = '';
$text['label-extension_setting_value']['de-ch'] = '';
$text['label-extension_setting_value']['de-de'] = '';
$text['label-extension_setting_value']['es-cl'] = '';
$text['label-extension_setting_value']['es-mx'] = '';
$text['label-extension_setting_value']['fr-ca'] = '';
$text['label-extension_setting_value']['fr-fr'] = '';
$text['label-extension_setting_value']['he-il'] = '';
$text['label-extension_setting_value']['it-it'] = '';
$text['label-extension_setting_value']['nl-nl'] = '';
$text['label-extension_setting_value']['pl-pl'] = '';
$text['label-extension_setting_value']['pt-br'] = '';
$text['label-extension_setting_value']['pt-pt'] = '';
$text['label-extension_setting_value']['ro-ro'] = '';
$text['label-extension_setting_value']['ru-ru'] = '';
$text['label-extension_setting_value']['sv-se'] = '';
$text['label-extension_setting_value']['uk-ua'] = '';
$text['description-extension_setting_value']['en-us'] = 'Enter the extension value.';
$text['description-extension_setting_value']['ar-eg'] = '';
$text['description-extension_setting_value']['de-at'] = '';
$text['description-extension_setting_value']['de-ch'] = '';
$text['description-extension_setting_value']['de-de'] = '';
$text['description-extension_setting_value']['es-cl'] = '';
$text['description-extension_setting_value']['es-mx'] = '';
$text['description-extension_setting_value']['fr-ca'] = '';
$text['description-extension_setting_value']['fr-fr'] = '';
$text['description-extension_setting_value']['he-il'] = '';
$text['description-extension_setting_value']['it-it'] = '';
$text['description-extension_setting_value']['nl-nl'] = '';
$text['description-extension_setting_value']['pl-pl'] = '';
$text['description-extension_setting_value']['pt-br'] = '';
$text['description-extension_setting_value']['pt-pt'] = '';
$text['description-extension_setting_value']['ro-ro'] = '';
$text['description-extension_setting_value']['ru-ru'] = '';
$text['description-extension_setting_value']['sv-se'] = '';
$text['description-extension_setting_value']['uk-ua'] = '';
$text['label-extension_setting_enabled']['en-us'] = 'Enabled';
$text['label-extension_setting_enabled']['ar-eg'] = '';
$text['label-extension_setting_enabled']['de-at'] = '';
$text['label-extension_setting_enabled']['de-ch'] = '';
$text['label-extension_setting_enabled']['de-de'] = '';
$text['label-extension_setting_enabled']['es-cl'] = '';
$text['label-extension_setting_enabled']['es-mx'] = '';
$text['label-extension_setting_enabled']['fr-ca'] = '';
$text['label-extension_setting_enabled']['fr-fr'] = '';
$text['label-extension_setting_enabled']['he-il'] = '';
$text['label-extension_setting_enabled']['it-it'] = '';
$text['label-extension_setting_enabled']['nl-nl'] = '';
$text['label-extension_setting_enabled']['pl-pl'] = '';
$text['label-extension_setting_enabled']['pt-br'] = '';
$text['label-extension_setting_enabled']['pt-pt'] = '';
$text['label-extension_setting_enabled']['ro-ro'] = '';
$text['label-extension_setting_enabled']['ru-ru'] = '';
$text['label-extension_setting_enabled']['sv-se'] = '';
$text['label-extension_setting_enabled']['uk-ua'] = '';
$text['description-extension_setting_enabled']['en-us'] = 'Enter the extension enabled.';
$text['description-extension_setting_enabled']['ar-eg'] = '';
$text['description-extension_setting_enabled']['de-at'] = '';
$text['description-extension_setting_enabled']['de-ch'] = '';
$text['description-extension_setting_enabled']['de-de'] = '';
$text['description-extension_setting_enabled']['es-cl'] = '';
$text['description-extension_setting_enabled']['es-mx'] = '';
$text['description-extension_setting_enabled']['fr-ca'] = '';
$text['description-extension_setting_enabled']['fr-fr'] = '';
$text['description-extension_setting_enabled']['he-il'] = '';
$text['description-extension_setting_enabled']['it-it'] = '';
$text['description-extension_setting_enabled']['nl-nl'] = '';
$text['description-extension_setting_enabled']['pl-pl'] = '';
$text['description-extension_setting_enabled']['pt-br'] = '';
$text['description-extension_setting_enabled']['pt-pt'] = '';
$text['description-extension_setting_enabled']['ro-ro'] = '';
$text['description-extension_setting_enabled']['ru-ru'] = '';
$text['description-extension_setting_enabled']['sv-se'] = '';
$text['description-extension_setting_enabled']['uk-ua'] = '';
$text['label-extension_setting_description']['en-us'] = 'Description';
$text['label-extension_setting_description']['ar-eg'] = '';
$text['label-extension_setting_description']['de-at'] = '';
$text['label-extension_setting_description']['de-ch'] = '';
$text['label-extension_setting_description']['de-de'] = '';
$text['label-extension_setting_description']['es-cl'] = '';
$text['label-extension_setting_description']['es-mx'] = '';
$text['label-extension_setting_description']['fr-ca'] = '';
$text['label-extension_setting_description']['fr-fr'] = '';
$text['label-extension_setting_description']['he-il'] = '';
$text['label-extension_setting_description']['it-it'] = '';
$text['label-extension_setting_description']['nl-nl'] = '';
$text['label-extension_setting_description']['pl-pl'] = '';
$text['label-extension_setting_description']['pt-br'] = '';
$text['label-extension_setting_description']['pt-pt'] = '';
$text['label-extension_setting_description']['ro-ro'] = '';
$text['label-extension_setting_description']['ru-ru'] = '';
$text['label-extension_setting_description']['sv-se'] = '';
$text['label-extension_setting_description']['uk-ua'] = '';
$text['description-extension_setting_description']['en-us'] = 'Enter the extension description.';
$text['description-extension_setting_description']['ar-eg'] = '';
$text['description-extension_setting_description']['de-at'] = '';
$text['description-extension_setting_description']['de-ch'] = '';
$text['description-extension_setting_description']['de-de'] = '';
$text['description-extension_setting_description']['es-cl'] = '';
$text['description-extension_setting_description']['es-mx'] = '';
$text['description-extension_setting_description']['fr-ca'] = '';
$text['description-extension_setting_description']['fr-fr'] = '';
$text['description-extension_setting_description']['he-il'] = '';
$text['description-extension_setting_description']['it-it'] = '';
$text['description-extension_setting_description']['nl-nl'] = '';
$text['description-extension_setting_description']['pl-pl'] = '';
$text['description-extension_setting_description']['pt-br'] = '';
$text['description-extension_setting_description']['pt-pt'] = '';
$text['description-extension_setting_description']['ro-ro'] = '';
$text['description-extension_setting_description']['ru-ru'] = '';
$text['description-extension_setting_description']['sv-se'] = '';
$text['description-extension_setting_description']['uk-ua'] = '';
?>

View File

@@ -0,0 +1,362 @@
<?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) 2021
the Initial Developer. All Rights Reserved.
*/
//includes
require_once "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('extension_setting_add') || permission_exists('extension_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";
$extension_setting_uuid = $_REQUEST["id"];
$id = $_REQUEST["id"];
}
else {
$action = "add";
}
//get the extension id
if (is_uuid($_REQUEST["extension_uuid"])) {
$extension_uuid = $_REQUEST["extension_uuid"];
}
//get http post variables and set them to php variables
if (is_array($_POST)) {
$domain_uuid = $_POST["domain_uuid"];
$extension_setting_type = $_POST["extension_setting_type"];
$extension_setting_name = $_POST["extension_setting_name"];
$extension_setting_value = $_POST["extension_setting_value"];
$extension_setting_enabled = $_POST["extension_setting_enabled"];
$extension_setting_description = $_POST["extension_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: extension_settings.php?id='.$extension_uuid);
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('extension_setting_add')) {
$obj = new database;
$obj->copy($array);
}
break;
case 'delete':
if (permission_exists('extension_setting_delete')) {
$obj = new database;
$obj->delete($array);
}
break;
case 'toggle':
if (permission_exists('extension_setting_update')) {
$obj = new database;
$obj->toggle($array);
}
break;
}
//redirect the user
if (in_array($_POST['action'], array('copy', 'delete', 'toggle')) && is_uuid($id) && is_uuid($extension_uuid)) {
header('Location: extension_setting_edit.php?id='.$id.'&extension_uuid='.$extension_uuid);
exit;
}
}
//check for all required data
$msg = '';
//if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."<br>\n"; }
if (strlen($extension_setting_type) == 0) { $msg .= $text['message-required']." ".$text['label-extension_setting_type']."<br>\n"; }
if (strlen($extension_setting_name) == 0) { $msg .= $text['message-required']." ".$text['label-extension_setting_name']."<br>\n"; }
//if (strlen($extension_setting_value) == 0) { $msg .= $text['message-required']." ".$text['label-extension_setting_value']."<br>\n"; }
if (strlen($extension_setting_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-extension_setting_enabled']."<br>\n"; }
//if (strlen($extension_setting_description) == 0) { $msg .= $text['message-required']." ".$text['label-extension_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 extension_setting_uuid
if (!is_uuid($$extension_setting_uuid)) {
$extension_setting_uuid = uuid();
}
//prepare the array
$array['extension_settings'][0]['extension_setting_uuid'] = $extension_setting_uuid;
$array['extension_settings'][0]['extension_uuid'] = $extension_uuid;
$array['extension_settings'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
//$array['extension_settings'][0]['domain_uuid'] = $domain_uuid;
$array['extension_settings'][0]['extension_setting_type'] = $extension_setting_type;
$array['extension_settings'][0]['extension_setting_name'] = $extension_setting_name;
$array['extension_settings'][0]['extension_setting_value'] = $extension_setting_value;
$array['extension_settings'][0]['extension_setting_enabled'] = $extension_setting_enabled;
$array['extension_settings'][0]['extension_setting_description'] = $extension_setting_description;
//save the data
$database = new database;
$database->app_name = 'extension settings';
$database->app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
$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: extension_settings.php');
header('Location: extension_setting_edit.php?id='.urlencode($extension_setting_uuid).'&extension_uuid='.$extension_uuid);
return;
}
}
//pre-populate the form
if (is_array($_GET) && $_POST["persistformvar"] != "true") {
$sql = "select ";
//$sql .= "extension_uuid, ";
//$sql .= "domain_uuid, ";
$sql .= "extension_setting_uuid, ";
$sql .= "extension_setting_type, ";
$sql .= "extension_setting_name, ";
$sql .= "extension_setting_value, ";
$sql .= "cast(extension_setting_enabled as text), ";
$sql .= "extension_setting_description ";
$sql .= "from v_extension_settings ";
$sql .= "where extension_setting_uuid = :extension_setting_uuid ";
//$sql .= "and domain_uuid = :domain_uuid ";
//$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['extension_setting_uuid'] = $extension_setting_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row) && @sizeof($row) != 0) {
if (is_uuid($row["extension_uuid"])) {
$extension_uuid = $row["extension_uuid"];
}
//$domain_uuid = $row["domain_uuid"];
$extension_setting_type = $row["extension_setting_type"];
$extension_setting_name = $row["extension_setting_name"];
$extension_setting_value = $row["extension_setting_value"];
$extension_setting_enabled = $row["extension_setting_enabled"];
$extension_setting_description = $row["extension_setting_description"];
}
unset($sql, $parameters, $row);
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//show the header
$document['title'] = $text['title-extension_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='extension_setting_uuid' value='".escape($extension_setting_uuid)."'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-extension_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'=>'extension_settings.php?id='.$extension_uuid]);
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-extension_settings']."\n";
echo "<br /><br />\n";
if ($action == 'update') {
if (permission_exists('extension_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('extension_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='vncell' valign='top' align='left' nowrap='nowrap'>\n";
//echo " ".$text['label-domain_uuid']."\n";
//echo "</td>\n";
//echo "<td class='vtable' style='position: relative;' align='left'>\n";
//echo " <select class='formfld' name='domain_uuid'>\n";
//if (strlen($domain_uuid) == 0) {
// echo " <option value='' selected='selected'>".$text['select-global']."</option>\n";
//}
//else {
// echo " <option value=''>".$text['label-global']."</option>\n";
//}
//foreach ($_SESSION['domains'] as $row) {
// if ($row['domain_uuid'] == $domain_uuid) {
// echo " <option value='".$row['domain_uuid']."' selected='selected'>".escape($row['domain_name'])."</option>\n";
// }
// else {
// echo " <option value='".$row['domain_uuid']."'>".$row['domain_name']."</option>\n";
// }
//}
//echo " </select>\n";
//echo "<br />\n";
//echo $text['description-domain_uuid']."\n";
//echo "</td>\n";
//echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_type']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <select class='formfld' name='extension_setting_type'>\n";
echo " <option value=''></option>\n";
if ($extension_setting_type == "param") {
echo " <option value='param' selected='selected'>".$text['label-param']."</option>\n";
}
else {
echo " <option value='param'>".$text['label-param']."</option>\n";
}
if ($extension_setting_type == "variable") {
echo " <option value='variable' selected='selected'>".$text['label-variable']."</option>\n";
}
else {
echo " <option value='variable'>".$text['label-variable']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-extension_setting_type']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_name']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='extension_setting_name' maxlength='255' value='".escape($extension_setting_name)."'>\n";
echo "<br />\n";
echo $text['description-extension_setting_name']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension_setting_value']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='extension_setting_value' maxlength='255' value='".escape($extension_setting_value)."'>\n";
echo "<br />\n";
echo $text['description-extension_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-extension_setting_enabled']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <select class='formfld' name='extension_setting_enabled'>\n";
if ($extension_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 ($extension_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-extension_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-extension_setting_description']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='extension_setting_description' maxlength='255' value='".escape($extension_setting_description)."'>\n";
echo "<br />\n";
echo $text['description-extension_setting_description']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br /><br />\n";
echo "<input type='hidden' name='extension_uuid' value='".$extension_uuid."'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>

View File

@@ -0,0 +1,327 @@
<?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) 2021
the Initial Developer. All Rights Reserved.
*/
//includes
require_once "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('extension_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['extension_settings'])) {
$action = $_POST['action'];
$search = $_POST['search'];
$extension_settings = $_POST['extension_settings'];
}
//action add or update
if (is_uuid($_REQUEST["id"])) {
$extension_uuid = $_REQUEST["id"];
}
//process the http post data by action
if ($action != '' && is_array($extension_settings) && @sizeof($extension_settings) != 0) {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: extension_settings.php');
exit;
}
//prepare the array
foreach($extension_settings as $row) {
$array['extension_settings'][$x]['checked'] = $row['checked'];
$array['extension_settings'][$x]['extension_setting_uuid'] = $row['extension_setting_uuid'];
$array['extension_settings'][$x]['extension_setting_enabled'] = $row['extension_setting_enabled'];
$x++;
}
//prepare the database object
$database = new database;
$database->app_name = 'extension_settings';
$database->app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
//send the array to the database class
switch ($action) {
case 'copy':
if (permission_exists('extension_setting_add')) {
$database->copy($array);
}
break;
case 'toggle':
if (permission_exists('extension_setting_edit')) {
$database->toggle($array);
}
break;
case 'delete':
if (permission_exists('extension_setting_delete')) {
$database->delete($array);
}
break;
}
//redirect the user
header('Location: extension_settings.php?id='.urlencode($extension_uuid).'&'.($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(extension_setting_uuid) ";
$sql .= "from v_extension_settings ";
$sql .= "where extension_uuid = :extension_uuid ";
if (isset($search)) {
$sql .= "and (";
$sql .= " lower(extension_setting_type) like :search ";
$sql .= " or lower(extension_setting_name) like :search ";
$sql .= " or lower(extension_setting_description) like :search ";
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
else {
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
if (isset($sql_search)) {
$sql .= "and ".$sql_search;
}
$parameters['domain_uuid'] = $domain_uuid;
}
$parameters['extension_uuid'] = $extension_uuid;
$database = new database;
$num_rows = $database->select($sql, $parameters, 'column');
unset($sql, $parameters);
//get the list
$sql = "select ";
//$sql .= "d.domain_name, ";
$sql .= "extension_setting_uuid, ";
$sql .= "extension_setting_type, ";
$sql .= "extension_setting_name, ";
$sql .= "extension_setting_value, ";
$sql .= "cast(extension_setting_enabled as text), ";
$sql .= "extension_setting_description ";
$sql .= "from v_extension_settings as e ";
//$sql .= ",v_domains as d ";
$sql .= "where extension_uuid = :extension_uuid ";
$sql .= "and (e.domain_uuid = :domain_uuid or e.domain_uuid is null) ";
//$sql .= "and d.domain_uuid = e.domain_uuid ";
if (isset($_GET["search"])) {
$sql .= "and (";
$sql .= " lower(extension_setting_type) like :search ";
$sql .= " or lower(extension_setting_name) like :search ";
$sql .= " or lower(extension_setting_description) like :search ";
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
$sql .= order_by($order_by, $order, 'extension_setting_type', 'asc');
$sql .= limit_offset($rows_per_page, $offset);
$parameters['extension_uuid'] = $extension_uuid;
$parameters['domain_uuid'] = $domain_uuid;
$database = new database;
$extension_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-extension_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-extension_settings']." (".$num_rows.")</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_add','name'=>'btn_add','link'=>'/app/extensions/extension_edit.php?id='.$extension_uuid]);
if (permission_exists('extension_setting_add')) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','name'=>'btn_add','link'=>'extension_setting_edit.php?extension_uuid='.$extension_uuid]);
}
if (permission_exists('extension_setting_add') && $extension_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('extension_setting_edit') && $extension_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('extension_setting_delete') && $extension_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";
//if (permission_exists('extension_setting_all')) {
// if ($_GET['show'] == 'all') {
// echo " <input type='hidden' name='show' value='all'>\n";
// }
// else {
// echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?show=all&id='.$extension_uuid]);
// }
//}
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'=>'extension_settings.php?id='.$extension_uuid,'style'=>($search == '' ? 'display: none;' : null)]);
if ($paging_controls_mini != '') {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
}
echo " <input type='hidden' name='id' value='".$extension_uuid."'>\n";
echo " </form>\n";
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (permission_exists('extension_setting_add') && $extension_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('extension_setting_edit') && $extension_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('extension_setting_delete') && $extension_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-extension_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";
if (is_array($extension_settings) && @sizeof($extension_settings) != 0) {
$x = 0;
foreach ($extension_settings as $row) {
$extension_setting_type = $row['extension_setting_type'];
$extension_setting_type = strtolower($extension_setting_type);
$label_extension_setting_type = $row['extension_setting_type'];
$label_extension_setting_type = str_replace("_", " ", $label_extension_setting_type);
$label_extension_setting_type = str_replace("-", " ", $label_extension_setting_type);
$label_extension_setting_type = ucwords($label_extension_setting_type);
if ($previous_extension_setting_type !== $row['extension_setting_type']) {
echo " <tr>";
echo " <td align='left' colspan='999'>&nbsp;</td>\n";
echo " </tr>";
echo " <tr>";
echo " <td align='left' colspan='999' nowrap='nowrap'><b>".escape($label_extension_setting_type)."</b></td>\n";
echo " </tr>";
echo "<tr class='list-header'>\n";
if (permission_exists('extension_setting_add') || permission_exists('extension_setting_edit') || permission_exists('extension_setting_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all_".$extension_setting_type."' name='checkbox_all' onclick=\"list_all_toggle('".$extension_setting_type."'); checkbox_on_change(this);\">\n";
echo " </th>\n";
}
//if ($_GET['show'] == 'all' && permission_exists('extension_setting_all')) {
// echo th_order_by('domain_name', $text['label-domain'], $order_by, $order);
//}
//echo th_order_by('extension_setting_type', $text['label-extension_setting_type'], $order_by, $order);
//echo th_order_by('extension_setting_name', $text['label-extension_setting_name'], $order_by, $order);
//echo th_order_by('extension_setting_value', $text['label-extension_setting_value'], $order_by, $order);
//echo th_order_by('extension_setting_enabled', $text['label-extension_setting_enabled'], $order_by, $order, null, "class='center'");
echo " <th>".$text['label-extension_setting_type']."</th>\n";
echo " <th>".$text['label-extension_setting_name']."</th>\n";
echo " <th>".$text['label-extension_setting_value']."</th>\n";
echo " <th class='center'>".$text['label-extension_setting_enabled']."</th>\n";
echo " <th class='hide-sm-dn'>".$text['label-extension_setting_description']."</th>\n";
if (permission_exists('extension_setting_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
}
if (permission_exists('extension_setting_edit')) {
$list_row_url = "extension_setting_edit.php?id=".urlencode($row['extension_setting_uuid'])."&extension_uuid=".urlencode($extension_uuid);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('extension_setting_add') || permission_exists('extension_setting_edit') || permission_exists('extension_setting_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='extension_settings[$x][checked]' id='checkbox_".$x."' class='checkbox_".$extension_setting_type."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all_".$extension_setting_type."').checked = false; }\">\n";
echo " <input type='hidden' name='extension_settings[$x][extension_setting_uuid]' value='".escape($row['extension_setting_uuid'])."' />\n";
echo " </td>\n";
}
//if ($_GET['show'] == 'all' && permission_exists('extension_setting_all')) {
// echo " <td>".escape($row['domain_name'])."</td>\n";
//}
echo " <td>".escape($row['extension_setting_type'])."</td>\n";
echo " <td>".escape($row['extension_setting_name'])."</td>\n";
echo " <td>".escape($row['extension_setting_value'])."</td>\n";
if (permission_exists('extension_setting_edit')) {
echo " <td class='no-link center'>\n";
echo " <input type='hidden' name='number_translations[$x][extension_setting_enabled]' value='".escape($row['extension_setting_enabled'])."' />\n";
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['extension_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['extension_setting_enabled']];
}
echo " </td>\n";
echo " <td class='description overflow hide-sm-dn'>".escape($row['extension_setting_description'])."</td>\n";
if (permission_exists('extension_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";
//set the previous category
$previous_extension_setting_type = $row['extension_setting_type'];
$x++;
}
unset($extension_settings);
}
echo "</table>\n";
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "<input type='hidden' name='".$id."' value='".$extension_uuid."'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//include the footer
require_once "resources/footer.php";
?>

View File

@@ -0,0 +1,266 @@
<?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) 2021
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
/**
* extension_settings class
*
* @method null delete
* @method null toggle
* @method null copy
*/
if (!class_exists('extension_settings')) {
class extension_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 = 'extension_settings';
$this->app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
$this->name = 'extension_setting';
$this->table = 'extension_settings';
$this->toggle_field = 'extension_setting_enabled';
$this->toggle_values = ['true','false'];
$this->description_field = 'extension_setting_description';
$this->location = 'extension_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][$this->name.'_uuid'] = $record['uuid'];
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_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['uuid'])) {
$uuids[] = "'".$record['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).") ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$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($record['uuid'])) {
$uuids[] = "'".$record['uuid']."'";
}
}
//create the array from existing data
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select * from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$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][$this->name.'_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);
}
}
}
}
}
?>

90
app/extension_settings/root.php Executable file
View File

@@ -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"]);
}
?>