Changeset View
Changeset View
Standalone View
Standalone View
src/applications/maniphest/editor/ManiphestTransactionEditor.php
Show First 20 Lines • Show All 321 Lines • ▼ Show 20 Lines | protected function expandTransactions( | ||||
$actor = $this->getActor(); | $actor = $this->getActor(); | ||||
$actor_phid = $actor->getPHID(); | $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_xassign = null; | ||||
foreach ($xactions as $xaction) { | foreach ($xactions as $xaction) { | ||||
if ($xaction->getTransactionType() == | if ($xaction->getTransactionType() == | ||||
ManiphestTaskOwnerTransaction::TRANSACTIONTYPE) { | ManiphestTaskOwnerTransaction::TRANSACTIONTYPE) { | ||||
$any_assign = true; | $any_xassign = $xaction; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
$is_open = !$object->isClosed(); | $is_open = !$object->isClosed(); | ||||
$new_status = null; | $new_status = null; | ||||
foreach ($xactions as $xaction) { | foreach ($xactions as $xaction) { | ||||
switch ($xaction->getTransactionType()) { | switch ($xaction->getTransactionType()) { | ||||
case ManiphestTaskStatusTransaction::TRANSACTIONTYPE: | case ManiphestTaskStatusTransaction::TRANSACTIONTYPE: | ||||
$new_status = $xaction->getNewValue(); | $new_status = $xaction->getNewValue(); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if ($new_status === null) { | if ($new_status === null) { | ||||
$is_closing = false; | $is_closing = false; | ||||
} 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) { | |||||
$is_claim = ManiphestTaskStatus::isClaimStatus($new_status); | |||||
// Don't assign the actor if they aren't a real user. | // Don't assign the actor if they aren't a real user. | ||||
// Don't claim the task if the status is configured to not claim. | if ($is_unassigned && $is_open && $is_closing && $actor_phid) { | ||||
if ($actor_phid && $is_claim) { | $is_autoclaim = ManiphestTaskStatus::isClaimStatus($new_status); | ||||
if ($is_autoclaim) { | |||||
if ($any_xassign === null) { | |||||
$results[] = id(new ManiphestTransaction()) | $results[] = id(new ManiphestTransaction()) | ||||
->setTransactionType(ManiphestTaskOwnerTransaction::TRANSACTIONTYPE) | ->setTransactionType(ManiphestTaskOwnerTransaction::TRANSACTIONTYPE) | ||||
->setNewValue($actor_phid); | ->setNewValue($actor_phid); | ||||
} else if ($any_xassign->getNewValue() === null) { | |||||
// We have an explicit "Assign / Claim" = nothing in the frontend. | |||||
// The user is trying to "undo" the above automatic auto-claim. | |||||
// When saving, this would cause the "no effect" warning. | |||||
// So we suppress that confusing warning. | |||||
// https://we.phorge.it/T15164 | |||||
$any_xassign->setIgnoreOnNoEffect(true); | |||||
} | |||||
} | } | ||||
} | } | ||||
// Automatically subscribe the author when they create a task. | // Automatically subscribe the author when they create a task. | ||||
if ($this->getIsNewObject()) { | if ($this->getIsNewObject()) { | ||||
if ($actor_phid) { | if ($actor_phid) { | ||||
$results[] = id(new ManiphestTransaction()) | $results[] = id(new ManiphestTransaction()) | ||||
->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS) | ->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS) | ||||
▲ Show 20 Lines • Show All 561 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0