diff options
Diffstat (limited to 'modules-available/statistics_reporting')
9 files changed, 59 insertions, 29 deletions
diff --git a/modules-available/statistics_reporting/page.inc.php b/modules-available/statistics_reporting/page.inc.php index 52accaea..1a85bfa8 100644 --- a/modules-available/statistics_reporting/page.inc.php +++ b/modules-available/statistics_reporting/page.inc.php @@ -52,16 +52,25 @@ 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 + } else { + Message::addError('main.no-permission'); + } } // 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(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)); + } else { + Message::addError('main.no-permission'); + } + } } @@ -124,7 +133,12 @@ class Page_Statistics_Reporting extends Page 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); + else + Message::addError('main.no-permission'); + } } @@ -132,8 +146,8 @@ class Page_Statistics_Reporting extends Page { $this->action = Request::any('action', false, 'string'); if ($this->action === 'setReporting') { - if (!User::isLoggedIn()) { - die("No."); + if (!User::hasPermission("reporting.change")) { + die("Permission denied."); } $state = Request::post('reporting', false, 'string'); if ($state === false) { @@ -266,9 +280,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..14f4ff3b --- /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.", + "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..d0408b6f 100644 --- a/modules-available/statistics_reporting/templates/columnChooser.html +++ b/modules-available/statistics_reporting/templates/columnChooser.html @@ -112,15 +112,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> |