mirror of https://github.com/itflow-org/itflow
Merge pull request #964 from wrongecho/user-roles-initial
User roles - Initial
This commit is contained in:
commit
f177045432
|
|
@ -55,9 +55,15 @@
|
||||||
</div>
|
</div>
|
||||||
<select class="form-control select2" name="role" required>
|
<select class="form-control select2" name="role" required>
|
||||||
<option value="">- Role -</option>
|
<option value="">- Role -</option>
|
||||||
<option value="3">Administrator</option>
|
<?php
|
||||||
<option value="2">Technician</option>
|
$sql_user_roles = mysqli_query($mysqli, "SELECT * FROM user_roles WHERE user_role_archived_at IS NULL");
|
||||||
<option value="1">Accountant</option>
|
while ($row = mysqli_fetch_array($sql_user_roles)) {
|
||||||
|
$user_role_id = intval($row['user_role_id']);
|
||||||
|
$user_role_name = nullable_htmlentities($row['user_role_name']);
|
||||||
|
|
||||||
|
?>
|
||||||
|
<option value="<?php echo $user_role_id; ?>"><?php echo $user_role_name; ?></option>
|
||||||
|
<?php } ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -67,19 +67,16 @@
|
||||||
<span class="input-group-text"><i class="fa fa-fw fa-user-shield"></i></span>
|
<span class="input-group-text"><i class="fa fa-fw fa-user-shield"></i></span>
|
||||||
</div>
|
</div>
|
||||||
<select class="form-control select2" name="role" required>
|
<select class="form-control select2" name="role" required>
|
||||||
<option value="">- Role -</option>
|
<?php
|
||||||
<option <?php if ($user_role == 3) {
|
$sql_user_roles = mysqli_query($mysqli, "SELECT * FROM user_roles WHERE user_role_archived_at IS NULL");
|
||||||
echo "selected";
|
while ($row = mysqli_fetch_array($sql_user_roles)) {
|
||||||
} ?> value="3">Administrator
|
$user_role_id = intval($row['user_role_id']);
|
||||||
</option>
|
$user_role_name = nullable_htmlentities($row['user_role_name']);
|
||||||
<option <?php if ($user_role == 2) {
|
|
||||||
echo "selected";
|
?>
|
||||||
} ?> value="2">Technician
|
<option <?php if ($user_role == $user_role_id) {echo "selected";} ?> value="<?php echo $user_role_id; ?>"><?php echo $user_role_name; ?></option>
|
||||||
</option>
|
<?php } ?>
|
||||||
<option <?php if ($user_role == 1) {
|
|
||||||
echo "selected";
|
|
||||||
} ?> value="1">Accountant
|
|
||||||
</option>
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,9 @@ $url_query_strings_sort = http_build_query($get_copy);
|
||||||
|
|
||||||
$sql = mysqli_query(
|
$sql = mysqli_query(
|
||||||
$mysqli,
|
$mysqli,
|
||||||
"SELECT SQL_CALC_FOUND_ROWS * FROM users, user_settings
|
"SELECT SQL_CALC_FOUND_ROWS * FROM users, user_settings, user_roles
|
||||||
WHERE users.user_id = user_settings.user_id
|
WHERE users.user_id = user_settings.user_id
|
||||||
|
AND user_settings.user_role = user_roles.user_role_id
|
||||||
AND (user_name LIKE '%$q%' OR user_email LIKE '%$q%')
|
AND (user_name LIKE '%$q%' OR user_email LIKE '%$q%')
|
||||||
AND user_archived_at IS NULL
|
AND user_archived_at IS NULL
|
||||||
ORDER BY $sort $order LIMIT $record_from, $record_to"
|
ORDER BY $sort $order LIMIT $record_from, $record_to"
|
||||||
|
|
@ -98,13 +99,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||||
}
|
}
|
||||||
$user_config_force_mfa = intval($row['user_config_force_mfa']);
|
$user_config_force_mfa = intval($row['user_config_force_mfa']);
|
||||||
$user_role = $row['user_role'];
|
$user_role = $row['user_role'];
|
||||||
if ($user_role == 3) {
|
$user_role_display = nullable_htmlentities($row['user_role_name']);
|
||||||
$user_role_display = "Administrator";
|
|
||||||
} elseif ($user_role == 2) {
|
|
||||||
$user_role_display = "Technician";
|
|
||||||
} else {
|
|
||||||
$user_role_display = "Accountant";
|
|
||||||
}
|
|
||||||
$user_initials = nullable_htmlentities(initials($user_name));
|
$user_initials = nullable_htmlentities(initials($user_name));
|
||||||
|
|
||||||
$sql_last_login = mysqli_query(
|
$sql_last_login = mysqli_query(
|
||||||
|
|
|
||||||
|
|
@ -1889,14 +1889,25 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
|
||||||
if (CURRENT_DATABASE_VERSION == '1.2.9') {
|
if (CURRENT_DATABASE_VERSION == '1.2.9') {
|
||||||
|
|
||||||
mysqli_query($mysqli, "CREATE TABLE `user_permissions` (`user_id` int(11) NOT NULL,`client_id` int(11) NOT NULL, PRIMARY KEY (`user_id`,`client_id`))");
|
mysqli_query($mysqli, "CREATE TABLE `user_permissions` (`user_id` int(11) NOT NULL,`client_id` int(11) NOT NULL, PRIMARY KEY (`user_id`,`client_id`))");
|
||||||
|
|
||||||
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.3.0'");
|
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.3.0'");
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (CURRENT_DATABASE_VERSION == '1.3.0') {
|
if (CURRENT_DATABASE_VERSION == '1.3.0') {
|
||||||
// // Insert queries here required to update to DB version 1.3.0
|
|
||||||
|
mysqli_query($mysqli, "CREATE TABLE `itflow`.`user_roles` (`user_role_id` INT(11) NOT NULL AUTO_INCREMENT , `user_role_name` VARCHAR(200) NOT NULL , `user_role_description` VARCHAR(200) NULL DEFAULT NULL , `user_role_created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP , `user_role_updated_at` DATETIME on update CURRENT_TIMESTAMP NULL , `user_role_archived_at` DATETIME NULL , PRIMARY KEY (`user_role_id`)) ENGINE = InnoDB");
|
||||||
|
|
||||||
|
mysqli_query($mysqli, "INSERT INTO `user_roles` SET user_role_id = 1, user_role_name = 'Accountant', user_role_description = 'Built-in - Limited access to financial-focused modules'");
|
||||||
|
mysqli_query($mysqli, "INSERT INTO `user_roles` SET user_role_id = 2, user_role_name = 'Technician', user_role_description = 'Built-in - Limited access to technical-focused modules'");
|
||||||
|
mysqli_query($mysqli, "INSERT INTO `user_roles` SET user_role_id = 3, user_role_name = 'Administrator', user_role_description = 'Built-in - Full administrative access to all modules (including user management)'");
|
||||||
|
|
||||||
|
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.3.1'");
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (CURRENT_DATABASE_VERSION == '1.3.1') {
|
||||||
|
// // Insert queries here required to update to DB version 1.3.1
|
||||||
// // Then, update the database to the next sequential version
|
// // Then, update the database to the next sequential version
|
||||||
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.3.1");
|
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.3.2'");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,4 @@
|
||||||
* It is used in conjunction with database_updates.php
|
* It is used in conjunction with database_updates.php
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DEFINE("LATEST_DATABASE_VERSION", "1.3.0");
|
DEFINE("LATEST_DATABASE_VERSION", "1.3.1");
|
||||||
|
|
|
||||||
17
db.sql
17
db.sql
|
|
@ -1791,6 +1791,23 @@ CREATE TABLE `user_permissions` (
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `user_roles`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `user_roles`;
|
||||||
|
CREATE TABLE IF NOT EXISTS `user_roles` (
|
||||||
|
`user_role_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`user_role_name` varchar(200) NOT NULL,
|
||||||
|
`user_role_description` varchar(200) DEFAULT NULL,
|
||||||
|
`user_role_created_at` datetime NOT NULL DEFAULT current_timestamp(),
|
||||||
|
`user_role_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
|
||||||
|
`user_role_archived_at` datetime DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`user_role_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `user_settings`
|
-- Table structure for table `user_settings`
|
||||||
--
|
--
|
||||||
|
|
|
||||||
|
|
@ -302,6 +302,11 @@ if (isset($_POST['add_company_settings'])) {
|
||||||
mysqli_query($mysqli, "INSERT INTO ticket_statuses SET ticket_status_name = 'Auto Close', ticket_status_color = '#343a40'"); // 4
|
mysqli_query($mysqli, "INSERT INTO ticket_statuses SET ticket_status_name = 'Auto Close', ticket_status_color = '#343a40'"); // 4
|
||||||
mysqli_query($mysqli, "INSERT INTO ticket_statuses SET ticket_status_name = 'Closed', ticket_status_color = '#343a40'"); // 5
|
mysqli_query($mysqli, "INSERT INTO ticket_statuses SET ticket_status_name = 'Closed', ticket_status_color = '#343a40'"); // 5
|
||||||
|
|
||||||
|
// Add default roles
|
||||||
|
mysqli_query($mysqli, "INSERT INTO `user_roles` SET user_role_id = 1, user_role_name = 'Accountant', user_role_description = 'Built-in - Limited access to financial-focused modules'");
|
||||||
|
mysqli_query($mysqli, "INSERT INTO `user_roles` SET user_role_id = 2, user_role_name = 'Technician', user_role_description = 'Built-in - Limited access to technical-focused modules'");
|
||||||
|
mysqli_query($mysqli, "INSERT INTO `user_roles` SET user_role_id = 3, user_role_name = 'Administrator', user_role_description = 'Built-in - Full administrative access to all modules (including user management)'");
|
||||||
|
|
||||||
|
|
||||||
$_SESSION['alert_message'] = "Company <strong>$name</strong> created!";
|
$_SESSION['alert_message'] = "Company <strong>$name</strong> created!";
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue