mirror of
https://github.com/silverstripe/silverstripe-environmentcheck
synced 2024-10-22 17:05:40 +02:00
Merge pull request #5 from candidasa
This commit is contained in:
parent
d16ca16e67
commit
82241b4f9d
@ -1,9 +1,14 @@
|
||||
<?php
|
||||
|
||||
class DevCheckController extends Controller {
|
||||
|
||||
public static $allowed_actions = array(
|
||||
'index'
|
||||
);
|
||||
|
||||
function index() {
|
||||
$e = new EnvironmentChecker('check', 'Environment status');
|
||||
$e->init();
|
||||
$e->init('ADMIN'); //check for admin permissions before running this check
|
||||
return $e;
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,14 @@
|
||||
<?php
|
||||
|
||||
class DevHealthController extends Controller {
|
||||
|
||||
public static $allowed_actions = array(
|
||||
'index'
|
||||
);
|
||||
|
||||
function index() {
|
||||
$e = new EnvironmentChecker('health', 'Site health');
|
||||
$e->init();
|
||||
$e->init(''); //empty permission check, the "health" check does not require a permission check to run
|
||||
$e->setErrorCode(404);
|
||||
return $e;
|
||||
}
|
||||
|
@ -28,19 +28,20 @@ class EnvironmentChecker extends RequestHandler {
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
function init() {
|
||||
if(!$this->canAccess()) return $this->httpError(403);
|
||||
function init($permission = 'ADMIN') {
|
||||
if(!$this->canAccess(null, $permission)) return $this->httpError(403);
|
||||
}
|
||||
|
||||
function canAccess($member = null) {
|
||||
function canAccess($member = null, $permission = "ADMIN") {
|
||||
if(!$member) $member = Member::currentUser();
|
||||
|
||||
// We allow access to this controller regardless of live-status or ADMIN permission only
|
||||
// if on CLI. Access to this controller is always allowed in "dev-mode", or of the user is ADMIN.
|
||||
if(
|
||||
Director::isDev()
|
||||
|| Director::is_cli()
|
||||
|| Permission::checkMember($member, "ADMIN")
|
||||
|| Director::is_cli()
|
||||
|| empty($permission)
|
||||
|| Permission::checkMember($member, $permission)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
@ -66,6 +67,7 @@ class EnvironmentChecker extends RequestHandler {
|
||||
}
|
||||
|
||||
$resultText = $result->customise(array(
|
||||
"URL" => Director::absoluteBaseURL(),
|
||||
"Title" => $this->title,
|
||||
"Name" => $this->checkSuiteName,
|
||||
"ErrorCode" => $this->errorCode,
|
||||
|
@ -13,9 +13,14 @@
|
||||
|
||||
h1 {
|
||||
font-size: 30px;
|
||||
margin-bottom: 10px;
|
||||
margin-bottom: 3px;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 16px;
|
||||
margin: 2px 0 10px 8px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-left: 10px;
|
||||
@ -57,6 +62,7 @@
|
||||
|
||||
<body>
|
||||
<h1 class="$Status">$Title: $Status</h1>
|
||||
<h2 class="website">Site: $URL</h2>
|
||||
|
||||
<table>
|
||||
<tr><th>Check</th> <th>Status</th> <th>Message</th></tr>
|
||||
|
Loading…
Reference in New Issue
Block a user