PHP Class Piwik\Plugins\ScheduledReports\API

"generateReport" will generate the requested report (for a specific date range, website and in the requested language). "sendEmailReport" will send the report by email to the recipients specified for this report. You can also get the list of all existing reports via "getReports", create new reports via "addReport", or manage existing reports with "updateReport" and "deleteReport". See also the documentation about Scheduled Email reports in Piwik.
Inheritance: extends Piwik\Plugin\API
Show file Open project: piwik/piwik Class Usage Examples

Public Properties

Property Type Description
$cache static cache storing reports

Public Methods

Method Description
__construct ( Psr\Log\LoggerInterface $logger )
addReport ( integer $idSite, string $description, string $period, integer $hour, string $reportType, string $reportFormat, array $reports, array $parameters, boolean | integer $idSegment = false ) : integer Creates a new report and schedules it.
allowMultipleReports ( $reportType )
deleteReport ( integer $idReport ) Deletes a specific report
generateReport ( integer $idReport, string $date, boolean | false | string $language = false, boolean | false | integer $outputType = false, boolean | false | string $period = false, boolean | false | string $reportFormat = false, boolean | false | array $parameters = false ) : array | void Generates a report file.
getReportFormats ( $reportType )
getReportMetadata ( $idSite, $reportType )
getReportRecipients ( $report )
getReportTypes ( )
getReports ( boolean | integer $idSite = false, boolean | string $period = false, boolean | integer $idReport = false, boolean $ifSuperUserReturnOnlySuperUserReports = false, boolean | integer $idSegment = false ) : array Returns the list of reports matching the passed parameters
getSegment ( $idSegment )
isSegmentEditorActivated ( )
sendReport ( $idReport, $period = false, $date = false, $force = false )
updateReport ( $idReport, $idSite, $description, $period, $hour, $reportType, $reportFormat, $reports, $parameters, $idSegment = false ) Updates an existing report.

Private Methods

Method Description
checkUserHasViewPermission ( $login, $idSite )
ensureLanguageSetForUser ( $currentUser )
getAttachments ( $reportRenderer, $report, $processedReports, $prettyDate )
getModel ( )
getReportSubjectAndReportTitle ( $websiteName, $reports )
validateAndTruncateDescription ( &$description )
validateCommonReportAttributes ( $period, $hour, &$description, &$idSegment, $reportType, $reportFormat )
validateIdSegment ( &$idSegment )
validateReportFormat ( $reportType, $reportFormat )
validateReportHour ( $hour )
validateReportParameters ( $reportType, $parameters )
validateReportPeriod ( $period )
validateReportType ( $reportType )
validateRequestedReports ( $idSite, $reportType, $requestedReports )

Method Details

__construct() public method

public __construct ( Psr\Log\LoggerInterface $logger )
$logger Psr\Log\LoggerInterface

addReport() public method

Creates a new report and schedules it.
public addReport ( integer $idSite, string $description, string $period, integer $hour, string $reportType, string $reportFormat, array $reports, array $parameters, boolean | integer $idSegment = false ) : integer
$idSite integer
$description string Report description
$period string Schedule frequency: day, week or month
$hour integer Hour (0-23) when the report should be sent
$reportType string 'email' or any other format provided via the ScheduledReports.getReportTypes hook
$reportFormat string 'pdf', 'html' or any other format provided via the ScheduledReports.getReportFormats hook
$reports array array of reports
$parameters array array of parameters
$idSegment boolean | integer Segment Identifier
return integer idReport generated

allowMultipleReports() public static method

public static allowMultipleReports ( $reportType )

deleteReport() public method

Deletes a specific report
public deleteReport ( integer $idReport )
$idReport integer

generateReport() public method

Generates a report file.
public generateReport ( integer $idReport, string $date, boolean | false | string $language = false, boolean | false | integer $outputType = false, boolean | false | string $period = false, boolean | false | string $reportFormat = false, boolean | false | array $parameters = false ) : array | void
$idReport integer ID of the report to generate.
$date string YYYY-MM-DD
$language boolean | false | string If not passed, will use default language.
$outputType boolean | false | integer 1 = download report, 2 = save report to disk, 3 = output report in browser, 4 = return report content to caller, defaults to download
$period boolean | false | string Defaults to 'day'. If not specified, will default to the report's period set when creating the report
$reportFormat boolean | false | string 'pdf', 'html' or any other format provided via the ScheduledReports.getReportFormats hook
$parameters boolean | false | array array of parameters
return array | void

getReportFormats() public static method

public static getReportFormats ( $reportType )

getReportMetadata() public static method

public static getReportMetadata ( $idSite, $reportType )

getReportRecipients() public static method

public static getReportRecipients ( $report )

getReportTypes() public static method

public static getReportTypes ( )

getReports() public method

Returns the list of reports matching the passed parameters
public getReports ( boolean | integer $idSite = false, boolean | string $period = false, boolean | integer $idReport = false, boolean $ifSuperUserReturnOnlySuperUserReports = false, boolean | integer $idSegment = false ) : array
$idSite boolean | integer If specified, will filter reports that belong to a specific idsite
$period boolean | string If specified, will filter reports that are scheduled for this period (day,week,month)
$idReport boolean | integer If specified, will filter the report that has the given idReport
$ifSuperUserReturnOnlySuperUserReports boolean
$idSegment boolean | integer If specified, will filter the report that has the given idSegment
return array

getSegment() public static method

public static getSegment ( $idSegment )

isSegmentEditorActivated() public static method

public static isSegmentEditorActivated ( )

sendReport() public method

public sendReport ( $idReport, $period = false, $date = false, $force = false )

updateReport() public method

Updates an existing report.
See also: addReport()
public updateReport ( $idReport, $idSite, $description, $period, $hour, $reportType, $reportFormat, $reports, $parameters, $idSegment = false )

Property Details

$cache public static property

static cache storing reports
public static $cache