3 final class PhabricatorRepositoryIdentityAssignTransaction
4 extends PhabricatorRepositoryIdentityTransactionType
{
6 const TRANSACTIONTYPE
= 'repository:identity:assign';
8 public function generateOldValue($object) {
9 return nonempty($object->getManuallySetUserPHID(), null);
12 public function applyInternalEffects($object, $value) {
13 $object->setManuallySetUserPHID($value);
16 public function getTitle() {
17 $old = $this->getOldValue();
18 $new = $this->getNewValue();
22 '%s assigned this identity to %s.',
23 $this->renderAuthor(),
24 $this->renderIdentityHandle($new));
27 '%s removed %s as the assignee of this identity.',
28 $this->renderAuthor(),
29 $this->renderIdentityHandle($old));
32 '%s changed the assigned user for this identity from %s to %s.',
33 $this->renderAuthor(),
34 $this->renderIdentityHandle($old),
35 $this->renderIdentityHandle($new));
39 private function renderIdentityHandle($handle) {
40 $unassigned_token = DiffusionIdentityUnassignedDatasource
::FUNCTION_TOKEN
;
41 if ($handle === $unassigned_token) {
42 return phutil_tag('em', array(), pht('Explicitly Unassigned'));
44 return $this->renderHandle($handle);
48 public function validateTransactions($object, array $xactions) {
50 $unassigned_token = DiffusionIdentityUnassignedDatasource
::FUNCTION_TOKEN
;
52 foreach ($xactions as $xaction) {
53 $old = $xaction->getOldValue();
54 $new = $xaction->getNewValue();
63 if ($new === $unassigned_token) {
67 $assignee_list = id(new PhabricatorPeopleQuery())
68 ->setViewer($this->getActor())
69 ->withPHIDs(array($new))
72 if (!$assignee_list) {
73 $errors[] = $this->newInvalidError(
74 pht('User "%s" is not a valid user.',