Changeset View
Changeset View
Standalone View
Standalone View
src/applications/maniphest/editor/ManiphestTransactionEditor.php
Show First 20 Lines • Show All 742 Lines • ▼ Show 20 Lines | protected function validateTransaction( | ||||
} | } | ||||
return $errors; | return $errors; | ||||
} | } | ||||
protected function expandTransactions( | protected function expandTransactions( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
array $xactions) { | array $xactions) { | ||||
$actor = $this->getActor(); | |||||
$actor_phid = $actor->getPHID(); | |||||
$results = parent::expandTransactions($object, $xactions); | $results = parent::expandTransactions($object, $xactions); | ||||
$is_unassigned = ($object->getOwnerPHID() === null); | $is_unassigned = ($object->getOwnerPHID() === null); | ||||
$any_assign = false; | $any_assign = false; | ||||
foreach ($xactions as $xaction) { | foreach ($xactions as $xaction) { | ||||
if ($xaction->getTransactionType() == ManiphestTransaction::TYPE_OWNER) { | if ($xaction->getTransactionType() == ManiphestTransaction::TYPE_OWNER) { | ||||
$any_assign = true; | $any_assign = true; | ||||
Show All 17 Lines | protected function expandTransactions( | ||||
} else { | } else { | ||||
$is_closing = ManiphestTaskStatus::isClosedStatus($new_status); | $is_closing = ManiphestTaskStatus::isClosedStatus($new_status); | ||||
} | } | ||||
// If the task is not assigned, not being assigned, currently open, and | // If the task is not assigned, not being assigned, currently open, and | ||||
// being closed, try to assign the actor as the owner. | // being closed, try to assign the actor as the owner. | ||||
if ($is_unassigned && !$any_assign && $is_open && $is_closing) { | if ($is_unassigned && !$any_assign && $is_open && $is_closing) { | ||||
// Don't assign the actor if they aren't a real user. | // Don't assign the actor if they aren't a real user. | ||||
$actor = $this->getActor(); | |||||
$actor_phid = $actor->getPHID(); | |||||
if ($actor_phid) { | if ($actor_phid) { | ||||
$results[] = id(new ManiphestTransaction()) | $results[] = id(new ManiphestTransaction()) | ||||
->setTransactionType(ManiphestTransaction::TYPE_OWNER) | ->setTransactionType(ManiphestTransaction::TYPE_OWNER) | ||||
->setNewValue($actor_phid); | ->setNewValue($actor_phid); | ||||
} | } | ||||
} | } | ||||
// Automatically subscribe the author when they create a task. | |||||
if ($this->getIsNewObject()) { | |||||
if ($actor_phid) { | |||||
$results[] = id(new ManiphestTransaction()) | |||||
->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS) | |||||
->setNewValue( | |||||
array( | |||||
'+' => array($actor_phid => $actor_phid), | |||||
)); | |||||
} | |||||
} | |||||
return $results; | return $results; | ||||
} | } | ||||
protected function expandTransaction( | protected function expandTransaction( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
PhabricatorApplicationTransaction $xaction) { | PhabricatorApplicationTransaction $xaction) { | ||||
$results = parent::expandTransaction($object, $xaction); | $results = parent::expandTransaction($object, $xaction); | ||||
Show All 23 Lines |