Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2681490
D25740.1734643191.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
2 KB
Referenced Files
None
Subscribers
None
D25740.1734643191.diff
View Options
diff --git a/src/applications/badges/controller/PhabricatorBadgesEditRecipientsController.php b/src/applications/badges/controller/PhabricatorBadgesEditRecipientsController.php
--- a/src/applications/badges/controller/PhabricatorBadgesEditRecipientsController.php
+++ b/src/applications/badges/controller/PhabricatorBadgesEditRecipientsController.php
@@ -7,6 +7,8 @@
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$xactions = array();
+ $errors = array();
+ $e_recipient = true;
$badge = id(new PhabricatorBadgesQuery())
->setViewer($viewer)
@@ -29,24 +31,29 @@
$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');
}
- $xactions[] = id(new PhabricatorBadgesTransaction())
- ->setTransactionType(
- PhabricatorBadgesBadgeAwardTransaction::TRANSACTIONTYPE)
- ->setNewValue($award_phids);
+ if (!$errors) {
+ $xactions[] = id(new PhabricatorBadgesTransaction())
+ ->setTransactionType(
+ PhabricatorBadgesBadgeAwardTransaction::TRANSACTIONTYPE)
+ ->setNewValue($award_phids);
- $editor = id(new PhabricatorBadgesEditor())
- ->setActor($viewer)
- ->setContentSourceFromRequest($request)
- ->setContinueOnNoEffect(true)
- ->setContinueOnMissingFields(true)
- ->applyTransactions($badge, $xactions);
+ $editor = id(new PhabricatorBadgesEditor())
+ ->setActor($viewer)
+ ->setContentSourceFromRequest($request)
+ ->setContinueOnNoEffect(true)
+ ->setContinueOnMissingFields(true)
+ ->applyTransactions($badge, $xactions);
- return id(new AphrontRedirectResponse())
- ->setURI($view_uri);
+ return id(new AphrontRedirectResponse())
+ ->setURI($view_uri);
+ }
}
$form = new AphrontFormView();
@@ -57,6 +64,7 @@
id(new AphrontFormTokenizerControl())
->setName('phids')
->setLabel(pht('Recipients'))
+ ->setError($e_recipient)
->setDatasource(new PhabricatorPeopleDatasource()));
$dialog = id(new AphrontDialogView())
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 21:19 (2 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1015636
Default Alt Text
D25740.1734643191.diff (2 KB)
Attached To
Mode
D25740: Disallow awarding a badge without selecting recipient
Attached
Detach File
Event Timeline
Log In to Comment