diff --git a/core/ReportRenderer.php b/core/ReportRenderer.php index b09505efa14..4634f9197c8 100644 --- a/core/ReportRenderer.php +++ b/core/ReportRenderer.php @@ -18,7 +18,6 @@ /** * A Report Renderer produces user friendly renderings of any given Piwik report. * All new Renderers must be copied in ReportRenderer and added to the $availableReportRenderers. - * */ abstract class ReportRenderer { @@ -32,10 +31,12 @@ abstract class ReportRenderer const HTML_FORMAT = 'html'; const PDF_FORMAT = 'pdf'; + const CSV_FORMAT = 'csv'; static private $availableReportRenderers = array( self::PDF_FORMAT, self::HTML_FORMAT, + self::CSV_FORMAT, ); /** diff --git a/plugins/ScheduledReports/ScheduledReports.php b/plugins/ScheduledReports/ScheduledReports.php index 9deaa618dd2..cb2309b5cef 100644 --- a/plugins/ScheduledReports/ScheduledReports.php +++ b/plugins/ScheduledReports/ScheduledReports.php @@ -11,7 +11,6 @@ use Exception; use Piwik\Common; use Piwik\Config; -use Piwik\Date; use Piwik\Db; use Piwik\DbHelper; use Piwik\Mail; @@ -69,7 +68,8 @@ class ScheduledReports extends \Piwik\Plugin static private $managedReportFormats = array( ReportRenderer::HTML_FORMAT => 'plugins/Zeitgeist/images/html_icon.png', - ReportRenderer::PDF_FORMAT => 'plugins/UserSettings/images/plugins/pdf.gif' + ReportRenderer::PDF_FORMAT => 'plugins/UserSettings/images/plugins/pdf.gif', + ReportRenderer::CSV_FORMAT => 'plugins/Morpheus/images/export.png', ); /** @@ -304,6 +304,24 @@ public function sendReport($reportType, $report, $contents, $filename, $prettyDa $mail->setBodyHtml($message . "

" . $contents); break; + + case 'csv': + $message .= "\n" . Piwik::translate('ScheduledReports_PleaseFindAttachedFile', array($periods[$report['period']], $reportTitle)); + + if ($displaySegmentInfo) { + $message .= " " . $segmentInfo; + } + + $mail->setBodyText($message); + $mail->createAttachment( + $contents, + 'application/csv', + Zend_Mime::DISPOSITION_INLINE, + Zend_Mime::ENCODING_BASE64, + $attachmentName . '.csv' + ); + break; + default: case 'pdf': $message .= "\n" . Piwik::translate('ScheduledReports_PleaseFindAttachedFile', array($periods[$report['period']], $reportTitle));