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

BUGFIX - Fix user personnal folder creation. #4257

Merged
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
6 changes: 0 additions & 6 deletions pages/tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,9 @@
<button class="btn btn-primary task-define" data-task="users_personal_folder_task">
<i class="fa-solid fa-cogs"></i>
</button>
<?php
if (defined('WIP') === true && WIP === true) {
?>
<button class="btn btn-primary task-perform ml-1" data-task="users_personal_folder_task">
<i class="fa-solid fa-play"></i>
</button>
<?php
}
?>
</div>
</div>

Expand Down
16 changes: 3 additions & 13 deletions scripts/task_maintenance_users_personal_folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use TeampassClasses\SessionManager\SessionManager;
use Symfony\Component\HttpFoundation\Request;
use TeampassClasses\Language\Language;
use TeampassClasses\ConfigManager\ConfigManager;

// Load functions
require_once __DIR__.'/../sources/main.functions.php';
Expand Down Expand Up @@ -75,26 +76,15 @@ function createUserPersonalFolder(): void
//Libraries call
$tree = new NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title');

//get through all users
//get through all users with enabled personnal folder.
$users = DB::query(
'SELECT id, login, email
FROM ' . prefixTable('users') . '
WHERE id NOT IN ('.OTV_USER_ID.', '.TP_USER_ID.', '.SSH_USER_ID.', '.API_USER_ID.')
AND personal_folder = 1
ORDER BY login ASC'
);
foreach ($users as $user) {
/*
//update PF field for user
DB::update(
prefixTable('users'),
array(
'personal_folder' => '1',
),
'id = %i',
$user['id']
);
*/

//if folder doesn't exist then create it
$data = DB::queryfirstrow(
'SELECT id
Expand Down
6 changes: 4 additions & 2 deletions sources/items.queries.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@
// if not allowed then warn user
if (($session->has('user-create_item_without_password') && $session->has('user-create_item_without_password') && null !== $session->get('user-create_item_without_password')
&& (int) $session->get('user-create_item_without_password') !== 1) ||
empty($post_password) === false
empty($post_password) === false ||
(int) $post_folder_is_personal === 1
) {
// NEW ENCRYPTION
$cryptedStuff = doDataEncryption($post_password);
Expand Down Expand Up @@ -3903,7 +3904,8 @@
// Prepare tree
$arbo = $tree->getPath($inputData['id'], true);
foreach ($arbo as $elem) {
if ($elem->title === $session->get('user-id') && (int) $elem->nlevel === 1) {
// Personnal folder
if ((int) $elem->title === (int) $session->get('user-id') && (int) $elem->nlevel === 1) {
$elem->title = $session->get('user-login');
}
// Store path elements
Expand Down