diff options
author | vincent-peugnet <v.peugnet@free.fr> | 2020-04-29 02:23:29 +0200 |
---|---|---|
committer | vincent-peugnet <v.peugnet@free.fr> | 2020-04-29 02:23:29 +0200 |
commit | 7370dee913a63a2f7d4bc09bd4e5605eac2eb382 (patch) | |
tree | 950a1fc6997daf4a3e3aae778ca3ed6f7f835ede /app | |
parent | 3075127e848150da8b8d19b45325460346c415c6 (diff) | |
download | wcms-7370dee913a63a2f7d4bc09bd4e5605eac2eb382.tar.gz wcms-7370dee913a63a2f7d4bc09bd4e5605eac2eb382.zip |
fix bookmark construction in user
fix colortag file creation
by fixing fn access media
Diffstat (limited to 'app')
-rw-r--r-- | app/class/Modelmedia.php | 4 | ||||
-rw-r--r-- | app/class/User.php | 10 | ||||
-rw-r--r-- | app/fn/fn.php | 3 | ||||
-rw-r--r-- | app/view/templates/media.php | 4 |
4 files changed, 13 insertions, 8 deletions
diff --git a/app/class/Modelmedia.php b/app/class/Modelmedia.php index 4da7707..89a2305 100644 --- a/app/class/Modelmedia.php +++ b/app/class/Modelmedia.php @@ -376,9 +376,13 @@ class Modelmedia extends Model { try { accessfile($oldname); + accessfile($newname); } catch (InvalidArgumentException $e) { throw new InvalidArgumentException($e->getMessage()); } + if (!file_exists($oldname)) { + throw new InvalidArgumentException("File : $oldname does not exist"); + } return rename($oldname, $newname); } } diff --git a/app/class/User.php b/app/class/User.php index efd89ae..e78c10c 100644 --- a/app/class/User.php +++ b/app/class/User.php @@ -202,9 +202,13 @@ class User extends Item if (is_array($bookmark)) { $bookmark = array_map( function ($datas) { - try { - return new Bookmark($datas); - } catch (RuntimeException $e) { + if (is_array($datas)) { + try { + return new Bookmark($datas); + } catch (RuntimeException $e) { + return false; + } + } else { return false; } }, diff --git a/app/fn/fn.php b/app/fn/fn.php index 461f129..103062a 100644 --- a/app/fn/fn.php +++ b/app/fn/fn.php @@ -425,9 +425,6 @@ function accessfile(string $path, bool $createdir = false): bool if (!is_writable($dir)) { throw new \InvalidArgumentException("Directory '$dir' is not writable."); } - if (!file_exists($path)) { - throw new \InvalidArgumentException("The file '$path' does not exist."); - } if (is_file($path) && !is_writable($path)) { throw new \InvalidArgumentException("The file '$path' is not writable."); } diff --git a/app/view/templates/media.php b/app/view/templates/media.php index d0caaf2..ea87fba 100644 --- a/app/view/templates/media.php +++ b/app/view/templates/media.php @@ -140,8 +140,8 @@ $this->layout('layout', ['title' => 'media', 'stylesheets' => [$css . 'home.css' <input type="hidden" name="path" value="<?= $media->path() ?>"> <input type="hidden" name="oldid" value="<?= $media->id() ?>"> <input type="hidden" name="oldextension" value="<?= $media->extension() ?>"> - <input type="text" name="newid" value="<?= $media->id() ?>" id="newid" maxlength="<?= Wcms\Model::MAX_ID_LENGTH ?>"> - <input type="text" name="newextension" value="<?= $media->extension() ?>" id="" style="width: 30px" maxlength="16"> + <input type="text" name="newid" value="<?= $media->id() ?>" id="newid" maxlength="<?= Wcms\Model::MAX_ID_LENGTH ?>" minlength="1" required> + <input type="text" name="newextension" value="<?= $media->extension() ?>" id="" style="width: 30px" maxlength="16" minlength="1" required> <input type="submit" value="rename"> </form> </details> |