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
@@ -1,6 +1,7 @@
## ChangeLog

--- develop ---
* bug: Pass a boolean (not the integer `1`) to `api_plugin_register_hook()`'s `$enable` argument so the hook registration stays type-correct under Cacti 1.3's strict `bool $enable` type-hint (the int only coerces while this file lacks `declare(strict_types=1)`)
* feature: Show each threshold's status as a sortable, clickable pill in a new Status column (right of Name) on the Thresholds and Device Status pages instead of colouring the whole row; rows now zebra-stripe, clicking a pill filters the list to that status, and the Status filter gains per-severity options
* security: Replace the confirmation pages' inline `onClick='cactiReturnTo()'` Cancel buttons with the CSP-safe `cactiReturnTo` class so they no longer trip Cacti's Content-Security-Policy `script-src-attr` directive
* security: Move the filter controls' inline `onChange`/`onClick` handlers into jQuery `ready()` event bindings on the threshold, notification list, notification queue, template and device/log status pages so they no longer trip Cacti's Content-Security-Policy `script-src-attr` directive
Expand Down
38 changes: 19 additions & 19 deletions includes/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,14 @@ function thold_upgrade_database($force = false) {
AND hook = "poller_bottom"');

// Register the new hooks
api_plugin_register_hook('thold', 'rrd_graph_graph_options', 'thold_rrd_graph_graph_options', 'setup.php', '1');
api_plugin_register_hook('thold', 'graph_buttons', 'thold_graph_button', 'setup.php', '1');
api_plugin_register_hook('thold', 'data_source_action_array', 'thold_data_source_action_array', 'setup.php', '1');
api_plugin_register_hook('thold', 'data_source_action_prepare', 'thold_data_source_action_prepare', 'setup.php', '1');
api_plugin_register_hook('thold', 'data_source_action_execute', 'thold_data_source_action_execute', 'setup.php', '1');
api_plugin_register_hook('thold', 'graphs_action_array', 'thold_graphs_action_array', 'setup.php', '1');
api_plugin_register_hook('thold', 'graphs_action_prepare', 'thold_graphs_action_prepare', 'setup.php', '1');
api_plugin_register_hook('thold', 'graphs_action_execute', 'thold_graphs_action_execute', 'setup.php', '1');
api_plugin_register_hook('thold', 'rrd_graph_graph_options', 'thold_rrd_graph_graph_options', 'setup.php', true);
api_plugin_register_hook('thold', 'graph_buttons', 'thold_graph_button', 'setup.php', true);
api_plugin_register_hook('thold', 'data_source_action_array', 'thold_data_source_action_array', 'setup.php', true);
api_plugin_register_hook('thold', 'data_source_action_prepare', 'thold_data_source_action_prepare', 'setup.php', true);
api_plugin_register_hook('thold', 'data_source_action_execute', 'thold_data_source_action_execute', 'setup.php', true);
api_plugin_register_hook('thold', 'graphs_action_array', 'thold_graphs_action_array', 'setup.php', true);
api_plugin_register_hook('thold', 'graphs_action_prepare', 'thold_graphs_action_prepare', 'setup.php', true);
api_plugin_register_hook('thold', 'graphs_action_execute', 'thold_graphs_action_execute', 'setup.php', true);

// Fix our realms
db_execute('UPDATE plugin_realms
Expand All @@ -275,8 +275,8 @@ function thold_upgrade_database($force = false) {
db_execute('DELETE FROM plugin_hooks WHERE name = "thold" AND hook = "config_insert"');
db_execute('DELETE FROM plugin_hooks WHERE name = "thold" AND hook = "config_arrays"');

api_plugin_register_hook('thold', 'config_insert', 'thold_config_insert', 'includes/settings.php', '1');
api_plugin_register_hook('thold', 'config_arrays', 'thold_config_arrays', 'includes/settings.php', '1');
api_plugin_register_hook('thold', 'config_insert', 'thold_config_insert', 'includes/settings.php', true);
api_plugin_register_hook('thold', 'config_arrays', 'thold_config_arrays', 'includes/settings.php', true);

api_plugin_enable_hooks('thold');

Expand Down Expand Up @@ -544,7 +544,7 @@ function thold_upgrade_database($force = false) {
db_execute('ALTER TABLE thold_template DROP COLUMN bl_enabled', false);
}

api_plugin_register_hook('thold', 'config_form', 'thold_config_form', 'includes/settings.php', '1');
api_plugin_register_hook('thold', 'config_form', 'thold_config_form', 'includes/settings.php', true);
api_plugin_register_realm('thold', 'notify_lists.php', 'Manage Notification Lists', 1);

// set unique hash values for all thold templates
Expand Down Expand Up @@ -781,10 +781,10 @@ function thold_upgrade_database($force = false) {
$data['comment'] = 'Table of Device Template Threshold Templates';
api_plugin_db_table_create('thold', 'plugin_thold_host_template', $data);

api_plugin_register_hook('thold', 'device_template_edit', 'thold_device_template_edit', 'setup.php', '1');
api_plugin_register_hook('thold', 'device_template_top', 'thold_device_template_top', 'setup.php', '1');
api_plugin_register_hook('thold', 'device_edit_pre_bottom', 'thold_device_edit_pre_bottom', 'setup.php', '1');
api_plugin_register_hook('thold', 'api_device_new', 'thold_api_device_new', 'setup.php', '1');
api_plugin_register_hook('thold', 'device_template_edit', 'thold_device_template_edit', 'setup.php', true);
api_plugin_register_hook('thold', 'device_template_top', 'thold_device_template_top', 'setup.php', true);
api_plugin_register_hook('thold', 'device_edit_pre_bottom', 'thold_device_edit_pre_bottom', 'setup.php', true);
api_plugin_register_hook('thold', 'api_device_new', 'thold_api_device_new', 'setup.php', true);
api_plugin_register_hook('thold', 'page_head', 'thold_page_head', 'setup.php');

if (api_plugin_is_enabled('thold')) {
Expand Down Expand Up @@ -1815,8 +1815,8 @@ function thold_upgrade_database($force = false) {

db_execute('ALTER TABLE thold_data MODIFY COLUMN name varchar(255) NOT NULL default ""');

api_plugin_register_hook('thold', 'device_template_change', 'thold_device_template_change', 'setup.php', 1);
api_plugin_register_hook('thold', 'settings_bottom', 'thold_settings_bottom', 'setup.php', 1);
api_plugin_register_hook('thold', 'device_template_change', 'thold_device_template_change', 'setup.php', true);
api_plugin_register_hook('thold', 'settings_bottom', 'thold_settings_bottom', 'setup.php', true);
Comment thread
TheWitness marked this conversation as resolved.

api_plugin_register_realm('thold', 'notify_lists.php,notify_queue.php', 'Manage Notification Lists', 1);

Expand Down Expand Up @@ -2107,8 +2107,8 @@ function thold_setup_database() {
$data['comment'] = 'Table of Notification Lists';
api_plugin_db_table_create('thold', 'plugin_notification_lists', $data);

api_plugin_register_hook('thold', 'host_edit_bottom', 'thold_host_edit_bottom', 'setup.php', '1');
api_plugin_register_hook('thold', 'device_top', 'thold_device_top', 'setup.php', '1');
api_plugin_register_hook('thold', 'host_edit_bottom', 'thold_host_edit_bottom', 'setup.php', true);
api_plugin_register_hook('thold', 'device_top', 'thold_device_top', 'setup.php', true);

api_plugin_db_add_column('thold', 'host', ['name' => 'thold_send_email', 'type' => 'int(10)', 'NULL' => false, 'default' => '1', 'after' => 'disabled']);
api_plugin_db_add_column('thold', 'host', ['name' => 'thold_host_email', 'type' => 'int(10)', 'NULL' => true, 'after' => 'thold_send_email']);
Expand Down
8 changes: 7 additions & 1 deletion setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ function plugin_thold_install($upgrade = false) {
return false;
}

// The reinstall below registers the plugin's hooks/realms and provisions
// its schema against a live Cacti database (include_once database.php plus
// thold_setup_database()/thold_upgrade_database()), so it cannot run in the
// isolated unit process.
// @codeCoverageIgnoreStart
$plugin = 'thold';

// Insert CSS and JavaScript
Expand Down Expand Up @@ -118,7 +123,7 @@ function plugin_thold_install($upgrade = false) {
api_plugin_register_hook($plugin, 'api_device_new', 'thold_api_device_new', 'setup.php');

// Allow settings javascript hooks
api_plugin_register_hook('thold', 'settings_bottom', 'thold_settings_bottom', 'setup.php', 1);
api_plugin_register_hook('thold', 'settings_bottom', 'thold_settings_bottom', 'setup.php', true);

// Miscellaneous hooks
api_plugin_register_hook($plugin, 'graphs_new_top_links', 'thold_graphs_new', 'setup.php');
Expand Down Expand Up @@ -146,6 +151,7 @@ function plugin_thold_install($upgrade = false) {
thold_setup_database();
thold_snmpagent_cache_install();
}
// @codeCoverageIgnoreEnd
}

/**
Expand Down
Loading