# Conflicts:
#	CHANGELOG.md
#	classes/adminbasecontroller.php
#	themes/grav/js/admin.min.js
This commit is contained in:
Matias Griese
2019-01-08 11:36:20 +02:00
3 changed files with 34 additions and 8 deletions

View File

@@ -5,6 +5,7 @@
* Unset state from user if not super or user admin * Unset state from user if not super or user admin
* Make new System Config layout responsive [#1579](https://github.com/getgrav/grav-plugin-admin/issues/1579) * Make new System Config layout responsive [#1579](https://github.com/getgrav/grav-plugin-admin/issues/1579)
* Take admin setting for 2FA into account when showing user 2FA badge [#1568](https://github.com/getgrav/grav-plugin-admin/issues/1568) * Take admin setting for 2FA into account when showing user 2FA badge [#1568](https://github.com/getgrav/grav-plugin-admin/issues/1568)
* v.1.8.16 fixes merged in
1. [](#bugfix) 1. [](#bugfix)
* Removed `tabs`, `tab`, and `toggle` fields as they are now in Form plugin * Removed `tabs`, `tab`, and `toggle` fields as they are now in Form plugin
@@ -68,6 +69,13 @@
* New `Backups` configuration panel in tools * New `Backups` configuration panel in tools
* New `Cache::purge()` option in cache drop-down to clear out old cache only * New `Cache::purge()` option in cache drop-down to clear out old cache only
# v1.8.16
## mm/dd/2019
1. [](#bugfix)
* Fixed calendar js module not properly loading for datetime field [#1581](https://github.com/getgrav/grav-plugin-admin/issues/1581)
* Fixed deleting file when using file field type [#1558](https://github.com/getgrav/grav-plugin-admin/issues/1558)
# v1.8.15 # v1.8.15
## 12/14/2018 ## 12/14/2018
@@ -107,7 +115,7 @@
1. [](#improved) 1. [](#improved)
* Change usage of basename where possible [#1480](https://github.com/getgrav/grav-plugin-admin/pull/1480) * Change usage of basename where possible [#1480](https://github.com/getgrav/grav-plugin-admin/pull/1480)
* Improved filename validation (requires Grav 1.5.3) * Improved filename validation (requires Grav 1.5.3)
* Updated various lang strings * Updated various lang codes
1. [](#bugfix) 1. [](#bugfix)
* File Uploads: Do not trust mimetype sent by the browser * File Uploads: Do not trust mimetype sent by the browser
* Fixed file extension detection * Fixed file extension detection

View File

@@ -1403,9 +1403,9 @@ class Admin
return $found_fields; return $found_fields;
} }
public function getPagePathFromToken($path) public function getPagePathFromToken($path, $page = null)
{ {
return Utils::getPagePathFromToken($path, $this->page(true)); return Utils::getPagePathFromToken($path, $page ?: $this->page(true));
} }
/** /**

View File

@@ -6,6 +6,7 @@ use Grav\Common\Filesystem\Folder;
use Grav\Common\Grav; use Grav\Common\Grav;
use Grav\Common\Media\Interfaces\MediaInterface; use Grav\Common\Media\Interfaces\MediaInterface;
use Grav\Common\Page\Media; use Grav\Common\Page\Media;
use Grav\Common\Uri;
use Grav\Common\Utils; use Grav\Common\Utils;
use Grav\Common\Plugin; use Grav\Common\Plugin;
use Grav\Common\Theme; use Grav\Common\Theme;
@@ -902,22 +903,40 @@ class AdminBaseController
*/ */
protected function taskRemoveFileFromBlueprint() protected function taskRemoveFileFromBlueprint()
{ {
/** @var Uri $uri */
$uri = $this->grav['uri']; $uri = $this->grav['uri'];
$blueprint = base64_decode($uri->param('blueprint')); $blueprint = base64_decode($uri->param('blueprint'));
$path = base64_decode($uri->param('path')); $path = base64_decode($uri->param('path'));
$filename = basename(isset($this->post['filename']) ? $this->post['filename'] : $path);
$proute = base64_decode($uri->param('proute')); $proute = base64_decode($uri->param('proute'));
$type = $uri->param('type'); $type = $uri->param('type');
$field = $uri->param('field'); $field = $uri->param('field');
// Get Blueprint // Get Blueprint
$settings = (object) $this->admin->blueprints($blueprint)->schema()->getProperty($field); if ($type === 'pages' || strpos($blueprint, 'pages/') === 0) {
$page = $this->admin->page(true, $proute);
if (!$page) {
$this->admin->json_response = [
'status' => 'error',
'message' => 'Page not found'
];
return false;
}
$blueprints = $page->blueprints();
$path = Folder::getRelativePath($page->path());
$settings = (object)$blueprints->schema()->getProperty($field);
} else {
$page = null;
$settings = (object)$this->admin->blueprints($blueprint)->schema()->getProperty($field);
}
// Get destination // Get destination
if ($this->grav['locator']->isStream($settings->destination)) { if ($this->grav['locator']->isStream($settings->destination)) {
$destination = $this->grav['locator']->findResource($settings->destination, false, true); $destination = $this->grav['locator']->findResource($settings->destination, false, true);
} else { } else {
$destination = Folder::getRelativePath(rtrim($settings->destination, '/')); $destination = Folder::getRelativePath(rtrim($settings->destination, '/'));
$destination = $this->admin->getPagePathFromToken($destination); $destination = $this->admin->getPagePathFromToken($destination, $page);
} }
// Not in path // Not in path
@@ -931,10 +950,9 @@ class AdminBaseController
} }
// Only remove files from correct destination... // Only remove files from correct destination...
$this->taskRemoveMedia($destination . '/' . basename($path)); $this->taskRemoveMedia($destination . '/' . $filename);
if ($type === 'pages') { if ($page) {
$page = $this->admin->page(true, $proute);
$keys = explode('.', preg_replace('/^header./', '', $field)); $keys = explode('.', preg_replace('/^header./', '', $field));
$header = (array)$page->header(); $header = (array)$page->header();
$data_path = implode('.', $keys); $data_path = implode('.', $keys);