1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 06:42:42 +01:00

Disallow awarding a badge without selecting recipient

Summary:
Do not continue on missing fields (in this case: the badge recipient) in `PhabricatorBadgesEditRecipientsController`.

Closes T15827

Test Plan: See steps in T15827.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15827

Differential Revision: https://we.phorge.it/D25740
This commit is contained in:
Andre Klapper 2024-07-23 00:08:18 +02:00
parent f75b66b27a
commit 8793bdbaa8

View file

@ -7,6 +7,8 @@ final class PhabricatorBadgesEditRecipientsController
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$xactions = array();
$errors = array();
$e_recipient = true;
$badge = id(new PhabricatorBadgesQuery())
->setViewer($viewer)
@ -29,10 +31,14 @@ final class PhabricatorBadgesEditRecipientsController
$add_recipients = $request->getArr('phids');
if ($add_recipients) {
foreach ($add_recipients as $phid) {
$award_phids[] = $phid;
$award_phids[$phid] = $phid;
}
} else {
$errors[] = pht('Recipient name is required.');
$e_recipient = pht('Required');
}
if (!$errors) {
$xactions[] = id(new PhabricatorBadgesTransaction())
->setTransactionType(
PhabricatorBadgesBadgeAwardTransaction::TRANSACTIONTYPE)
@ -48,6 +54,7 @@ final class PhabricatorBadgesEditRecipientsController
return id(new AphrontRedirectResponse())
->setURI($view_uri);
}
}
$form = new AphrontFormView();
$form
@ -57,6 +64,7 @@ final class PhabricatorBadgesEditRecipientsController
id(new AphrontFormTokenizerControl())
->setName('phids')
->setLabel(pht('Recipients'))
->setError($e_recipient)
->setDatasource(new PhabricatorPeopleDatasource()));
$dialog = id(new AphrontDialogView())