Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/badges/controller/PhabricatorBadgesAwardController.php b/src/applications/badges/controller/PhabricatorBadgesAwardController.php
index 63af70b791..1a31584a51 100644
--- a/src/applications/badges/controller/PhabricatorBadgesAwardController.php
+++ b/src/applications/badges/controller/PhabricatorBadgesAwardController.php
@@ -1,77 +1,84 @@
<?php
final class PhabricatorBadgesAwardController
extends PhabricatorBadgesController {
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
+ $errors = array();
+ $e_badge = true;
$user = id(new PhabricatorPeopleQuery())
->setViewer($viewer)
->withIDs(array($id))
->executeOne();
if (!$user) {
return new Aphront404Response();
}
$view_uri = '/people/badges/'.$user->getID().'/';
if ($request->isFormPost()) {
$badge_phids = $request->getArr('badgePHIDs');
- $badges = id(new PhabricatorBadgesQuery())
- ->setViewer($viewer)
- ->withPHIDs($badge_phids)
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_EDIT,
- PhabricatorPolicyCapability::CAN_VIEW,
- ))
- ->execute();
- if (!$badges) {
- return new Aphront404Response();
+
+ if (empty($badge_phids)) {
+ $errors[] = pht('Badge name is required.');
+ $e_badge = pht('Required');
}
- $award_phids = array($user->getPHID());
+ if (!$errors) {
+ $badges = id(new PhabricatorBadgesQuery())
+ ->setViewer($viewer)
+ ->withPHIDs($badge_phids)
+ ->requireCapabilities(
+ array(
+ PhabricatorPolicyCapability::CAN_EDIT,
+ PhabricatorPolicyCapability::CAN_VIEW,
+ ))
+ ->execute();
+ $award_phids = array($user->getPHID());
- foreach ($badges as $badge) {
- $xactions = array();
- $xactions[] = id(new PhabricatorBadgesTransaction())
- ->setTransactionType(
- PhabricatorBadgesBadgeAwardTransaction::TRANSACTIONTYPE)
- ->setNewValue($award_phids);
+ foreach ($badges as $badge) {
+ $xactions = array();
+ $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 = id(new AphrontFormView())
->setUser($viewer)
->appendControl(
id(new AphrontFormTokenizerControl())
->setLabel(pht('Badge'))
->setName('badgePHIDs')
+ ->setError($e_badge)
->setDatasource(
id(new PhabricatorBadgesDatasource())
->setParameters(
array(
'recipientPHID' => $user->getPHID(),
))));
$dialog = $this->newDialog()
->setTitle(pht('Award Badge'))
->appendForm($form)
->addCancelButton($view_uri)
->addSubmitButton(pht('Award'));
return $dialog;
}
}

File Metadata

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

Event Timeline