Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue related to user allowed folder by definition #4439

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions includes/tables_integrity.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
},
{
"table_name": "background_tasks",
"structure_hash": "a16bfe9a8067dbb06f7d7d00192f36602ffa48460ccc5b1d76dbb952f3a0fd12"
"structure_hash": "e772b139800353e3f4e6fb4988b58358ece6100a6e955889e01c5760a18496dd"
},
{
"table_name": "background_tasks_logs",
"structure_hash": "e4af7ed71b16cbabb5d8d833d8105fde35fa5fe82cfafc1b45baac6255b33822"
"structure_hash": "a4391b91f150d47503717bf9510bec04987b186aa5674d3752acd896c1368ab8"
},
{
"table_name": "cache",
Expand Down Expand Up @@ -65,7 +65,7 @@
},
{
"table_name": "items_edition",
"structure_hash": "2765684d18e5ec9df9997e06a093e4e5d9488e2ec1f3263ca5f2d5ff8e19825e"
"structure_hash": "e47ac1d0a60dfc921f85bb618e0fa18cc80955f51da6c82ca90e9e7813a83981"
},
{
"table_name": "items_otp",
Expand Down Expand Up @@ -97,15 +97,15 @@
},
{
"table_name": "log_items",
"structure_hash": "11260246c92ccab29f3244be9f0dc06cab7a5a3b36d9a7102d2d3a526cf0d119"
"structure_hash": "f29ee1e97b386ffe1ec9ad461f43592c86033c26d676df325dfab1638072807a"
},
{
"table_name": "log_system",
"structure_hash": "27d2764bf1d26a0f483aceaf82075382672563d93ab2a4ae34f0a63a34e801f4"
"structure_hash": "81d0d2379faa884c71ca8a31544c9136a47d322ddf547efea6e8871cdf626e04"
},
{
"table_name": "misc",
"structure_hash": "aa3b8db6a4d5751b6d006758e152913f82aca172712bc378fb863c6ccc6a4115"
"structure_hash": "f15d8b74690ff1b8518540d990c9c6650c7ca4dfef7fd5e10e84c0e80025b765"
},
{
"table_name": "nested_tree",
Expand Down Expand Up @@ -185,7 +185,7 @@
},
{
"table_name": "tags",
"structure_hash": "9d0ed6c74f9c4924443a47ad3e2585b33157b67bbdfb41a5677407961a02e31c"
"structure_hash": "e0dd91554725bb2084ecd15154008bc34575bacf2b03d8cdb69960a46e8fe99d"
},
{
"table_name": "templates",
Expand Down
29 changes: 16 additions & 13 deletions pages/items.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -3197,8 +3197,10 @@ function(data) {
);
return false;
}
if (debugJavascript === true) console.log('RETURNED DATA');
if (debugJavascript === true) console.log(data);
if (debugJavascript === true) {
console.log('RETURNED DATA');
console.log(data);
}
if (data.error === true) {
toastr.remove();
toastr.error(
Expand Down Expand Up @@ -3259,7 +3261,7 @@ function(data) {
// Close edit form and reopen folders-tree-card with refreshed item.
$('.form-item, #form-item-attachments-zone').addClass('hidden');
$('#folders-tree-card').removeClass('hidden');
item_id = store.get('teampassItem').id !== '' ? store.get('teampassItem').id : data.item_id;
item_id = store.get('teampassItem').id !== '' ? store.get('teampassItem').id : data.item_id;
Details(item_id, 'show', true);
}
}
Expand Down Expand Up @@ -4851,7 +4853,6 @@ function(teampassItem) {
}
);

