Skip to content

Commit

Permalink
Allow to change status without commenting
Browse files Browse the repository at this point in the history
  • Loading branch information
partydragen committed Jul 2, 2021
1 parent a437aa4 commit a7b14e9
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions upload/modules/Suggestions/pages/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'))) {
Expand All @@ -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 {
Expand Down

0 comments on commit a7b14e9

Please sign in to comment.