2009-03-25 Esteban Sanchez <estebans@artica.es>
* include/functions_alerts.php: Finished the alerts API by removing useless and focus of problems clean_*(). All the functions now uses process_sql_*(). * godmode/alerts/alert_actions.php, godmode/alerts/alert_commands.php: Adapted to changes in functions_alerts.php. * godmode/alerts/configure_alert_template.php: Fixed default action updating when it's set to None. Fixed textarea height. * include/functions_reports.php: Added to repository. API to manage user reports. * include/functions_db.php: Moved get_reports() to functions_reports.php. Escape ` on get_db_value(). Use format_array_to_update_sql() on process_sql_update(). * godmode/reporting/reporting_builder.php: Use functions from reports API. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1560 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
8dac9ddee2
commit
8a8c508e86
|
@ -1,3 +1,26 @@
|
||||||
|
2009-03-25 Esteban Sanchez <estebans@artica.es>
|
||||||
|
|
||||||
|
* include/functions_alerts.php: Finished the alerts API by removing
|
||||||
|
useless and focus of problems clean_*(). All the functions now uses
|
||||||
|
process_sql_*().
|
||||||
|
|
||||||
|
* godmode/alerts/alert_actions.php,
|
||||||
|
godmode/alerts/alert_commands.php: Adapted to changes in
|
||||||
|
functions_alerts.php.
|
||||||
|
|
||||||
|
* godmode/alerts/configure_alert_template.php: Fixed default action
|
||||||
|
updating when it's set to None. Fixed textarea height.
|
||||||
|
|
||||||
|
* include/functions_reports.php: Added to repository. API to manage
|
||||||
|
user reports.
|
||||||
|
|
||||||
|
* include/functions_db.php: Moved get_reports() to
|
||||||
|
functions_reports.php. Escape ` on get_db_value(). Use
|
||||||
|
format_array_to_update_sql() on process_sql_update().
|
||||||
|
|
||||||
|
* godmode/reporting/reporting_builder.php: Use functions from reports
|
||||||
|
API.
|
||||||
|
|
||||||
2009-03-25 Esteban Sanchez <estebans@artica.es>
|
2009-03-25 Esteban Sanchez <estebans@artica.es>
|
||||||
|
|
||||||
* include/auth/mysql.php: Fixed an error on get_user_id() which was
|
* include/auth/mysql.php: Fixed an error on get_user_id() which was
|
||||||
|
|
|
@ -71,10 +71,13 @@ if ($update_action) {
|
||||||
$field2 = (string) get_parameter ('field2');
|
$field2 = (string) get_parameter ('field2');
|
||||||
$field3 = (string) get_parameter ('field3');
|
$field3 = (string) get_parameter ('field3');
|
||||||
|
|
||||||
$result = update_alert_action ($id, $id_alert_command, $name,
|
$values = array ();
|
||||||
array ('field1' => $field1,
|
$values['name'] = $name;
|
||||||
'field2' => $field2,
|
$values['id_alert_command'] = $id_alert_command;
|
||||||
'field3' => $field3));
|
$values['field1'] = $field1;
|
||||||
|
$values['field2'] = $field2;
|
||||||
|
$values['field3'] = $field3;
|
||||||
|
$result = update_alert_action ($id, $values);
|
||||||
|
|
||||||
print_error_message ($result, __('Successfully updated'),
|
print_error_message ($result, __('Successfully updated'),
|
||||||
__('Could not be updated'));
|
__('Could not be updated'));
|
||||||
|
|
|
@ -68,8 +68,11 @@ if ($update_command) {
|
||||||
$command = (string) get_parameter ('command');
|
$command = (string) get_parameter ('command');
|
||||||
$description = (string) get_parameter ('description');
|
$description = (string) get_parameter ('description');
|
||||||
|
|
||||||
$result = update_alert_command ($id, $name, $command,
|
$values = array ();
|
||||||
array ('description' => $description));
|
$values['name'] = $name;
|
||||||
|
$values['command'] = $command;
|
||||||
|
$values['description'] = $description;
|
||||||
|
$result = update_alert_command ($id, $values);
|
||||||
|
|
||||||
print_error_message ($result, __('Successfully updated'),
|
print_error_message ($result, __('Successfully updated'),
|
||||||
__('Could not be updated'));
|
__('Could not be updated'));
|
||||||
|
|
|
@ -163,7 +163,7 @@ function update_template ($step) {
|
||||||
'time_from' => $time_from,
|
'time_from' => $time_from,
|
||||||
'time_to' => $time_to,
|
'time_to' => $time_to,
|
||||||
'time_threshold' => $threshold,
|
'time_threshold' => $threshold,
|
||||||
'default_action' => $default_action,
|
'id_alert_action' => $default_action,
|
||||||
'field1' => $field1,
|
'field1' => $field1,
|
||||||
'field2' => $field2,
|
'field2' => $field2,
|
||||||
'field3' => $field3,
|
'field3' => $field3,
|
||||||
|
@ -171,10 +171,6 @@ function update_template ($step) {
|
||||||
'min_alerts' => $min_alerts
|
'min_alerts' => $min_alerts
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($default_action) {
|
|
||||||
$values['id_alert_action'] = $default_action;
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = update_alert_template ($id, $values);
|
$result = update_alert_template ($id, $values);
|
||||||
} elseif ($step == 3) {
|
} elseif ($step == 3) {
|
||||||
$recovery_notify = (bool) get_parameter ('recovery_notify');
|
$recovery_notify = (bool) get_parameter ('recovery_notify');
|
||||||
|
@ -300,8 +296,8 @@ print_alert_template_steps ($step, $id);
|
||||||
$table->id = 'template';
|
$table->id = 'template';
|
||||||
$table->width = '90%';
|
$table->width = '90%';
|
||||||
$table->style = array ();
|
$table->style = array ();
|
||||||
$table->style[0] = 'font-weight: bold';
|
$table->style[0] = 'font-weight: bold; vertical-align: top';
|
||||||
$table->style[2] = 'font-weight: bold';
|
$table->style[2] = 'font-weight: bold; vertical-align: top';
|
||||||
$table->size = array ();
|
$table->size = array ();
|
||||||
$table->size[0] = '20%';
|
$table->size[0] = '20%';
|
||||||
$table->size[2] = '20%';
|
$table->size[2] = '20%';
|
||||||
|
@ -370,7 +366,7 @@ if ($step == 2) {
|
||||||
$table->data['field2'][1] = print_input_text ('field2', $field2, '', 35, 255, true);
|
$table->data['field2'][1] = print_input_text ('field2', $field2, '', 35, 255, true);
|
||||||
|
|
||||||
$table->data['field3'][0] = __('Field 3');
|
$table->data['field3'][0] = __('Field 3');
|
||||||
$table->data['field3'][1] = print_textarea ('field3', 30, 30, $field3, '', true);
|
$table->data['field3'][1] = print_textarea ('field3', 10, 30, $field3, '', true);
|
||||||
|
|
||||||
$table->data[4][0] = __('Default action');
|
$table->data[4][0] = __('Default action');
|
||||||
$table->data[4][1] = print_select_from_sql ('SELECT id, name FROM talert_actions ORDER BY name',
|
$table->data[4][1] = print_select_from_sql ('SELECT id, name FROM talert_actions ORDER BY name',
|
||||||
|
|
|
@ -23,11 +23,13 @@ check_login ();
|
||||||
|
|
||||||
if (! give_acl ($config['id_user'], 0, "AW")) {
|
if (! give_acl ($config['id_user'], 0, "AW")) {
|
||||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
||||||
"Trying to access graph builder");
|
"Trying to access report builder");
|
||||||
require ("general/noaccess.php");
|
require ("general/noaccess.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require_once ("include/functions_reports.php");
|
||||||
|
|
||||||
if (is_ajax ()) {
|
if (is_ajax ()) {
|
||||||
$get_report_type_data_source = (bool) get_parameter ('get_report_type_data_source');
|
$get_report_type_data_source = (bool) get_parameter ('get_report_type_data_source');
|
||||||
|
|
||||||
|
@ -57,72 +59,34 @@ $edit_sla_report_content = (bool) get_parameter ('edit_sla_report_content');
|
||||||
$content_up = (bool) get_parameter ('content_up');
|
$content_up = (bool) get_parameter ('content_up');
|
||||||
$content_down = (bool) get_parameter ('content_down');
|
$content_down = (bool) get_parameter ('content_down');
|
||||||
|
|
||||||
if (isset($_GET["get_agent"])) {
|
|
||||||
$id_agent = $_POST["id_agent"];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete module SQL code
|
// Delete module SQL code
|
||||||
if ($delete_report_content) {
|
if ($delete_report_content) {
|
||||||
$id_report_content = (int) get_parameter ('id_report_content');
|
$id_report_content = (int) get_parameter ('id_report_content');
|
||||||
$sql = sprintf ('SELECT `order`
|
|
||||||
FROM treport_content
|
$result = delete_report_content ($id_report_content);
|
||||||
WHERE id_rc = %d',
|
print_error_message ($result,
|
||||||
$id_report_content);
|
__('Successfully deleted'),
|
||||||
$order = get_db_sql ($sql);
|
__('Could not be deleted'));
|
||||||
$sql = sprintf ('UPDATE treport_content
|
|
||||||
SET `order` = `order` -1
|
|
||||||
WHERE id_report = %d AND `order` > %d',
|
|
||||||
$id_report, $order);
|
|
||||||
process_sql ($sql);
|
|
||||||
$sql = sprintf ('DELETE FROM treport_content WHERE id_rc = %d', $id_report_content);
|
|
||||||
$result = process_sql ($sql);
|
|
||||||
if ($result !== false) {
|
|
||||||
echo "<h3 class='suc'>".__('Deleted successfully')."</h3>";
|
|
||||||
} else {
|
|
||||||
echo "<h3 class='error'>".__('Not deleted. Error deleting data')."</h3>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move content up
|
// Move content up
|
||||||
if ($content_up) {
|
if ($content_up) {
|
||||||
$id_report_content = (int) get_parameter ('id_report_content');
|
$id_report_content = (int) get_parameter ('id_report_content');
|
||||||
$order = get_db_value ('`order`', 'treport_content', 'id_rc', $id_report_content);
|
move_report_content_up ($id_report_content, $id_report);
|
||||||
/* Set the previous element order to the current of the content we want to change */
|
|
||||||
$sql = sprintf ('UPDATE treport_content
|
|
||||||
SET `order` = `order` + 1
|
|
||||||
WHERE id_report = %d
|
|
||||||
AND `order` = %d',
|
|
||||||
$id_report, $order - 1);
|
|
||||||
$result = process_sql ($sql);
|
|
||||||
$sql = sprintf ('UPDATE treport_content
|
|
||||||
SET `order` = `order` - 1
|
|
||||||
WHERE id_rc = %d',
|
|
||||||
$id_report_content);
|
|
||||||
$result = process_sql ($sql);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move content down
|
// Move content down
|
||||||
if ($content_down) {
|
if ($content_down) {
|
||||||
$id_report_content = (int) get_parameter ('id_report_content');
|
$id_report_content = (int) get_parameter ('id_report_content');
|
||||||
$order = get_db_value ('`order`', 'treport_content', 'id_rc', $id_report_content);
|
move_report_content_down ($id_report_content, $id_report);
|
||||||
/* Set the previous element order to the current of the content we want to change */
|
|
||||||
$sql = sprintf ('UPDATE treport_content SET `order` = `order` - 1 WHERE id_report = %d AND `order` = %d',
|
|
||||||
$id_report, $order + 1);
|
|
||||||
$result = process_sql ($sql);
|
|
||||||
$sql = sprintf ('UPDATE treport_content SET `order` = `order` + 1 WHERE id_rc = %d', $id_report_content);
|
|
||||||
$result = process_sql ($sql);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete report SQL code
|
// Delete report SQL code
|
||||||
if ($delete_report) {
|
if ($delete_report) {
|
||||||
$sql = sprintf ('DELETE FROM treport_content WHERE id_report = %d', $id_report);
|
$result = delete_report ($id_report);
|
||||||
$sql2 = sprintf ('DELETE FROM treport WHERE id_report = %d', $id_report);
|
print_error_message ($result,
|
||||||
$res = process_sql ($sql);
|
__('Successfully deleted'),
|
||||||
$res2 = process_sql ($sql2);
|
__('Could not be deleted'));
|
||||||
if ($res && $res2)
|
|
||||||
echo "<h3 class=suc>".__('Reporting successfully deleted')."</h3>";
|
|
||||||
else
|
|
||||||
echo "<h3 class=error>".__('There was a problem deleting reporting')."</h3>";
|
|
||||||
$id_report = 0;
|
$id_report = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,20 +100,19 @@ if ($add_content) {
|
||||||
$id_agent_module = (int) get_parameter ('id_module');
|
$id_agent_module = (int) get_parameter ('id_module');
|
||||||
$period = (int) get_parameter ('period');
|
$period = (int) get_parameter ('period');
|
||||||
$type = (string) get_parameter ('type');
|
$type = (string) get_parameter ('type');
|
||||||
$id_agent = (int) get_parameter ('id_agent',0);
|
$id_agent = (int) get_parameter ('id_agent');
|
||||||
$id_custom_graph = (int) get_parameter ('id_custom_graph');
|
$id_custom_graph = (int) get_parameter ('id_custom_graph');
|
||||||
$module_description = (string) get_parameter ('module_description', '');
|
$module_description = (string) get_parameter ('module_description');
|
||||||
|
|
||||||
$order = (int) get_db_value ('COUNT(*)', 'treport_content', 'id_report', $id_report);
|
$values = array ();
|
||||||
|
$values['id_custom_graph'] = $id_custom_graph ? $id_custom_graph : NULL;
|
||||||
$sql = sprintf ('INSERT INTO treport_content (id_report, id_gs, id_agent_module,
|
$values['id_agent_module'] = $id_agent_module ? $id_agent_module : NULL;
|
||||||
`order`, type, period, description, id_agent)
|
$values['type'] = $type;
|
||||||
VALUES (%d, %s, %s, %d, "%s", %d, "%s", %d)',
|
$values['period'] = $period * 3600;
|
||||||
$id_report, $id_custom_graph ? $id_custom_graph : "NULL",
|
$values['description'] = $module_description;
|
||||||
$id_agent_module ? $id_agent_module : "NULL",
|
$values['id_agent'] = $id_agent;
|
||||||
$order, $type, $period * 3600, $module_description, $id_agent);
|
|
||||||
$result = process_sql ($sql);
|
|
||||||
|
|
||||||
|
$result = create_report_content ($id_report, $values);
|
||||||
if ($result !== false) {
|
if ($result !== false) {
|
||||||
echo '<h3 class="suc">'.__('Reporting successfully created').'</h3>';
|
echo '<h3 class="suc">'.__('Reporting successfully created').'</h3>';
|
||||||
$id_agent = 0;
|
$id_agent = 0;
|
||||||
|
@ -170,34 +133,31 @@ if ($add_content) {
|
||||||
|
|
||||||
// Create report
|
// Create report
|
||||||
if ($create_report) {
|
if ($create_report) {
|
||||||
$sql = sprintf ('INSERT INTO treport (name, description, id_user, private, id_group)
|
$values = array ();
|
||||||
VALUES ("%s", "%s", "%s", %d, %d)',
|
$values['description'] = $report_description;
|
||||||
$report_name, $report_description, $config['id_user'], $report_private, $report_id_group);
|
$values['private'] = $report_private;
|
||||||
$id_report = process_sql ($sql, "insert_id");
|
$id_report = create_report ($name, $id_group, $values);
|
||||||
if ($id_report !== false) {
|
print_error_message ($id_report,
|
||||||
echo "<h3 class=suc>".__('Reporting successfully created')."</h3>";
|
__('Successfully created'),
|
||||||
} else {
|
__('Could not be created'));
|
||||||
echo "<h3 class=error>".__('There was a problem creating reporting')."</h3>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update report
|
// Update report
|
||||||
if ($update_report) {
|
if ($update_report) {
|
||||||
$sql = sprintf ('UPDATE treport SET name = "%s",
|
$values = array ();
|
||||||
description = "%s", private = %d
|
$values['name'] = $report_name;
|
||||||
WHERE id_report = %d',
|
$values['description'] = $report_description;
|
||||||
$report_name, $report_description,
|
$values['private'] = $report_private;
|
||||||
$report_private, $id_report);
|
$result = update_report ($id_report, $values);
|
||||||
$result = process_sql ($sql);
|
print_error_message ($result,
|
||||||
if ($result) {
|
__('Successfully updated'),
|
||||||
echo "<h3 class=suc>".__('Updated successfully')."</h3>";
|
__('Could not be updated'));
|
||||||
} else {
|
|
||||||
echo "<h3 class=error>".__('Not updated. Error updating data')."</h3>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($id_report) {
|
if ($id_report) {
|
||||||
$report = get_db_row ('treport', 'id_report', (int) $id_report);
|
$report = get_report ($id_report);
|
||||||
|
if ($report === false)
|
||||||
|
require ("general/noaccess.php");
|
||||||
$report_name = $report["name"];
|
$report_name = $report["name"];
|
||||||
$report_description = $report["description"];
|
$report_description = $report["description"];
|
||||||
$report_private = $report["private"];
|
$report_private = $report["private"];
|
||||||
|
@ -367,7 +327,7 @@ if ($edit_sla_report_content) {
|
||||||
if ($id_report) {
|
if ($id_report) {
|
||||||
print_input_hidden ('id_report', $id_report);
|
print_input_hidden ('id_report', $id_report);
|
||||||
print_input_hidden ('update_report', 1);
|
print_input_hidden ('update_report', 1);
|
||||||
print_submit_button (__('Update'), 'submit', false, 'class="sub next"');
|
print_submit_button (__('Update'), 'submit', false, 'class="sub upd"');
|
||||||
} else {
|
} else {
|
||||||
print_input_hidden ('create_report', 1);
|
print_input_hidden ('create_report', 1);
|
||||||
print_submit_button (__('Create'), 'submit', false, 'class="sub wand"');
|
print_submit_button (__('Create'), 'submit', false, 'class="sub wand"');
|
||||||
|
@ -415,8 +375,9 @@ if ($edit_sla_report_content) {
|
||||||
$table->data[3][0] = __('Module');
|
$table->data[3][0] = __('Module');
|
||||||
$modules = array ();
|
$modules = array ();
|
||||||
if ($id_agent) {
|
if ($id_agent) {
|
||||||
$sql = sprintf ('SELECT id_agente_modulo, LOWER(nombre) FROM tagente_modulo WHERE id_agente = %d ORDER BY nombre', $id_agent);
|
$modules = get_db_all_rows_filter ('tagente_modulo',
|
||||||
$modules = get_db_all_rows_sql ($sql);
|
array ('id_agente' => $id_agent, 'order' => 'nombre');
|
||||||
|
array ('id_agente_modulo', 'nombre'));
|
||||||
}
|
}
|
||||||
$table->data[3][1] = print_select ($modules, 'id_module', 0, '', '--', 0, true);
|
$table->data[3][1] = print_select ($modules, 'id_module', 0, '', '--', 0, true);
|
||||||
|
|
||||||
|
@ -459,8 +420,8 @@ if ($edit_sla_report_content) {
|
||||||
$table->head[6] = __('Delete');
|
$table->head[6] = __('Delete');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = sprintf ('SELECT * FROM treport_content WHERE id_report = %d ORDER BY `order`', $id_report);
|
$report_contents = get_report_contents ($id_report);
|
||||||
$report_contents = get_db_all_rows_sql ($sql);
|
|
||||||
if (sizeof ($report_contents)) {
|
if (sizeof ($report_contents)) {
|
||||||
$first_id = $report_contents[0]['id_rc'];
|
$first_id = $report_contents[0]['id_rc'];
|
||||||
$last_id = $report_contents[sizeof ($report_contents) - 1]['id_rc'];
|
$last_id = $report_contents[sizeof ($report_contents) - 1]['id_rc'];
|
||||||
|
@ -470,14 +431,24 @@ if ($edit_sla_report_content) {
|
||||||
$data = array ();
|
$data = array ();
|
||||||
$data[0] = '';
|
$data[0] = '';
|
||||||
if ($first_id != $report_content['id_rc']) {
|
if ($first_id != $report_content['id_rc']) {
|
||||||
$data[0] .= '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&edit_report=1&id_report='.
|
$data[0] .= '<form method="post" style="display:inline">';
|
||||||
$id_report.'&content_up=1&id_report_content='.$report_content['id_rc'].
|
$data[0] .= print_input_hidden ('edit_report', 1, true);
|
||||||
'"><img src="images/up.png" title="'.__('Up').'"></a>';
|
$data[0] .= print_input_hidden ('id_report', $id_report, true);
|
||||||
|
$data[0] .= print_input_hidden ('content_up', 1, true);
|
||||||
|
$data[0] .= print_input_hidden ('id_report_content', $report_content['id_rc'], true);
|
||||||
|
$data[0] .= print_input_image ('up', 'images/up.png', 1, '',
|
||||||
|
true, array ('title' => __('Up')));
|
||||||
|
$data[0] .= '</form>';
|
||||||
}
|
}
|
||||||
if ($last_id != $report_content['id_rc']) {
|
if ($last_id != $report_content['id_rc']) {
|
||||||
$data[0] .= '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&edit_report=1&id_report='.
|
$data[0] .= '<form method="post" style="display:inline">';
|
||||||
$id_report.'&content_down=1&id_report_content='.$report_content['id_rc'].
|
$data[0] .= print_input_hidden ('edit_report', 1, true);
|
||||||
'"><img src="images/down.png" title="'.__('Down').'"></a>';
|
$data[0] .= print_input_hidden ('id_report', $id_report, true);
|
||||||
|
$data[0] .= print_input_hidden ('content_down', 1, true);
|
||||||
|
$data[0] .= print_input_hidden ('id_report_content', $report_content['id_rc'], true);
|
||||||
|
$data[0] .= print_input_image ('down', 'images/down.png', 1, '',
|
||||||
|
true, array ('title' => __('Down')));
|
||||||
|
$data[0] .= '</form>';
|
||||||
}
|
}
|
||||||
$data[1] = get_report_name ($report_content['type']);
|
$data[1] = get_report_name ($report_content['type']);
|
||||||
$data[2] = get_agent_name ($report_content['id_agent']);
|
$data[2] = get_agent_name ($report_content['id_agent']);
|
||||||
|
@ -492,8 +463,15 @@ if ($edit_sla_report_content) {
|
||||||
if ($report_content['type'] == 'SLA') {
|
if ($report_content['type'] == 'SLA') {
|
||||||
$data[5] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&id_report='.$id_report.'&edit_sla_report_content=1&id_report_content='.$report_content['id_rc'].'"><img src="images/setup.png"></a>';
|
$data[5] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&id_report='.$id_report.'&edit_sla_report_content=1&id_report_content='.$report_content['id_rc'].'"><img src="images/setup.png"></a>';
|
||||||
}
|
}
|
||||||
if ($report_id_user == $config['id_user']) {
|
if ($report_id_user == $config['id_user'] || is_user_admin ($config['id_user'])) {
|
||||||
$data[6] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&id_report='.$id_report.'&delete_report_content=1&id_report_content='.$report_content['id_rc'].'"><img src="images/cross.png"></a>';
|
$data[6] = '<form method="post" style="display:inline" onsubmit="if (!confirm (\''.__('Are you sure?').'\')) return false">';
|
||||||
|
$data[6] .= print_input_hidden ('edit_report', 1, true);
|
||||||
|
$data[6] .= print_input_hidden ('id_report', $id_report, true);
|
||||||
|
$data[6] .= print_input_hidden ('delete_report_content', 1, true);
|
||||||
|
$data[6] .= print_input_hidden ('id_report_content', $report_content['id_rc'], true);
|
||||||
|
$data[6] .= print_input_image ('delete', 'images/cross.png', 1, '',
|
||||||
|
true, array ('title' => __('Delete')));
|
||||||
|
$data[6] .= '</form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
array_push ($table->data, $data);
|
array_push ($table->data, $data);
|
||||||
|
@ -506,9 +484,10 @@ if ($edit_sla_report_content) {
|
||||||
echo "<h2>".__('Reporting')." > ";
|
echo "<h2>".__('Reporting')." > ";
|
||||||
echo __('Custom reporting')."</h2>";
|
echo __('Custom reporting')."</h2>";
|
||||||
|
|
||||||
$reports = get_db_all_rows_in_table ('treport', 'name');
|
$reports = get_reports (array ('order' => 'name'),
|
||||||
|
array ('name', 'id_report', 'description'));
|
||||||
$table->width = '0px';
|
$table->width = '0px';
|
||||||
if ($reports !== false) {
|
if (sizeof ($reports)) {
|
||||||
$table->id = 'report_list';
|
$table->id = 'report_list';
|
||||||
$table->width = '600px';
|
$table->width = '600px';
|
||||||
$table->head = array ();
|
$table->head = array ();
|
||||||
|
@ -520,14 +499,16 @@ if ($edit_sla_report_content) {
|
||||||
$table->head[2] = __('Delete');
|
$table->head[2] = __('Delete');
|
||||||
|
|
||||||
foreach ($reports as $report) {
|
foreach ($reports as $report) {
|
||||||
if ($report["private"] || $report["id_user"] != $config['id_user'])
|
|
||||||
continue;
|
|
||||||
$data = array ();
|
$data = array ();
|
||||||
$data[0] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&edit_report=1&id_report='.
|
$data[0] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&edit_report=1&id_report='.
|
||||||
$report['id_report'].'">'.$report['name'].'</a>';
|
$report['id_report'].'">'.$report['name'].'</a>';
|
||||||
$data[1] = $report['description'];
|
$data[1] = $report['description'];
|
||||||
$data[2] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&delete_report=1&id_report='.
|
$data[2] = '<form method="post" style="display:inline" onsubmit="if (!confirm (\''.__('Are you sure?').'\')) return false">';
|
||||||
$report['id_report'].'"><img src="images/cross.png"></a>';
|
$data[2] .= print_input_hidden ('id_report', $report['id_report'], true);
|
||||||
|
$data[2] .= print_input_hidden ('delete_report', 1, true);
|
||||||
|
$data[2] .= print_input_image ('delete', 'images/cross.png', 1, '',
|
||||||
|
true, array ('title' => __('Delete')));
|
||||||
|
$data[2] .= '</form>';
|
||||||
|
|
||||||
array_push ($table->data, $data);
|
array_push ($table->data, $data);
|
||||||
|
|
||||||
|
|
|
@ -17,51 +17,29 @@
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
function clean_alert_command_values ($values, $set_empty = true) {
|
|
||||||
$retvalues = array ();
|
|
||||||
|
|
||||||
if ($set_empty) {
|
|
||||||
$retvalues['description'] = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty ($values))
|
|
||||||
return $retvalues;
|
|
||||||
|
|
||||||
if (isset ($values['description']))
|
|
||||||
$retvalues['description'] = (string) $values['description'];
|
|
||||||
|
|
||||||
return $retvalues;
|
|
||||||
}
|
|
||||||
|
|
||||||
function create_alert_command ($name, $command, $values = false) {
|
function create_alert_command ($name, $command, $values = false) {
|
||||||
if (empty ($name))
|
if (empty ($name))
|
||||||
return false;
|
return false;
|
||||||
if (empty ($command))
|
if (empty ($command))
|
||||||
return false;
|
return false;
|
||||||
|
if (! is_array ($values))
|
||||||
|
$values = array ();
|
||||||
|
$values['name'] = $name;
|
||||||
|
$values['description'] = $description;
|
||||||
|
|
||||||
$values = clean_alert_command_values ($values);
|
return @process_sql_insert ('talert_commands', $values);
|
||||||
|
|
||||||
$sql = sprintf ('INSERT talert_commands (name, command, description)
|
|
||||||
VALUES ("%s", "%s", "%s")',
|
|
||||||
$name, $command, $values['description']);
|
|
||||||
return @process_sql ($sql, 'insert_id');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_alert_command ($id_alert_command, $name, $command, $description = '', $values = false) {
|
function update_alert_command ($id_alert_command, $values) {
|
||||||
$id_alert_command = safe_int ($id_alert_command, 1);
|
$id_alert_command = safe_int ($id_alert_command, 1);
|
||||||
if (empty ($id_alert_command))
|
if (empty ($id_alert_command))
|
||||||
return false;
|
return false;
|
||||||
if (empty ($name))
|
if (! is_array ($values))
|
||||||
return false;
|
|
||||||
if (empty ($command))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$values = clean_alert_command_values ($values);
|
return (@process_sql_update ('talert_commands',
|
||||||
|
$values,
|
||||||
$sql = sprintf ('UPDATE talert_commands SET name = "%s", command = "%s",
|
array ('id' => $id_alert_command))) !== false;
|
||||||
description = "%s" WHERE id = %d',
|
|
||||||
$name, $command, $values['description'], $id_alert_command);
|
|
||||||
return @process_sql ($sql) !== false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete_alert_command ($id_alert_command) {
|
function delete_alert_command ($id_alert_command) {
|
||||||
|
@ -69,9 +47,8 @@ function delete_alert_command ($id_alert_command) {
|
||||||
if (empty ($id_alert_command))
|
if (empty ($id_alert_command))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$sql = sprintf ('DELETE FROM talert_commands WHERE id = %d',
|
return (@proces_sql_delete ('talert_commands',
|
||||||
$id_alert_command);
|
array ('id' => $id_alert_command))) !== false;
|
||||||
return @process_sql ($sql);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_alert_command ($id_alert_command) {
|
function get_alert_command ($id_alert_command) {
|
||||||
|
@ -114,28 +91,6 @@ function get_alert_command_description ($id_alert_command) {
|
||||||
return get_db_value ('description', 'talert_commands', 'id', $id_alert_command);
|
return get_db_value ('description', 'talert_commands', 'id', $id_alert_command);
|
||||||
}
|
}
|
||||||
|
|
||||||
function clean_alert_action_values ($values, $set_empty = true) {
|
|
||||||
$retvalues = array ();
|
|
||||||
|
|
||||||
if ($set_empty) {
|
|
||||||
$retvalues['field1'] = '';
|
|
||||||
$retvalues['field2'] = '';
|
|
||||||
$retvalues['field3'] = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty ($values))
|
|
||||||
return $retvalues;
|
|
||||||
|
|
||||||
if (isset ($values['field1']))
|
|
||||||
$retvalues['field1'] = (string) $values['field1'];
|
|
||||||
if (isset ($values['field2']))
|
|
||||||
$retvalues['field2'] = (string) $values['field2'];
|
|
||||||
if (isset ($values['field3']))
|
|
||||||
$retvalues['field3'] = (string) $values['field3'];
|
|
||||||
|
|
||||||
return $retvalues;
|
|
||||||
}
|
|
||||||
|
|
||||||
function create_alert_action ($name, $id_alert_command, $values = false) {
|
function create_alert_action ($name, $id_alert_command, $values = false) {
|
||||||
$id_alert_command = safe_int ($id_alert_command, 1);
|
$id_alert_command = safe_int ($id_alert_command, 1);
|
||||||
if (empty ($id_alert_command))
|
if (empty ($id_alert_command))
|
||||||
|
@ -143,35 +98,24 @@ function create_alert_action ($name, $id_alert_command, $values = false) {
|
||||||
if (empty ($name))
|
if (empty ($name))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$values = clean_alert_action_values ($values);
|
if (! is_array ($values))
|
||||||
|
$values = array ();
|
||||||
|
$values['name'] = $name;
|
||||||
|
$values['id_alert_command'] = $id_alert_command;
|
||||||
|
|
||||||
$sql = sprintf ('INSERT talert_actions (name, id_alert_command, field1, field2, field3)
|
return @proces_sql_insert ('talert_actions', $values);
|
||||||
VALUES ("%s", %d, "%s", "%s", "%s")',
|
|
||||||
$name, $id_alert_command, $values['field1'], $values['field2'],
|
|
||||||
$values['field3']);
|
|
||||||
|
|
||||||
return @process_sql ($sql, 'insert_id');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_alert_action ($id_alert_action, $id_alert_command, $name, $values = false) {
|
function update_alert_action ($id_alert_action, $values) {
|
||||||
$id_alert_action = safe_int ($id_alert_action, 1);
|
$id_alert_action = safe_int ($id_alert_action, 1);
|
||||||
if (empty ($id_alert_action))
|
if (empty ($id_alert_action))
|
||||||
return false;
|
return false;
|
||||||
$id_alert_command = safe_int ($id_alert_command, 1);
|
if (! is_array ($values))
|
||||||
if (empty ($id_alert_command))
|
|
||||||
return false;
|
|
||||||
if (empty ($name))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$values = clean_alert_action_values ($values);
|
return (@proces_sql_update ('talert_actions',
|
||||||
|
$values,
|
||||||
$sql = sprintf ('UPDATE talert_actions SET name = "%s",
|
array ('id' => $id_alert_action))) !== false;
|
||||||
id_alert_command = %d, field1 = "%s",
|
|
||||||
field2 = "%s", field3 = "%s" WHERE id = %d',
|
|
||||||
$name, $id_alert_command, $values['field1'], $values['field2'],
|
|
||||||
$values['field3'], $id_alert_action);
|
|
||||||
|
|
||||||
return @process_sql ($sql) !== false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete_alert_action ($id_alert_action) {
|
function delete_alert_action ($id_alert_action) {
|
||||||
|
@ -179,9 +123,8 @@ function delete_alert_action ($id_alert_action) {
|
||||||
if (empty ($id_alert_action))
|
if (empty ($id_alert_action))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$sql = sprintf ('DELETE FROM talert_actions WHERE id = %d',
|
return (@proces_sql_delete ('talert_actions',
|
||||||
$id_alert_action);
|
array ('id' => $id_alert_action))) !== false;
|
||||||
return @process_sql ($sql);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_alert_actions ($only_names = true) {
|
function get_alert_actions ($only_names = true) {
|
||||||
|
@ -254,113 +197,14 @@ function get_alert_templates_type_name ($type) {
|
||||||
return $types[$type];
|
return $types[$type];
|
||||||
}
|
}
|
||||||
|
|
||||||
function clean_alert_template_values ($values, $set_empty = true) {
|
|
||||||
$retvalues = array ();
|
|
||||||
|
|
||||||
if ($set_empty) {
|
|
||||||
$retvalues['type'] = 'equal';
|
|
||||||
$retvalues['description'] = '';
|
|
||||||
$retvalues['id_alert_action'] = NULL;
|
|
||||||
$retvalues['field1'] = '';
|
|
||||||
$retvalues['field2'] = '';
|
|
||||||
$retvalues['field3'] = '';
|
|
||||||
$retvalues['value'] = '';
|
|
||||||
$retvalues['max_value'] = 0;
|
|
||||||
$retvalues['min_value'] = 0;
|
|
||||||
$retvalues['time_threshold'] = 0;
|
|
||||||
$retvalues['max_alerts'] = 0;
|
|
||||||
$retvalues['min_alerts'] = 0;
|
|
||||||
$retvalues['monday'] = 0;
|
|
||||||
$retvalues['tuesday'] = 0;
|
|
||||||
$retvalues['wednesday'] = 0;
|
|
||||||
$retvalues['thursday'] = 0;
|
|
||||||
$retvalues['friday'] = 0;
|
|
||||||
$retvalues['saturday'] = 0;
|
|
||||||
$retvalues['sunday'] = 0;
|
|
||||||
$retvalues['time_from'] = '00:00';
|
|
||||||
$retvalues['time_to'] = '00:00';
|
|
||||||
$retvalues['time_threshold'] = '300';
|
|
||||||
$retvalues['recovery_notify'] = '';
|
|
||||||
$retvalues['field2_recovery'] = '';
|
|
||||||
$retvalues['field2_recovery'] = '';
|
|
||||||
$retvalues['matches_value'] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty ($values))
|
|
||||||
return $retvalues;
|
|
||||||
|
|
||||||
if (isset ($values['name']))
|
|
||||||
$retvalues['name'] = (string) $values['name'];
|
|
||||||
if (isset ($values['type']))
|
|
||||||
$retvalues['type'] = (string) $values['type'];
|
|
||||||
if (isset ($values['description']))
|
|
||||||
$retvalues['description'] = (string) $values['description'];
|
|
||||||
if (isset ($values['id_alert_action']))
|
|
||||||
$retvalues['id_alert_action'] = (int) $values['id_alert_action'];
|
|
||||||
if (isset ($values['field1']))
|
|
||||||
$retvalues['field1'] = (string) $values['field1'];
|
|
||||||
if (isset ($values['field2']))
|
|
||||||
$retvalues['field2'] = (string) $values['field2'];
|
|
||||||
if (isset ($values['field3']))
|
|
||||||
$retvalues['field3'] = (string) $values['field3'];
|
|
||||||
if (isset ($values['value']))
|
|
||||||
$retvalues['value'] = (string) $values['value'];
|
|
||||||
if (isset ($values['matches_value']))
|
|
||||||
$retvalues['matches_value'] = (bool) $values['matches_value'];
|
|
||||||
if (isset ($values['max_value']))
|
|
||||||
$retvalues['max_value'] = (float) $values['max_value'];
|
|
||||||
if (isset ($values['min_value']))
|
|
||||||
$retvalues['min_value'] = (float) $values['min_value'];
|
|
||||||
if (isset ($values['time_threshold']))
|
|
||||||
$retvalues['time_threshold'] = (int) $values['time_threshold'];
|
|
||||||
if (isset ($values['max_alerts']))
|
|
||||||
$retvalues['max_alerts'] = (int) $values['max_alerts'];
|
|
||||||
if (isset ($values['min_alerts']))
|
|
||||||
$retvalues['min_alerts'] = (int) $values['min_alerts'];
|
|
||||||
/* Ensure max an min orders */
|
|
||||||
if (isset ($values['min_alerts']) && isset ($values['max_alerts'])) {
|
|
||||||
$max = max ($retvalues['max_alerts'], $retvalues['min_alerts']);
|
|
||||||
$min = min ($retvalues['max_alerts'], $retvalues['min_alerts']);
|
|
||||||
$retvalues['max_alerts'] = $max;
|
|
||||||
$retvalues['min_alerts'] = $min;
|
|
||||||
}
|
|
||||||
if (isset ($values['monday']))
|
|
||||||
$retvalues['monday'] = (bool) $values['monday'];
|
|
||||||
if (isset ($values['tuesday']))
|
|
||||||
$retvalues['tuesday'] = (bool) $values['tuesday'];
|
|
||||||
if (isset ($values['wednesday']))
|
|
||||||
$retvalues['wednesday'] = (bool) $values['wednesday'];
|
|
||||||
if (isset ($values['thursday']))
|
|
||||||
$retvalues['thursday'] = (bool) $values['thursday'];
|
|
||||||
if (isset ($values['friday']))
|
|
||||||
$retvalues['friday'] = (bool) $values['friday'];
|
|
||||||
if (isset ($values['saturday']))
|
|
||||||
$retvalues['saturday'] = (bool) $values['saturday'];
|
|
||||||
if (isset ($values['sunday']))
|
|
||||||
$retvalues['sunday'] = (bool) $values['sunday'];
|
|
||||||
if (isset ($values['time_from']))
|
|
||||||
$retvalues['time_from'] = (string) $values['time_from'];
|
|
||||||
if (isset ($values['time_to']))
|
|
||||||
$retvalues['time_to'] = (string) $values['time_to'];
|
|
||||||
if (isset ($values['time_threshold']))
|
|
||||||
$retvalues['time_threshold'] = (int) $values['time_threshold'];
|
|
||||||
if (isset ($values['recovery_notify']))
|
|
||||||
$retvalues['recovery_notify'] = (bool) $values['recovery_notify'];
|
|
||||||
if (isset ($values['field2_recovery']))
|
|
||||||
$retvalues['field2_recovery'] = (string) $values['field2_recovery'];
|
|
||||||
if (isset ($values['field3_recovery']))
|
|
||||||
$retvalues['field3_recovery'] = (string) $values['field3_recovery'];
|
|
||||||
|
|
||||||
return $retvalues;
|
|
||||||
}
|
|
||||||
|
|
||||||
function create_alert_template ($name, $type, $values = false) {
|
function create_alert_template ($name, $type, $values = false) {
|
||||||
if (empty ($name))
|
if (empty ($name))
|
||||||
return false;
|
return false;
|
||||||
if (empty ($type))
|
if (empty ($type))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$values = clean_alert_template_values ($values);
|
if (! is_array ($values))
|
||||||
|
$values = array ();
|
||||||
$values['name'] = $name;
|
$values['name'] = $name;
|
||||||
$values['type'] = $type;
|
$values['type'] = $type;
|
||||||
|
|
||||||
|
@ -371,12 +215,12 @@ function create_alert_template ($name, $type, $values = false) {
|
||||||
return @process_sql_insert ('talert_templates', $values);
|
return @process_sql_insert ('talert_templates', $values);
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_alert_template ($id_alert_template, $values = false) {
|
function update_alert_template ($id_alert_template, $values) {
|
||||||
$id_alert_template = safe_int ($id_alert_template, 1);
|
$id_alert_template = safe_int ($id_alert_template, 1);
|
||||||
if (empty ($id_alert_template))
|
if (empty ($id_alert_template))
|
||||||
return false;
|
return false;
|
||||||
|
if (! is_array ($values))
|
||||||
$values = clean_alert_template_values ($values, false);
|
return false;
|
||||||
|
|
||||||
return (@process_sql_update ('talert_templates',
|
return (@process_sql_update ('talert_templates',
|
||||||
$values,
|
$values,
|
||||||
|
@ -530,58 +374,25 @@ function duplicate_alert_template ($id_alert_template) {
|
||||||
return create_alert_template ($name, $type, $template);
|
return create_alert_template ($name, $type, $template);
|
||||||
}
|
}
|
||||||
|
|
||||||
function clean_alert_agent_module_values ($values, $set_empty = true) {
|
|
||||||
$retvalues = array ();
|
|
||||||
|
|
||||||
if ($set_empty) {
|
|
||||||
$retvalues['internal_counter'] = 0;
|
|
||||||
$retvalues['last_fired'] = 0;
|
|
||||||
$retvalues['times_fired'] = 0;
|
|
||||||
$retvalues['disabled'] = 0;
|
|
||||||
$retvalues['priority'] = 0;
|
|
||||||
$retvalues['force_execution'] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty ($values))
|
|
||||||
return $retvalues;
|
|
||||||
|
|
||||||
if (isset ($values['internal_counter']))
|
|
||||||
$retvalues['internal_counter'] = (int) $values['internal_counter'];
|
|
||||||
if (isset ($values['last_fired']))
|
|
||||||
$retvalues['last_fired'] = (int) $values['last_fired'];
|
|
||||||
if (isset ($values['times_fired']))
|
|
||||||
$retvalues['times_fired'] = (int) $values['times_fired'];
|
|
||||||
if (isset ($values['disabled']))
|
|
||||||
$retvalues['disabled'] = (int) $values['disabled'];
|
|
||||||
if (isset ($values['priority']))
|
|
||||||
$retvalues['priority'] = (int) $values['priority'];
|
|
||||||
if (isset ($values['force_execution']))
|
|
||||||
$retvalues['force_execution'] = (int) $values['force_execution'];
|
|
||||||
|
|
||||||
return $retvalues;
|
|
||||||
}
|
|
||||||
|
|
||||||
function create_alert_agent_module ($id_agent_module, $id_alert_template, $values = false) {
|
function create_alert_agent_module ($id_agent_module, $id_alert_template, $values = false) {
|
||||||
if (empty ($id_agent_module))
|
if (empty ($id_agent_module))
|
||||||
return false;
|
return false;
|
||||||
if (empty ($id_alert_template))
|
if (empty ($id_alert_template))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$values = clean_alert_agent_module_values ($values);
|
if (! is_array ($values))
|
||||||
|
$values = array ();
|
||||||
$values['id_agent_module'] = $id_agent_module;
|
$values['id_agent_module'] = $id_agent_module;
|
||||||
$values['id_alert_template'] = $id_alert_template;
|
$values['id_alert_template'] = $id_alert_template;
|
||||||
return @process_sql_insert ('talert_template_modules',
|
|
||||||
$values,
|
return @process_sql_insert ('talert_template_modules', $values);
|
||||||
array ('id' => $id_alert_template));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_alert_agent_module ($id_alert_agent_module, $values = false) {
|
function update_alert_agent_module ($id_alert_agent_module, $values) {
|
||||||
if (empty ($id_agent_module))
|
if (empty ($id_agent_module))
|
||||||
return false;
|
return false;
|
||||||
|
if (! is_array ($values))
|
||||||
$values = clean_alert_agent_module_values ($values, false);
|
return false;
|
||||||
if ($empty ($values))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return (@process_sql_update ('talert_template_modules',
|
return (@process_sql_update ('talert_template_modules',
|
||||||
$values,
|
$values,
|
||||||
|
@ -810,97 +621,23 @@ function get_alert_compound_operations () {
|
||||||
return $operations;
|
return $operations;
|
||||||
}
|
}
|
||||||
|
|
||||||
function clean_alert_compound_values ($values, $set_empty = true) {
|
|
||||||
$retvalues = array ();
|
|
||||||
|
|
||||||
if ($set_empty) {
|
|
||||||
$retvalues['description'] = '';
|
|
||||||
$retvalues['time_threshold'] = 0;
|
|
||||||
$retvalues['max_alerts'] = 0;
|
|
||||||
$retvalues['min_alerts'] = 0;
|
|
||||||
$retvalues['monday'] = 0;
|
|
||||||
$retvalues['tuesday'] = 0;
|
|
||||||
$retvalues['wednesday'] = 0;
|
|
||||||
$retvalues['thursday'] = 0;
|
|
||||||
$retvalues['friday'] = 0;
|
|
||||||
$retvalues['saturday'] = 0;
|
|
||||||
$retvalues['sunday'] = 0;
|
|
||||||
$retvalues['time_from'] = '00:00';
|
|
||||||
$retvalues['time_to'] = '00:00';
|
|
||||||
$retvalues['time_threshold'] = '300';
|
|
||||||
$retvalues['recovery_notify'] = '';
|
|
||||||
$retvalues['field2_recovery'] = '';
|
|
||||||
$retvalues['field2_recovery'] = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty ($values))
|
|
||||||
return $retvalues;
|
|
||||||
|
|
||||||
if (isset ($values['name']))
|
|
||||||
$retvalues['name'] = (string) $values['name'];
|
|
||||||
if (isset ($values['description']))
|
|
||||||
$retvalues['description'] = (string) $values['description'];
|
|
||||||
if (isset ($values['id_agent']))
|
|
||||||
$retvalues['id_agent'] = (int) $values['id_agent'];
|
|
||||||
if (isset ($values['time_threshold']))
|
|
||||||
$retvalues['time_threshold'] = (int) $values['time_threshold'];
|
|
||||||
if (isset ($values['max_alerts']))
|
|
||||||
$retvalues['max_alerts'] = (int) $values['max_alerts'];
|
|
||||||
if (isset ($values['min_alerts']))
|
|
||||||
$retvalues['min_alerts'] = (int) $values['min_alerts'];
|
|
||||||
/* Ensure max an min orders */
|
|
||||||
if (isset ($values['min_alerts']) && isset ($values['max_alerts'])) {
|
|
||||||
$max = max ($retvalues['max_alerts'], $retvalues['min_alerts']);
|
|
||||||
$min = min ($retvalues['max_alerts'], $retvalues['min_alerts']);
|
|
||||||
$retvalues['max_alerts'] = $max;
|
|
||||||
$retvalues['min_alerts'] = $min;
|
|
||||||
}
|
|
||||||
if (isset ($values['monday']))
|
|
||||||
$retvalues['monday'] = (bool) $values['monday'];
|
|
||||||
if (isset ($values['tuesday']))
|
|
||||||
$retvalues['tuesday'] = (bool) $values['tuesday'];
|
|
||||||
if (isset ($values['wednesday']))
|
|
||||||
$retvalues['wednesday'] = (bool) $values['wednesday'];
|
|
||||||
if (isset ($values['thursday']))
|
|
||||||
$retvalues['thursday'] = (bool) $values['thursday'];
|
|
||||||
if (isset ($values['friday']))
|
|
||||||
$retvalues['friday'] = (bool) $values['friday'];
|
|
||||||
if (isset ($values['saturday']))
|
|
||||||
$retvalues['saturday'] = (bool) $values['saturday'];
|
|
||||||
if (isset ($values['sunday']))
|
|
||||||
$retvalues['sunday'] = (bool) $values['sunday'];
|
|
||||||
if (isset ($values['time_from']))
|
|
||||||
$retvalues['time_from'] = (string) $values['time_from'];
|
|
||||||
if (isset ($values['time_to']))
|
|
||||||
$retvalues['time_to'] = (string) $values['time_to'];
|
|
||||||
if (isset ($values['time_threshold']))
|
|
||||||
$retvalues['time_threshold'] = (int) $values['time_threshold'];
|
|
||||||
if (isset ($values['recovery_notify']))
|
|
||||||
$retvalues['recovery_notify'] = (bool) $values['recovery_notify'];
|
|
||||||
if (isset ($values['field2_recovery']))
|
|
||||||
$retvalues['field2_recovery'] = (string) $values['field2_recovery'];
|
|
||||||
if (isset ($values['field3_recovery']))
|
|
||||||
$retvalues['field3_recovery'] = (string) $values['field3_recovery'];
|
|
||||||
|
|
||||||
return $retvalues;
|
|
||||||
}
|
|
||||||
|
|
||||||
function create_alert_compound ($name, $id_agent, $values = false) {
|
function create_alert_compound ($name, $id_agent, $values = false) {
|
||||||
if (empty ($name))
|
if (empty ($name))
|
||||||
return false;
|
return false;
|
||||||
|
if (! is_array ($values))
|
||||||
$values = clean_alert_compound_values ($values);
|
$values = array ();
|
||||||
$values['name'] = $name;
|
$values['name'] = $name;
|
||||||
$values['id_agent'] = $id_agent;
|
$values['id_agent'] = $id_agent;
|
||||||
|
|
||||||
return @process_sql_insert ('talert_compound', $values);
|
return @process_sql_insert ('talert_compound', $values);
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_alert_compound ($id_alert_compound, $values = false) {
|
function update_alert_compound ($id_alert_compound, $values) {
|
||||||
$id_alert_compound = safe_int ($id_alert_compound);
|
$id_alert_compound = safe_int ($id_alert_compound);
|
||||||
if (empty ($id_alert_compound))
|
if (empty ($id_alert_compound))
|
||||||
return false;
|
return false;
|
||||||
$values = clean_alert_compound_values ($values, false);
|
if (! is_array ($values))
|
||||||
|
return false;
|
||||||
|
|
||||||
return (@process_sql_update ('talert_compound', $values,
|
return (@process_sql_update ('talert_compound', $values,
|
||||||
array ('id' => $id_alert_compound))) !== false;
|
array ('id' => $id_alert_compound))) !== false;
|
||||||
|
|
|
@ -432,36 +432,6 @@ function get_agent_modules_count ($id_agent = 0) {
|
||||||
return (int) get_db_sql ("SELECT COUNT(*) FROM tagente_modulo".$filter);
|
return (int) get_db_sql ("SELECT COUNT(*) FROM tagente_modulo".$filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a list of the reports the user can view.
|
|
||||||
*
|
|
||||||
* A user can view a report by two ways:
|
|
||||||
* - The user created the report (id_user field in treport)
|
|
||||||
* - The report is not private and the user has reading privileges on
|
|
||||||
* the group associated to the report
|
|
||||||
*
|
|
||||||
* @param string $id_user User id
|
|
||||||
*
|
|
||||||
* @return array An array with all the reports the user can view.
|
|
||||||
*/
|
|
||||||
function get_reports ($id_user) {
|
|
||||||
$user_reports = array ();
|
|
||||||
$all_reports = get_db_all_rows_in_table ('treport', 'name');
|
|
||||||
if ($all_reports === false) {
|
|
||||||
return $user_reports;
|
|
||||||
}
|
|
||||||
foreach ($all_reports as $report) {
|
|
||||||
/* The report is private and it does not belong to the user */
|
|
||||||
if ($report['private'] && $report['id_user'] != $id_user)
|
|
||||||
continue;
|
|
||||||
/* Check ACL privileges on report group */
|
|
||||||
if (! give_acl ($id_user, $report['id_group'], 'AR'))
|
|
||||||
continue;
|
|
||||||
array_push ($user_reports, $report);
|
|
||||||
}
|
|
||||||
return $user_reports;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get group icon from group.
|
* Get group icon from group.
|
||||||
*
|
*
|
||||||
|
@ -1430,7 +1400,8 @@ function get_db_value ($field, $table, $field_search = 1, $condition = 1) {
|
||||||
|
|
||||||
if ($result === false)
|
if ($result === false)
|
||||||
return false;
|
return false;
|
||||||
|
if ($field[0] == '`')
|
||||||
|
$field = str_replace ('`', '', $field);
|
||||||
return $result[0][$field];
|
return $result[0][$field];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1861,9 +1832,9 @@ function get_db_all_fields_in_table ($table, $field = '', $condition = '', $orde
|
||||||
echo $sql;
|
echo $sql;
|
||||||
</code>
|
</code>
|
||||||
* Will return:
|
* Will return:
|
||||||
* <code>
|
<code>
|
||||||
* UPDATE table SET `name` = "Name", `description` = "Long description" WHERE id=1
|
UPDATE table SET `name` = "Name", `description` = "Long description" WHERE id=1
|
||||||
* </code>
|
</code>
|
||||||
*
|
*
|
||||||
* @param array Values to be formatted in an array indexed by the field name.
|
* @param array Values to be formatted in an array indexed by the field name.
|
||||||
*
|
*
|
||||||
|
@ -1874,8 +1845,10 @@ function format_array_to_update_sql ($values) {
|
||||||
$fields = array ();
|
$fields = array ();
|
||||||
|
|
||||||
foreach ($values as $field => $value) {
|
foreach ($values as $field => $value) {
|
||||||
if (! is_string ($field))
|
if (is_numeric ($field)) {
|
||||||
|
array_push ($fields, $value);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($value === NULL) {
|
if ($value === NULL) {
|
||||||
$sql = sprintf ("`%s` = NULL", $field);
|
$sql = sprintf ("`%s` = NULL", $field);
|
||||||
|
@ -1884,6 +1857,11 @@ function format_array_to_update_sql ($values) {
|
||||||
} elseif (is_float ($value) || is_double ($value)) {
|
} elseif (is_float ($value) || is_double ($value)) {
|
||||||
$sql = sprintf ("`%s` = %f", $field, $value);
|
$sql = sprintf ("`%s` = %f", $field, $value);
|
||||||
} else {
|
} else {
|
||||||
|
/* String */
|
||||||
|
if (isset ($value[0]) && $value[0] == '`')
|
||||||
|
/* Don't round with quotes if it references a field */
|
||||||
|
$sql = sprintf ("`%s` = %s", $field, $value);
|
||||||
|
else
|
||||||
$sql = sprintf ("`%s` = '%s'", $field, $value);
|
$sql = sprintf ("`%s` = '%s'", $field, $value);
|
||||||
}
|
}
|
||||||
array_push ($fields, $sql);
|
array_push ($fields, $sql);
|
||||||
|
@ -2890,30 +2868,9 @@ process_sql_update ('table', array ('field' => 2), 'id in (1, 2, 3) OR id > 10')
|
||||||
* @return mixed False in case of error or invalid values passed. Affected rows otherwise
|
* @return mixed False in case of error or invalid values passed. Affected rows otherwise
|
||||||
*/
|
*/
|
||||||
function process_sql_update ($table, $values, $where = false, $where_join = 'AND') {
|
function process_sql_update ($table, $values, $where = false, $where_join = 'AND') {
|
||||||
$query = sprintf ("UPDATE `%s` SET ", $table);
|
$query = sprintf ("UPDATE `%s` SET %s",
|
||||||
|
$table,
|
||||||
$i = 1;
|
format_array_to_update_sql ($values));
|
||||||
$max = count ($values);
|
|
||||||
foreach ($values as $field => $value) {
|
|
||||||
if ($field[0] != "`") {
|
|
||||||
$field = "`".$field."`";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_null ($value)) {
|
|
||||||
$query .= sprintf ("%s = NULL", $field);
|
|
||||||
} elseif (is_int ($value) || is_bool ($value)) {
|
|
||||||
$query .= sprintf ("%s = %d", $field, $value);
|
|
||||||
} else if (is_float ($value) || is_double ($value)) {
|
|
||||||
$query .= sprintf ("%s = %f", $field, $value);
|
|
||||||
} else {
|
|
||||||
$query .= sprintf ("%s = '%s'", $field, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($i < $max) {
|
|
||||||
$query .= ",";
|
|
||||||
}
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($where) {
|
if ($where) {
|
||||||
if (is_string ($where)) {
|
if (is_string ($where)) {
|
||||||
|
|
|
@ -0,0 +1,294 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// Pandora FMS - the Flexible Monitoring System
|
||||||
|
// ============================================
|
||||||
|
// Copyright (c) 2009 Artica Soluciones Tecnologicas, http://www.artica.es
|
||||||
|
// Please see http://pandora.sourceforge.net for full contribution list
|
||||||
|
|
||||||
|
// This program is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License (LGPL)
|
||||||
|
// as published by the Free Software Foundation for version 2.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a custom user report.
|
||||||
|
*
|
||||||
|
* @param int Report id to get.
|
||||||
|
* @param array Extra filter.
|
||||||
|
* @param array Fields to get.
|
||||||
|
*
|
||||||
|
* @return Report with the given id. False if not available or readable.
|
||||||
|
*/
|
||||||
|
function get_report ($id_report, $filter = false, $fields = false) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$id_report = safe_int ($id_report);
|
||||||
|
if (empty ($id_report))
|
||||||
|
return false;
|
||||||
|
if (! is_array ($filter))
|
||||||
|
$filter = array ();
|
||||||
|
$filter['id_report'] = $id_report;
|
||||||
|
$filter[] = sprintf ('private = 0 OR (private = 1 AND id_user = "%s")', $config['id_user']);
|
||||||
|
if (is_array ($fields))
|
||||||
|
$fields[] = 'id_group';
|
||||||
|
|
||||||
|
$report = get_db_row_filter ('treport', $filter, $fields);
|
||||||
|
if (! give_acl ($config['id_user'], $report['id_group'], 'AR'))
|
||||||
|
return false;
|
||||||
|
return $report;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of the reports the user can view.
|
||||||
|
*
|
||||||
|
* A user can view a report by two ways:
|
||||||
|
* - The user created the report (id_user field in treport)
|
||||||
|
* - The report is not private and the user has reading privileges on
|
||||||
|
* the group associated to the report
|
||||||
|
*
|
||||||
|
* @param string $id_user User id
|
||||||
|
*
|
||||||
|
* @return array An array with all the reports the user can view.
|
||||||
|
*/
|
||||||
|
function get_reports ($filter = false, $fields = false) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
if (! is_array ($filter))
|
||||||
|
$filter = array ();
|
||||||
|
$filter[] = sprintf ('private = 0 OR (private = 1 AND id_user = "%s")', $config['id_user']);
|
||||||
|
if (is_array ($fields)) {
|
||||||
|
$fields[] = 'id_group';
|
||||||
|
$fields[] = 'id_user';
|
||||||
|
}
|
||||||
|
|
||||||
|
$reports = array ();
|
||||||
|
$all_reports = get_db_all_rows_filter ('treport', $filter, $fields);
|
||||||
|
foreach ($all_reports as $report){
|
||||||
|
if ($config['id_user'] != $report['id_user'] && ! give_acl ($config['id_user'], $report['id_group'], 'AR'))
|
||||||
|
continue;
|
||||||
|
array_push ($reports, $report);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $reports;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a report.
|
||||||
|
*
|
||||||
|
* @param string Report name.
|
||||||
|
* @param int Group where the report will operate.
|
||||||
|
* @param array Extra values to be set. Notice that id_user is automatically
|
||||||
|
* set to the logged user.
|
||||||
|
*
|
||||||
|
* @return mixed New report id if created. False if it could not be created.
|
||||||
|
*/
|
||||||
|
function create_report ($name, $id_group, $values = false) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
if (! is_array ($values))
|
||||||
|
$values = array ();
|
||||||
|
$values['name'] = $name;
|
||||||
|
$values['id_group'] = $id_group;
|
||||||
|
$values['id_user'] = $config['id_user'];
|
||||||
|
|
||||||
|
return @process_sql_insert ('treport', $values);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a report.
|
||||||
|
*
|
||||||
|
* @param int Report id.
|
||||||
|
* @param array Extra values to be set.
|
||||||
|
*
|
||||||
|
* @return bool True if the report was updated. False otherwise.
|
||||||
|
*/
|
||||||
|
function update_report ($id_report, $values) {
|
||||||
|
$report = get_report ($id_report);
|
||||||
|
if ($report === false)
|
||||||
|
return false;
|
||||||
|
return (@process_sql_update ('treport',
|
||||||
|
$values,
|
||||||
|
array ('id_report' => $id_report))) !== false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a report.
|
||||||
|
*
|
||||||
|
* @param int Report id to be deleted.
|
||||||
|
*
|
||||||
|
* @return bool True if deleted, false otherwise.
|
||||||
|
*/
|
||||||
|
function delete_report ($id_report) {
|
||||||
|
$id_report = safe_int ($id_report);
|
||||||
|
if (empty ($id_report))
|
||||||
|
return false;
|
||||||
|
$report = get_report ($id_report);
|
||||||
|
if ($report === false)
|
||||||
|
return false;
|
||||||
|
$res1 = @process_sql_delete ('treport_content', array ('id_report' => $id_report));
|
||||||
|
$res2 = @process_sql_delete ('treport', array ('id_report' => $id_report));
|
||||||
|
|
||||||
|
return $res1 && $res2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a content from a report.
|
||||||
|
*
|
||||||
|
* @param int Report content id to be deleted.
|
||||||
|
*
|
||||||
|
* @return bool True if deleted, false otherwise.
|
||||||
|
*/
|
||||||
|
function get_report_content ($id_report_content, $filter = false, $fields = false) {
|
||||||
|
$id_report_content = safe_int ($id_report_content);
|
||||||
|
if (empty ($id_report_content))
|
||||||
|
return false;
|
||||||
|
if (! is_array ($filter))
|
||||||
|
$filter = array ();
|
||||||
|
if (is_array ($fields))
|
||||||
|
$fields[] = 'id_report';
|
||||||
|
$filter['id_rc'] = $id_report_content;
|
||||||
|
|
||||||
|
$content = @get_db_row_filter ('treport_content', $filter, $fields);
|
||||||
|
if ($content === false)
|
||||||
|
return false;
|
||||||
|
$report = get_report ($content['id_report']);
|
||||||
|
if ($report === false)
|
||||||
|
return false;
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the contents of a report.
|
||||||
|
*
|
||||||
|
* @param int Report id to get contents.
|
||||||
|
* @param array Extra filters for the contents.
|
||||||
|
* @param array Fields to be fetched. All fields by default
|
||||||
|
*
|
||||||
|
* @return array All the contents of a report.
|
||||||
|
*/
|
||||||
|
function create_report_content ($id_report, $values) {
|
||||||
|
$id_report = safe_int ($id_report);
|
||||||
|
if (empty ($id_report))
|
||||||
|
return false;
|
||||||
|
$report = get_report ($id_report);
|
||||||
|
if ($report === false)
|
||||||
|
return false;
|
||||||
|
if (! is_array ($values))
|
||||||
|
return false;
|
||||||
|
$values['id_report'] = $id_report;
|
||||||
|
unset ($values['`order`']);
|
||||||
|
$order = (int) get_db_value ('MAX(`order`)', 'treport_content', 'id_report', $id_report);
|
||||||
|
$values['`order`'] = $order + 1;
|
||||||
|
|
||||||
|
return @process_sql_insert ('treport_content', $values);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the contents of a report.
|
||||||
|
*
|
||||||
|
* @param int Report id to get contents.
|
||||||
|
* @param array Extra filters for the contents.
|
||||||
|
* @param array Fields to be fetched. All fields by default
|
||||||
|
*
|
||||||
|
* @return array All the contents of a report.
|
||||||
|
*/
|
||||||
|
function get_report_contents ($id_report, $filter = false, $fields = false) {
|
||||||
|
$id_report = safe_int ($id_report);
|
||||||
|
if (empty ($id_report))
|
||||||
|
return array ();
|
||||||
|
|
||||||
|
$report = get_report ($id_report);
|
||||||
|
if ($report === false)
|
||||||
|
return array ();
|
||||||
|
if (! is_array ($filter))
|
||||||
|
$filter = array ();
|
||||||
|
$filter['id_report'] = $id_report;
|
||||||
|
$filter['order'] = '`order`';
|
||||||
|
|
||||||
|
$contents = get_db_all_rows_filter ('treport_content', $filter, $fields);
|
||||||
|
if ($contents === false)
|
||||||
|
return array ();
|
||||||
|
return $contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves a content from a report up.
|
||||||
|
*
|
||||||
|
* @param int Report content id to be moved.
|
||||||
|
*
|
||||||
|
* @return bool True if moved, false otherwise.
|
||||||
|
*/
|
||||||
|
function move_report_content_up ($id_report_content) {
|
||||||
|
if (empty ($id_report_content))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$content = get_report_content ($id_report_content);
|
||||||
|
if ($content === false)
|
||||||
|
return false;
|
||||||
|
$order = get_db_value ('`order`', 'treport_content', 'id_rc', $id_report_content);
|
||||||
|
/* Set the previous element order to the current of the content we want to change */
|
||||||
|
process_sql_update ('treport_content',
|
||||||
|
array ('`order` = `order` + 1'),
|
||||||
|
array ('id_report' => $content['id_report'],
|
||||||
|
'`order` = '.($order - 1)));
|
||||||
|
return (@process_sql_update ('treport_content',
|
||||||
|
array ('`order` = `order` - 1'),
|
||||||
|
array ('id_rc' => $id_report_content))) !== false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves a content from a report up.
|
||||||
|
*
|
||||||
|
* @param int Report content id to be moved.
|
||||||
|
*
|
||||||
|
* @return bool True if moved, false otherwise.
|
||||||
|
*/
|
||||||
|
function move_report_content_down ($id_report_content) {
|
||||||
|
if (empty ($id_report_content))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$content = get_report_content ($id_report_content);
|
||||||
|
if ($content === false)
|
||||||
|
return false;
|
||||||
|
$order = get_db_value ('`order`', 'treport_content', 'id_rc', $id_report_content);
|
||||||
|
/* Set the previous element order to the current of the content we want to change */
|
||||||
|
process_sql_update ('treport_content',
|
||||||
|
array ('`order` = `order` - 1'),
|
||||||
|
array ('id_report' => (int) $content['id_report'],
|
||||||
|
'`order` = '.($order + 1)));
|
||||||
|
return (@process_sql_update ('treport_content',
|
||||||
|
array ('`order` = `order` + 1'),
|
||||||
|
array ('id_rc' => $id_report_content))) !== false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a content from a report.
|
||||||
|
*
|
||||||
|
* @param int Report content id to be deleted.
|
||||||
|
*
|
||||||
|
* @return bool True if deleted, false otherwise.
|
||||||
|
*/
|
||||||
|
function delete_report_content ($id_report_content) {
|
||||||
|
if (empty ($id_report_content))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$content = get_report_content ($id_report_content);
|
||||||
|
if ($content === false)
|
||||||
|
return false;
|
||||||
|
$order = get_db_value ('`order`', 'treport_content', 'id_rc', $id_report_content);
|
||||||
|
process_sql_update ('treport_content',
|
||||||
|
array ('`order` = `order` - 1'),
|
||||||
|
array ('id_report' => (int) $content['id_report'],
|
||||||
|
'`order` > '.$order));
|
||||||
|
return (@process_sql_delete ('treport_content',
|
||||||
|
array ('id_rc' => $id_report_content))) !== false;
|
||||||
|
}
|
||||||
|
?>
|
|
@ -19,13 +19,15 @@
|
||||||
// Login check
|
// Login check
|
||||||
check_login ();
|
check_login ();
|
||||||
|
|
||||||
|
require_once ('include/functions_reports.php');
|
||||||
|
|
||||||
// Load enterprise extensions
|
// Load enterprise extensions
|
||||||
enterprise_include ('operation/reporting/custom_reporting.php');
|
enterprise_include ('operation/reporting/custom_reporting.php');
|
||||||
|
|
||||||
echo "<h2>".__('Reporting')." > ";
|
echo "<h2>".__('Reporting')." > ";
|
||||||
echo __('Custom reporting')."</h2>";
|
echo __('Custom reporting')."</h2>";
|
||||||
|
|
||||||
$reports = get_reports ($config['id_user']);
|
$reports = get_reports ();
|
||||||
|
|
||||||
if (sizeof ($reports) == 0) {
|
if (sizeof ($reports) == 0) {
|
||||||
echo "<div class='nf'>".__('There are no defined reportings')."</div>";
|
echo "<div class='nf'>".__('There are no defined reportings')."</div>";
|
||||||
|
|
Loading…
Reference in New Issue