Implemented support to user user or group configured logstream sources in commandline report generator

This commit is contained in:
Andre Lorbach 2011-09-12 19:00:01 +02:00
parent 2b59c7db1f
commit c64bcce98c
3 changed files with 52 additions and 4 deletions

View File

@ -1299,10 +1299,19 @@ function InitOutputtargetDefinitions($myReport, $outputTargetDetails)
function CreateCronCommand( $myReportID, $mySavedReportID = null )
{
global $content, $gl_root_path;
global $content, $gl_root_path, $myReport;
if ( isset($mySavedReportID) )
{
// Get Reference to report!
$myReport = $content['REPORTS'][ $myReportID ];
// Get reference to savedreport
$mySavedReport = $myReport['SAVEDREPORTS'][ $mySavedReportID ];
// Get configured Source for savedreport
$myReportSource = $content['Sources'][ $mySavedReport['sourceid'] ];
$pos = strpos( strtoupper(PHP_OS), "WIN");
if ($pos !== false)
{
@ -1320,6 +1329,17 @@ function CreateCronCommand( $myReportID, $mySavedReportID = null )
// Enable display of report command
$content['enableCronCommand'] = true;
$szCommand = $phpCmd . " " . $phpScript . " runreport " . $myReportID . " " . $mySavedReportID;
// --- Check for user or group sources
if ( $myReportSource['userid'] != null )
{
$szCommand .= " " . "userid=" . $myReportSource['userid'];
}
else if ( $myReportSource['groupid'] != null )
{
$szCommand .= " " . "groupid=" . $myReportSource['userid'];
}
// ---
}
else
{

View File

@ -72,8 +72,8 @@ include_once($gl_root_path . 'classes/logstream.class.php');
define('IN_PHPLOGCON_COMMANDLINE', true);
$content['IN_PHPLOGCON_COMMANDLINE'] = true;
InitPhpLogCon();
InitSourceConfigs();
InitFilterHelpers(); // Helpers for frontend filtering!
InitSourceConfigs();
// Firts of all init List of Reports!
InitReportModules();
@ -107,7 +107,7 @@ function RunReport()
if ( $res != SUCCESS )
{
// Print error and die!
$szError = GetAndReplaceLangStr( $content['LN_REPORTS_ERROR_ERRORCHECKINGSOURCE'], GetAndReplaceLangStr( GetErrorMessage($res), $mySavedReport['sourceid']) );
$szError = GetAndReplaceLangStr( $content['LN_GEN_ERROR_REPORTGENFAILED'], $mySavedReport['customTitle'], GetAndReplaceLangStr( GetErrorMessage($res), $mySavedReport['sourceid']) );
if ( isset($extraErrorDescription) )
$szError .= "<br><br>" . GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription);
DieWithErrorMsg( $szError );
@ -206,6 +206,34 @@ function RunReport()
}
else
DieWithErrorMsg( $content["LN_CMD_NOSAVEDREPORTID"] );
// Run Optional Params first: userid/groupid
if ( isset($_SERVER["argv"][4]) )
{
// Set to SourceID property!
$tmpvar = $_SERVER["argv"][4];
if ( strpos($tmpvar, "=") !== false )
{
$tmparr = explode("=", $tmpvar);
if ( $tmparr[0] == "userid" )
{
$userid = $tmparr[1];
$_SESSION['SESSION_LOGGEDIN'] = true;
$_SESSION['SESSION_USERID'] = $userid;
$content['SESSION_LOGGEDIN'] = true;
$content['SESSION_USERID'] = $userid;
}
else if ( $tmparr[0] == "groupid" )
{
$groupid = $tmparr[1];
}
}
// Reload Configured Sources
LoadSourcesFromDatabase();
InitSourceConfigs();
}
// ---
// --- Operation Handling now

View File

@ -985,7 +985,7 @@ function LoadSourcesFromDatabase()
$myrows = DB_GetAllRows($result, true);
if ( isset($myrows) && count($myrows) > 0 )
{
// Overwrite existing Views array
// Overwrite existing Sources array
unset($CFG['Sources']);
// Append to Source Array