Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/badges/controller/PhabricatorBadgesEditRecipientsController.php b/src/applications/badges/controller/PhabricatorBadgesEditRecipientsController.php
index 1706b0a644..f25fd93542 100644
--- a/src/applications/badges/controller/PhabricatorBadgesEditRecipientsController.php
+++ b/src/applications/badges/controller/PhabricatorBadgesEditRecipientsController.php
@@ -1,72 +1,80 @@
<?php
final class PhabricatorBadgesEditRecipientsController
extends PhabricatorBadgesController {
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$xactions = array();
+ $errors = array();
+ $e_recipient = true;
$badge = id(new PhabricatorBadgesQuery())
->setViewer($viewer)
->withIDs(array($id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_EDIT,
PhabricatorPolicyCapability::CAN_VIEW,
))
->executeOne();
if (!$badge) {
return new Aphront404Response();
}
$view_uri = $this->getApplicationURI('recipients/'.$badge->getID().'/');
if ($request->isFormPost()) {
$award_phids = array();
$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();
$form
->setUser($viewer)
->setFullWidth(true)
->appendControl(
id(new AphrontFormTokenizerControl())
->setName('phids')
->setLabel(pht('Recipients'))
+ ->setError($e_recipient)
->setDatasource(new PhabricatorPeopleDatasource()));
$dialog = id(new AphrontDialogView())
->setUser($viewer)
->setTitle(pht('Add Recipients'))
->appendForm($form)
->addCancelButton($view_uri)
->addSubmitButton(pht('Add Recipients'));
return $dialog;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Nov 25, 12:45 AM (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1110
Default Alt Text
(3 KB)

Event Timeline