private static function validateReportParameters($reportType, $parameters)
{
// get list of valid parameters
$availableParameters = array();
/**
* Triggered when gathering the available parameters for a scheduled report type.
*
* Plugins that provide their own scheduled report transport mediums should use this
* event to list the available report parameters for their transport medium.
*
* @param array $availableParameters The list of available parameters for this report type.
* This is an array that maps paramater IDs with a boolean
* that indicates whether the parameter is mandatory or not.
* @param string $reportType A string ID describing how the report is sent, eg,
* `'sms'` or `'email'`.
*/
Piwik::postEvent(self::GET_REPORT_PARAMETERS_EVENT, array(&$availableParameters, $reportType));
// unset invalid parameters
$availableParameterKeys = array_keys($availableParameters);
foreach ($parameters as $key => $value) {
if (!in_array($key, $availableParameterKeys)) {
unset($parameters[$key]);
}
}
// test that all required parameters are provided
foreach ($availableParameters as $parameter => $mandatory) {
if ($mandatory && !isset($parameters[$parameter])) {
throw new Exception('Missing parameter : ' . $parameter);
}
}
/**
* Triggered when validating the parameters for a scheduled report.
*
* Plugins that provide their own scheduled reports backend should use this
* event to validate the custom parameters defined with {@link ScheduledReports::getReportParameters()}.
*
* @param array $parameters The list of parameters for the scheduled report.
* @param string $reportType A string ID describing how the report is sent, eg,
* `'sms'` or `'email'`.
*/
Piwik::postEvent(self::VALIDATE_PARAMETERS_EVENT, array(&$parameters, $reportType));
return json_encode($parameters);
}