mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +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:
parent
f75b66b27a
commit
8793bdbaa8
1 changed files with 21 additions and 13 deletions
|
@ -7,6 +7,8 @@ final class PhabricatorBadgesEditRecipientsController
|
||||||
$viewer = $request->getViewer();
|
$viewer = $request->getViewer();
|
||||||
$id = $request->getURIData('id');
|
$id = $request->getURIData('id');
|
||||||
$xactions = array();
|
$xactions = array();
|
||||||
|
$errors = array();
|
||||||
|
$e_recipient = true;
|
||||||
|
|
||||||
$badge = id(new PhabricatorBadgesQuery())
|
$badge = id(new PhabricatorBadgesQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
|
@ -29,10 +31,14 @@ final class PhabricatorBadgesEditRecipientsController
|
||||||
$add_recipients = $request->getArr('phids');
|
$add_recipients = $request->getArr('phids');
|
||||||
if ($add_recipients) {
|
if ($add_recipients) {
|
||||||
foreach ($add_recipients as $phid) {
|
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())
|
$xactions[] = id(new PhabricatorBadgesTransaction())
|
||||||
->setTransactionType(
|
->setTransactionType(
|
||||||
PhabricatorBadgesBadgeAwardTransaction::TRANSACTIONTYPE)
|
PhabricatorBadgesBadgeAwardTransaction::TRANSACTIONTYPE)
|
||||||
|
@ -48,6 +54,7 @@ final class PhabricatorBadgesEditRecipientsController
|
||||||
return id(new AphrontRedirectResponse())
|
return id(new AphrontRedirectResponse())
|
||||||
->setURI($view_uri);
|
->setURI($view_uri);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$form = new AphrontFormView();
|
$form = new AphrontFormView();
|
||||||
$form
|
$form
|
||||||
|
@ -57,6 +64,7 @@ final class PhabricatorBadgesEditRecipientsController
|
||||||
id(new AphrontFormTokenizerControl())
|
id(new AphrontFormTokenizerControl())
|
||||||
->setName('phids')
|
->setName('phids')
|
||||||
->setLabel(pht('Recipients'))
|
->setLabel(pht('Recipients'))
|
||||||
|
->setError($e_recipient)
|
||||||
->setDatasource(new PhabricatorPeopleDatasource()));
|
->setDatasource(new PhabricatorPeopleDatasource()));
|
||||||
|
|
||||||
$dialog = id(new AphrontDialogView())
|
$dialog = id(new AphrontDialogView())
|
||||||
|
|
Loading…
Reference in a new issue