Added more default methods into report classes and added verify data source method and multiple other stuff

This commit is contained in:
Andre Lorbach 2009-11-03 15:57:23 +01:00
parent 6688465c0c
commit 0fd1a11072
7 changed files with 128 additions and 16 deletions

View File

@ -491,6 +491,37 @@ if ( isset($_POST['op']) )
}
// ---
// --- Now Verify Report Source!
// Create tmpSavedReport!
$tmpSavedReport["SavedReportID"] = $content['customFilters'];
$tmpSavedReport["sourceid"] = $content['SourceID'];
$tmpSavedReport["customTitle"] = $content['customTitle'];
$tmpSavedReport["customComment"] = $content['customComment'];
$tmpSavedReport["filterString"] = $content['filterString'];
$tmpSavedReport["customFilters"] = $content['customFilters'];
$tmpSavedReport["outputFormat"] = $content['outputFormat'];
$tmpSavedReport["outputTarget"] = $content['outputTarget'];
$tmpSavedReport["scheduleSettings"] = $content['scheduleSettings'];
// Get Objectreference to report
$myReportObj = $myReport["ObjRef"];
// Set SavedReport Settings!
$myReportObj->InitFromSavedReport($tmpSavedReport);
// Perform check
$res = $myReportObj->verifyDataSource();
if ( $res != SUCCESS )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_REPORTS_ERROR_ERRORCHECKINGSOURCE'], GetAndReplaceLangStr( GetErrorMessage($res), $content['SourceID']) );
if ( isset($extraErrorDescription) )
$content['ERROR_MSG'] .= "<br><br>" . GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription);
}
// ---
// --- Now ADD/EDIT do the processing!
if ( !isset($content['ISERROR']) )
{

View File

@ -133,7 +133,7 @@ if ( !$content['error_occured'] )
// Create LogStream Object
$stream = $stream_config->LogStreamFactory($stream_config);
// Set Columns we want to open!
// Set Columns we want to open!
$content['ChartColumns'][] = SYSLOG_UID;
$content['ChartColumns'][] = $content['chart_field'];
$res = $stream->Open( $content['ChartColumns'], true );

View File

@ -116,6 +116,7 @@ class LogStreamDisk extends LogStream {
* @return integer Error state
*/
public function Verify() {
// Check if file exists!
if(!file_exists($this->_logStreamConfigObj->FileName)) {
return ERROR_FILE_NOT_FOUND;

View File

@ -43,6 +43,10 @@ require_once($gl_root_path . 'include/constants_errors.php');
require_once($gl_root_path . 'include/constants_logstream.php');
// ---
// Include LogStream facility
include_once($gl_root_path . 'classes/logstream.class.php');
abstract class Report {
// Common Properties
@ -55,10 +59,15 @@ abstract class Report {
public $_reportNeedsInit = false; // True means that this report needs additional init stuff
public $_reportInitialized = false; // True means report is installed
// Configuration Properties
// SavedReport Configuration Properties
protected $_customTitle = "";
protected $_customComment = "";
protected $_filterString = "";
protected $_advancedOptionsXml = "";
protected $_outputType = REPORT_OUTPUT_HTML; // Default HTML Output
protected $_customFilters = "";
protected $_outputFormat = REPORT_OUTPUT_HTML; // Default HTML Output
protected $_outputTarget = "";
protected $_scheduleSettings = "";
protected $_mySourceID = "";
protected $_arrProperties = null; // List of properties we need for the main logstream query!
@ -150,13 +159,31 @@ abstract class Report {
/*
* Helper function to set the OutputType
*/
public function SetOutputType($newOutputType)
public function SetOutputFormat($newOutputType)
{
// Set new Outputtype
$this->_outputType = $newOutputType;
$this->_outputFormat = $newOutputType;
// Set Filebasename
$this->_baseFileName = $this->_reportID . ".template." . $this->_outputType;
$this->_baseFileName = $this->_reportID . ".template." . $this->_outputFormat;
}
/*
* Helper function to set the OutputTarget
*/
public function SetOutputTarget($newOutputTarget)
{
// Set new OutputTarget
$this->_outputTarget = $newOutputTarget;
}
/*
* Helper function to set the Scheduled Settings
*/
public function SetScheduleSettings($newScheduleSettings)
{
// Set new ScheduleSettings
$this->_scheduleSettings = $newScheduleSettings;
}
/*
@ -171,12 +198,31 @@ abstract class Report {
/*
* Helper function to set the FilterString
*/
public function SetAdvancedOptions($newAdvancedOptions)
public function SetCustomFilters($newAdvancedOptions)
{
// Set new Outputtype
$this->_advancedOptionsXml = $newAdvancedOptions;
$this->_customFilters = $newAdvancedOptions;
}
/*
* Helper function to set the FilterString
*/
public function SetCustomTitle($newCustomTitle)
{
// Set new Custom Title
$this->_customTitle = $newCustomTitle;
}
/*
* Helper function to set the FilterString
*/
public function SetCustomComment($newCustomComment)
{
// Set new Custom Comment
$this->_customComment = $newCustomComment;
}
/*
* Helper function to set the FilterString
*/
@ -194,7 +240,6 @@ abstract class Report {
}
}
/*
* Helper function to trigger initialisation
*/
@ -203,6 +248,22 @@ abstract class Report {
$this->SetOutputType( REPORT_OUTPUT_HTML );
}
/*
* Helper function to set settings from savedreport!
*/
public function InitFromSavedReport( $mySavedReport )
{
// Copy settings from saved report!
$this->SetSourceID( $mySavedReport["sourceid"] );
$this->SetCustomTitle( $mySavedReport["customTitle"] );
$this->SetCustomComment( $mySavedReport["customComment"] );
$this->SetFilterString( $mySavedReport["filterString"] );
$this->SetCustomFilters( $mySavedReport["customFilters"] );
$this->SetOutputFormat( $mySavedReport["outputFormat"] );
$this->SetOutputTarget( $mySavedReport["outputTarget"] );
$this->SetScheduleSettings( $mySavedReport["scheduleSettings"] );
}
}
?>

View File

@ -121,10 +121,21 @@ class Report_monilog extends Report {
*/
public function verifyDataSource()
{
global $content;
if ( $this->_streamCfgObj == null )
{
// Obtain and get the Config Object
$this->_streamCfgObj = $content['Sources'][$this->_mySourceID]['ObjRef'];
if ( isset($content['Sources'][$this->_mySourceID]['ObjRef']) )
{
// Obtain and get the Config Object
$this->_streamCfgObj = $content['Sources'][$this->_mySourceID]['ObjRef'];
// Fix Filename manually for FILE LOGSTREAM!
if ( $content['Sources'][$this->_mySourceID]['SourceType'] == SOURCE_DISK )
$this->_streamCfgObj->FileName = CheckAndPrependRootPath(DB_StripSlahes($content['Sources'][$this->_mySourceID]['DiskFile']));
}
else
return ERROR_SOURCENOTFOUND;
}
if ( $this->_streamObj == null )
@ -133,8 +144,9 @@ class Report_monilog extends Report {
$this->_streamObj = $this->_streamCfgObj ->LogStreamFactory($this->_streamCfgObj);
}
// Success!
return SUCCESS;
// Check datasource and return result
$res = $this->_streamObj->Verify();
return $res;
}

View File

@ -1672,8 +1672,14 @@ function CheckAndPrependRootPath( $szFileName)
// Nothing really todo
true;
}
else // prepend basepath!
$szNewFileName = $gl_root_path . $szFileName;
else
{
// replace ./ with gl_root_path in this case
if ( ($pos = strpos($szFileName, "./")) !== FALSE )
$szNewFileName = str_replace( "./", $gl_root_path, $szFileName );
else // prepend basepath!
$szNewFileName = $gl_root_path . $szFileName;
}
// return result
return $szNewFileName;

View File

@ -421,6 +421,7 @@ $content['LN_REPORTS_RUNNOW'] = "Run saved report now!";
$content['LN_REPORTS_WARNDELETESAVEDREPORT'] = "Are you sure that you want to delete the savedreport '%1'?";
$content['LN_REPORTS_ERROR_DELSAVEDREPORT'] = "Deleting of the savedreport with id '%1' failed!";
$content['LN_REPORTS_ERROR_HASBEENDEL'] = "The savedreport '%1' has been successfully deleted!";
$content['LN_REPORTS_ERROR_ERRORCHECKINGSOURCE'] = "Error while checking Savedreport Source: %1";
$content['LN_REPORTS_'] = "";