Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- issue: Fix quicktree_show_tab() building an invalid `?location=tabtab`/`?location=tabconsole` URL, an undefined-variable text-domain typo in the QuickTree page's "no graph specified" message, and a misspelled `qucktree` text domain
- security: Migrate quicktree SQL helpers to prepared statements, normalize location handling, and ensure redirects terminate execution
- test: Migrate test suite to Pest with a Cacti-provided test harness and CI workflow
- feature: Give the QuickTree add/remove graph glyphs their own theme-appropriate colors across every packaged Cacti theme, instead of reusing the core deviceUp/deviceDown classes


--- 2.0 ---
Expand Down
32 changes: 32 additions & 0 deletions css/classic.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2010-2022 Howard Jones |
| Copyright (C) 2022-2025 The Cacti Group |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDtool-based Graphing Solution |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/

/* QuickTree graph action glyphs */
.quicktreeAdd {
color: #2e7d32;
}

.quicktreeRemove {
color: #c62828;
}
32 changes: 32 additions & 0 deletions css/dark.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2010-2022 Howard Jones |
| Copyright (C) 2022-2025 The Cacti Group |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDtool-based Graphing Solution |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/

/* QuickTree graph action glyphs */
.quicktreeAdd {
color: #4caf50;
}

.quicktreeRemove {
color: #e06666;
}
32 changes: 32 additions & 0 deletions css/midwinter.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2010-2022 Howard Jones |
| Copyright (C) 2022-2025 The Cacti Group |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDtool-based Graphing Solution |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/

/* QuickTree graph action glyphs */
.quicktreeAdd {
color: #4caf50;
}

.quicktreeRemove {
color: #e06666;
}
32 changes: 32 additions & 0 deletions css/modern.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2010-2022 Howard Jones |
| Copyright (C) 2022-2025 The Cacti Group |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDtool-based Graphing Solution |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/

/* QuickTree graph action glyphs */
.quicktreeAdd {
color: #2e7d32;
}

.quicktreeRemove {
color: #c62828;
}
32 changes: 32 additions & 0 deletions css/paper-plane.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2010-2022 Howard Jones |
| Copyright (C) 2022-2025 The Cacti Group |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDtool-based Graphing Solution |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/

/* QuickTree graph action glyphs */
.quicktreeAdd {
color: #4caf50;
}

.quicktreeRemove {
color: #e06666;
}
32 changes: 32 additions & 0 deletions css/paw.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2010-2022 Howard Jones |
| Copyright (C) 2022-2025 The Cacti Group |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDtool-based Graphing Solution |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/

/* QuickTree graph action glyphs */
.quicktreeAdd {
color: #2e7d32;
}

.quicktreeRemove {
color: #c62828;
}
10 changes: 10 additions & 0 deletions css/quicktree.css
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,13 @@
padding: 20px;
}

/* Default QuickTree graph action glyph colors; the per-theme stylesheets in
this directory override these for each packaged Cacti theme. */
.quicktreeAdd {
color: #2e7d32;
}

.quicktreeRemove {
color: #c62828;
}

32 changes: 32 additions & 0 deletions css/sunrise.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2010-2022 Howard Jones |
| Copyright (C) 2022-2025 The Cacti Group |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDtool-based Graphing Solution |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/

/* QuickTree graph action glyphs */
.quicktreeAdd {
color: #4caf50;
}

.quicktreeRemove {
color: #e06666;
}
6 changes: 3 additions & 3 deletions quicktree.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@
['<b>' . __('Save To Branch', 'quicktree') . '</b>', __('Save your selection as a branch to an existing tree so that they appear in a specific section of an existing tree.', 'quicktree')],
['<b>' . __('Clear all graphs', 'quicktree') . '</b>', __('Clear the Graphs on this page from the Graphs Queue so that you have a blank QuickTree ready for new selections', 'quicktree')],
['<hr>' . __('You can manage the individual graphs that appear here by clicking:', 'quicktree')],
['<i class="deviceUp fas fa-plus-circle"></i>' . __('Add', 'quicktree'), __('This icon is next to a Graph on the %s tab.', '<a href="../../graph_view.php">' . __('Graph View Page', 'quicktree') . '</a>', 'quicktree')],
['<i class="deviceDown fas fa-times-circle"></i>' . __('Delete', 'quicktree'), __('This icon next to the Graphs below to remove them from the QuickTree Queue.', 'quicktree')],
['<i class="quicktreeAdd fas fa-plus-circle"></i>' . __('Add', 'quicktree'), __('This icon is next to a Graph on the %s tab.', '<a href="../../graph_view.php">' . __('Graph View Page', 'quicktree') . '</a>', 'quicktree')],
['<i class="quicktreeRemove fas fa-times-circle"></i>' . __('Delete', 'quicktree'), __('This icon next to the Graphs below to remove them from the QuickTree Queue.', 'quicktree')],
['<hr><b>' . __('Note:', 'quicktree') . '</br>'],
[__('Adding, removing or clearing on this page does not affect any other parts of Cacti (only Creating/Saving does)', 'quicktree')]
];
Expand Down Expand Up @@ -394,7 +394,7 @@
print '<table class="cactiTable"><thead><tr><th class="center">' . $graph_title;

