Skip to content

Commit

Permalink
Fix user personnal folder creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
corentin-soriano committed Jul 26, 2024
1 parent c1d01fe commit aadbe56
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
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
3 changes: 2 additions & 1 deletion sources/items.queries.php
Original file line number Diff line number Diff line change
Expand Up @@ -3903,7 +3903,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

0 comments on commit aadbe56

Please sign in to comment.