//$('#items-list-container');
if (actionType === 'show') {
// Prepare Views
$('.item-details-card, #item-details-card-categories').removeClass('hidden');
Expand Down Expand Up @@ -4879,7 +4880,7 @@ function(teampassItem) {
$('#items-list-container').removeClass('col-md-7').addClass('hidden');
$('#items-details-container').removeClass('col-md-5').addClass('col-md-12');
}

// Show item details
$('#items-details-container').removeClass('hidden');

Expand Down Expand Up @@ -4985,7 +4986,6 @@ function(teampassItem) {
if (debugJavascript === true) console.log('onChange:', contents, $editable);
userDidAChange = true;
if (debugJavascript === true) console.log('User did a change on #form-item-suggestion-description > ' + userDidAChange);
//$('#form-item-suggestion-description').attr('data-change-ongoing', true);;
}
}
}
Expand Down Expand Up @@ -5347,10 +5347,10 @@ function(teampassItem) {
.attr('data-next-item-id', dataItemKey.next('.list-item-row').attr('data-item-id'))
.removeClass('hidden');
}
*/
if (debugJavascript === true) {
//console.log("PREV: " + dataItemKey.attr('data-item-key') + " - NEXT: " + $('#list-item-row_'+data.id).next('.list-item-row').attr('data-item-id'));
console.log("PREV: " + dataItemKey.attr('data-item-key') + " - NEXT: " + $('#list-item-row_'+data.id).next('.list-item-row').attr('data-item-id'));
}
*/

// Inform user
toastr.remove();
Expand Down Expand Up @@ -5511,8 +5511,10 @@ function(data) {
$.when(
getPrivilegesOnItem(selectedFolderId, 1)
).then(function(retData) {
console.log('getPrivilegesOnItem 3')
console.log(retData)
if (debugJavascript === true) {
console.log('getPrivilegesOnItem 3');
console.log(retData);
}
if (retData.error === true) {
toastr.remove();
toastr.error(
Expand Down Expand Up @@ -5656,9 +5658,10 @@ function(data) {
);
e.clearSelection();
});

console.log("-------------");
console.log(data);
if (debugJavascript === true) {
console.log("-------------");
console.log(data);
}

// Prepare recursive call to get new OTP code
var replayDelayInMilliseconds = data.otp_expires_in*1000;
Expand Down
18 changes: 15 additions & 3 deletions sources/items.queries.php
Original file line number Diff line number Diff line change
Expand Up @@ -4055,6 +4055,13 @@
array_push($arrTmp, 0);
}
}
} else {
// Ensure to give access Right if allowed folder
if (in_array($inputData['id'], $session->get('user-accessible_folders')) === true) {
array_push($arrTmp, 50);
} else {
array_push($arrTmp, 0);
}
}
}
// 3.0.0.0 - changed MIN to MAX
Expand Down Expand Up @@ -4446,11 +4453,11 @@
// ----- END CASE 6 -----
} elseif (
(int) $record['perso'] !== 1
&& (int) $session->get('user-read_only') === 1
&& in_array($record['tree_id'], $session->get('user-allowed_folders_by_definition'))
) {
// Case 7 - Is user readonly?
// Case 7 - Is folder allowed by definition for this user?
// Allow limited rights
$right = 10;
$right = 70;
// ---
// ----- END CASE 7 -----
} elseif (
Expand Down Expand Up @@ -7458,6 +7465,11 @@ function getCurrentAccessRights(int $userId, int $itemId, int $treeId): array
if (in_array($treeId, $session->get('user-read_only_folders'))) {
return getAccessResponse(false, true, false, false);
}

// Check if the folder is in the user's allowed folders list defined by admin
if (in_array($treeId, $session->get('user-allowed_folders_by_definition'))) {
return getAccessResponse(false, true, true, true);
}

// Check if the folder is personal to the user
foreach ($visibleFolders as $folder) {
Expand Down
2 changes: 1 addition & 1 deletion sources/main.functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@ function identUser(
array $SETTINGS,
object $tree
) {

$session = SessionManager::getSession();
// Init
$session->set('user-accessible_folders', []);
Expand All @@ -447,6 +446,7 @@ function identUser(
$noAccessFolders = convertToArray($noAccessFolders);
$userRoles = convertToArray($userRoles);
$allowedFolders = convertToArray($allowedFolders);
$session->set('user-allowed_folders_by_definition', $allowedFolders);

// Get list of folders depending on Roles
$arrays = identUserGetFoldersFromRoles(
Expand Down