From aa5c82df75ffc50edfd324c95ecbffc0c73b5d2c Mon Sep 17 00:00:00 2001 From: Tuomas Pelkonen Date: Tue, 29 Mar 2011 14:27:31 -0700 Subject: [PATCH] Solving an unassigned task assigns it to the user. Summary: Also commenting on a task will add the user to CCs if not there already. Test Plan: Tested manually with UI that everything works as expected: Reviewed By: epriestley Reviewers: epriestley CC: epriestley Differential Revision: 85 --- .../ManiphestTransactionSaveController.php | 28 +++++++++++++++++++ .../controller/transactionsave/__init__.php | 1 + 2 files changed, 29 insertions(+) diff --git a/src/applications/maniphest/controller/transactionsave/ManiphestTransactionSaveController.php b/src/applications/maniphest/controller/transactionsave/ManiphestTransactionSaveController.php index 07762ee649..ee2eafde7d 100644 --- a/src/applications/maniphest/controller/transactionsave/ManiphestTransactionSaveController.php +++ b/src/applications/maniphest/controller/transactionsave/ManiphestTransactionSaveController.php @@ -110,6 +110,34 @@ class ManiphestTransactionSaveController extends ManiphestController { $transactions[] = $cc; } break; + case ManiphestTransactionType::TYPE_STATUS: + if (!$task->getOwnerPHID() && + $request->getStr('resolution') != + ManiphestTaskStatus::STATUS_OPEN) { + // Closing an unassigned task. Assign the user for this task + $assign = new ManiphestTransaction(); + $assign->setAuthorPHID($user->getPHID()); + $assign->setTransactionType(ManiphestTransactionType::TYPE_OWNER); + $assign->setNewValue($user->getPHID()); + $transactions[] = $assign; + } + break; + case ManiphestTransactionType::TYPE_NONE: + $ccs = $task->getCCPHIDs(); + $owner = $task->getOwnerPHID(); + + if ($user->getPHID() !== $owner && !in_array($user->getPHID(), $ccs)) { + // Current user, who is commenting, is not the owner or in ccs. + // Add him to ccs + $ccs[] = $user->getPHID(); + $cc = new ManiphestTransaction(); + $cc->setAuthorPHID($user->getPHID()); + $cc->setTransactionType(ManiphestTransactionType::TYPE_CCS); + $cc->setNewValue($ccs); + $transactions[] = $cc; + } + default: + break; } $editor = new ManiphestTransactionEditor(); diff --git a/src/applications/maniphest/controller/transactionsave/__init__.php b/src/applications/maniphest/controller/transactionsave/__init__.php index b7e5685a08..2e4dd9538a 100644 --- a/src/applications/maniphest/controller/transactionsave/__init__.php +++ b/src/applications/maniphest/controller/transactionsave/__init__.php @@ -9,6 +9,7 @@ phutil_require_module('phabricator', 'aphront/response/404'); phutil_require_module('phabricator', 'aphront/response/redirect'); phutil_require_module('phabricator', 'applications/files/storage/file'); +phutil_require_module('phabricator', 'applications/maniphest/constants/status'); phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype'); phutil_require_module('phabricator', 'applications/maniphest/controller/base'); phutil_require_module('phabricator', 'applications/maniphest/editor/transaction');