2012-06-04 16:58:40 +02:00
|
|
|
<?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>
|
2023-06-07 00:05:05 +02:00
|
|
|
Portions created by the Initial Developer are Copyright (C) 2008-2023
|
2012-06-04 16:58:40 +02:00
|
|
|
the Initial Developer. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
Contributor(s):
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
|
|
|
|
*/
|
2018-07-01 01:23:54 +02:00
|
|
|
|
2022-10-11 00:35:14 +02:00
|
|
|
//includes files
|
2023-06-15 19:28:23 +02:00
|
|
|
require_once dirname(__DIR__, 2) . "/resources/require.php";
|
2018-07-01 01:23:54 +02:00
|
|
|
require_once "resources/check_auth.php";
|
|
|
|
|
|
|
|
|
|
//check permissions
|
|
|
|
|
if (permission_exists('module_add') || permission_exists('module_edit')) {
|
|
|
|
|
//access granted
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo "access denied";
|
|
|
|
|
exit;
|
|
|
|
|
}
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2013-05-29 23:46:48 +02:00
|
|
|
//add multi-lingual support
|
2015-01-18 11:06:08 +01:00
|
|
|
$language = new text;
|
|
|
|
|
$text = $language->get();
|
2013-05-29 23:46:48 +02:00
|
|
|
|
2023-05-25 18:52:28 +02:00
|
|
|
//define the variables
|
|
|
|
|
$module_label = '';
|
|
|
|
|
$modules = '';
|
|
|
|
|
$module_name = '';
|
|
|
|
|
$module_description = '';
|
|
|
|
|
$module_category = '';
|
|
|
|
|
$module_order = '';
|
|
|
|
|
$module_enabled = '';
|
|
|
|
|
$module_default_enabled = '';
|
|
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
//determin the action add or update
|
2023-05-25 18:52:28 +02:00
|
|
|
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
|
2012-06-04 16:58:40 +02:00
|
|
|
$action = "update";
|
2019-08-09 18:23:44 +02:00
|
|
|
$module_uuid = $_REQUEST["id"];
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$action = "add";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//set the http post variables to php variables
|
2023-05-25 18:52:28 +02:00
|
|
|
if (!empty($_POST)) {
|
2019-08-09 18:23:44 +02:00
|
|
|
$module_label = $_POST["module_label"];
|
|
|
|
|
$module_name = $_POST["module_name"];
|
|
|
|
|
$module_description = $_POST["module_description"];
|
|
|
|
|
$module_category = $_POST["module_category"];
|
|
|
|
|
$module_order = $_POST["module_order"];
|
2023-06-07 00:05:05 +02:00
|
|
|
$module_enabled = $_POST["module_enabled"] ?? 'false';
|
|
|
|
|
$module_default_enabled = $_POST["module_default_enabled"] ?? 'false';
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
|
2018-07-01 01:23:54 +02:00
|
|
|
//process the data
|
2023-05-25 18:52:28 +02:00
|
|
|
if (!empty($_POST) && empty($_POST["persistformvar"])) {
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2018-07-01 01:23:54 +02:00
|
|
|
//get the uuid
|
|
|
|
|
if ($action == "update") {
|
2019-08-09 18:23:44 +02:00
|
|
|
$module_uuid = $_POST["module_uuid"];
|
2018-07-01 01:23:54 +02:00
|
|
|
}
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2019-09-19 14:40:56 +02:00
|
|
|
//validate the token
|
|
|
|
|
$token = new token;
|
|
|
|
|
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
|
|
|
|
message::add($text['message-invalid_token'],'negative');
|
|
|
|
|
header('Location: modules.php');
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-01 01:23:54 +02:00
|
|
|
//check for all required data
|
|
|
|
|
$msg = '';
|
2023-05-05 18:46:37 +02:00
|
|
|
if (empty($module_label)) { $msg .= $text['message-required'].$text['label-label']."<br>\n"; }
|
|
|
|
|
if (empty($module_name)) { $msg .= $text['message-required'].$text['label-module_name']."<br>\n"; }
|
|
|
|
|
//if (empty($module_description)) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; }
|
|
|
|
|
if (empty($module_category)) { $msg .= $text['message-required'].$text['label-module_category']."<br>\n"; }
|
|
|
|
|
if (empty($module_enabled)) { $msg .= $text['message-required'].$text['label-enabled']."<br>\n"; }
|
|
|
|
|
if (empty($module_default_enabled)) { $msg .= $text['message-required'].$text['label-default_enabled']."<br>\n"; }
|
|
|
|
|
if (!empty($msg) && empty($_POST["persistformvar"])) {
|
2018-07-01 01:23:54 +02:00
|
|
|
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";
|
2012-06-04 16:58:40 +02:00
|
|
|
return;
|
2018-07-01 01:23:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//add or update the database
|
2023-05-25 18:52:28 +02:00
|
|
|
if (empty($_POST["persistformvar"])) {
|
2018-07-01 01:23:54 +02:00
|
|
|
if ($action == "add" && permission_exists('module_add')) {
|
|
|
|
|
$module_uuid = uuid();
|
2019-08-09 18:23:44 +02:00
|
|
|
$array['modules'][0]['module_uuid'] = $module_uuid;
|
2018-07-01 01:23:54 +02:00
|
|
|
|
2018-08-31 05:09:01 +02:00
|
|
|
message::add($text['message-add']);
|
2019-08-09 18:23:44 +02:00
|
|
|
}
|
2018-07-01 01:23:54 +02:00
|
|
|
|
|
|
|
|
if ($action == "update" && permission_exists('module_edit')) {
|
2019-08-09 18:23:44 +02:00
|
|
|
$array['modules'][0]['module_uuid'] = $module_uuid;
|
2018-07-01 01:23:54 +02:00
|
|
|
|
2018-08-31 05:09:01 +02:00
|
|
|
message::add($text['message-update']);
|
2019-08-09 18:23:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//add common array elements and execute
|
|
|
|
|
if (is_array($array) && @sizeof($array) != 0) {
|
|
|
|
|
$array['modules'][0]['module_label'] = $module_label;
|
|
|
|
|
$array['modules'][0]['module_name'] = $module_name;
|
|
|
|
|
$array['modules'][0]['module_description'] = $module_description;
|
|
|
|
|
$array['modules'][0]['module_category'] = $module_category;
|
|
|
|
|
$array['modules'][0]['module_order'] = $module_order;
|
|
|
|
|
$array['modules'][0]['module_enabled'] = $module_enabled;
|
|
|
|
|
$array['modules'][0]['module_default_enabled'] = $module_default_enabled;
|
|
|
|
|
|
|
|
|
|
$database = new database;
|
|
|
|
|
$database->app_name = 'modules';
|
|
|
|
|
$database->app_uuid = '5eb9cba1-8cb6-5d21-e36a-775475f16b5e';
|
|
|
|
|
$database->save($array);
|
|
|
|
|
unset($array);
|
|
|
|
|
|
|
|
|
|
$module = new modules;
|
|
|
|
|
$module->xml();
|
|
|
|
|
|
2018-07-01 01:23:54 +02:00
|
|
|
header("Location: modules.php");
|
2019-08-09 18:23:44 +02:00
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2012-06-04 16:58:40 +02:00
|
|
|
|
|
|
|
|
//pre-populate the form
|
2023-05-25 18:52:28 +02:00
|
|
|
if (!empty($_GET) && empty($_POST["persistformvar"])) {
|
2012-06-04 16:58:40 +02:00
|
|
|
$module_uuid = $_GET["id"];
|
2012-11-24 02:05:27 +01:00
|
|
|
$sql = "select * from v_modules ";
|
2019-08-09 18:23:44 +02:00
|
|
|
$sql .= "where module_uuid = :module_uuid ";
|
|
|
|
|
$parameters['module_uuid'] = $module_uuid;
|
|
|
|
|
$database = new database;
|
|
|
|
|
$row = $database->select($sql, $parameters, 'row');
|
|
|
|
|
if (is_array($row) && @sizeof($row) != 0) {
|
2012-06-04 16:58:40 +02:00
|
|
|
$module_label = $row["module_label"];
|
|
|
|
|
$module_name = $row["module_name"];
|
|
|
|
|
$module_description = $row["module_description"];
|
|
|
|
|
$module_category = $row["module_category"];
|
2016-05-25 07:16:30 +02:00
|
|
|
$module_order = $row["module_order"];
|
2012-06-04 16:58:40 +02:00
|
|
|
$module_enabled = $row["module_enabled"];
|
|
|
|
|
$module_default_enabled = $row["module_default_enabled"];
|
|
|
|
|
}
|
2019-08-09 18:23:44 +02:00
|
|
|
unset($sql, $parameters, $row);
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
|
2023-02-17 22:21:41 +01:00
|
|
|
//set the defaults
|
2023-05-05 18:46:37 +02:00
|
|
|
if (empty($module_enabled)) { $module_enabled = 'true'; }
|
|
|
|
|
if (empty($module_default_enabled)) { $module_default_enabled = 'true'; }
|
2023-02-17 22:21:41 +01:00
|
|
|
|
2019-09-19 14:40:56 +02:00
|
|
|
//create token
|
|
|
|
|
$object = new token;
|
|
|
|
|
$token = $object->create($_SERVER['PHP_SELF']);
|
|
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
//show the header
|
2013-05-29 23:46:48 +02:00
|
|
|
if ($action == "add") {
|
2014-07-10 02:32:50 +02:00
|
|
|
$document['title'] = $text['title-module_add'];
|
2013-05-29 23:46:48 +02:00
|
|
|
}
|
|
|
|
|
if ($action == "update") {
|
2014-07-10 02:32:50 +02:00
|
|
|
$document['title'] = $text['title-module_edit'];
|
2013-05-29 23:46:48 +02:00
|
|
|
}
|
2020-02-11 04:56:48 +01:00
|
|
|
require_once "resources/header.php";
|
2012-06-04 16:58:40 +02:00
|
|
|
|
|
|
|
|
//show the content
|
2020-03-05 18:02:25 +01:00
|
|
|
echo "<form method='post' name='frm' id='frm'>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2020-02-11 04:56:48 +01:00
|
|
|
echo "<div class='action_bar' id='action_bar'>\n";
|
|
|
|
|
echo " <div class='heading'>";
|
2012-06-04 16:58:40 +02:00
|
|
|
if ($action == "add") {
|
2020-02-11 04:56:48 +01:00
|
|
|
echo "<b>".$text['header-module_add']."</b>";
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
if ($action == "update") {
|
2020-02-11 04:56:48 +01:00
|
|
|
echo "<b>".$text['header-module_edit']."</b>";
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
2020-02-11 04:56:48 +01:00
|
|
|
echo " </div>\n";
|
|
|
|
|
echo " <div class='actions'>\n";
|
2020-03-05 08:05:45 +01:00
|
|
|
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'modules.php']);
|
|
|
|
|
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','id'=>'btn_save']);
|
2020-02-11 04:56:48 +01:00
|
|
|
echo " </div>\n";
|
|
|
|
|
echo " <div style='clear: both;'></div>\n";
|
|
|
|
|
echo "</div>\n";
|
|
|
|
|
|
2025-02-25 20:35:23 +01:00
|
|
|
echo "<div class='card'>\n";
|
2020-02-11 04:56:48 +01:00
|
|
|
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
|
|
|
|
|
echo "<tr>\n";
|
2020-02-11 04:56:48 +01:00
|
|
|
echo "<td width='30%' class='vncellreq' valign='top' align='left' nowrap>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " ".$text['label-label']."\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
2020-02-11 04:56:48 +01:00
|
|
|
echo "<td width='70%' class='vtable' align='left'>\n";
|
2018-07-01 01:23:54 +02:00
|
|
|
echo " <input class='formfld' type='text' name='module_label' maxlength='255' value=\"".escape($module_label)."\">\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
|
|
|
|
echo "<tr>\n";
|
2018-07-01 01:23:54 +02:00
|
|
|
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " ".$text['label-module_name']."\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2018-07-01 01:23:54 +02:00
|
|
|
echo " <input class='formfld' type='text' name='module_name' maxlength='255' value=\"".escape($module_name)."\">\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
2016-05-25 07:16:30 +02:00
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
|
2016-05-25 07:26:51 +02:00
|
|
|
echo " ".$text['label-order']."\n";
|
2016-05-25 07:16:30 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2018-07-01 01:23:54 +02:00
|
|
|
echo " <input class='formfld' type='text' name='module_order' maxlength='255' value=\"".escape($module_order)."\">\n";
|
2016-05-25 07:16:30 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " ".$text['label-module_category']."\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2019-08-29 01:53:34 +02:00
|
|
|
$table_name = 'v_modules';
|
|
|
|
|
$field_name = 'module_category';
|
|
|
|
|
$sql_where_optional = '';
|
|
|
|
|
$field_current_value = $module_category;
|
2023-06-09 19:51:01 +02:00
|
|
|
echo html_select_other($table_name, $field_name, $sql_where_optional, $field_current_value, $field_name.' asc', $text['label-other']);
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " ".$text['label-enabled']."\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2023-02-14 02:02:01 +01:00
|
|
|
if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') {
|
|
|
|
|
echo " <label class='switch'>\n";
|
|
|
|
|
echo " <input type='checkbox' id='module_enabled' name='module_enabled' value='true' ".($module_enabled == 'true' ? "checked='checked'" : null).">\n";
|
|
|
|
|
echo " <span class='slider'></span>\n";
|
|
|
|
|
echo " </label>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2023-02-14 02:02:01 +01:00
|
|
|
echo " <select class='formfld' id='module_enabled' name='module_enabled'>\n";
|
|
|
|
|
echo " <option value='true' ".($module_enabled == 'true' ? "selected='selected'" : null).">".$text['option-true']."</option>\n";
|
2023-02-14 19:19:02 +01:00
|
|
|
echo " <option value='false' ".($module_enabled == 'false' ? "selected='selected'" : null).">".$text['option-false']."</option>\n";
|
2023-02-14 02:02:01 +01:00
|
|
|
echo " </select>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " ".$text['label-default_enabled']."\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2023-02-14 02:02:01 +01:00
|
|
|
if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') {
|
|
|
|
|
echo " <label class='switch'>\n";
|
|
|
|
|
echo " <input type='checkbox' id='module_default_enabled' name='module_default_enabled' value='true' ".($module_default_enabled == 'true' ? "checked='checked'" : null).">\n";
|
|
|
|
|
echo " <span class='slider'></span>\n";
|
|
|
|
|
echo " </label>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2023-02-14 02:02:01 +01:00
|
|
|
echo " <select class='formfld' id='module_default_enabled' name='module_default_enabled'>\n";
|
|
|
|
|
echo " <option value='true' ".($module_default_enabled == 'true' ? "selected='selected'" : null).">".$text['option-true']."</option>\n";
|
2023-02-14 19:19:02 +01:00
|
|
|
echo " <option value='false' ".($module_default_enabled == 'false' ? "selected='selected'" : null).">".$text['option-false']."</option>\n";
|
2023-02-14 02:02:01 +01:00
|
|
|
echo " </select>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
2014-06-22 08:35:33 +02:00
|
|
|
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " ".$text['label-description']."\n";
|
2014-06-22 08:35:33 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2018-07-01 01:23:54 +02:00
|
|
|
echo " <input class='formfld' type='text' name='module_description' maxlength='255' value=\"".escape($module_description)."\">\n";
|
2014-06-22 08:35:33 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</table>";
|
2025-02-25 20:35:23 +01:00
|
|
|
echo "</div>";
|
2015-02-15 08:59:02 +01:00
|
|
|
echo "<br><br>";
|
2020-02-11 04:56:48 +01:00
|
|
|
|
|
|
|
|
if ($action == "update") {
|
|
|
|
|
echo "<input type='hidden' name='module_uuid' value='".escape($module_uuid)."'>\n";
|
|
|
|
|
}
|
|
|
|
|
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
|
|
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</form>";
|
|
|
|
|
|
2018-07-01 01:23:54 +02:00
|
|
|
//include the footer
|
2013-07-06 08:29:50 +02:00
|
|
|
require_once "resources/footer.php";
|
2018-07-01 01:23:54 +02:00
|
|
|
|
2023-02-14 02:02:01 +01:00
|
|
|
?>
|