" . __n('Click \'Continue\' to duplicate the following VDEF. You can optionally change the title format for the new VDEF.', 'Click \'Continue\' to duplicate following VDEFs. You can optionally change the title format for the new VDEFs.', cacti_sizeof($vdef_array)) . "
0';
} else {
$sql_having = '';
}
$total_rows = db_fetch_cell("SELECT
COUNT(`rows`)
FROM (
SELECT vd.id AS `rows`, vd.name,
SUM(CASE WHEN local_graph_id>0 THEN 1 ELSE 0 END) AS graphs
FROM vdef AS vd
LEFT JOIN graph_templates_item AS gti
ON gti.vdef_id=vd.id
GROUP BY vd.id
$sql_having
) AS rs
$sql_where");
$sql_order = get_order_string();
$sql_limit = ' LIMIT ' . ($rows * (get_request_var('page') - 1)) . ',' . $rows;
return db_fetch_assoc("SELECT rs.*,
SUM(CASE WHEN local_graph_id=0 THEN 1 ELSE 0 END) AS templates,
SUM(CASE WHEN local_graph_id>0 THEN 1 ELSE 0 END) AS graphs
FROM (
SELECT vd.*, gti.local_graph_id
FROM vdef AS vd
LEFT JOIN graph_templates_item AS gti
ON gti.vdef_id=vd.id
GROUP BY vd.id, gti.graph_template_id, gti.local_graph_id
) AS rs
$sql_where
GROUP BY rs.id
$sql_having
$sql_order
$sql_limit");
}
function vdef($refresh = true) {
global $vdef_actions;
/* ================= input validation and session storage ================= */
$filters = array(
'rows' => array(
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-1'
),
'page' => array(
'filter' => FILTER_VALIDATE_INT,
'default' => '1'
),
'filter' => array(
'filter' => FILTER_DEFAULT,
'pageset' => true,
'default' => ''
),
'sort_column' => array(
'filter' => FILTER_CALLBACK,
'default' => 'name',
'options' => array('options' => 'sanitize_search_string')
),
'sort_direction' => array(
'filter' => FILTER_CALLBACK,
'default' => 'ASC',
'options' => array('options' => 'sanitize_search_string')
),
'has_graphs' => array(
'filter' => FILTER_VALIDATE_REGEXP,
'options' => array('options' => array('regexp' => '(true|false)')),
'pageset' => true,
'default' => read_config_option('default_has') == 'on' ? 'true':'false'
)
);
validate_store_request_vars($filters, 'sess_vdef');
/* ================= input validation ================= */
vdef_filter();
$total_rows = 0;
$vdefs = array();
if (get_request_var('rows') == '-1') {
$rows = read_config_option('num_rows_table');
} else {
$rows = get_request_var('rows');
}
$vdefs = get_vdef_records($total_rows, $rows);
$nav = html_nav_bar('vdef.php?filter=' . get_request_var('filter'), MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, 5, __('VDEFs'), 'page', 'main');
form_start('vdef.php', 'chk');
print $nav;
html_start_box('', '100%', '', '3', 'center', '');
$display_text = array(
'name' => array('display' => __('VDEF Name'), 'align' => 'left', 'sort' => 'ASC', 'tip' => __esc('The name of this VDEF.') ),
'nosort' => array('display' => __('Deletable'), 'align' => 'right', 'tip' => __esc('VDEFs that are in use cannot be Deleted. In use is defined as being referenced by a Graph or a Graph Template.') ),
'graphs' => array('display' => __('Graphs Using'), 'align' => 'right', 'sort' => 'DESC', 'tip' => __esc('The number of Graphs using this VDEF.') ),
'templates' => array('display' => __('Templates Using'), 'align' => 'right', 'sort' => 'DESC', 'tip' => __esc('The number of Graphs Templates using this VDEF.') )
);
html_header_sort_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), false);
$i = 0;
if (cacti_sizeof($vdefs)) {
foreach ($vdefs as $vdef) {
if ($vdef['graphs'] == 0 && $vdef['templates'] == 0) {
$disabled = false;
} else {
$disabled = true;
}
form_alternate_row('line' . $vdef['id'], false, $disabled);
form_selectable_cell(filter_value($vdef['name'], get_request_var('filter'), 'vdef.php?action=edit&id=' . $vdef['id']), $vdef['id']);
form_selectable_cell($disabled ? __('No'):__('Yes'), $vdef['id'], '', 'right');
form_selectable_cell(number_format_i18n($vdef['graphs'], '-1'), $vdef['id'], '', 'right');
form_selectable_cell(number_format_i18n($vdef['templates'], '-1'), $vdef['id'], '', 'right');
form_checkbox_cell($vdef['name'], $vdef['id'], $disabled);
form_end_row();
}
} else {
print "
" . __('No VDEFs') . "
\n";
}
html_end_box(false);
if (cacti_sizeof($vdefs)) {
print $nav;
}
/* draw the dropdown containing a list of available actions for this form */
draw_actions_dropdown($vdef_actions);
form_end();
}