Regression: Fixed broken plugin/theme installer in admin

This commit is contained in:
Matias Griese
2021-04-14 13:54:01 +03:00
parent 9383007b93
commit cde46a2eb0
2 changed files with 21 additions and 10 deletions

View File

@@ -1,3 +1,9 @@
# v1.10.12
## 04/dd/2021
1. [](#bugfix)
* Regression: Fixed broken plugin/theme installer in admin
# v1.10.11 # v1.10.11
## 04/13/2021 ## 04/13/2021

View File

@@ -869,7 +869,12 @@ class AdminController extends AdminBaseController
*/ */
protected function taskGetPackagesDependencies() protected function taskGetPackagesDependencies()
{ {
if (!$this->authorizeTask('dashboard', ['admin.plugins', 'admin.themes', 'admin.super'])) { $type = $this->view;
if ($type !== 'plugins' && $type !== 'themes') {
return false;
}
if (!$this->authorizeTask('get package dependencies', ['admin.' . $type, 'admin.super'])) {
return false; return false;
} }
@@ -903,13 +908,12 @@ class AdminController extends AdminBaseController
*/ */
protected function taskInstallDependenciesOfPackages() protected function taskInstallDependenciesOfPackages()
{ {
$data = $this->post; $type = $this->view;
$type = $data['type'] ?? '';
if ($type !== 'plugins' && $type !== 'themes') { if ($type !== 'plugins' && $type !== 'themes') {
return false; return false;
} }
if (!$this->authorizeTask('install ' . $type, ['admin.' . $type, 'admin.super'])) { if (!$this->authorizeTask('install dependencies', ['admin.' . $type, 'admin.super'])) {
$this->admin->json_response = [ $this->admin->json_response = [
'status' => 'error', 'status' => 'error',
'message' => $this->admin::translate('PLUGIN_ADMIN.INSUFFICIENT_PERMISSIONS_FOR_TASK') 'message' => $this->admin::translate('PLUGIN_ADMIN.INSUFFICIENT_PERMISSIONS_FOR_TASK')
@@ -918,6 +922,7 @@ class AdminController extends AdminBaseController
return false; return false;
} }
$data = $this->post;
$packages = isset($data['packages']) ? explode(',', $data['packages']) : ''; $packages = isset($data['packages']) ? explode(',', $data['packages']) : '';
$packages = (array)$packages; $packages = (array)$packages;
@@ -956,8 +961,7 @@ class AdminController extends AdminBaseController
*/ */
protected function taskInstallPackage($reinstall = false) protected function taskInstallPackage($reinstall = false)
{ {
$data = $this->post; $type = $this->view;
$type = $data['type'] ?? '';
if ($type !== 'plugins' && $type !== 'themes') { if ($type !== 'plugins' && $type !== 'themes') {
return false; return false;
} }
@@ -971,6 +975,7 @@ class AdminController extends AdminBaseController
return false; return false;
} }
$data = $this->post;
$package = $data['package'] ?? ''; $package = $data['package'] ?? '';
try { try {
$result = Gpm::install($package, ['theme' => $type === 'theme']); $result = Gpm::install($package, ['theme' => $type === 'theme']);
@@ -1014,8 +1019,7 @@ class AdminController extends AdminBaseController
*/ */
protected function taskRemovePackage(): bool protected function taskRemovePackage(): bool
{ {
$data = $this->post; $type = $this->view;
$type = $data['type'] ?? '';
if ($type !== 'plugins' && $type !== 'themes') { if ($type !== 'plugins' && $type !== 'themes') {
return false; return false;
} }
@@ -1029,6 +1033,7 @@ class AdminController extends AdminBaseController
$this->sendJsonResponse($json_response, 403); $this->sendJsonResponse($json_response, 403);
} }
$data = $this->post;
$package = $data['package'] ?? ''; $package = $data['package'] ?? '';
$result = false; $result = false;
@@ -1090,8 +1095,7 @@ class AdminController extends AdminBaseController
*/ */
protected function taskReinstallPackage() protected function taskReinstallPackage()
{ {
$data = $this->post; $type = $this->view;
$type = $data['type'] ?? '';
if ($type !== 'plugins' && $type !== 'themes') { if ($type !== 'plugins' && $type !== 'themes') {
return false; return false;
} }
@@ -1105,6 +1109,7 @@ class AdminController extends AdminBaseController
$this->sendJsonResponse($json_response, 403); $this->sendJsonResponse($json_response, 403);
} }
$data = $this->post;
$slug = $data['slug'] ?? ''; $slug = $data['slug'] ?? '';
$package_name = $data['package_name'] ?? ''; $package_name = $data['package_name'] ?? '';
$current_version = $data['current_version'] ?? ''; $current_version = $data['current_version'] ?? '';