print '&nbsp;&nbsp;<a class="pic iconLink" href="' . html_escape('quicktree.php?location=' . $location . '&action=remove&id=' . $gr['id'])
. '" title="' . __esc('Remove This Graph From QuickTree', 'quicktree') . '"><i class="deviceDown fas fa-times-circle"></i></a>';
. '" title="' . __esc('Remove This Graph From QuickTree', 'quicktree') . '"><i class="quicktreeRemove fas fa-times-circle"></i></a>';
print '</th></tr></thead>';

print '<tbody><tr><td style="padding:5px;" class="center">';
Expand Down
19 changes: 11 additions & 8 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ function quicktree_graph_buttons($data): void {
$local_graph_id = $data[1]['local_graph_id'];
$rra_id = $data[1]['rra'];

print "<a class='iconLink' onClick='addQuickTree($local_graph_id, $rra_id)' title='" . __esc('Add this graph to QuickTree', 'quicktree') . "' href='#'><i class='deviceUp fas fa-plus-circle'></i></a><br>";
print "<a class='iconLink' onClick='addQuickTree($local_graph_id, $rra_id)' title='" . __esc('Add this graph to QuickTree', 'quicktree') . "' href='#'><i class='quicktreeAdd fas fa-plus-circle'></i></a><br>";
Comment thread
TheWitness marked this conversation as resolved.
}
}

Expand Down Expand Up @@ -245,9 +245,12 @@ function quicktree_config_arrays(): void {

/**
* Hook implementation for Cacti's 'page_head' filter. Includes this
* plugin's JavaScript on every page, and its stylesheet specifically on
* quicktree.php. Called by Cacti core via api_plugin_hook('page_head', ...)
* while rendering the page <head> section.
* plugin's JavaScript and stylesheets on every page. The base stylesheet
* and, when present, a stylesheet matching the user's selected theme are
* both loaded on every page because QuickTree's action glyphs are rendered
* on the graph view page as well as on quicktree.php. Called by Cacti core
* via api_plugin_hook('page_head', ...) while rendering the page <head>
* section.
*
* @return void Outputs HTML directly.
*
Expand All @@ -257,12 +260,12 @@ function quicktree_config_arrays(): void {
function quicktree_page_head(): void {
global $config;

$page = get_current_page();

print get_md5_include_js('plugins/quicktree/js/quicktree.js');

if (strstr($page, 'quicktree.php') !== false) {
print get_md5_include_css('plugins/quicktree/css/quicktree.css');
print get_md5_include_css('plugins/quicktree/css/quicktree.css');

if (file_exists($config['base_path'] . '/plugins/quicktree/css/' . get_selected_theme() . '.css')) {
print get_md5_include_css('plugins/quicktree/css/' . get_selected_theme() . '.css');
}
}

Expand Down
40 changes: 40 additions & 0 deletions tests/Unit/QuicktreeGraphButtonsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2026 The Cacti Group |
+-------------------------------------------------------------------------+
*/

/*
* Coverage for quicktree_graph_buttons(): the 'graph_buttons' hook prints an
* "Add this graph to QuickTree" glyph for the current graph, but only when
* the user is authorized for the quicktree realm.
*/

beforeAll(function () {
require_once __DIR__ . '/../../setup.php';
});

beforeEach(function () {
$GLOBALS['__test_realm_auth'] = true;
});

it('prints an Add-to-QuickTree glyph for the current graph when authorized', function () {
ob_start();
quicktree_graph_buttons(array(1 => array('local_graph_id' => 42, 'rra' => 7)));
$output = ob_get_clean();

expect($output)->toContain('quicktreeAdd');
expect($output)->toContain('fa-plus-circle');
expect($output)->toContain('addQuickTree(42, 7)');
});

it('prints nothing when the user is not authorized for the quicktree realm', function () {
$GLOBALS['__test_realm_auth'] = false;

ob_start();
quicktree_graph_buttons(array(1 => array('local_graph_id' => 42, 'rra' => 7)));
$output = ob_get_clean();

expect($output)->toBe('');
});
Loading
Loading