From a7b14e9f836a34c62a7b0c8d8c94db966afbda00 Mon Sep 17 00:00:00 2001 From: Partydragen Date: Fri, 2 Jul 2021 20:09:12 +0200 Subject: [PATCH] Allow to change status without commenting --- upload/modules/Suggestions/pages/view.php | 50 +++++++++++++---------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/upload/modules/Suggestions/pages/view.php b/upload/modules/Suggestions/pages/view.php index f813a64..5eb0de3 100644 --- a/upload/modules/Suggestions/pages/view.php +++ b/upload/modules/Suggestions/pages/view.php @@ -106,34 +106,37 @@ $validation = $validate->check($_POST, array( 'content' => array( - 'required' => true, 'min' => 3, 'max' => 10000 ) )); if($validation->passed()){ - $queries->create('suggestions_comments', array( - 'suggestion_id' => $suggestion->id, - 'user_id' => $user->data()->id, - 'created' => date('U'), - 'content' => Output::getClean(nl2br(Input::get('content'))) - )); + $discordAlert = array(); + if(!empty(Input::get('content'))) { + // New comment + $queries->create('suggestions_comments', array( + 'suggestion_id' => $suggestion->id, + 'user_id' => $user->data()->id, + 'created' => date('U'), + 'content' => Output::getClean(nl2br(Input::get('content'))) + )); - $queries->update('suggestions', $suggestion->id, array( - 'updated_by' => $user->data()->id, - 'last_updated' => date('U') - )); - - $discordAlert = array( - 'event' => 'newSuggestionComment', - 'username' => $user->getDisplayname(), - 'content' => str_replace(array('{x}', '{y}', '{z}'), array($user->getDisplayname(), Output::getClean($suggestion->likes), Output::getClean($suggestion->dislikes)), $suggestions_language->get('general', 'hook_new_comment')), - 'content_full' => str_replace(' ', '', strip_tags(htmlspecialchars_decode(Input::get('content')))), - 'avatar_url' => $user->getAvatar(null, 128, true), - 'title' => Output::getClean('#' . $suggestion->id . ' - ' . $suggestion->title), - 'url' => rtrim(Util::getSelfURL(), '/') . URL::build('/suggestions/view/' . $suggestion->id . '-' . Util::stringToURL(Output::getClean($suggestion->title))) - ); + $queries->update('suggestions', $suggestion->id, array( + 'updated_by' => $user->data()->id, + 'last_updated' => date('U') + )); + + $discordAlert = array( + 'event' => 'newSuggestionComment', + 'username' => $user->getDisplayname(), + 'content' => str_replace(array('{x}', '{y}', '{z}'), array($user->getDisplayname(), Output::getClean($suggestion->likes), Output::getClean($suggestion->dislikes)), $suggestions_language->get('general', 'hook_new_comment')), + 'content_full' => str_replace(' ', '', strip_tags(htmlspecialchars_decode(Input::get('content')))), + 'avatar_url' => $user->getAvatar(null, 128, true), + 'title' => Output::getClean('#' . $suggestion->id . ' - ' . $suggestion->title), + 'url' => rtrim(Util::getSelfURL(), '/') . URL::build('/suggestions/view/' . $suggestion->id . '-' . Util::stringToURL(Output::getClean($suggestion->title))) + ); + } if($user->canViewStaffCP()){ if($suggestion->status_id != htmlspecialchars(Input::get('status'))) { @@ -159,7 +162,10 @@ } } - HookHandler::executeEvent('newSuggestionComment', $discordAlert); + if(!empty(Input::get('content'))) { + HookHandler::executeEvent('newSuggestionComment', $discordAlert); + } + Redirect::to(URL::build('/suggestions/view/' . $suggestion->id . '-' . Util::stringToURL($suggestion->title))); die(); } else {