Finished Output Target admin coding parFinished Output Target admin coding partt

This commit is contained in:
Andre Lorbach 2009-12-18 17:14:26 +01:00
parent e740872b9f
commit 6d7437f9d9
6 changed files with 103 additions and 39 deletions

View File

@ -323,6 +323,9 @@ if ( isset($_GET['op']) )
// Create Outputtargetlist
$content['outputTarget'] = REPORT_TARGET_STDOUT;
CreateOutputtargetList( $content['outputTarget'] );
// Init other outputTarget properties
$content['outputTarget_filename'] = "";
// Other settings ... TODO!
// $content['customFilters'] = "";
@ -400,8 +403,12 @@ if ( isset($_GET['op']) )
CreateOutputformatList( $content['outputFormat'] );
// Create Outputtargetlist
$content['outputTarget'] = $mySavedReport['outputFormat'];
$content['outputTarget'] = $mySavedReport['outputTarget'];
CreateOutputtargetList( $content['outputTarget'] );
// Init other outputTarget properties
$content['outputTarget_filename'] = "";
InitOutputtargetDefinitions($myReport, $mySavedReport['outputTargetDetails']);
// Other settings ... TODO!
// $content['customFilters'] = "";
@ -839,6 +846,7 @@ if ( isset($_POST['op']) )
if ( isset($_POST['report_filterString']) ) { $content['filterString'] = DB_RemoveBadChars($_POST['report_filterString']); } else {$content['report_filterString'] = ""; }
if ( isset($_POST['outputFormat']) ) { $content['outputFormat'] = DB_RemoveBadChars($_POST['outputFormat']); }
if ( isset($_POST['outputTarget']) ) { $content['outputTarget'] = DB_RemoveBadChars($_POST['outputTarget']); }
if ( isset($_POST['outputTarget_filename']) ) { $content['outputTarget_filename'] = DB_RemoveBadChars($_POST['outputTarget_filename']); }
// Read Custom Filters
foreach ( $content['CUSTOMFILTERS'] as &$tmpCustomFilter )
@ -881,6 +889,11 @@ if ( isset($_POST['op']) )
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_CHARTS_ERROR_MISSINGPARAM'], $content['LN_REPORTS_OUTPUTFORMAT'] );
}
else if ( !isset($content['outputTarget']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_CHARTS_ERROR_MISSINGPARAM'], $content['LN_REPORTS_OUTPUTTARGET'] );
}
// ---
@ -895,6 +908,10 @@ if ( isset($_POST['op']) )
$tmpSavedReport["outputFormat"] = $content['outputFormat'];
$tmpSavedReport["outputTarget"] = $content['outputTarget'];
$tmpSavedReport["scheduleSettings"] = $content['scheduleSettings'];
$tmpSavedReport["outputTargetDetails"] = ""; // Init Value
if ( isset($content['outputTarget_filename']) )
$tmpSavedReport["outputTargetDetails"] .= "filename=>" . $content['outputTarget_filename'] . ",";
$content["outputTargetDetails"] = $tmpSavedReport["outputTargetDetails"]; // Copy into content var
// Get Objectreference to report
$myReportObj = $myReport["ObjRef"];
@ -921,7 +938,7 @@ if ( isset($_POST['op']) )
if ( $_POST['op'] == "addsavedreport" )
{
// Add custom search now!
$sqlquery = "INSERT INTO " . DB_SAVEDREPORTS . " (reportid, sourceid, customTitle, customComment, filterString, customFilters, outputFormat, outputTarget, scheduleSettings)
$sqlquery = "INSERT INTO " . DB_SAVEDREPORTS . " (reportid, sourceid, customTitle, customComment, filterString, customFilters, outputFormat, outputTarget, outputTargetDetails, scheduleSettings)
VALUES ('" . $content['ReportID'] . "',
" . $content['SourceID'] . ",
'" . $content['customTitle'] . "',
@ -930,6 +947,7 @@ if ( isset($_POST['op']) )
'" . $content['customFilters'] . "',
'" . $content['outputFormat'] . "',
'" . $content['outputTarget'] . "',
'" . $content['outputTargetDetails'] . "',
'" . $content['scheduleSettings'] . "'
)";
@ -958,6 +976,7 @@ if ( isset($_POST['op']) )
customFilters = '" . $content['customFilters'] . "',
outputFormat = '" . $content['outputFormat'] . "',
outputTarget = '" . $content['outputTarget'] . "',
outputTargetDetails = '" . $content['outputTargetDetails'] . "',
scheduleSettings = '" . $content['scheduleSettings'] . "'
WHERE ID = " . $content['SavedReportID'];
@ -1062,8 +1081,9 @@ $page -> parser($content, "admin/admin_reports.html");
$page -> output();
// ---
// ---
// --- BEGIN Helper functions
// ---
function InitCustomFilterDefinitions($myReport, $CustomFilterValues)
{
global $content;
@ -1126,6 +1146,32 @@ function InitCustomFilterDefinitions($myReport, $CustomFilterValues)
}
}
function InitOutputtargetDefinitions($myReport, $outputTargetDetails)
{
global $content;
// Get Objectreference to report
$myReportObj = $myReport["ObjRef"];
// Init Detail variables manually
$myReportObj->SetOutputTargetDetails($outputTargetDetails);
// Get Array of Custom filter Defs
$outputTargetArray = $myReportObj->GetOutputTargetDetails();
if ( isset($outputTargetArray) && count($outputTargetArray) > 0 )
{
// Loop through Detail Properties
$i = 0; // Help counter!
foreach( $outputTargetArray as $propertyID => $propertyValue )
{
// Set property Value by ID
$content['outputTarget_' . $propertyID] = $propertyValue;
}
}
}
// --- END Helper functions
?>

View File

@ -217,31 +217,37 @@ abstract class Report {
* Helper function to set the OutputTarget
*/
public function SetOutputTarget($newOutputTarget)
{
// TODO: Check if Outputtarget EXISTS!
// Set new OutputTarget
$this->_outputTarget = $newOutputTarget;
}
/*
* Helper function to set the OutputTarget
*/
public function SetOutputTargetDetails($newOutputTargetDetailsStr)
{
// Only set if valid string
if ( strlen($newOutputTarget) > 0 )
if ( strlen($newOutputTargetDetailsStr) > 0 )
{
// First of all split by comma
$tmpValues = explode( ",", $newOutputTarget );
$tmpValues = explode( ",", $newOutputTargetDetailsStr );
//Loop through mappings
foreach ($tmpValues as &$myValue )
{
// Split subvalues
$tmpArray = explode( "=>", $myValue );
// Get tmp fieldID
$tmpFieldID = trim($tmpArray[0]);
if ( $tmpFieldID == REPORT_TARGET_TYPE )
{
// Set new OutputTarget
$this->_outputTarget = trim($tmpArray[1]);
}
else
if ( strlen(trim($myValue)) > 0 )
{
// Split subvalues
$tmpArray = explode( "=>", $myValue );
// Get tmp fieldID
$tmpFieldID = trim($tmpArray[0]);
// Set into Details Array
$this->_arrOutputTargetDetails[$tmpFieldID] == trim($tmpArray[1]);
$this->_arrOutputTargetDetails[$tmpFieldID] = trim($tmpArray[1]);
}
}
}
@ -482,6 +488,14 @@ abstract class Report {
return $this->_arrCustomFilters;
}
/*
* Helper function to return the array of OutputTarget details
*/
public function GetOutputTargetDetails()
{
return $this->_arrOutputTargetDetails;
}
/*
* Helper function to trigger initialisation
*/
@ -505,6 +519,7 @@ abstract class Report {
$this->SetCustomFilters( $mySavedReport["customFilters"] );
$this->SetOutputFormat( $mySavedReport["outputFormat"] );
$this->SetOutputTarget( $mySavedReport["outputTarget"] );
$this->SetOutputTargetDetails( $mySavedReport["outputTargetDetails"] );
$this->SetScheduleSettings( $mySavedReport["scheduleSettings"] );
}

View File

@ -168,14 +168,15 @@ CREATE TABLE `logcon_dbmappings` (
-- Table structure for table `logcon_savedreports`
--
CREATE TABLE `logcon_savedreports` (
`ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`reportid` VARCHAR( 255 ) NOT NULL ,
`sourceid` INT NOT NULL ,
`customTitle` VARCHAR( 255 ) NOT NULL ,
`customComment` TEXT NOT NULL ,
`filterString` TEXT NOT NULL ,
`customFilters` TEXT NOT NULL ,
`outputFormat` VARCHAR( 64 ) NOT NULL ,
`outputTarget` TEXT NOT NULL ,
`scheduleSettings` TEXT NOT NULL
`ID` int(11) NOT NULL auto_increment,
`reportid` varchar(255) NOT NULL,
`sourceid` int(11) NOT NULL,
`customTitle` varchar(255) NOT NULL,
`customComment` text NOT NULL,
`filterString` text NOT NULL,
`customFilters` text NOT NULL,
`outputFormat` varchar(64) NOT NULL,
`outputTarget` varchar(64) NOT NULL,
`outputTargetDetails` text NOT NULL,
`scheduleSettings` text NOT NULL,
) ENGINE=MyISAM COMMENT = 'Table to store saved reports';

View File

@ -1,15 +1,16 @@
-- New Database Structure Updates
CREATE TABLE `logcon_savedreports` (
`ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`reportid` VARCHAR( 255 ) NOT NULL ,
`sourceid` INT NOT NULL ,
`customTitle` VARCHAR( 255 ) NOT NULL ,
`customComment` TEXT NOT NULL ,
`filterString` TEXT NOT NULL ,
`customFilters` TEXT NOT NULL ,
`outputFormat` VARCHAR( 64 ) NOT NULL ,
`outputTarget` TEXT NOT NULL ,
`scheduleSettings` TEXT NOT NULL
`ID` int(11) NOT NULL auto_increment,
`reportid` varchar(255) NOT NULL,
`sourceid` int(11) NOT NULL,
`customTitle` varchar(255) NOT NULL,
`customComment` text NOT NULL,
`filterString` text NOT NULL,
`customFilters` text NOT NULL,
`outputFormat` varchar(64) NOT NULL,
`outputTarget` varchar(64) NOT NULL,
`outputTargetDetails` text NOT NULL,
`scheduleSettings` text NOT NULL,
) ENGINE=MyISAM COMMENT = 'Table to store saved reports';
-- Insert data

View File

@ -367,6 +367,7 @@ function InitReportModules()
DB_SAVEDREPORTS . ".customFilters, " .
DB_SAVEDREPORTS . ".outputFormat, " .
DB_SAVEDREPORTS . ".outputTarget, " .
DB_SAVEDREPORTS . ".outputTargetDetails, " .
DB_SAVEDREPORTS . ".scheduleSettings " .
" FROM " . DB_SAVEDREPORTS .
" WHERE " . DB_SAVEDREPORTS . ".reportid = '" . $myReportID . "' " .

View File

@ -297,7 +297,7 @@
<tr>
<td align="left" class="cellmenu2" width="150" valign="top" nowrap><b>{LN_REPORTS_OUTPUTTARGET_FILE}</b></td>
<td align="left" class="line1" width="100%">
<input type="text" name="outputFormat_filename" size="80" maxlength="1024" value="{outputFormat_filename}">
<input type="text" name="outputTarget_filename" size="80" maxlength="1024" value="{outputTarget_filename}">
</td>
</tr>
</table>