@bkbeckman opened this Issue on February 8th 2017 Contributor

I'm building a plugin that integrates with ScheduledReports and I need the ability to pass in parameters.

I noticed there are callbacks for 'ScheduledReports.getReportParameters' and 'ScheduledReports.validateReportParameters'. However, it looks like the front-end does not take the results of a 'ScheduledReports.getReportParameters' into consideration when submitting the form field. Thus, the field is never populated when the user submits the form.

I added a handler with debug statements to each of these events and here are some results:

Piwik\Plugins\MyPlugin\MyPlugin::getScheduledReportParameters :: parameters :: Array
(
[emailMe] =>
[evolutionGraph] =>
[additionalEmails] =>
[displayFormat] => 1
[myCustomParameter] => 0 // here is the custom parameter that I added to the array
)
Piwik\Plugins\MyPlugin\MyPlugin::validateScheduledReportParameters :: parameters :: Array
(
[displayFormat] => 1
[emailMe] => 1
[evolutionGraph] =>
// custom parameter was not submitted
)

And form submission data from Chrome:

idReport:0
description:description
idSegment:
reportType:email
reportFormat:html
reports[]:MyCustomReport1
reports[]:MyCustomReport2
parameters[displayFormat]:1
parameters[emailMe]:true
parameters[evolutionGraph]:false
token_auth:

I believe the problem can be traced to the reportParametersScheduledReports.twig
file. As you can see, the parameters to submit are hard-coded in the javascript instead of being pulled dynamically from the $availableParameters variable.

@mattab commented on February 21st 2017 Owner

Thanks for the feedback @bkbeckman - we would welcome a pull request implementing this change and allowing you to build your plugin with custom parameters. So hopefully you have a chance to create and submit this PR for our review? :+1:

Powered by GitHub Issue Mirror