summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics_reporting
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/statistics_reporting')
-rw-r--r--modules-available/statistics_reporting/lang/de/template-tags.json2
-rw-r--r--modules-available/statistics_reporting/lang/en/template-tags.json2
-rw-r--r--modules-available/statistics_reporting/page.inc.php78
-rw-r--r--modules-available/statistics_reporting/permissions/permissions.json10
-rw-r--r--modules-available/statistics_reporting/style.css6
-rw-r--r--modules-available/statistics_reporting/templates/columnChooser.html127
-rw-r--r--modules-available/statistics_reporting/templates/table-client.html2
-rw-r--r--modules-available/statistics_reporting/templates/table-location.html2
-rw-r--r--modules-available/statistics_reporting/templates/table-total.html2
-rw-r--r--modules-available/statistics_reporting/templates/table-user.html2
-rw-r--r--modules-available/statistics_reporting/templates/table-vm.html2
11 files changed, 142 insertions, 93 deletions
diff --git a/modules-available/statistics_reporting/lang/de/template-tags.json b/modules-available/statistics_reporting/lang/de/template-tags.json
index fb624fad..f8829b79 100644
--- a/modules-available/statistics_reporting/lang/de/template-tags.json
+++ b/modules-available/statistics_reporting/lang/de/template-tags.json
@@ -10,11 +10,13 @@
"lang_location": "Ort",
"lang_longSessions": "Sitzungen \u2265 60s",
"lang_medianSessionLength": "Sitzungsdauer Median",
+ "lang_moduleName": "Statistikauswertung",
"lang_reportMoreInfo": "Weitere Informationen...",
"lang_reportingDescription": "Helfen Sie uns bwLehrpool durch das w\u00f6chentliche Verschicken eines anonymisierten Statistikberichts zu verbessern. Wenn Sie den Inhalt eines solchen Reports genauer inspizieren wollen, k\u00f6nnen Sie \u00fcber den untenstehenden Button einen aktuellen Report Ihres Servers herunterladen.",
"lang_reportingLabel": "Anonymisierte Nutzungsstatistiken \u00fcbermitteln",
"lang_sessions": "Sitzungen",
"lang_shortSessions": "Sitzungen < 60s",
+ "lang_show": "Anzeigen",
"lang_total": "Gesamt",
"lang_totalOffTime": "Gesamtzeit offline",
"lang_totalTime": "Gesamtzeit",
diff --git a/modules-available/statistics_reporting/lang/en/template-tags.json b/modules-available/statistics_reporting/lang/en/template-tags.json
index 4e33ffed..73c21112 100644
--- a/modules-available/statistics_reporting/lang/en/template-tags.json
+++ b/modules-available/statistics_reporting/lang/en/template-tags.json
@@ -10,11 +10,13 @@
"lang_location": "Location",
"lang_longSessions": "Sessions \u2265 60s",
"lang_medianSessionLength": "Median Session Length",
+ "lang_moduleName": "Statistics Reporting",
"lang_reportMoreInfo": "More information...",
"lang_reportingDescription": "Help us improve bwLehrpool by automatically sending an anonymized statistics report once a week. If you want to check what data the report contains, you can download such a report for reference below.",
"lang_reportingLabel": "Send anonymized usage statistics",
"lang_sessions": "Sessions",
"lang_shortSessions": "Sessions < 60s",
+ "lang_show": "Show",
"lang_total": "Total",
"lang_totalOffTime": "Total Time Offline",
"lang_totalTime": "Total Time",
diff --git a/modules-available/statistics_reporting/page.inc.php b/modules-available/statistics_reporting/page.inc.php
index 52accaea..5d586b6c 100644
--- a/modules-available/statistics_reporting/page.inc.php
+++ b/modules-available/statistics_reporting/page.inc.php
@@ -52,16 +52,20 @@ class Page_Statistics_Reporting extends Page
// Export - handle in doPreprocess so we don't render the menu etc.
if ($this->action === 'export') {
- $this->doExport();
- // Does not return
+ if (User::hasPermission("table.export") && User::hasPermission("table.view.$this->type")) {
+ $this->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(time());
- Header('Content-Disposition: attachment; filename=remote-report.json');
- Header('Content-Type: application/json; charset=utf-8');
- die(json_encode($report));
+ if(User::hasPermission("reporting.download")) {
+ $report = RemoteReport::generateReport(time());
+ Header('Content-Disposition: attachment; filename=remote-report.json');
+ Header('Content-Type: application/json; charset=utf-8');
+ die(json_encode($report));
+ }
}
}
@@ -100,6 +104,7 @@ class Page_Statistics_Reporting extends Page
$data['tables'][] = array(
'name' => Dictionary::translate('table_' . $table, true),
'value' => $table,
+ 'allowed' => User::hasPermission("table.view.$table"),
'selected' => ($this->type === $table) ? 'selected' : '',
);
}
@@ -121,10 +126,17 @@ class Page_Statistics_Reporting extends Page
$data['settingsButtonClass'] = 'danger';
}
+ $data['allowedExport'] = User::hasPermission("table.export") && User::hasPermission("table.view.$this->type");
+ $data['allowedDownload'] = User::hasPermission("reporting.download");
+ $data['allowedReportChange'] = User::hasPermission("reporting.change");
+
Render::addTemplate('columnChooser', $data);
$data['data'] = $this->fetchData(GETDATA_PRINTABLE);
- Render::addTemplate('table-' . $this->type, $data);
+
+ if (User::hasPermission("table.view.$this->type")) {
+ Render::addTemplate('table-' . $this->type, $data);
+ }
}
}
@@ -132,23 +144,24 @@ class Page_Statistics_Reporting extends Page
{
$this->action = Request::any('action', false, 'string');
if ($this->action === 'setReporting') {
- if (!User::isLoggedIn()) {
- die("No.");
- }
- $state = Request::post('reporting', false, 'string');
- if ($state === false) {
- die('Missing setting value.');
- }
- RemoteReport::setReportingEnabled($state);
- $data = array();
- if (RemoteReport::isReportingEnabled()) {
- $data['class'] = 'default';
- $data['checked'] = true;
+ if (User::hasPermission("reporting.change")) {
+ $state = Request::post('reporting', false, 'string');
+ if ($state === false) {
+ die('Missing setting value.');
+ }
+ RemoteReport::setReportingEnabled($state);
+ $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 {
- $data['class'] = 'danger';
+ die('No permission.');
}
- Header('Content-Type: application/json; charset=utf-8');
- die(json_encode($data));
} else {
echo 'Invalid action.';
}
@@ -266,9 +279,28 @@ class Page_Statistics_Reporting extends Page
}
}
}
+ // only show locations which you have permission for
+ $filterLocs = User::getAllowedLocations("table.view.location");
+ foreach ($data as $key => $row) {
+ if (!in_array($row['locationId'], $filterLocs)) {
+ unset($data[$key]);
+ }
+ }
+ // correct indexing of array after deletions
+ $data = array_values($data);
return $data;
case 'client':
- return GetData::perClient($flags);
+ $data = GetData::perClient($flags);
+ // only show clients from locations which you have permission for
+ $filterLocs = User::getAllowedLocations("table.view.location");
+ foreach ($data as $key => $row) {
+ if (!in_array($row['locationId'], $filterLocs)) {
+ unset($data[$key]);
+ }
+ }
+ // correct indexing of array after deletions
+ $data = array_values($data);
+ return $data;
case 'user':
return GetData::perUser($flags);
case 'vm':
diff --git a/modules-available/statistics_reporting/permissions/permissions.json b/modules-available/statistics_reporting/permissions/permissions.json
new file mode 100644
index 00000000..e6e550eb
--- /dev/null
+++ b/modules-available/statistics_reporting/permissions/permissions.json
@@ -0,0 +1,10 @@
+{
+ "table.view.total": "View total table.",
+ "table.view.location": "View location table.",
+ "table.view.client": "View client table.",
+ "table.view.user": "View user table.",
+ "table.view.vm": "View lecture table.",
+ "table.export": "Export tables as JSON/CSV/XML. Needs the permission to view the table to export it.",
+ "reporting.download": "Download weekly report.",
+ "reporting.change": "Change weekly reporting settings."
+} \ No newline at end of file
diff --git a/modules-available/statistics_reporting/style.css b/modules-available/statistics_reporting/style.css
index 81dc74b0..3cd6653f 100644
--- a/modules-available/statistics_reporting/style.css
+++ b/modules-available/statistics_reporting/style.css
@@ -35,8 +35,4 @@
margin-left: -1.5em;
text-align: center;
line-height: 1.6em;
-}
-
-th[data-sort] {
- cursor: pointer;
-}
+} \ No newline at end of file
diff --git a/modules-available/statistics_reporting/templates/columnChooser.html b/modules-available/statistics_reporting/templates/columnChooser.html
index e4069be9..a6561c47 100644
--- a/modules-available/statistics_reporting/templates/columnChooser.html
+++ b/modules-available/statistics_reporting/templates/columnChooser.html
@@ -1,64 +1,79 @@
<form method="get" id="controlsForm">
<input type="hidden" name="do" value="statistics_reporting">
- <div class="row">
- <div class="col-md-12">
- <button id="button-settings" type="button" class="pull-right btn btn-{{settingsButtonClass}}" data-toggle="modal" data-target="#modal-settings"><span class="glyphicon glyphicon-cog"></span></button>
- <strong class="text-capitalize">{{lang_displaySelection}}</strong>
- </div>
+
+ <div class="page-header">
+ <button id="button-settings" type="button" class="btn btn-{{settingsButtonClass}} pull-right" data-toggle="modal" data-target="#modal-settings"><span class="glyphicon glyphicon-cog"></span> Settings</button>
+ <h1>{{lang_moduleName}}</h1>
</div>
- <div class="row top-row">
- <div class="col-md-4">
- <select name="type" id="select-table" class="form-control">
- {{#tables}}
- <option value="{{value}}" {{selected}}>{{name}}</option>
- {{/tables}}
- </select>
- </div>
- <div class="col-md-4">
- <select name="cutoff" id="select-cutoff" class="form-control">
- {{#days}}
- <option value="{{days}}" {{selected}}>{{days}} {{lang_days}}</option>
- {{/days}}
- </select>
+
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ {{lang_displaySelection}}
</div>
- <div class="col-md-3">
- <div id="slider">
- <div id="lower-handle" class="ui-slider-handle"></div>
- <div id="upper-handle" class="ui-slider-handle"></div>
- <input type="hidden" id="lower-field" name="lower" value="{{lower}}">
- <input type="hidden" id="upper-field" name="upper" value="{{upper}}">
+ <div class="panel-body">
+ <div class="row top-row">
+ <div class="col-md-2">
+ <select name="type" id="select-table" class="form-control">
+ {{#tables}}
+ <option {{^allowed}}disabled{{/allowed}} value="{{value}}" {{selected}}>{{name}}</option>
+ {{/tables}}
+ </select>
+ </div>
+ <div class="col-md-2">
+ <select name="cutoff" id="select-cutoff" class="form-control">
+ {{#days}}
+ <option value="{{days}}" {{selected}}>{{days}} {{lang_days}}</option>
+ {{/days}}
+ </select>
+ </div>
+ <div class="col-md-3" style="margin-top: 10px;">
+ <div id="slider">
+ <div id="lower-handle" class="ui-slider-handle"></div>
+ <div id="upper-handle" class="ui-slider-handle"></div>
+ <input type="hidden" id="lower-field" name="lower" value="{{lower}}">
+ <input type="hidden" id="upper-field" name="upper" value="{{upper}}">
+ </div>
+ </div>
+ <div class="col-md-1">
+ <button type="submit" class="btn btn-primary">{{lang_show}}</button>
+ </div>
+ <div class="col-md-3">
+ <div class="input-group">
+ <select class="form-control" name="format">
+ <option value="json">JSON</option>
+ <option value="csv">CSV (Excel)</option>
+ <option value="xml">XML</option>
+ </select>
+ <div class="input-group-btn">
+ <button {{^allowedExport}}disabled {{/allowedExport}} type="submit" class="btn btn-default" name="action" value="export">{{lang_export}}</button>
+ </div>
+ </div>
+ </div>
+
</div>
+
</div>
</div>
- <div class="row top-row">
- <div class="col-md-12 form-inline">
- <div><strong class="text-capitalize">{{lang_displayColumns}}</strong></div>
- {{#columns}}
- <div class="checkbox">
- <input id="id_{{id}}" name="{{id}}" value="on" type="checkbox" class="column-toggle form-control" {{checked}}>
- <label for="id_{{id}}">{{name}}</label>
- </div>
- {{/columns}}
+
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ {{lang_displayColumns}}
</div>
- </div>
- <div class="row top-row">
- <div class="col-md-12 form-inline">
- <div class="pull-right input-group">
- <select class="form-control" name="format">
- <option value="json">JSON</option>
- <option value="csv">CSV (Excel)</option>
- <option value="xml">XML</option>
- </select>
- <div class="input-group-btn">
- <button type="submit" class="btn btn-default" name="action" value="export">{{lang_export}}</button>
+ <div class="panel-body">
+ <div class="row top-row">
+ <div class="col-md-12 form-inline">
+ {{#columns}}
+ <div class="checkbox">
+ <input id="id_{{id}}" name="{{id}}" value="on" type="checkbox" class="column-toggle form-control" {{checked}}>
+ <label for="id_{{id}}">{{name}}</label>
+ </div>
+ {{/columns}}
</div>
</div>
- <button type="submit" class="btn btn-primary">{{lang_apply}}</button>
</div>
</div>
</form>
-<hr>
<div id="modal-settings" class="modal fade" role="dialog">
<div class="modal-dialog">
@@ -71,17 +86,18 @@
</div>
<div class="modal-body">
<div class="checkbox">
- <input id="checkbox-reporting" type="checkbox" value="on" {{reportChecked}}>
- <label for="checkbox-reporting" style="padding-left: 40px">{{lang_reportingLabel}}</label>
+ <input {{^allowedReportChange}}disabled {{/allowedReportChange}} id="checkbox-reporting" type="checkbox" value="on" {{reportChecked}}>
+ <label for="checkbox-reporting" style="padding-left: 20px">{{lang_reportingLabel}}</label>
</div>
<div>
<p>{{lang_reportingDescription}}</p>
<p><a href="https://www.bwlehrpool.de/doku.php/satellite/statistics_reporting" target="_blank">{{lang_reportMoreInfo}}</a></p>
- <a class="btn btn-success" href="?do=statistics_reporting&amp;action=getreport">{{lang_downloadReport}}</a>
</div>
</div>
<div class="modal-footer">
- <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="saveSettings()">{{lang_save}}</button>
+ <button {{^allowedDownload}}disabled {{/allowedDownload}} class="btn btn-warning pull-left" onclick="window.location.href='?do=statistics_reporting&amp;action=getreport'">{{lang_downloadReport}}</button>
+ <button type="button" class="btn btn-default" data-dismiss="modal">{{lang_cancel}}</button>
+ <button {{^allowedReportChange}}disabled {{/allowedReportChange}} type="button" class="btn btn-primary" data-dismiss="modal" onclick="saveSettings()">{{lang_save}}</button>
</div>
</div>
@@ -112,15 +128,6 @@
},
});
- var table = $("table").stupidtable();
- table.on("aftertablesort", function (event, data) {
- var th = $(this).find("th");
- th.find(".arrow").remove();
- var dir = $.fn.stupidtable.dir;
- var arrow = data.direction === dir.ASC ? "up" : "down";
- th.eq(data.column).append(' <span class="arrow glyphicon glyphicon-chevron-'+arrow+'"></span>');
- });
-
$(".locationLink").click(function(e) {
e.preventDefault();
var form = $('#controlsForm');
diff --git a/modules-available/statistics_reporting/templates/table-client.html b/modules-available/statistics_reporting/templates/table-client.html
index be504cef..59153e01 100644
--- a/modules-available/statistics_reporting/templates/table-client.html
+++ b/modules-available/statistics_reporting/templates/table-client.html
@@ -1,4 +1,4 @@
-<table id="table-perclient" class="table table-condensed table-striped">
+<table id="table-perclient" class="table table-condensed table-striped stupidtable">
<thead>
<tr>
<th data-sort="string" class="text-left col-md-4">{{lang_hostname}}</th>
diff --git a/modules-available/statistics_reporting/templates/table-location.html b/modules-available/statistics_reporting/templates/table-location.html
index ccac623d..a0867208 100644
--- a/modules-available/statistics_reporting/templates/table-location.html
+++ b/modules-available/statistics_reporting/templates/table-location.html
@@ -1,4 +1,4 @@
-<table id="table-perlocation" class="table table-condensed table-striped">
+<table id="table-perlocation" class="table table-condensed table-striped stupidtable">
<thead>
<tr>
<th data-sort="string" class="text-left col-md-2">{{lang_location}}</th>
diff --git a/modules-available/statistics_reporting/templates/table-total.html b/modules-available/statistics_reporting/templates/table-total.html
index 4048a178..8d5d7571 100644
--- a/modules-available/statistics_reporting/templates/table-total.html
+++ b/modules-available/statistics_reporting/templates/table-total.html
@@ -1,4 +1,4 @@
-<table id="table-total" class="table table-condensed table-striped">
+<table id="table-total" class="table table-condensed table-striped stupidtable">
<thead>
<tr>
<th class="text-left col-md-2"></th>
diff --git a/modules-available/statistics_reporting/templates/table-user.html b/modules-available/statistics_reporting/templates/table-user.html
index 5c2ba56f..ea4d20f5 100644
--- a/modules-available/statistics_reporting/templates/table-user.html
+++ b/modules-available/statistics_reporting/templates/table-user.html
@@ -1,4 +1,4 @@
-<table id="table-peruser" class="table table-condensed table-striped">
+<table id="table-peruser" class="table table-condensed table-striped stupidtable">
<thead>
<tr>
<th data-sort="string" class="text-left col-md-4">{{lang_user}}</th>
diff --git a/modules-available/statistics_reporting/templates/table-vm.html b/modules-available/statistics_reporting/templates/table-vm.html
index 9a775709..4ffb4df2 100644
--- a/modules-available/statistics_reporting/templates/table-vm.html
+++ b/modules-available/statistics_reporting/templates/table-vm.html
@@ -1,4 +1,4 @@
-<table id="table-pervm" class="table table-condensed table-striped">
+<table id="table-pervm" class="table table-condensed table-striped stupidtable">
<thead>
<tr>
<th data-sort="string" class="text-left col-md-4">{{lang_vm}}</th>