Add user role management functionality with CRUD operations and permissions handling
- Created user_role.php for viewing and editing user roles and their permissions. - Implemented inline editing for role details and permissions. - Added user_role_manage.php for creating and managing user roles. - Introduced user_roles.php for listing all user roles with pagination and filtering options. - Integrated API calls for fetching and updating role data and permissions. - Enhanced user interface with success messages and navigation controls.
This commit is contained in:
65
assets/database/user_rbac
Normal file
65
assets/database/user_rbac
Normal file
@@ -0,0 +1,65 @@
|
||||
CREATE TABLE `user_roles` (
|
||||
`rowID` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`description` text DEFAULT NULL,
|
||||
`is_active` tinyint(1) NOT NULL DEFAULT 1,
|
||||
`created` timestamp NULL DEFAULT current_timestamp(),
|
||||
`createdby` int(11) DEFAULT NULL,
|
||||
`updated` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||
`updatedby` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`rowID`),
|
||||
UNIQUE KEY `unique_role_name` (`name`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
CREATE TABLE `user_role_assignments` (
|
||||
`rowID` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`user_id` int(11) NOT NULL,
|
||||
`role_id` int(11) NOT NULL,
|
||||
`is_active` tinyint(1) NOT NULL DEFAULT 1,
|
||||
`assigned_by` varchar(255) DEFAULT NULL,
|
||||
`assigned_at` timestamp NULL DEFAULT current_timestamp(),
|
||||
`expires_at` timestamp NULL DEFAULT NULL,
|
||||
`created` timestamp NULL DEFAULT current_timestamp(),
|
||||
`createdby` int(11) DEFAULT NULL,
|
||||
`updated` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||
`updatedby` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`rowID`),
|
||||
UNIQUE KEY `unique_user_role_active` (`user_id`,`role_id`,`is_active`),
|
||||
KEY `role_id` (`role_id`),
|
||||
CONSTRAINT `user_role_assignments_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`rowID`) ON DELETE CASCADE,
|
||||
CONSTRAINT `user_role_assignments_ibfk_2` FOREIGN KEY (`role_id`) REFERENCES `user_roles` (`rowID`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
REATE TABLE `role_access_permissions` (
|
||||
`rowID` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`role_id` int(11) NOT NULL,
|
||||
`access_id` int(11) NOT NULL,
|
||||
`can_create` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`can_read` tinyint(1) NOT NULL DEFAULT 1,
|
||||
`can_update` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`can_delete` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`created` timestamp NULL DEFAULT current_timestamp(),
|
||||
`createdby` int(11) DEFAULT NULL,
|
||||
`updated` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||
`updatedby` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`rowID`),
|
||||
UNIQUE KEY `unique_role_view` (`role_id`,`access_id`),
|
||||
KEY `access_id` (`access_id`),
|
||||
CONSTRAINT `role_view_permissions_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES `user_roles` (`rowID`) ON DELETE CASCADE,
|
||||
CONSTRAINT `role_view_permissions_ibfk_2` FOREIGN KEY (`access_id`) REFERENCES `system_views` (`rowID`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=112 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
CREATE TABLE `access_elements` (
|
||||
`rowID` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`access_group` varchar(100) NOT NULL,
|
||||
`access_name` varchar(100) NOT NULL,
|
||||
`access_path` varchar(255) NOT NULL,
|
||||
`description` text DEFAULT NULL,
|
||||
`is_active` tinyint(1) NOT NULL DEFAULT 1,
|
||||
`created` timestamp NULL DEFAULT current_timestamp(),
|
||||
`createdby` int(11) DEFAULT NULL,
|
||||
`updated` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||
`updatedby` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`rowID`),
|
||||
UNIQUE KEY `unique_access_path` (`access_path`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=393 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
Reference in New Issue
Block a user