mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-02 19:36:08 +01:00
Handle removing a media also if it's not a json request
Was not working after https://github.com/getgrav/grav-plugin-admin/commit/6b343365996ce838759d 80fa3917d4d994f1aeb4
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
1. [](#bugfix)
|
||||
* Fixed issue with downloaded package when installing a testing release
|
||||
* Fix #943 allow non admin.super users to change their account information. Allow `admin.super` and `admin.users` to change other users information.
|
||||
* Handle removing a media file also if it's not a json request. Was not working after https://github.com/getgrav/grav-plugin-admin/commit/6b343365996ce838759d80fa3917d4d994f1aeb4
|
||||
|
||||
# v1.2.9
|
||||
## 01/18/2017
|
||||
|
||||
@@ -876,6 +876,9 @@ class AdminBaseController
|
||||
}
|
||||
|
||||
$filename = base64_decode($this->grav['uri']->param('route'));
|
||||
if (!$filename) {
|
||||
$filename = base64_decode($this->route);
|
||||
}
|
||||
|
||||
$file = File::instance($filename);
|
||||
$resultRemoveMedia = false;
|
||||
@@ -895,17 +898,27 @@ class AdminBaseController
|
||||
}
|
||||
|
||||
if ($resultRemoveMedia && $resultRemoveMediaMeta) {
|
||||
$this->admin->json_response = [
|
||||
'status' => 'success',
|
||||
'message' => $this->admin->translate('PLUGIN_ADMIN.REMOVE_SUCCESSFUL')
|
||||
];
|
||||
if ($this->grav['uri']->extension() === 'json') {
|
||||
$this->admin->json_response = [
|
||||
'status' => 'success',
|
||||
'message' => $this->admin->translate('PLUGIN_ADMIN.REMOVE_SUCCESSFUL')
|
||||
];
|
||||
} else {
|
||||
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.REMOVE_SUCCESSFUL'), 'info');
|
||||
$this->clearMediaCache();
|
||||
$this->setRedirect('/media-manager');
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
$this->admin->json_response = [
|
||||
'status' => 'success',
|
||||
'message' => $this->admin->translate('PLUGIN_ADMIN.REMOVE_FAILED')
|
||||
];
|
||||
if ($this->grav['uri']->extension() === 'json') {
|
||||
$this->admin->json_response = [
|
||||
'status' => 'success',
|
||||
'message' => $this->admin->translate('PLUGIN_ADMIN.REMOVE_FAILED')
|
||||
];
|
||||
} else {
|
||||
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.REMOVE_FAILED'), 'error');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user