Skip to content

Commit

Permalink
Added separate statistics-only plugin permission
Browse files Browse the repository at this point in the history
  • Loading branch information
Eoler committed Dec 5, 2023
1 parent 1146d80 commit b9e1709
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
14 changes: 12 additions & 2 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public function registerPermissions(): array
'label' => 'vdlp.redirect::lang.permission.access_redirects.label',
'tab' => 'vdlp.redirect::lang.permission.access_redirects.tab',
],
'vdlp.redirect.access_redirect_stats' => [
'label' => 'vdlp.redirect::lang.permission.access_redirect_stats.label',
'tab' => 'vdlp.redirect::lang.permission.access_redirects.tab',
],
];
}

Expand Down Expand Up @@ -150,7 +154,7 @@ public function registerNavigation(): array
'url' => $defaultBackendUrl,
'order' => 201,
'permissions' => [
'vdlp.redirect.access_redirects',
'vdlp.redirect.*',
],
'sideMenu' => $sideMenu,
],
Expand All @@ -163,7 +167,7 @@ public function registerNavigation(): array
'url' => Backend::url('vdlp/redirect/statistics'),
'order' => 10,
'permissions' => [
'vdlp.redirect.access_redirects',
'vdlp.redirect.access_redirect_stats',
],
];
}
Expand Down Expand Up @@ -220,6 +224,9 @@ public function registerReportWidgets(): array
$reportWidgets[ReportWidgets\CreateRedirect::class] = [
'label' => 'vdlp.redirect::lang.buttons.create_redirect',
'context' => 'dashboard',
'permissions' => [
'vdlp.redirect.access_redirects',
],
];

if (Settings::isStatisticsEnabled()) {
Expand All @@ -231,6 +238,9 @@ public function registerReportWidgets(): array
]
)),
'context' => 'dashboard',
'permissions' => [
'vdlp.redirect.access_redirect_stats',
],
];
}

Expand Down
2 changes: 1 addition & 1 deletion controllers/Statistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
final class Statistics extends Controller
{
public $requiredPermissions = ['vdlp.redirect.access_redirects'];
public $requiredPermissions = ['vdlp.redirect.access_redirect_stats'];
private StatisticsHelper $helper;

public function __construct()
Expand Down
3 changes: 3 additions & 0 deletions lang/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
'label' => 'Redirects',
'tab' => 'Redirects',
],
'access_redirect_stats' => [
'label' => 'Redirect Statistics',
],
],
'navigation' => [
'menu_label' => 'Redirects',
Expand Down

0 comments on commit b9e1709

Please sign in to comment.