mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Do not allow empty comments
Fixes FS#45870. Signed-off-by: Marcel Korpel <marcel.korpel@gmail.com> Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
parent
60433a930d
commit
095986b449
2 changed files with 11 additions and 2 deletions
|
@ -107,8 +107,7 @@ if (check_token()) {
|
||||||
list($ret, $output) = pkgbase_set_comaintainers($base_id, explode("\n", $_POST['users']));
|
list($ret, $output) = pkgbase_set_comaintainers($base_id, explode("\n", $_POST['users']));
|
||||||
} elseif (current_action("do_AddComment")) {
|
} elseif (current_action("do_AddComment")) {
|
||||||
$uid = uid_from_sid($_COOKIE["AURSID"]);
|
$uid = uid_from_sid($_COOKIE["AURSID"]);
|
||||||
pkgbase_add_comment($base_id, $uid, $_REQUEST['comment']);
|
list($ret, $output) = pkgbase_add_comment($base_id, $uid, $_REQUEST['comment']);
|
||||||
$ret = true;
|
|
||||||
$fragment = '#news';
|
$fragment = '#news';
|
||||||
} elseif (current_action("do_EditComment")) {
|
} elseif (current_action("do_EditComment")) {
|
||||||
list($ret, $output) = pkgbase_edit_comment($_REQUEST['comment']);
|
list($ret, $output) = pkgbase_edit_comment($_REQUEST['comment']);
|
||||||
|
|
|
@ -81,6 +81,10 @@ function pkgbase_comments($base_id, $limit, $include_deleted) {
|
||||||
function pkgbase_add_comment($base_id, $uid, $comment) {
|
function pkgbase_add_comment($base_id, $uid, $comment) {
|
||||||
$dbh = DB::connect();
|
$dbh = DB::connect();
|
||||||
|
|
||||||
|
if (trim($comment) == '') {
|
||||||
|
return array(false, __('Comment cannot be empty.'));
|
||||||
|
}
|
||||||
|
|
||||||
$q = "INSERT INTO PackageComments ";
|
$q = "INSERT INTO PackageComments ";
|
||||||
$q.= "(PackageBaseID, UsersID, Comments, CommentTS) VALUES (";
|
$q.= "(PackageBaseID, UsersID, Comments, CommentTS) VALUES (";
|
||||||
$q.= intval($base_id) . ", " . $uid . ", ";
|
$q.= intval($base_id) . ", " . $uid . ", ";
|
||||||
|
@ -102,6 +106,8 @@ function pkgbase_add_comment($base_id, $uid, $comment) {
|
||||||
if ($result) {
|
if ($result) {
|
||||||
notify(array('comment', $uid, $base_id), $comment);
|
notify(array('comment', $uid, $base_id), $comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return array(true, __('Comment has been added.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -860,6 +866,10 @@ function pkgbase_edit_comment($comment) {
|
||||||
return array(false, __("Missing comment ID."));
|
return array(false, __("Missing comment ID."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (trim($comment) == '') {
|
||||||
|
return array(false, __('Comment cannot be empty.'));
|
||||||
|
}
|
||||||
|
|
||||||
$dbh = DB::connect();
|
$dbh = DB::connect();
|
||||||
if (can_edit_comment($comment_id)) {
|
if (can_edit_comment($comment_id)) {
|
||||||
$q = "UPDATE PackageComments ";
|
$q = "UPDATE PackageComments ";
|
||||||
|
|
Loading…
Add table
Reference in a new issue