Path: blob/master/src/applications/maniphest/xaction/ManiphestTaskStatusTransaction.php
12256 views
<?php12final class ManiphestTaskStatusTransaction3extends ManiphestTaskTransactionType {45const TRANSACTIONTYPE = 'status';67public function generateOldValue($object) {8return $object->getStatus();9}1011public function applyInternalEffects($object, $value) {12$this->updateStatus($object, $value);13}1415public function shouldHide() {16if ($this->getOldValue() === null) {17return true;18} else {19return false;20}21}2223public function getActionStrength() {24return 130;25}2627public function getActionName() {28$old = $this->getOldValue();29$new = $this->getNewValue();3031$action = ManiphestTaskStatus::getStatusActionName($new);32if ($action) {33return $action;34}3536$old_closed = ManiphestTaskStatus::isClosedStatus($old);37$new_closed = ManiphestTaskStatus::isClosedStatus($new);3839if ($new_closed && !$old_closed) {40return pht('Closed');41} else if (!$new_closed && $old_closed) {42return pht('Reopened');43} else {44return pht('Changed Status');45}46}4748public function getTitle() {49$old = $this->getOldValue();50$new = $this->getNewValue();5152$old_closed = ManiphestTaskStatus::isClosedStatus($old);53$new_closed = ManiphestTaskStatus::isClosedStatus($new);5455$old_name = ManiphestTaskStatus::getTaskStatusName($old);56$new_name = ManiphestTaskStatus::getTaskStatusName($new);5758$commit_phid = $this->getMetadataValue('commitPHID');5960if ($new_closed && !$old_closed) {61if ($new == ManiphestTaskStatus::getDuplicateStatus()) {62if ($commit_phid) {63return pht(64'%s closed this task as a duplicate by committing %s.',65$this->renderAuthor(),66$this->renderHandle($commit_phid));67} else {68return pht(69'%s closed this task as a duplicate.',70$this->renderAuthor());71}72} else {73if ($commit_phid) {74return pht(75'%s closed this task as %s by committing %s.',76$this->renderAuthor(),77$this->renderValue($new_name),78$this->renderHandle($commit_phid));79} else {80return pht(81'%s closed this task as %s.',82$this->renderAuthor(),83$this->renderValue($new_name));84}85}86} else if (!$new_closed && $old_closed) {87if ($commit_phid) {88return pht(89'%s reopened this task as %s by committing %s.',90$this->renderAuthor(),91$this->renderValue($new_name),92$this->renderHandle($commit_phid));93} else {94return pht(95'%s reopened this task as %s.',96$this->renderAuthor(),97$this->renderValue($new_name));98}99} else {100if ($commit_phid) {101return pht(102'%s changed the task status from %s to %s by committing %s.',103$this->renderAuthor(),104$this->renderValue($old_name),105$this->renderValue($new_name),106$this->renderHandle($commit_phid));107} else {108return pht(109'%s changed the task status from %s to %s.',110$this->renderAuthor(),111$this->renderValue($old_name),112$this->renderValue($new_name));113}114}115116}117118public function getTitleForFeed() {119$old = $this->getOldValue();120$new = $this->getNewValue();121122$old_closed = ManiphestTaskStatus::isClosedStatus($old);123$new_closed = ManiphestTaskStatus::isClosedStatus($new);124125$old_name = ManiphestTaskStatus::getTaskStatusName($old);126$new_name = ManiphestTaskStatus::getTaskStatusName($new);127128$commit_phid = $this->getMetadataValue('commitPHID');129130if ($new_closed && !$old_closed) {131if ($new == ManiphestTaskStatus::getDuplicateStatus()) {132if ($commit_phid) {133return pht(134'%s closed %s as a duplicate by committing %s.',135$this->renderAuthor(),136$this->renderObject(),137$this->renderHandle($commit_phid));138} else {139return pht(140'%s closed %s as a duplicate.',141$this->renderAuthor(),142$this->renderObject());143}144} else {145if ($commit_phid) {146return pht(147'%s closed %s as %s by committing %s.',148$this->renderAuthor(),149$this->renderObject(),150$this->renderValue($new_name),151$this->renderHandle($commit_phid));152} else {153return pht(154'%s closed %s as %s.',155$this->renderAuthor(),156$this->renderObject(),157$this->renderValue($new_name));158}159}160} else if (!$new_closed && $old_closed) {161if ($commit_phid) {162return pht(163'%s reopened %s as %s by committing %s.',164$this->renderAuthor(),165$this->renderObject(),166$this->renderValue($new_name),167$this->renderHandle($commit_phid));168} else {169return pht(170'%s reopened %s as "%s".',171$this->renderAuthor(),172$this->renderObject(),173$new_name);174}175} else {176if ($commit_phid) {177return pht(178'%s changed the status of %s from %s to %s by committing %s.',179$this->renderAuthor(),180$this->renderObject(),181$this->renderValue($old_name),182$this->renderValue($new_name),183$this->renderHandle($commit_phid));184} else {185return pht(186'%s changed the status of %s from %s to %s.',187$this->renderAuthor(),188$this->renderObject(),189$this->renderValue($old_name),190$this->renderValue($new_name));191}192}193}194195public function getIcon() {196$old = $this->getOldValue();197$new = $this->getNewValue();198199$action = ManiphestTaskStatus::getStatusIcon($new);200if ($action !== null) {201return $action;202}203204if (ManiphestTaskStatus::isClosedStatus($new)) {205return 'fa-check';206} else {207return 'fa-pencil';208}209}210211public function getColor() {212$old = $this->getOldValue();213$new = $this->getNewValue();214215$color = ManiphestTaskStatus::getStatusColor($new);216if ($color !== null) {217return $color;218}219220if (ManiphestTaskStatus::isOpenStatus($new)) {221return 'green';222} else {223return 'indigo';224}225226}227228public function getTransactionTypeForConduit($xaction) {229return 'status';230}231232public function getFieldValuesForConduit($xaction, $data) {233return array(234'old' => $xaction->getOldValue(),235'new' => $xaction->getNewValue(),236);237}238239}240241242