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