From 27062ddfa045d8b0a2fcf75326363108ad640f7b Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Fri, 14 Apr 2017 08:07:11 +1000 Subject: [PATCH] Fixes folder creation and rename in asset list --- modules/cms/widgets/AssetList.php | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/modules/cms/widgets/AssetList.php b/modules/cms/widgets/AssetList.php index 73dd02f94..03ab0581c 100644 --- a/modules/cms/widgets/AssetList.php +++ b/modules/cms/widgets/AssetList.php @@ -221,13 +221,6 @@ class AssetList extends WidgetBase throw new ApplicationException(Lang::get('cms::lang.asset.invalid_name')); } - if (!$this->validateFileType($newName)) { - throw new ApplicationException(Lang::get( - 'cms::lang.asset.type_not_allowed', - ['allowed_types' => implode(', ', $this->assetExtensions)] - )); - } - $originalPath = Input::get('originalPath'); if (!$this->validatePath($originalPath)) { throw new ApplicationException(Lang::get('cms::lang.asset.invalid_path')); @@ -238,6 +231,13 @@ class AssetList extends WidgetBase throw new ApplicationException(Lang::get('cms::lang.asset.original_not_found')); } + if (!is_dir($originalFullPath) && !$this->validateFileType($newName)) { + throw new ApplicationException(Lang::get( + 'cms::lang.asset.type_not_allowed', + ['allowed_types' => implode(', ', $this->assetExtensions)] + )); + } + $newFullPath = $this->getFullPath(dirname($originalPath).'/'.$newName); if (file_exists($newFullPath) && $newFullPath !== $originalFullPath) { throw new ApplicationException(Lang::get('cms::lang.asset.already_exists')); @@ -276,13 +276,6 @@ class AssetList extends WidgetBase throw new ApplicationException(Lang::get('cms::lang.asset.invalid_name')); } - if (!$this->validateFileType($newName)) { - throw new ApplicationException(Lang::get( - 'cms::lang.asset.type_not_allowed', - ['allowed_types' => implode(', ', $this->assetExtensions)] - )); - } - $newFullPath = $this->getCurrentPath().'/'.$newName; if (file_exists($newFullPath)) { throw new ApplicationException(Lang::get('cms::lang.asset.already_exists'));