[DOCS] Better debug text for errors generated by GridFieldDetailForm_ItemRequest

This commit is contained in:
mattclegg 2020-03-31 12:09:16 +05:45
parent ba3deb9b72
commit 24bc80ed35
No known key found for this signature in database
GPG Key ID: 38F89AD4DDF94EC3
2 changed files with 21 additions and 4 deletions

View File

@ -111,6 +111,8 @@ en:
NEW: 'Add new record' NEW: 'Add new record'
NEXT: 'Go to next record' NEXT: 'Go to next record'
PREVIOUS: 'Go to previous record' PREVIOUS: 'Go to previous record'
EditPermissionsFailure: 'It seems you don''t have the necessary permissions to edit {ObjectTitle}'
ViewPermissionsFailure: 'It seems you don''t have the necessary permissions to view {ObjectTitle}'
SilverStripe\Forms\GridField\GridFieldEditButton: SilverStripe\Forms\GridField\GridFieldEditButton:
EDIT: Edit EDIT: Edit
SilverStripe\Forms\GridField\GridFieldFilterHeader: SilverStripe\Forms\GridField\GridFieldFilterHeader:

View File

@ -111,7 +111,12 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler
public function view($request) public function view($request)
{ {
if (!$this->record->canView()) { if (!$this->record->canView()) {
$this->httpError(403); $this->httpError(403, _t(
__CLASS__.'.ViewPermissionsFailure',
'It seems you don\'t have the necessary permissions to view {ObjectTitle}',
'',
['ObjectTitle' => $this->record->singular_name()]
));
} }
$controller = $this->getToplevelController(); $controller = $this->getToplevelController();
@ -189,8 +194,12 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler
if (!$this->record->canView()) { if (!$this->record->canView()) {
$controller = $this->getToplevelController(); $controller = $this->getToplevelController();
// TODO More friendly error return $controller->httpError(403, _t(
return $controller->httpError(403); __CLASS__.'.ViewPermissionsFailure',
'It seems you don\'t have the necessary permissions to view {ObjectTitle}',
'',
['ObjectTitle' => $this->record->singular_name()]
));
} }
$fields = $this->component->getFields(); $fields = $this->component->getFields();
@ -490,7 +499,13 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler
// Check permission // Check permission
if (!$this->record->canEdit()) { if (!$this->record->canEdit()) {
return $this->httpError(403); $this->httpError(403, _t(
__CLASS__.'.EditPermissionsFailure',
'It seems you don\'t have the necessary permissions to edit {ObjectTitle}',
'',
['ObjectTitle' => $this->record->singular_name()]
));
return null;
} }
// Save from form data // Save from form data