From 5a6575b1c07997ba1af20952f435290ce8ce970c Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 8 Feb 2017 12:13:57 +0100 Subject: [statistics_reporting] Nag user if statistics reporting is disabled --- .../hooks/main-warning.inc.php | 5 +++ .../statistics_reporting/inc/remotereport.inc.php | 2 +- .../lang/de/template-tags.json | 4 +- .../lang/en/template-tags.json | 4 +- .../statistics_reporting/page.inc.php | 26 ++++++++++++- .../templates/columnChooser.html | 43 ++++++++++++---------- 6 files changed, 60 insertions(+), 24 deletions(-) create mode 100644 modules-available/statistics_reporting/hooks/main-warning.inc.php (limited to 'modules-available/statistics_reporting') diff --git a/modules-available/statistics_reporting/hooks/main-warning.inc.php b/modules-available/statistics_reporting/hooks/main-warning.inc.php new file mode 100644 index 00000000..33381c9f --- /dev/null +++ b/modules-available/statistics_reporting/hooks/main-warning.inc.php @@ -0,0 +1,5 @@ +doExport(); // Does not return } + // Get report - fetch data exactly the way it would automatically be reported + // so the user can know what is going on + if ($this->action === 'getreport') { + $report = RemoteReport::generateReport(strtotime('-7 days'), time('now')); + Header('Content-Disposition: attachment; filename=remote-report.json'); + Header('Content-Type: application/json; charset=utf-8'); + die(json_encode($report)); + } } /** @@ -105,6 +113,13 @@ class Page_Statistics_Reporting extends Page $data['lower'] = $this->lower; $data['upper'] = $this->upper; + if (RemoteReport::isReportingEnabled()) { + $data['settingsButtonClass'] = 'default'; + $data['reportChecked'] = 'checked'; + } else { + $data['settingsButtonClass'] = 'danger'; + } + Render::addTemplate('columnChooser', $data); $data['data'] = $this->fetchData(GETDATA_PRINTABLE); @@ -124,8 +139,15 @@ class Page_Statistics_Reporting extends Page die('Missing setting value.'); } RemoteReport::setReportingEnabled($state); - } elseif ($this->action === 'getReporting') { - echo RemoteReport::isReportingEnabled() ? 'on' : ''; + $data = array(); + if (RemoteReport::isReportingEnabled()) { + $data['class'] = 'default'; + $data['checked'] = true; + } else { + $data['class'] = 'danger'; + } + Header('Content-Type: application/json; charset=utf-8'); + die(json_encode($data)); } else { echo 'Invalid action.'; } diff --git a/modules-available/statistics_reporting/templates/columnChooser.html b/modules-available/statistics_reporting/templates/columnChooser.html index efc1f355..9707c970 100644 --- a/modules-available/statistics_reporting/templates/columnChooser.html +++ b/modules-available/statistics_reporting/templates/columnChooser.html @@ -2,7 +2,7 @@
- + {{lang_displaySelection}}
@@ -72,8 +72,12 @@