Path: blob/master/src/applications/maniphest/xaction/ManiphestTaskUnblockTransaction.php
12256 views
<?php12final class ManiphestTaskUnblockTransaction3extends ManiphestTaskTransactionType {45const TRANSACTIONTYPE = 'unblock';67public function generateOldValue($object) {8return null;9}1011public function getActionName() {12$old = $this->getOldValue();13$new = $this->getNewValue();1415$old_status = head($old);16$new_status = head($new);1718$old_closed = ManiphestTaskStatus::isClosedStatus($old_status);19$new_closed = ManiphestTaskStatus::isClosedStatus($new_status);2021if ($old_closed && !$new_closed) {22return pht('Block');23} else if (!$old_closed && $new_closed) {24return pht('Unblock');25} else {26return pht('Blocker');27}28}2930public function getTitle() {31$old = $this->getOldValue();32$new = $this->getNewValue();3334$blocker_phid = key($new);35$old_status = head($old);36$new_status = head($new);3738$old_closed = ManiphestTaskStatus::isClosedStatus($old_status);39$new_closed = ManiphestTaskStatus::isClosedStatus($new_status);4041$old_name = ManiphestTaskStatus::getTaskStatusName($old_status);42$new_name = ManiphestTaskStatus::getTaskStatusName($new_status);4344if ($this->getMetadataValue('blocker.new')) {45return pht(46'%s created subtask %s.',47$this->renderAuthor(),48$this->renderHandle($blocker_phid));49} else if ($old_closed && !$new_closed) {50return pht(51'%s reopened subtask %s as %s.',52$this->renderAuthor(),53$this->renderHandle($blocker_phid),54$this->renderValue($new_name));55} else if (!$old_closed && $new_closed) {56return pht(57'%s closed subtask %s as %s.',58$this->renderAuthor(),59$this->renderHandle($blocker_phid),60$this->renderValue($new_name));61} else {62return pht(63'%s changed the status of subtask %s from %s to %s.',64$this->renderAuthor(),65$this->renderHandle($blocker_phid),66$this->renderValue($old_name),67$this->renderValue($new_name));68}69}7071public function getTitleForFeed() {72$old = $this->getOldValue();73$new = $this->getNewValue();74$blocker_phid = key($new);75$old_status = head($old);76$new_status = head($new);7778$old_closed = ManiphestTaskStatus::isClosedStatus($old_status);79$new_closed = ManiphestTaskStatus::isClosedStatus($new_status);8081$old_name = ManiphestTaskStatus::getTaskStatusName($old_status);82$new_name = ManiphestTaskStatus::getTaskStatusName($new_status);8384if ($old_closed && !$new_closed) {85return pht(86'%s reopened %s, a subtask of %s, as %s.',87$this->renderAuthor(),88$this->renderHandle($blocker_phid),89$this->renderObject(),90$this->renderValue($new_name));91} else if (!$old_closed && $new_closed) {92return pht(93'%s closed %s, a subtask of %s, as %s.',94$this->renderAuthor(),95$this->renderHandle($blocker_phid),96$this->renderObject(),97$this->renderValue($new_name));98} else {99return pht(100'%s changed the status of %s, a subtask of %s, '.101'from %s to %s.',102$this->renderAuthor(),103$this->renderHandle($blocker_phid),104$this->renderObject(),105$this->renderValue($old_name),106$this->renderValue($new_name));107}108}109110public function getIcon() {111return 'fa-shield';112}113114public function shouldHideForFeed() {115// Hide "alice created X, a task blocking Y." from feed because it116// will almost always appear adjacent to "alice created Y".117$is_new = $this->getMetadataValue('blocker.new');118if ($is_new) {119return true;120}121122return parent::shouldHideForFeed();123}124125public function getRequiredCapabilities(126$object,127PhabricatorApplicationTransaction $xaction) {128129// When you close a task, we want to apply this transaction to its parents130// even if you can not edit (or even see) those parents, so don't require131// any capabilities. See PHI1059.132133return null;134}135}136137138