Added macro for sql custom reports

This commit is contained in:
Luis Calvo 2019-07-19 10:05:01 +02:00
parent fdbc3b5366
commit af8055212f
1 changed files with 26 additions and 0 deletions

View File

@ -5309,6 +5309,9 @@ function reporting_sql($report, $content)
$sql = io_safe_output($content['external_source']);
}
// Check if exist timeform macro
$sql = reporting_sql_macro($report, $sql);
// Do a security check on SQL coming from the user.
$sql = check_sql($sql);
@ -12080,6 +12083,29 @@ function reporting_label_macro($item, $label)
}
/**
* Convert macro in sql string to value
*
* @param array $report
* @param string $sql
* @return $ql
*/
function reporting_sql_macro($report, $sql)
{
if (preg_match('/_timefrom/', $sql)) {
$sql = str_replace(
'_timefrom_',
$report['datetime'],
$sql
);
}
return $sql;
}
/**
* @brief Calculates the SLA compliance value given an sla array
*