From 5b2770aa34f0fb329492311080c101c03c493fb3 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Thu, 5 Aug 2021 17:08:55 +0200 Subject: Simplify the insert/update HTTP-POST params check Simplify the HTTP-POST parameter presence check in the administration controllers for creating and modifying entities. Since we already use fallback values for each attribute, we don't need a full param check. --- admin/category/insert.php | 2 +- admin/category/update.php | 2 +- admin/page/insert.php | 2 +- admin/page/update.php | 2 +- admin/post/insert.php | 2 +- admin/post/update.php | 2 +- admin/user/insert.php | 2 +- admin/user/update.php | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) (limited to 'admin') diff --git a/admin/category/insert.php b/admin/category/insert.php index f6f193e..773bb29 100644 --- a/admin/category/insert.php +++ b/admin/category/insert.php @@ -23,7 +23,7 @@ $Category = new ORM\Entities\Category; #=============================================================================== # Check for insert request #=============================================================================== -if(HTTP::issetPOST('parent', 'slug', 'name', 'body', 'argv', 'time_insert', 'time_update', 'insert')) { +if(HTTP::issetPOST('insert')) { $Category->set('parent', HTTP::POST('parent') ?: NULL); $Category->set('slug', HTTP::POST('slug') ?: generateSlug(HTTP::POST('name'))); $Category->set('name', HTTP::POST('name') ?: NULL); diff --git a/admin/category/update.php b/admin/category/update.php index 7cee587..4791d79 100644 --- a/admin/category/update.php +++ b/admin/category/update.php @@ -25,7 +25,7 @@ if(!$Category = $CategoryRepository->find(HTTP::GET('id'))) { #=============================================================================== # Check for update request #=============================================================================== -if(HTTP::issetPOST('parent', 'slug', 'name', 'body', 'argv', 'time_insert', 'time_update', 'update')) { +if(HTTP::issetPOST('update')) { $Category->set('slug', HTTP::POST('slug') ?: generateSlug(HTTP::POST('name'))); $Category->set('name', HTTP::POST('name') ?: NULL); $Category->set('body', HTTP::POST('body') ?: NULL); diff --git a/admin/page/insert.php b/admin/page/insert.php index 76e9fb4..c1d9e5d 100644 --- a/admin/page/insert.php +++ b/admin/page/insert.php @@ -24,7 +24,7 @@ $Page = new ORM\Entities\Page; #=============================================================================== # Check for insert request #=============================================================================== -if(HTTP::issetPOST('user', 'slug', 'name', 'body', 'argv', 'time_insert', 'time_update', 'insert')) { +if(HTTP::issetPOST('insert')) { $Page->set('user', HTTP::POST('user')); $Page->set('slug', HTTP::POST('slug') ?: generateSlug(HTTP::POST('name'))); $Page->set('name', HTTP::POST('name') ?: NULL); diff --git a/admin/page/update.php b/admin/page/update.php index 2ea5156..5ec5f73 100644 --- a/admin/page/update.php +++ b/admin/page/update.php @@ -26,7 +26,7 @@ if(!$Page = $PageRepository->find(HTTP::GET('id'))) { #=============================================================================== # Check for update request #=============================================================================== -if(HTTP::issetPOST('user', 'slug', 'name', 'body', 'argv', 'time_insert', 'time_update', 'update')) { +if(HTTP::issetPOST('update')) { $Page->set('user', HTTP::POST('user')); $Page->set('slug', HTTP::POST('slug') ?: generateSlug(HTTP::POST('name'))); $Page->set('name', HTTP::POST('name') ?: NULL); diff --git a/admin/post/insert.php b/admin/post/insert.php index bad55ae..1a8cac7 100644 --- a/admin/post/insert.php +++ b/admin/post/insert.php @@ -25,7 +25,7 @@ $Post = new ORM\Entities\Post; #=============================================================================== # Check for insert request #=============================================================================== -if(HTTP::issetPOST('category', 'user', 'slug', 'name', 'body', 'argv', 'time_insert', 'time_update', 'insert')) { +if(HTTP::issetPOST('insert')) { $Post->set('category', HTTP::POST('category') ?: NULL); $Post->set('user', HTTP::POST('user')); $Post->set('slug', HTTP::POST('slug') ?: generateSlug(HTTP::POST('name'))); diff --git a/admin/post/update.php b/admin/post/update.php index e68b3ec..b35c379 100644 --- a/admin/post/update.php +++ b/admin/post/update.php @@ -27,7 +27,7 @@ if(!$Post = $PostRepository->find(HTTP::GET('id'))) { #=============================================================================== # Check for update request #=============================================================================== -if(HTTP::issetPOST('category', 'user', 'slug', 'name', 'body', 'argv', 'time_insert', 'time_update', 'update')) { +if(HTTP::issetPOST('update')) { $Post->set('category', HTTP::POST('category') ?: NULL); $Post->set('user', HTTP::POST('user')); $Post->set('slug', HTTP::POST('slug') ?: generateSlug(HTTP::POST('name'))); diff --git a/admin/user/insert.php b/admin/user/insert.php index 2d9e09f..48cbf65 100644 --- a/admin/user/insert.php +++ b/admin/user/insert.php @@ -23,7 +23,7 @@ $User = new ORM\Entities\User; #=============================================================================== # Check for insert request #=============================================================================== -if(HTTP::issetPOST('slug', 'username', 'password', 'fullname', 'mailaddr', 'body', 'argv', 'time_insert', 'time_update', 'insert')) { +if(HTTP::issetPOST('insert')) { $User->set('slug', HTTP::POST('slug') ?: generateSlug(HTTP::POST('username'))); $User->set('username', HTTP::POST('username') ?: NULL); $User->set('password', HTTP::POST('password') ? password_hash(HTTP::POST('password'), PASSWORD_BCRYPT, ['cost' => 10]) : FALSE); diff --git a/admin/user/update.php b/admin/user/update.php index bff21b3..78685d7 100644 --- a/admin/user/update.php +++ b/admin/user/update.php @@ -25,7 +25,7 @@ if(!$User = $UserRepository->find(HTTP::GET('id'))) { #=============================================================================== # Check for update request #=============================================================================== -if(HTTP::issetPOST('slug', 'username', 'password', 'fullname', 'mailaddr', 'body', 'argv', 'time_insert', 'time_update', 'update')) { +if(HTTP::issetPOST('update')) { $User->set('slug', HTTP::POST('slug') ?: generateSlug(HTTP::POST('username'))); $User->set('username', HTTP::POST('username') ?: NULL); $User->set('password', HTTP::POST('password') ? password_hash(HTTP::POST('password'), PASSWORD_BCRYPT, ['cost' => 10]) : FALSE); -- cgit v1.2.3