From e88ca1fb0509fce7d9f2c54eabf4bfcb4e431f55 Mon Sep 17 00:00:00 2001 From: Shish Date: Fri, 26 Feb 2021 23:54:53 +0000 Subject: [PATCH] Nicer upload error messages --- ext/upload/main.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ext/upload/main.php b/ext/upload/main.php index f30b2a88..9c06e719 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -188,10 +188,12 @@ class Upload extends Extension if ($event->page_matches("upload/replace")) { if (!$user->can(Permissions::REPLACE_IMAGE)) { - throw new UploadException("You don't have permission to replace images"); + $this->theme->display_error(403, "Error", "You don't have permission to replace images"); + return; } if ($this->is_full) { - throw new UploadException("Can not replace Post: disk nearly full"); + $this->theme->display_error(507, "Error", "Can't replace images: disk nearly full"); + return; } // Try to get the image ID @@ -226,10 +228,12 @@ class Upload extends Extension } } elseif ($event->page_matches("upload")) { if (!$user->can(Permissions::CREATE_IMAGE)) { - throw new UploadException("You don't have permission to replace images"); + $this->theme->display_error(403, "Error", "You don't have permission to upload images"); + return; } if ($this->is_full) { - throw new UploadException("Can not replace Post: disk nearly full"); + $this->theme->display_error(507, "Error", "Can't upload images: disk nearly full"); + return; } /* Regular Upload Image */