ikinci temizlik tamamlandı
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
@php
|
||||
use App\Models\DocumentManagerPermission;
|
||||
|
||||
$userLevel = $request->get('user_level', 'Admin');
|
||||
$folderPath = $request->get('folder_path', '');
|
||||
|
||||
if (!$userLevel || !$folderPath) {
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(['success' => false, 'message' => 'User level and folder path are required']);
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
// Get all permissions for specific user level and folder (both allowed and denied)
|
||||
$allPermissions = DocumentManagerPermission::where('user_level', $userLevel)
|
||||
->where('folder_path', $folderPath)
|
||||
->get();
|
||||
|
||||
// Create array with all permission types and their status
|
||||
$permissions = [];
|
||||
$permissionTypes = ['read', 'write'];
|
||||
|
||||
foreach ($permissionTypes as $permissionType) {
|
||||
$permission = $allPermissions->where('permission_type', $permissionType)->first();
|
||||
if ($permission && $permission->is_allowed) {
|
||||
$permissions[] = $permissionType;
|
||||
}
|
||||
}
|
||||
|
||||
// No inheritance - only return explicit permissions for each folder
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'permissions' => $permissions,
|
||||
'user_level' => $userLevel,
|
||||
'folder_path' => $folderPath
|
||||
]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'message' => 'Error loading folder permissions: ' . $e->getMessage()
|
||||
]);
|
||||
}
|
||||
@endphp
|
||||
Reference in New Issue
Block a user