Path: blob/master/src/applications/maniphest/xaction/ManiphestTaskOwnerTransaction.php
12256 views
<?php12final class ManiphestTaskOwnerTransaction3extends ManiphestTaskTransactionType {45const TRANSACTIONTYPE = 'reassign';67public function generateOldValue($object) {8return nonempty($object->getOwnerPHID(), null);9}1011public function applyInternalEffects($object, $value) {12// Update the "ownerOrdering" column to contain the full name of the13// owner, if the task is assigned.1415$handle = null;16if ($value) {17$handle = id(new PhabricatorHandleQuery())18->setViewer($this->getActor())19->withPHIDs(array($value))20->executeOne();21}2223if ($handle) {24$object->setOwnerOrdering($handle->getName());25} else {26$object->setOwnerOrdering(null);27}2829$object->setOwnerPHID($value);30}3132public function getActionStrength() {33return 120;34}3536public function getActionName() {37$old = $this->getOldValue();38$new = $this->getNewValue();3940if ($this->getAuthorPHID() == $new) {41return pht('Claimed');42} else if (!$new) {43return pht('Unassigned');44} else if (!$old) {45return pht('Assigned');46} else {47return pht('Reassigned');48}49}5051public function getTitle() {52$old = $this->getOldValue();53$new = $this->getNewValue();5455if ($this->getAuthorPHID() == $new) {56return pht(57'%s claimed this task.',58$this->renderAuthor());59} else if (!$new) {60return pht(61'%s removed %s as the assignee of this task.',62$this->renderAuthor(),63$this->renderHandle($old));64} else if (!$old) {65return pht(66'%s assigned this task to %s.',67$this->renderAuthor(),68$this->renderHandle($new));69} else {70return pht(71'%s reassigned this task from %s to %s.',72$this->renderAuthor(),73$this->renderHandle($old),74$this->renderHandle($new));75}76}7778public function getTitleForFeed() {79$old = $this->getOldValue();80$new = $this->getNewValue();8182if ($this->getAuthorPHID() == $new) {83return pht(84'%s claimed %s.',85$this->renderAuthor(),86$this->renderObject());87} else if (!$new) {88return pht(89'%s placed %s up for grabs.',90$this->renderAuthor(),91$this->renderObject());92} else if (!$old) {93return pht(94'%s assigned %s to %s.',95$this->renderAuthor(),96$this->renderObject(),97$this->renderHandle($new));98} else {99return pht(100'%s reassigned %s from %s to %s.',101$this->renderAuthor(),102$this->renderObject(),103$this->renderHandle($old),104$this->renderHandle($new));105}106}107108public function validateTransactions($object, array $xactions) {109$errors = array();110111foreach ($xactions as $xaction) {112$old = $xaction->getOldValue();113$new = $xaction->getNewValue();114115if (!phutil_nonempty_string($new)) {116continue;117}118119if ($new === $old) {120continue;121}122123$assignee_list = id(new PhabricatorPeopleQuery())124->setViewer($this->getActor())125->withPHIDs(array($new))126->execute();127128if (!$assignee_list) {129$errors[] = $this->newInvalidError(130pht('User "%s" is not a valid user.', $new));131}132}133return $errors;134}135136public function getIcon() {137return 'fa-user';138}139140public function getColor() {141$old = $this->getOldValue();142$new = $this->getNewValue();143144if ($this->getAuthorPHID() == $new) {145return 'green';146} else if (!$new) {147return 'black';148} else if (!$old) {149return 'green';150} else {151return 'green';152}153154}155156public function getTransactionTypeForConduit($xaction) {157return 'owner';158}159160public function getFieldValuesForConduit($xaction, $data) {161return array(162'old' => $xaction->getOldValue(),163'new' => $xaction->getNewValue(),164);165}166167}168169170