true,
'text' => ''.html_print_image('images/list.png', true, ['title' => __('Graph list')]).'',
];
if ($enterpriseEnable) {
$buttons = reporting_enterprise_add_template_graph_tabs($buttons);
}
$subsection = '';
switch ($activeTab) {
case 'main':
$buttons['graph_list']['active'] = true;
$subsection = ' » '.__('Graph list');
break;
default:
$subsection = reporting_enterprise_add_graph_template_subsection($activeTab, $buttons);
break;
}
switch ($activeTab) {
case 'main':
include_once 'godmode/reporting/graphs.php';
break;
default:
reporting_enterprise_select_graph_template_tab($activeTab);
break;
}
if ($enterpriseEnable) {
$buttons['graph_container'] = [
'active' => false,
'text' => ''.html_print_image('images/graph-container.png', true, ['title' => __('Graphs containers')]).'',
];
}
$delete_graph = (bool) get_parameter('delete_graph');
$view_graph = (bool) get_parameter('view_graph');
$id = (int) get_parameter('id');
$multiple_delete = (bool) get_parameter('multiple_delete', 0);
// Header
ui_print_page_header(__('Reporting').' » '.__('Custom graphs'), 'images/chart.png', false, '', false, $buttons);
// Delete module SQL code
if ($delete_graph) {
$graph_group = db_get_value('id_group', 'tgraph', 'id_graph', $id);
if (check_acl_restricted_all($config['id_user'], $graph_group, 'RW')
|| check_acl_restricted_all($config['id_user'], $graph_group, 'RM')
) {
$exist = db_get_value('id_graph', 'tgraph_source', 'id_graph', $id);
if ($exist) {
$result = db_process_sql_delete('tgraph_source', ['id_graph' => $id]);
if ($result) {
$result = ui_print_success_message(__('Successfully deleted'));
} else {
$result = ui_print_error_message(__('Not deleted. Error deleting data'));
}
}
$result = db_process_sql_delete('tgraph', ['id_graph' => $id]);
if ($result) {
db_pandora_audit('Report management', "Delete graph #$id");
$result = ui_print_success_message(__('Successfully deleted'));
} else {
db_pandora_audit('Report management', "Fail try to delete graph #$id");
$result = ui_print_error_message(__('Not deleted. Error deleting data'));
}
echo $result;
} else {
db_pandora_audit('ACL Violation', 'Trying to delete a graph from access graph builder');
include 'general/noaccess.php';
exit;
}
}
if ($multiple_delete) {
$ids = (array) get_parameter('delete_multiple', []);
foreach ($ids as $id) {
$result = db_process_sql_delete(
'tgraph',
['id_graph' => $id]
);
if ($result === false) {
break;
}
}
if ($result !== false) {
$result = true;
} else {
$result = false;
}
$str_ids = implode(',', $ids);
if ($result) {
db_pandora_audit('Report management', "Multiple delete graph: $str_ids");
} else {
db_pandora_audit('Report management', "Fail try to delete graphs: $str_ids");
}
ui_print_result_message(
$result,
__('Successfully deleted'),
__('Not deleted. Error deleting data')
);
}
$id_group = (int) get_parameter('id_group', 0);
$search = trim(get_parameter('search', ''));
$graphs = custom_graphs_get_user($config['id_user'], false, true, $access);
$offset = (int) get_parameter('offset');
$table_aux = new stdClass();
$table_aux->width = '100%';
$table_aux->class = 'databox filters';
$table_aux->cellpadding = 0;
$table_aux->cellspacing = 0;
$table_aux->colspan[0][0] = 4;
$table_aux->data[0][0] = ''.__('Group').'';
$table_aux->data[0][1] = html_print_select_groups(false, $access, true, 'id_group', $id_group, '', '', '', true, false, true, '', false, '', false, false, 'id_grupo', $strict_user).'
';
$table_aux->data[0][2] = ''.__('Free text for search: ').ui_print_help_tip(
__('Search by report name or description, list matches.'),
true
).'';
$table_aux->data[0][3] = html_print_input_text('search', $search, '', 30, '', true);
$table_aux->data[0][6] = html_print_submit_button(__('Search'), 'search_submit', false, 'class="sub upd"', true);
if (is_metaconsole()) {
$filter = "