TeamPass
TeamPass copied to clipboard
Importing from KeePass : Always goes public
https://github.com/nilsteampassnet/TeamPass/blob/1fa47b58af48301812da5d193b3a5bdff60c903e/sources/import.queries.php#L1259
When importing from KeePass.xml, all new folders are public, even if the parent folder is private Also find out why most new imported folders are shown duplicated ( Checking existing nlevel goes for a different value than created nlevel)
Please, review , use and reformat if You feel si the right fix.
Thank You
diff --git a/sources/import.queries.php b/sources/import.queries.php
index 1460dd059..5e1e9f8ea 100755
--- a/sources/import.queries.php
+++ b/sources/import.queries.php
@@ -1267,6 +1267,7 @@ function createFolder($folderTitle, $parentId, $folderLevel, $startPathLevel, $l
$folderTitle,
$parentId
);
+ $personalFolder = in_array($parentId, $session->get('user-personal_folders')) ? 1 : 0;
if (DB::count() === 0) {
//do query
DB::insert(
@@ -1274,8 +1275,9 @@ function createFolder($folderTitle, $parentId, $folderLevel, $startPathLevel, $l
array(
'parent_id' => (int) $parentId,
'title' => (string) stripslashes($folderTitle),
- 'nlevel' => (int) $folderLevel,
+ 'nlevel' => (int) intval($folderLevel + $startPathLevel),
'categories' => '',
+ 'personal_folder' => (int) $personalFolder,
)
);
$id = DB::insertId();
@@ -1302,8 +1304,9 @@ function createFolder($folderTitle, $parentId, $folderLevel, $startPathLevel, $l
'last_folder_change'
);
- //For each role to which the user depends on, add the folder just created.
- foreach ($session->get('system-array_roles') as $role) {
+ //For each role to which the user depends on, add the folder just created. (if not personal, otherwise, add to user-personal_folders)
+ if ( $personalFolder ) SessionManager::addRemoveFromSessionArray('user-personal_folders', [$id], 'add');
+ else foreach ($session->get('system-array_roles') as $role) {
DB::insert(
prefixTable('roles_values'),
array(
@adieguez-emais Thank you