Skip to content

Commit

Permalink
refactor: move canView() to UsageGraphs_UsageGraphs
Browse files Browse the repository at this point in the history
since the permissions required to view admin usage graphs are the same
no matter the section, canView() can be moved to the abstract
UsageGraphs_UsageGraphs class to be used as is by all usagegraph classes
  • Loading branch information
Chloe070196 committed Aug 30, 2024
1 parent 0cf5cef commit 535281e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 7 additions & 0 deletions code/web/services/Admin/AbstractUsageGraphs.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,11 @@ protected function launchGraph(string $sectionName): void {
$this->display('usage-graph.tpl', $graphTitle);
}

public function canView(): bool {
return UserAccount::userHasPermission([
'View Dashboards',
'View System Reports',
]);
}

}
6 changes: 0 additions & 6 deletions code/web/services/Admin/UsageGraphs.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ function getActiveAdminSection(): string {
return 'system_reports';
}

function canView(): bool {
return UserAccount::userHasPermission([
'View Dashboards',
'View System Reports',
]);
}

public function buildCSV() {
global $interface;
Expand Down

0 comments on commit 535281e

Please sign in to comment.