mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +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,24 +31,29 @@ 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');
|
||||||
}
|
}
|
||||||
|
|
||||||
$xactions[] = id(new PhabricatorBadgesTransaction())
|
if (!$errors) {
|
||||||
->setTransactionType(
|
$xactions[] = id(new PhabricatorBadgesTransaction())
|
||||||
PhabricatorBadgesBadgeAwardTransaction::TRANSACTIONTYPE)
|
->setTransactionType(
|
||||||
->setNewValue($award_phids);
|
PhabricatorBadgesBadgeAwardTransaction::TRANSACTIONTYPE)
|
||||||
|
->setNewValue($award_phids);
|
||||||
|
|
||||||
$editor = id(new PhabricatorBadgesEditor())
|
$editor = id(new PhabricatorBadgesEditor())
|
||||||
->setActor($viewer)
|
->setActor($viewer)
|
||||||
->setContentSourceFromRequest($request)
|
->setContentSourceFromRequest($request)
|
||||||
->setContinueOnNoEffect(true)
|
->setContinueOnNoEffect(true)
|
||||||
->setContinueOnMissingFields(true)
|
->setContinueOnMissingFields(true)
|
||||||
->applyTransactions($badge, $xactions);
|
->applyTransactions($badge, $xactions);
|
||||||
|
|
||||||
return id(new AphrontRedirectResponse())
|
return id(new AphrontRedirectResponse())
|
||||||
->setURI($view_uri);
|
->setURI($view_uri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$form = new AphrontFormView();
|
$form = new AphrontFormView();
|
||||||
|
@ -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