diff --git a/src/applications/maniphest/controller/ManiphestBatchEditController.php b/src/applications/maniphest/controller/ManiphestBatchEditController.php index eab1a25a16..5b1c71ad9c 100644 --- a/src/applications/maniphest/controller/ManiphestBatchEditController.php +++ b/src/applications/maniphest/controller/ManiphestBatchEditController.php @@ -22,11 +22,20 @@ final class ManiphestBatchEditController extends ManiphestController { if ($request->isFormPost() && is_array($actions)) { foreach ($tasks as $task) { + $field_list = PhabricatorCustomField::getObjectFields( + $task, + PhabricatorCustomField::ROLE_EDIT); + $field_list->readFieldsFromStorage($task); + $xactions = $this->buildTransactions($actions, $task); if ($xactions) { - $editor = new ManiphestTransactionEditor(); - $editor->setActor($user); - $editor->applyTransactions($task, $xactions); + // TODO: Set content source to "batch edit". + + $editor = id(new ManiphestTransactionEditorPro()) + ->setActor($user) + ->setContentSourceFromRequest($request) + ->setContinueOnNoEffect(true) + ->applyTransactions($task, $xactions); } } @@ -296,13 +305,7 @@ final class ManiphestBatchEditController extends ManiphestController { $value_map[$type] = $value; } - $template = new ManiphestTransaction(); - $template->setAuthorPHID($this->getRequest()->getUser()->getPHID()); - - // TODO: Set content source to "batch edit". - - $template->setContentSource( - PhabricatorContentSource::newFromRequest($this->getRequest())); + $template = new ManiphestTransactionPro(); foreach ($value_map as $type => $value) { $xaction = clone $template; @@ -310,7 +313,9 @@ final class ManiphestBatchEditController extends ManiphestController { switch ($type) { case PhabricatorTransactions::TYPE_COMMENT: - $xaction->setComments($value); + $xaction->attachComment( + id(new ManiphestTransactionComment()) + ->setContent($value)); break; default: $xaction->setNewValue($value); diff --git a/src/applications/maniphest/editor/ManiphestTransactionEditor.php b/src/applications/maniphest/editor/ManiphestTransactionEditor.php index b0f5bad0e3..f3ae5876fa 100644 --- a/src/applications/maniphest/editor/ManiphestTransactionEditor.php +++ b/src/applications/maniphest/editor/ManiphestTransactionEditor.php @@ -253,6 +253,7 @@ final class ManiphestTransactionEditor extends PhabricatorEditor { $main_body = array(); foreach ($transactions as $transaction) { $main_body[] = id(clone $transaction->getModernTransaction()) + ->attachViewer($this->getActor()) ->setHandles($handles) ->setRenderingTarget('text') ->getTitle(); diff --git a/src/applications/transactions/query/PhabricatorApplicationTransactionQuery.php b/src/applications/transactions/query/PhabricatorApplicationTransactionQuery.php index 8ddad3a366..00523cffe4 100644 --- a/src/applications/transactions/query/PhabricatorApplicationTransactionQuery.php +++ b/src/applications/transactions/query/PhabricatorApplicationTransactionQuery.php @@ -65,6 +65,10 @@ abstract class PhabricatorApplicationTransactionQuery $xactions = $table->loadAllFromArray($data); + foreach ($xactions as $xaction) { + $xaction->attachViewer($this->getViewer()); + } + if ($this->needComments) { $comment_phids = array_filter(mpull($xactions, 'getCommentPHID')); diff --git a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php index 71e4bedd52..1f3089caf7 100644 --- a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php +++ b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php @@ -28,6 +28,7 @@ abstract class PhabricatorApplicationTransaction private $handles; private $renderingTarget = self::TARGET_HTML; private $transactionGroup = array(); + private $viewer = self::ATTACHABLE; abstract public function getApplicationTransactionType(); @@ -120,6 +121,15 @@ abstract class PhabricatorApplicationTransaction return $this->renderingTarget; } + public function attachViewer(PhabricatorUser $viewer) { + $this->viewer = $viewer; + return $this; + } + + public function getViewer() { + return $this->assertAttached($this->viewer); + } + public function getRequiredHandlePHIDs() { $phids = array(); @@ -363,6 +373,7 @@ abstract class PhabricatorApplicationTransaction PhabricatorCustomField::ROLE_APPLICATIONTRANSACTIONS, $key); if ($field) { + $field->setViewer($this->getViewer()); return $field->getApplicationTransactionTitle($this); } else { return pht(