Started work on additional assets per ticket, added table ticket_assets, Fixed Legacy Check User Role Functions

This commit is contained in:
johnnyq 2025-03-11 15:10:23 -04:00
parent 4921d1eb19
commit f61c30bd5a
6 changed files with 43 additions and 12 deletions

View File

@ -12,6 +12,8 @@
<h1>Blank Page</h1>
<hr>
<p>This is a great starting point for new custom pages.</p>
<h1><?php echo $session_user_role; ?></h1>
<?php validateAdminRole(); ?>
<?php

View File

@ -2478,10 +2478,22 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.9.3'");
}
// if (CURRENT_DATABASE_VERSION == '1.9.3') {
// // Insert queries here required to update to DB version 1.9.4
if (CURRENT_DATABASE_VERSION == '1.9.3') {
mysqli_query($mysqli,
"CREATE TABLE `ticket_assets` (
`ticket_id` INT(11) NOT NULL,
`asset_id` INT(11) NOT NULL,
PRIMARY KEY (`ticket_id`,`asset_id`),
FOREIGN KEY (`asset_id`) REFERENCES `assets`(`asset_id`) ON DELETE CASCADE,
FOREIGN KEY (`ticket_id`) REFERENCES `tickets`(`ticket_id`) ON DELETE CASCADE
)");
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.9.4'");
}
// if (CURRENT_DATABASE_VERSION == '1.9.4') {
// // Insert queries here required to update to DB version 1.9.5
// // Then, update the database to the next sequential version
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.9.4'");
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.9.5'");
// }
} else {

19
db.sql
View File

@ -1989,6 +1989,23 @@ CREATE TABLE `taxes` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `ticket_assets`
--
DROP TABLE IF EXISTS `ticket_assets`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `ticket_assets` (
`ticket_id` int(11) NOT NULL,
`asset_id` int(11) NOT NULL,
PRIMARY KEY (`ticket_id`,`asset_id`),
KEY `asset_id` (`asset_id`),
CONSTRAINT `ticket_assets_ibfk_1` FOREIGN KEY (`asset_id`) REFERENCES `assets` (`asset_id`) ON DELETE CASCADE,
CONSTRAINT `ticket_assets_ibfk_2` FOREIGN KEY (`ticket_id`) REFERENCES `tickets` (`ticket_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `ticket_attachments`
--
@ -2383,4 +2400,4 @@ CREATE TABLE `vendors` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2025-03-10 15:52:38
-- Dump completed on 2025-03-11 15:09:10

View File

@ -539,8 +539,8 @@ function validateCSRFToken($token)
* Accountant - 1
*/
function validateAdminRole()
{
function validateAdminRole() {
global $session_user_role;
if (!isset($session_user_role) || $session_user_role != 3) {
$_SESSION['alert_type'] = "danger";
$_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
@ -551,8 +551,8 @@ function validateAdminRole()
// LEGACY
// Validates a user is a tech (or admin). Stops page load and attempts to direct away from the page if not (i.e. user is an accountant)
function validateTechRole()
{
function validateTechRole() {
global $session_user_role;
if (!isset($session_user_role) || $session_user_role == 1) {
$_SESSION['alert_type'] = "danger";
$_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
@ -563,8 +563,8 @@ function validateTechRole()
// LEGACY
// Validates a user is an accountant (or admin). Stops page load and attempts to direct away from the page if not (i.e. user is a tech)
function validateAccountantRole()
{
function validateAccountantRole() {
global $session_user_role;
if (!isset($session_user_role) || $session_user_role == 2) {
$_SESSION['alert_type'] = "danger";
$_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;

View File

@ -5,4 +5,4 @@
* It is used in conjunction with database_updates.php
*/
DEFINE("LATEST_DATABASE_VERSION", "1.9.3");
DEFINE("LATEST_DATABASE_VERSION", "1.9.4");

View File

@ -285,7 +285,7 @@ if (isset($_GET['update'])) {
if (isset($_GET['update_db'])) {
validateAdminRole(); // Old function
//validateAdminRole(); // Old function
// Get the current version
require_once ('includes/database_version.php');