Differential D17412 Diff 41873 src/applications/badges/xaction/PhabricatorBadgesBadgeRevokeTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/badges/xaction/PhabricatorBadgesBadgeRevokeTransaction.php
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | return pht( | ||||
new PhutilNumber(count($new)), | new PhutilNumber(count($new)), | ||||
$handles); | $handles); | ||||
} | } | ||||
public function getIcon() { | public function getIcon() { | ||||
return 'fa-user-times'; | return 'fa-user-times'; | ||||
} | } | ||||
public function validateTransactions($object, array $xactions) { | |||||
$errors = array(); | |||||
foreach ($xactions as $xaction) { | |||||
$award_phids = $xaction->getNewValue(); | |||||
if (!$award_phids) { | |||||
$errors[] = $this->newRequiredError( | |||||
pht('Recipient is required.')); | |||||
continue; | |||||
} | |||||
foreach ($award_phids as $award_phid) { | |||||
$award = id(new PhabricatorBadgesAwardQuery()) | |||||
->setViewer($this->getActor()) | |||||
->withRecipientPHIDs(array($award_phid)) | |||||
->withBadgePHIDs(array($object->getPHID())) | |||||
->executeOne(); | |||||
if (!$award) { | |||||
$errors[] = $this->newInvalidError( | |||||
pht( | |||||
'Recipient PHID "%s" has not been awarded.', | |||||
$award_phid)); | |||||
} | |||||
} | |||||
epriestley: Instead, maybe just validate that the recipient is currently awarded, but ignore their PHID… | |||||
} | |||||
return $errors; | |||||
} | |||||
} | } |
Instead, maybe just validate that the recipient is currently awarded, but ignore their PHID type? That's a little more future-proof, and I think we'll currently crash if you un-award a badge to a user who doesn't have it.