Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/Cacti/cacti into feature…
Browse files Browse the repository at this point in the history
…s/installupdate
  • Loading branch information
micke2k committed Mar 27, 2016
2 parents a58bd0e + aea9662 commit b2f0d67
Show file tree
Hide file tree
Showing 14 changed files with 3,848 additions and 4,141 deletions.
2 changes: 1 addition & 1 deletion cdef.php
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ function cdef_edit() {

html_header($display_text, 2);

$cdef_items = db_fetch_assoc_prepared('SELECT * FROM cdef_items WHERE system=0 AND cdef_id = ? ORDER BY sequence', array(get_request_var('id')));
$cdef_items = db_fetch_assoc_prepared('SELECT * FROM cdef_items WHERE cdef_id = ? ORDER BY sequence', array(get_request_var('id')));

$i = 0;
if (sizeof($cdef_items)) {
Expand Down
123 changes: 96 additions & 27 deletions data_input.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@
form_actions();

break;
case 'field_remove':
get_filter_request_var('data_input_id');
case 'field_remove_confirm':
field_remove_confirm();

break;
case 'field_remove':
field_remove();

header('Location: data_input.php?header=false&action=edit&id=' . get_request_var('data_input_id'));
header('Location: data_input.php?header=false&action=edit&id=' . get_filter_request_var('data_input_id'));
break;
case 'field_edit':
top_header();
Expand Down Expand Up @@ -233,38 +235,79 @@ function form_actions() {
CDEF Item Functions
-------------------------- */

function field_remove() {
global $registered_cacti_names;

function field_remove_confirm() {
/* ================= input validation ================= */
get_filter_request_var('id');
get_filter_request_var('data_input_id');
/* ==================================================== */

if ((read_config_option('deletion_verification') == 'on') && (!isset_request_var('confirm'))) {
top_header();
form_start('data_intput.php?action=edit&id' . get_request_var('data_input_id'));

form_confirm('Are You Sure?', "Are you sure you want to delete the field '" . htmlspecialchars(db_fetch_cell_prepared('SELECT name FROM data_input_fields WHERE id = ?', array(get_request_var('id'))), ENT_QUOTES) . "'?", htmlspecialchars('data_input.php?action=edit&id=' . get_request_var('data_input_id')), htmlspecialchars('data_input.php?action=field_remove&id=' . get_request_var('id') . '&data_input_id=' . get_request_var('data_input_id')));
html_start_box('', '100%', '', '3', 'center', '');

bottom_footer();
exit;
}
$field = db_fetch_row_prepared('SELECT * FROM data_input_fields WHERE id = ?', array(get_request_var('id')));

if ((read_config_option('deletion_verification') == '') || (isset_request_var('confirm'))) {
/* get information about the field we're going to delete so we can re-order the seqs */
$field = db_fetch_row_prepared('SELECT input_output,data_input_id FROM data_input_fields WHERE id = ?', array(get_request_var('id')));
?>
<tr>
<td class='topBoxAlt'>
<p>Click 'Continue' to delete the following Data Input Field.</p>
<p>Field Name: '<?php print $field['data_name'];?>'<br>
<p>Friendly Name: '<?php print $field['name'];?>'<br>
</td>
</tr>
<tr>
<td align='right'>
<input id='cancel' type='button' value='Cancel' onClick='$("#cdialog").dialog("close")' name='cancel'>
<input id='continue' type='button' value='Continue' name='continue' title='Remove Data Input Field'>
</td>
</tr>
<?php

db_execute_prepared('DELETE FROM data_input_fields WHERE id = ?', array(get_request_var('id')));
db_execute_prepared('DELETE FROM data_input_data WHERE data_input_field_id = ?', array(get_request_var('id')));
html_end_box();

/* when a field is deleted; we need to re-order the field sequences */
if (($field['input_output'] == 'in') && (preg_match_all('/<([_a-zA-Z0-9]+)>/', db_fetch_cell_prepared('SELECT input_string FROM data_input WHERE id = ?', array($field['data_input_id'])), $matches))) {
$j = 0;
for ($i=0; ($i < count($matches[1])); $i++) {
if (in_array($matches[1][$i], $registered_cacti_names) == false) {
$j++;
db_execute_prepared("UPDATE data_input_fields SET sequence = ? WHERE data_input_id = ? AND input_output = 'in' AND data_name = ?", array($j, $field['data_input_id'], $matches[1][$i]));
}
form_end();

?>
<script type='text/javascript'>
$(function() {
$('#cdialog').dialog();
});

$('#continue').click(function(data) {
$.post('data_input.php?action=field_remove', {
__csrf_magic: csrfMagicToken,
data_input_id: <?php print get_request_var('data_input_id');?>,
id: <?php print get_request_var('id');?>
}, function(data) {
$('#cdialog').dialog('close');
loadPageNoHeader('data_input.php?action=edit&header=false&id=<?php print get_request_var('data_input_id');?>');
});
});
</script>
<?php
}

function field_remove() {
global $registered_cacti_names;

/* ================= input validation ================= */
get_filter_request_var('id');
get_filter_request_var('data_input_id');
/* ==================================================== */

/* get information about the field we're going to delete so we can re-order the seqs */
$field = db_fetch_row_prepared('SELECT input_output,data_input_id FROM data_input_fields WHERE id = ?', array(get_request_var('id')));

db_execute_prepared('DELETE FROM data_input_fields WHERE id = ?', array(get_request_var('id')));
db_execute_prepared('DELETE FROM data_input_data WHERE data_input_field_id = ?', array(get_request_var('id')));

/* when a field is deleted; we need to re-order the field sequences */
if (($field['input_output'] == 'in') && (preg_match_all('/<([_a-zA-Z0-9]+)>/', db_fetch_cell_prepared('SELECT input_string FROM data_input WHERE id = ?', array($field['data_input_id'])), $matches))) {
$j = 0;
for ($i=0; ($i < count($matches[1])); $i++) {
if (in_array($matches[1][$i], $registered_cacti_names) == false) {
$j++;
db_execute_prepared("UPDATE data_input_fields SET sequence = ? WHERE data_input_id = ? AND input_output = 'in' AND data_name = ?", array($j, $field['data_input_id'], $matches[1][$i]));
}
}
}
Expand Down Expand Up @@ -418,7 +461,7 @@ function data_edit() {
<?php print htmlspecialchars($field['name']);?>
</td>
<td align="right">
<a class='pic deleteMarker fa fa-remove' href='<?php print htmlspecialchars('data_input.php?action=field_remove&id=' . $field['id'] . '&data_input_id=' . get_request_var('id'));?>' title='Delete'></a>
<a class='delete deleteMarker fa fa-remove' href='<?php print htmlspecialchars('data_input.php?action=field_remove_confirm&id=' . $field['id'] . '&data_input_id=' . get_request_var('id'));?>' title='Delete'></a>
</td>
<?php
form_end_row();
Expand Down Expand Up @@ -456,7 +499,7 @@ function data_edit() {
<?php print html_boolean_friendly($field['update_rra']);?>
</td>
<td align="right">
<a class='pic deleteMarker fa fa-remove' href='<?php print htmlspecialchars('data_input.php?action=field_remove&id=' . $field['id'] . '&data_input_id=' . get_request_var('id'));?>' title='Delete'></a>
<a class='delete deleteMarker fa fa-remove' href='<?php print htmlspecialchars('data_input.php?action=field_remove_confirm&id=' . $field['id'] . '&data_input_id=' . get_request_var('id'));?>' title='Delete'></a>
</td>
<?php
form_end_row();
Expand All @@ -469,6 +512,32 @@ function data_edit() {
}

form_save_button('data_input.php', 'return');

?>
<script type='text/javascript'>

$(function() {
$('body').append("<div id='cdialog'></div>");

$('.delete').click(function (event) {
event.preventDefault();

request = $(this).attr('href');
$.get(request, function(data) {
$('#cdialog').html(data);
applySkin();
$('#cdialog').dialog({
title: 'Delete Data Input Field',
close: function () { $('.delete').blur(); $('.selectable').removeClass('selected'); },
minHeight: 80,
minWidth: 500
});
});
}).css('cursor', 'pointer');
});

</script>
<?php
}

function data() {
Expand Down
133 changes: 92 additions & 41 deletions data_queries.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,59 +42,43 @@

break;
case 'item_moveup_dssv':
get_filter_request_var('snmp_query_graph_id');
get_filter_request_var('snmp_query_id');

data_query_item_moveup_dssv();

header('Location: data_queries.php?header=false&action=item_edit&id=' . get_request_var('snmp_query_graph_id') . '&snmp_query_id=' . get_request_var('snmp_query_id'));
header('Location: data_queries.php?header=false&action=item_edit&id=' . get_filter_request_var('snmp_query_graph_id') . '&snmp_query_id=' . get_filter_request_var('snmp_query_id'));
break;
case 'item_movedown_dssv':
get_filter_request_var('snmp_query_graph_id');
get_filter_request_var('snmp_query_id');

data_query_item_movedown_dssv();

header('Location: data_queries.php?header=false&action=item_edit&id=' . get_request_var('snmp_query_graph_id') . '&snmp_query_id=' . get_request_var('snmp_query_id'));
header('Location: data_queries.php?header=false&action=item_edit&id=' . get_filter_request_var('snmp_query_graph_id') . '&snmp_query_id=' . get_filter_request_var('snmp_query_id'));
break;
case 'item_remove_dssv':
get_filter_request_var('snmp_query_graph_id');
get_filter_request_var('snmp_query_id');

data_query_item_remove_dssv();

header('Location: data_queries.php?header=false&action=item_edit&id=' . get_request_var('snmp_query_graph_id') . '&snmp_query_id=' . get_request_var('snmp_query_id'));
header('Location: data_queries.php?header=false&action=item_edit&id=' . get_filter_request_var('snmp_query_graph_id') . '&snmp_query_id=' . get_filter_request_var('snmp_query_id'));
break;
case 'item_moveup_gsv':
get_filter_request_var('snmp_query_graph_id');
get_filter_request_var('snmp_query_id');

data_query_item_moveup_gsv();

header('Location: data_queries.php?header=false&action=item_edit&id=' . get_request_var('snmp_query_graph_id') . '&snmp_query_id=' . get_request_var('snmp_query_id'));
header('Location: data_queries.php?header=false&action=item_edit&id=' . get_filter_request_var('snmp_query_graph_id') . '&snmp_query_id=' . get_filter_request_var('snmp_query_id'));
break;
case 'item_movedown_gsv':
get_filter_request_var('snmp_query_graph_id');
get_filter_request_var('snmp_query_id');

data_query_item_movedown_gsv();

header('Location: data_queries.php?header=false&action=item_edit&id=' . get_request_var('snmp_query_graph_id') . '&snmp_query_id=' . get_request_var('snmp_query_id'));
header('Location: data_queries.php?header=false&action=item_edit&id=' . get_filter_request_var('snmp_query_graph_id') . '&snmp_query_id=' . get_filter_request_var('snmp_query_id'));
break;
case 'item_remove_gsv':
get_filter_request_var('snmp_query_graph_id');
get_filter_request_var('snmp_query_id');

data_query_item_remove_gsv();

header('Location: data_queries.php?header=false&action=item_edit&id=' . get_request_var('snmp_query_graph_id') . '&snmp_query_id=' . get_request_var('snmp_query_id'));
header('Location: data_queries.php?header=false&action=item_edit&id=' . get_filter_request_var('snmp_query_graph_id') . '&snmp_query_id=' . get_filter_request_var('snmp_query_id'));
break;
case 'item_remove':
get_filter_request_var('snmp_query_id');
case 'item_remove_confirm':
data_query_item_remove_confirm();

break;
case 'item_remove':
data_query_item_remove();

header('Location: data_queries.php?header=false&action=edit&id=' . get_request_var('snmp_query_id'));
header('Location: data_queries.php?header=false&action=edit&id=' . get_filter_request_var('snmp_query_id'));
break;
case 'item_edit':
top_header();
Expand Down Expand Up @@ -369,27 +353,68 @@ function data_query_item_remove_dssv() {
db_execute_prepared('DELETE FROM snmp_query_graph_rrd_sv WHERE id = ?', array(get_request_var('id')));
}

function data_query_item_remove() {
function data_query_item_remove_confirm() {
global $vdef_functions, $vdef_item_types, $custom_vdef_data_source_types;

/* ================= input validation ================= */
get_filter_request_var('id');
get_filter_request_var('snmp_query_id');
/* ==================================================== */

if ((read_config_option('deletion_verification') == 'on') && (!isset_request_var('confirm'))) {
top_header();
form_start('data_queries.php?action=edit&id' . get_request_var('snmp_query_id'));

form_confirm('Are You Sure?', "Are you sure you want to delete the Data Query Graph '" . htmlspecialchars(db_fetch_cell_prepared('SELECT name FROM snmp_query_graph WHERE id = ?', array(get_request_var('id'))), ENT_QUOTES) . "'?", htmlspecialchars('data_queries.php?action=edit&id=' . get_request_var('snmp_query_id')), htmlspecialchars('data_queries.php?action=item_remove&id=' . get_request_var('id') . '&snmp_query_id=' . get_request_var('snmp_query_id')));
html_start_box('', '100%', '', '3', 'center', '');

bottom_footer();
exit;
}
$graph_template = db_fetch_row('SELECT * FROM snmp_query_graph WHERE id=' . get_request_var('id'));

if ((read_config_option('deletion_verification') == '') || (isset_request_var('confirm'))) {
db_execute_prepared('DELETE FROM snmp_query_graph WHERE id = ?', array(get_request_var('id')));
db_execute_prepared('DELETE FROM snmp_query_graph_rrd WHERE snmp_query_graph_id = ?', array(get_request_var('id')));
db_execute_prepared('DELETE FROM snmp_query_graph_rrd_sv WHERE snmp_query_graph_id = ?', array(get_request_var('id')));
db_execute_prepared('DELETE FROM snmp_query_graph_sv WHERE snmp_query_graph_id = ?', array(get_request_var('id')));
}
?>
<tr>
<td class='topBoxAlt'>
<p>Click 'Continue' to delete the following Data Query Graph Association.</p>
<p>Graph Name: '<?php print $graph_template['name'];?>'<br>
</td>
</tr>
<tr>
<td align='right'>
<input id='cancel' type='button' value='Cancel' onClick='$("#cdialog").dialog("close");' name='cancel'>
<input id='continue' type='button' value='Continue' name='continue' title='Remove VDEF Item'>
</td>
</tr>
<?php

html_end_box();

form_end();

?>
<script type='text/javascript'>
$(function() {
$('#cdialog').dialog();
});

$('#continue').click(function(data) {
$.post('data_queries.php?action=item_remove', {
__csrf_magic: csrfMagicToken,
snmp_query_id: <?php print get_request_var('snmp_query_id');?>,
id: <?php print get_request_var('id');?>
}, function(data) {
$('#cdialog').dialog('close');
loadPageNoHeader('data_queries.php?action=edit&header=false&id=<?php print get_request_var('snmp_query_id');?>');
});
});
</script>
<?php
}

function data_query_item_remove() {
/* ================= input validation ================= */
get_filter_request_var('id');
/* ==================================================== */

db_execute_prepared('DELETE FROM snmp_query_graph WHERE id = ?', array(get_request_var('id')));
db_execute_prepared('DELETE FROM snmp_query_graph_rrd WHERE snmp_query_graph_id = ?', array(get_request_var('id')));
db_execute_prepared('DELETE FROM snmp_query_graph_rrd_sv WHERE snmp_query_graph_id = ?', array(get_request_var('id')));
db_execute_prepared('DELETE FROM snmp_query_graph_sv WHERE snmp_query_graph_id = ?', array(get_request_var('id')));
}

function data_query_item_edit() {
Expand Down Expand Up @@ -841,7 +866,7 @@ function data_query_edit() {
<?php print $snmp_query_graph['id'];?>
</td>
<td class='right'>
<a class='deleteMarker fa fa-remove' title='Delete' href='<?php print htmlspecialchars('data_queries.php?action=item_remove&id=' . $snmp_query_graph['id'] . '&snmp_query_id=' . $snmp_query['id']);?>'></a>
<a class='delete deleteMarker fa fa-remove' title='Delete' href='<?php print htmlspecialchars('data_queries.php?action=item_remove_confirm&id=' . $snmp_query_graph['id'] . '&snmp_query_id=' . $snmp_query['id']);?>'></a>
</td>
</tr>
<?php
Expand All @@ -855,6 +880,32 @@ function data_query_edit() {
}

form_save_button('data_queries.php', 'return');

?>
<script type='text/javascript'>

$(function() {
$('body').append("<div id='cdialog'></div>");

$('.delete').click(function (event) {
event.preventDefault();

request = $(this).attr('href');
$.get(request, function(data) {
$('#cdialog').html(data);
applySkin();
$('#cdialog').dialog({
title: 'Delete Associated Graph',
close: function () { $('.delete').blur(); $('.selectable').removeClass('selected'); },
minHeight: 80,
minWidth: 500
});
});
}).css('cursor', 'pointer');
});

</script>
<?php
}

function data_query() {
Expand Down
7 changes: 6 additions & 1 deletion data_source_profiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,12 @@ function profile_edit() {
$.get(request, function(data) {
$('#cdialog').html(data);
applySkin();
$('#cdialog').dialog({ title: 'Delete Data Source Profile Item', minHeight: 80, minWidth: 500 });
$('#cdialog').dialog({
title: 'Delete Data Source Profile Item',
close: function () { $('.delete').blur(); $('.selectable').removeClass('selected'); },
minHeight: 80,
minWidth: 500
});
});
}).css('cursor', 'pointer');
<?php }else{ ?>
Expand Down
Loading

0 comments on commit b2f0d67

Please sign in to comment.