Skip to content
Open
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: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Fixed

- Performance: remove an unused query and a CSRF token per tree group, read only the displayed columns, load `treeview.css` on the tree frame only, add an index on the preferences `users_id` column

## [1.20.4] - 2026-11-05

### Fixed
Expand Down
8 changes: 7 additions & 1 deletion hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,18 @@ function plugin_treeview_install()
`id` int {$default_key_sign} NOT NULL auto_increment,
`users_id` int {$default_key_sign} NOT NULL default '0' COMMENT 'RELATION to glpi_users (id)',
`show_on_load` int NOT NULL default '0',
PRIMARY KEY (`id`)
PRIMARY KEY (`id`),
KEY `users_id` (`users_id`)
) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;";

$DB->doQuery($query);
}

// Preferences are looked up by user on each profile change
$migration = new Migration(PLUGIN_TREEVIEW_VERSION);
$migration->addKey('glpi_plugin_treeview_preferences', 'users_id');
$migration->executeMigration();

// No autoload when plugin is not activated
require_once __DIR__ . '/inc/profile.class.php';

Expand Down
24 changes: 9 additions & 15 deletions inc/config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,17 +329,22 @@ public function getNodesFromDb()
$itemtable = getTableForItemType($type);

$criteria = [
'FROM' => $itemtable,
'WHERE' => [
'SELECT' => [$itemtable . '.id', $itemtable . '.name'],
'FROM' => $itemtable,
'WHERE' => [
'locations_id' => $r['id'],
],
'ORDER' => [$itemtable . '.name'],
'ORDER' => [$itemtable . '.name'],
];

if ($item->maybeTemplate()) {
$criteria['WHERE']['is_template'] = 0;
}

if ($item->isField('otherserial')) {
$criteria['SELECT'][] = $itemtable . '.otherserial';
}

if ($item->maybeDeleted()) {
$criteria['WHERE']['is_deleted'] = 0;
}
Expand All @@ -354,19 +359,8 @@ public function getNodesFromDb()
$pid = $tv_id;
$field_num = 3;

$result_location = $DB->request([
'SELECT' => ['completename'],
'FROM' => 'glpi_locations',
'WHERE' => ['id' => $r['id']],
]);

foreach ($result_location as $row) {
$name_location = $row['completename'];
}

$value = $r['id'];
$token = Session::getNewCSRFToken();
$getParam = sprintf('?is_deleted=0&criteria[0][field]=%d&criteria[0][searchtype]=equals&criteria[0][value]=%s&search=Rechercher&start=0&_glpi_csrf_token=%s', $field_num, $value, $token);
$getParam = sprintf('?is_deleted=0&criteria[0][field]=%d&criteria[0][searchtype]=equals&criteria[0][value]=%s&search=Rechercher&start=0', $field_num, $value);

$searchUrl = Toolbox::getItemTypeSearchURL($type) . $getParam;

Expand Down
6 changes: 6 additions & 0 deletions public/left.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
Html::includeHeader('TreeView');

echo "<body style='overflow:auto; overflow:initial;'>";
// Only this page needs the explorer bar styles, they are not loaded on the other GLPI pages
echo sprintf(
"<link rel='stylesheet' type='text/css' href='%s/plugins/treeview/css/treeview.css?v=%s'>",
$CFG_GLPI['root_doc'],
PLUGIN_TREEVIEW_VERSION,
);
// Title bar
echo '<div id="explorer_bar" class="d-flex justify-content-between align-items-center border-bottom">';
echo '<div id=explorer_title>';
Expand Down
5 changes: 1 addition & 4 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function plugin_init_treeview()
&& $_SESSION['glpi_plugin_treeview_loaded'] == 1
&& class_exists(PluginTreeviewConfig::class)
) {
foreach (PluginTreeviewConfig::getTypes() as $type) {
foreach (PluginTreeviewConfig::getTypes(true) as $type) {
$PLUGIN_HOOKS[Hooks::ITEM_UPDATE]['treeview'][$type] = 'plugin_item_update_treeview';
$PLUGIN_HOOKS[Hooks::ITEM_DELETE]['treeview'][$type] = 'plugin_treeview_reload';
$PLUGIN_HOOKS[Hooks::ITEM_RESTORE]['treeview'][$type] = 'plugin_treeview_reload';
Expand All @@ -95,9 +95,6 @@ function plugin_init_treeview()
$config = new PluginTreeviewConfig();
$config->hideTreeview();
}

// Add specific files to add to the header : javascript or css
$PLUGIN_HOOKS[Hooks::ADD_CSS]['treeview'] = 'css/treeview.css';
}

// Config page
Expand Down
Loading