Skip to content
Draft
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
# +-------------------------------------------------------------------------+

locales/po/*.mo
.omc/
18 changes: 11 additions & 7 deletions cycle.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@
break;
}

function cycle_get_timespan() {
$timespan = [];
$first_weekdayid = read_user_setting('first_weekdayid');
get_timespan($timespan, time(), get_request_var('timespan'), $first_weekdayid);

return $timespan;
}

function cycle_graphs() {
global $graphs_ppage, $graph_cols, $graphs;
global $page_refresh_interval, $graph_timespans;
Expand All @@ -77,9 +85,7 @@ function cycle_graphs() {
if (empty($id)) $id = -1;

/* get the start and end times for the graph */
$timespan = array();
$first_weekdayid = read_user_setting('first_weekdayid');
get_timespan($timespan, time(), get_request_var('timespan'), $first_weekdayid);
$timespan = cycle_get_timespan();

$graph_tree = $tree_id;
$html = '';
Expand Down Expand Up @@ -176,9 +182,7 @@ function cycle() {
}

/* get the start and end times for the graph */
$timespan = array();
$first_weekdayid = read_user_setting('first_weekdayid');
get_timespan($timespan, time(), get_request_var('timespan') , $first_weekdayid);
$timespan = cycle_get_timespan();

$graph_tree = $tree_id;
$html = '';
Expand Down Expand Up @@ -300,7 +304,7 @@ function cycle() {
WHERE title != ""
AND graph_tree_id = ?
ORDER BY parent, position',
array($graph_tree));
[$graph_tree]);

if (cacti_sizeof($leaves)) {
$html .= "<select id='leaf_id' title='" . __esc('Select Tree Leaf to Display', 'cycle') . "'>";
Expand Down
32 changes: 16 additions & 16 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,18 @@ function validate_request_vars($force = false) {

/* ================= input validation and session storage ================= */
$filters = array(
'id' => array(
'id' => [
'filter' => FILTER_VALIDATE_INT,
'default' => '-1'
),
],
'tree_id' => array(
Comment on lines 116 to 121
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In validate_request_vars(), the $filters structure now mixes short array syntax ([]) with legacy array() in the same literal, which conflicts with the PR goal of using short array syntax across the plugin and makes the block harder to scan. Convert the remaining nested array(...) entries within $filters to [...] for consistency.

Copilot uses AI. Check for mistakes.
'filter' => FILTER_VALIDATE_INT,
'default' => read_config_option('cycle_custom_graphs_tree', $force),
),
'leaf_id' => array(
'leaf_id' => [
'filter' => FILTER_VALIDATE_INT,
'default' => '-2'
),
],
'graphs' => array(
'filter' => FILTER_VALIDATE_INT,
'default' => read_user_setting('cycle_graphs', read_config_option('cycle_graphs'), $force)
Expand Down Expand Up @@ -153,13 +153,13 @@ function validate_request_vars($force = false) {
'legend' => array(
'filter' => FILTER_CALLBACK,
'default' => read_user_setting('cycle_legend', read_config_option('cycle_legend'), $force),
'options' => array('options' => 'sanitize_search_string')
'options' => ['options' => 'sanitize_search_string']
),
'rfilter' => array(
'filter' => FILTER_VALIDATE_IS_REGEX,
'pageset' => true,
'default' => read_user_setting('cycle_filter', '', $force),
'options' => array('options' => 'sanitize_search_string')
'options' => ['options' => 'sanitize_search_string']
)
);

Expand All @@ -171,7 +171,7 @@ function cycle_set_defaults() {
$user = $_SESSION['sess_user_id'];

if (!isset($_SESSION['sess_cycle_defaults'])) {
$defaults = array(
$defaults = [
'cycle_delay' => '60',
'cycle_timespan' => '5',
'cycle_columns' => '2',
Expand All @@ -185,20 +185,20 @@ function cycle_set_defaults() {
'cycle_font_color' => '1',
'cycle_legend' => '',
'cycle_custom_graphs_type' => '2'
);
];

foreach($defaults as $name => $value) {
$current = db_fetch_cell_prepared('SELECT value
FROM settings_user
WHERE name = ?
AND user_id = ?',
array($name, $user));
[$name, $user]);

if ($current === false) {
db_execute_prepared('REPLACE INTO settings_user
(user_id, name, value)
VALUES (?, ?, ?)',
array($user, $name, $value));
[$user, $name, $value]);
}
}

Expand Down Expand Up @@ -246,7 +246,7 @@ function get_next_graphid($graphpp, $filter, $graph_tree, $leaf_id) {
}elseif ($type == 2) {
$newcase = '';
$graph_data = get_tree_graphs($graph_tree, $leaf_id);
$local_graph_ids = array();
$local_graph_ids = [];

if (sizeof($graph_data)) {
$local_graph_ids = array_keys($graph_data);
Expand All @@ -266,7 +266,7 @@ function get_next_graphid($graphpp, $filter, $graph_tree, $leaf_id) {
$next_graph_id = 0;
$prev_graph_id = 0;
$title = '';
$graphs = array();
$graphs = [];
$i = 0;

/* Build a graphs array of the number of graphs requested
Expand Down Expand Up @@ -423,7 +423,7 @@ function get_next_graphid($graphpp, $filter, $graph_tree, $leaf_id) {

$done = false;
$start = 0;
$pgraphs = array();
$pgraphs = [];

while (!$done) {
$sql = "SELECT gl.id,
Expand Down Expand Up @@ -513,9 +513,9 @@ function get_next_graphid($graphpp, $filter, $graph_tree, $leaf_id) {
}

function get_tree_graphs($tree_id, $leaf_id) {
$graphs = array();
$hosts = array();
$outArray = array();
$graphs = [];
$hosts = [];
$outArray = [];

if (is_tree_allowed($tree_id)) {
if ($leaf_id == -2) {
Expand Down
4 changes: 2 additions & 2 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function plugin_cycle_upgrade () {
function cycle_check_upgrade () {
global $config;

$files = array('index.php', 'plugins.php', 'cycle.php');
$files = ['index.php', 'plugins.php', 'cycle.php'];
if (isset($_SERVER['PHP_SELF']) && !in_array(basename($_SERVER['PHP_SELF']), $files)) {
return;
}
Expand Down Expand Up @@ -101,7 +101,7 @@ function cycle_check_upgrade () {
db_execute_prepared('UPDATE plugin_config
SET name = ?, author = ?, webpage = ?, version = ?
WHERE id = ?',
array($info['longname'], $info['author'], $info['homepage'], $info['version'], $id));
[$info['longname'], $info['author'], $info['homepage'], $info['version'], $id]);
}
}

Expand Down