Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2685277
D25636.1734701860.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
3 KB
Referenced Files
None
Subscribers
None
D25636.1734701860.diff
View Options
diff --git a/src/applications/badges/controller/PhabricatorBadgesAwardController.php b/src/applications/badges/controller/PhabricatorBadgesAwardController.php
--- a/src/applications/badges/controller/PhabricatorBadgesAwardController.php
+++ b/src/applications/badges/controller/PhabricatorBadgesAwardController.php
@@ -6,6 +6,8 @@
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
+ $errors = array();
+ $e_badge = true;
$user = id(new PhabricatorPeopleQuery())
->setViewer($viewer)
@@ -19,37 +21,41 @@
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())
@@ -58,6 +64,7 @@
id(new AphrontFormTokenizerControl())
->setLabel(pht('Badge'))
->setName('badgePHIDs')
+ ->setError($e_badge)
->setDatasource(
id(new PhabricatorBadgesDatasource())
->setParameters(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 20, 13:37 (8 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1016378
Default Alt Text
D25636.1734701860.diff (3 KB)
Attached To
Mode
D25636: Fix exception awarding empty badge to user
Attached
Detach File
Event Timeline
Log In to Comment