Update menu_edit.php
This commit is contained in:
parent
f615fdd10c
commit
dc53519fdf
|
|
@ -17,22 +17,26 @@
|
||||||
|
|
||||||
The Initial Developer of the Original Code is
|
The Initial Developer of the Original Code is
|
||||||
Mark J Crane <markjcrane@fusionpbx.com>
|
Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
Portions created by the Initial Developer are Copyright (C) 2008-2015
|
Portions created by the Initial Developer are Copyright (C) 2008-2019
|
||||||
the Initial Developer. All Rights Reserved.
|
the Initial Developer. All Rights Reserved.
|
||||||
|
|
||||||
Contributor(s):
|
Contributor(s):
|
||||||
Mark J Crane <markjcrane@fusionpbx.com>
|
Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
*/
|
*/
|
||||||
require_once "root.php";
|
|
||||||
require_once "resources/require.php";
|
//includes
|
||||||
require_once "resources/check_auth.php";
|
require_once "root.php";
|
||||||
if (permission_exists('menu_add') || permission_exists('menu_edit')) {
|
require_once "resources/require.php";
|
||||||
//access granted
|
require_once "resources/check_auth.php";
|
||||||
}
|
|
||||||
else {
|
//check permissions
|
||||||
echo "access denied";
|
if (permission_exists('menu_add') || permission_exists('menu_edit')) {
|
||||||
exit;
|
//access granted
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
echo "access denied";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
//add multi-lingual support
|
//add multi-lingual support
|
||||||
$language = new text;
|
$language = new text;
|
||||||
|
|
@ -48,98 +52,87 @@ else {
|
||||||
}
|
}
|
||||||
|
|
||||||
//get http post variables and set them to php variables
|
//get http post variables and set them to php variables
|
||||||
if (count($_POST)>0) {
|
if (count($_POST) > 0) {
|
||||||
$menu_uuid = $_POST["menu_uuid"];
|
$menu_uuid = $_POST["menu_uuid"];
|
||||||
$menu_name = $_POST["menu_name"];
|
$menu_name = $_POST["menu_name"];
|
||||||
$menu_language = $_POST["menu_language"];
|
$menu_language = $_POST["menu_language"];
|
||||||
$menu_description = $_POST["menu_description"];
|
$menu_description = $_POST["menu_description"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
//process the http post
|
||||||
|
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||||
|
|
||||||
$msg = '';
|
//validate the token
|
||||||
if ($action == "update") {
|
$token = new token;
|
||||||
$menu_uuid = $_POST["menu_uuid"];
|
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||||
}
|
message::add($text['message-invalid_token'],'negative');
|
||||||
|
header('Location: menu.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
//validate the token
|
//check for all required data
|
||||||
$token = new token;
|
$msg = '';
|
||||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
//if (strlen($menu_name) == 0) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; }
|
||||||
message::add($text['message-invalid_token'],'negative');
|
//if (strlen($menu_language) == 0) { $msg .= $text['message-required'].$text['label-language']."<br>\n"; }
|
||||||
header('Location: menu.php');
|
//if (strlen($menu_description) == 0) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; }
|
||||||
exit;
|
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||||
}
|
require_once "resources/header.php";
|
||||||
|
require_once "resources/persist_form_var.php";
|
||||||
//check for all required data
|
echo "<div align='center'>\n";
|
||||||
//if (strlen($menu_name) == 0) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; }
|
echo "<table><tr><td>\n";
|
||||||
//if (strlen($menu_language) == 0) { $msg .= $text['message-required'].$text['label-language']."<br>\n"; }
|
echo $msg."<br />";
|
||||||
//if (strlen($menu_description) == 0) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; }
|
echo "</td></tr></table>\n";
|
||||||
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
persistformvar($_POST);
|
||||||
require_once "resources/header.php";
|
echo "</div>\n";
|
||||||
require_once "resources/persist_form_var.php";
|
require_once "resources/footer.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 or update the database
|
|
||||||
if ($_POST["persistformvar"] != "true") {
|
|
||||||
if ($action == "add") {
|
|
||||||
//create a new unique id
|
|
||||||
$menu_uuid = uuid();
|
|
||||||
|
|
||||||
//start a new menu
|
|
||||||
$array['menus'][0]['menu_uuid'] = $menu_uuid;
|
|
||||||
$array['menus'][0]['menu_name'] = $menu_name;
|
|
||||||
$array['menus'][0]['menu_language'] = $menu_language;
|
|
||||||
$array['menus'][0]['menu_description'] = $menu_description;
|
|
||||||
$database = new database;
|
|
||||||
$database->app_name = 'menu';
|
|
||||||
$database->app_uuid = 'f4b3b3d2-6287-489c-2a00-64529e46f2d7';
|
|
||||||
$database->save($array);
|
|
||||||
unset($array);
|
|
||||||
|
|
||||||
//add the default items in the menu
|
|
||||||
require_once "resources/classes/menu.php";
|
|
||||||
$menu = new menu;
|
|
||||||
$menu->db = $db;
|
|
||||||
$menu->menu_uuid = $menu_uuid;
|
|
||||||
$menu->menu_language = $menu_language;
|
|
||||||
$menu->restore();
|
|
||||||
|
|
||||||
//redirect the user back to the main menu
|
|
||||||
message::add($text['message-add']);
|
|
||||||
header("Location: menu.php");
|
|
||||||
return;
|
return;
|
||||||
} //if ($action == "add")
|
}
|
||||||
|
|
||||||
if ($action == "update") {
|
//add or update the database
|
||||||
//update the menu
|
if ($_POST["persistformvar"] != "true") {
|
||||||
$array['menus'][0]['menu_uuid'] = $menu_uuid;
|
if ($action == "add") {
|
||||||
$array['menus'][0]['menu_name'] = $menu_name;
|
//create a new unique id
|
||||||
$array['menus'][0]['menu_language'] = $menu_language;
|
$menu_uuid = uuid();
|
||||||
$array['menus'][0]['menu_description'] = $menu_description;
|
|
||||||
$database = new database;
|
|
||||||
$database->app_name = 'menu';
|
|
||||||
$database->app_uuid = 'f4b3b3d2-6287-489c-2a00-64529e46f2d7';
|
|
||||||
$database->save($array);
|
|
||||||
unset($array);
|
|
||||||
|
|
||||||
//redirect the user back to the main menu
|
//start a new menu
|
||||||
message::add($text['message-update']);
|
$array['menus'][0]['menu_uuid'] = $menu_uuid;
|
||||||
header("Location: menu.php");
|
$array['menus'][0]['menu_name'] = $menu_name;
|
||||||
return;
|
$array['menus'][0]['menu_language'] = $menu_language;
|
||||||
|
$array['menus'][0]['menu_description'] = $menu_description;
|
||||||
|
$database = new database;
|
||||||
|
$database->app_name = 'menu';
|
||||||
|
$database->app_uuid = 'f4b3b3d2-6287-489c-2a00-64529e46f2d7';
|
||||||
|
$database->save($array);
|
||||||
|
unset($array);
|
||||||
|
|
||||||
|
//redirect the user back to the main menu
|
||||||
|
message::add($text['message-add']);
|
||||||
|
header("Location: menu.php");
|
||||||
|
return;
|
||||||
|
} //if ($action == "add")
|
||||||
|
|
||||||
|
if ($action == "update") {
|
||||||
|
//update the menu
|
||||||
|
$array['menus'][0]['menu_uuid'] = $menu_uuid;
|
||||||
|
$array['menus'][0]['menu_name'] = $menu_name;
|
||||||
|
$array['menus'][0]['menu_language'] = $menu_language;
|
||||||
|
$array['menus'][0]['menu_description'] = $menu_description;
|
||||||
|
$database = new database;
|
||||||
|
$database->app_name = 'menu';
|
||||||
|
$database->app_uuid = 'f4b3b3d2-6287-489c-2a00-64529e46f2d7';
|
||||||
|
$database->save($array);
|
||||||
|
unset($array);
|
||||||
|
|
||||||
|
//redirect the user back to the main menu
|
||||||
|
message::add($text['message-update']);
|
||||||
|
header("Location: menu.php");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//pre-populate the form
|
//pre-populate the form
|
||||||
if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
|
if (count($_GET) > 0 && is_array($_GET["id"]) && $_POST["persistformvar"] != "true") {
|
||||||
$menu_uuid = $_GET["id"];
|
$menu_uuid = $_GET["id"];
|
||||||
$sql = "select * from v_menus ";
|
$sql = "select * from v_menus ";
|
||||||
$sql .= "where menu_uuid = :menu_uuid ";
|
$sql .= "where menu_uuid = :menu_uuid ";
|
||||||
|
|
@ -251,4 +244,5 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||||
|
|
||||||
//include the footer
|
//include the footer
|
||||||
require_once "resources/footer.php";
|
require_once "resources/footer.php";
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue