Skip to content

Commit

Permalink
Adds user permission check
Browse files Browse the repository at this point in the history
  • Loading branch information
sinan-evanshunt committed Jan 9, 2021
1 parent 61ab939 commit 1160a4a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ From where you have the `composer.json` file run `composer require evanshunt/ser

Run `dev/build`

Then you can assign user groups the permission for `ServerInfoAccess`
Then you can assign user groups the permission for `Access Serverinfo` under `Other` category
## Changelog:

- 2021-01-09: code cleanup
Expand Down
25 changes: 10 additions & 15 deletions code/ServerInfo.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
<?php


class ServerInfo extends LeftAndMain
class ServerInfo extends LeftAndMain implements PermissionProvider
{

private static $url_segment = 'serverinfo';
private static $menu_priority = -3;

private static $allowed_actions = array(
'getinfo',
);

public function init() {
parent::init();
if ( !Permission::check('ServerInfoAccess') ) {
CMSMenu::remove_menu_item('ServerInfo');
}
public function providePermissions() {
return array(
"CMS_ACCESS_ServerInfo" => "Access Serverinfo",
);
}

public function canView($member = null) {
return Permission::check('CMS_ACCESS_ServerInfo', 'any', $member);
}

public function getinfo(){
if ( Permission::check('ServerInfoAccess') ) {
if ( Permission::check('CMS_ACCESS_ServerInfo', 'any', Member::currentUser()) ) {
ob_start();
phpinfo();
$info = ob_get_contents();
Expand All @@ -28,10 +29,4 @@ public function getinfo(){
}
return NULL;
}

}

class ServerInfoAccess extends ModelAdmin
{

}

0 comments on commit 1160a4a

Please sign in to comment.