From 4a50d2f0e209fb852ed011149596a4af06fa856b Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Tue, 2 Aug 2016 17:48:07 +0200 Subject: [PATCH] Only avoid overwriting files (introduced in b15958115654d90cb185ac7b974d4dbe34a4b816) if avoid_overwriting is set on the field --- CHANGELOG.md | 2 +- classes/controller.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 314e509d..659542a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ * Fixed issue in `selfupgrade` where the package would get downloaded in the wrong destination * Hide tab when user is not authorized to access it [#712](https://github.com/getgrav/grav-plugin-admin/issues/712) * Fixed Lists issue when reindexing, causing Radio fields to potentially lose their `checked` status - * Avoid overwriting a file when uploaded with the same filename through the Admin blueprint `file` type + * Avoid overwriting a file when uploaded with the same filename through the Admin blueprint `file` field type if `avoid_overwriting` is enabled on the field # v1.1.2 ## 07/16/2016 diff --git a/classes/controller.php b/classes/controller.php index 1262531c..dbbda0c0 100644 --- a/classes/controller.php +++ b/classes/controller.php @@ -1351,8 +1351,10 @@ class AdminController Folder::mkdir($resolved_destination); } - if (file_exists("$resolved_destination/$name")) { - $name = date('YmdHis') . '-' . $name; + if (isset($field['avoid_overwriting']) && $field['avoid_overwriting'] === true) { + if (file_exists("$resolved_destination/$name")) { + $name = date('YmdHis') . '-' . $name; + } } if (move_uploaded_file($tmp_name, "$resolved_destination/$name")) {