diff --git a/src/applications/differential/__tests__/DifferentialParseRenderTestCase.php b/src/applications/differential/__tests__/DifferentialParseRenderTestCase.php --- a/src/applications/differential/__tests__/DifferentialParseRenderTestCase.php +++ b/src/applications/differential/__tests__/DifferentialParseRenderTestCase.php @@ -48,6 +48,7 @@ $engine->setViewer(new PhabricatorUser()); $cparser = new DifferentialChangesetParser(); + $cparser->setUser(new PhabricatorUser()); $cparser->setDisableCache(true); $cparser->setChangeset($changeset); $cparser->setMarkupEngine($engine); diff --git a/src/applications/differential/controller/DifferentialChangesetViewController.php b/src/applications/differential/controller/DifferentialChangesetViewController.php --- a/src/applications/differential/controller/DifferentialChangesetViewController.php +++ b/src/applications/differential/controller/DifferentialChangesetViewController.php @@ -207,11 +207,12 @@ $engine->process(); $parser->setMarkupEngine($engine); + $parser->setUser($request->getUser()); if ($request->isAjax()) { - // TODO: This is sort of lazy, the effect is just to not render "Edit" - // and "Reply" links on the "standalone view". - $parser->setUser($request->getUser()); + $parser->setShowEditAndReplyLinks(true); + } else { + $parser->setShowEditAndReplyLinks(false); } $output = $parser->render($range_s, $range_e, $mask); diff --git a/src/applications/differential/parser/DifferentialChangesetParser.php b/src/applications/differential/parser/DifferentialChangesetParser.php --- a/src/applications/differential/parser/DifferentialChangesetParser.php +++ b/src/applications/differential/parser/DifferentialChangesetParser.php @@ -43,6 +43,15 @@ private $renderer; private $characterEncoding; private $highlightAs; + private $showEditAndReplyLinks = true; + + public function setShowEditAndReplyLinks($bool) { + $this->showEditAndReplyLinks = $bool; + return $this; + } + public function getShowEditAndReplyLinks() { + return $this->showEditAndReplyLinks; + } public function setHighlightAs($highlight_as) { $this->highlightAs = $highlight_as; @@ -62,7 +71,7 @@ return $this->characterEncoding; } - public function setRenderer($renderer) { + public function setRenderer(DifferentialChangesetRenderer $renderer) { $this->renderer = $renderer; return $this; } @@ -252,6 +261,10 @@ return $this; } + public function getUser() { + return $this->user; + } + public function setCoverage($coverage) { $this->coverage = $coverage; return $this; @@ -739,6 +752,7 @@ count($this->new)); $renderer = $this->getRenderer() + ->setUser($this->getUser()) ->setChangeset($this->changeset) ->setRenderPropertyChangeHeader($render_pch) ->setIsTopLevel($this->isTopLevel) @@ -755,11 +769,8 @@ ->setHandles($this->handles) ->setOldLines($this->old) ->setNewLines($this->new) - ->setOriginalCharacterEncoding($encoding); - - if ($this->user) { - $renderer->setUser($this->user); - } + ->setOriginalCharacterEncoding($encoding) + ->setShowEditAndReplyLinks($this->getShowEditAndReplyLinks()); $shield = null; if ($this->isTopLevel && !$this->comments) { @@ -905,10 +916,10 @@ $file_phids[] = $new_phid; } - // TODO: (T603) Probably fine to use omnipotent viewer here? - $files = id(new PhabricatorFile())->loadAllWhere( - 'phid IN (%Ls)', - $file_phids); + $files = id(new PhabricatorFileQuery()) + ->setViewer($this->getUser()) + ->withPHIDs($file_phids) + ->execute(); foreach ($files as $file) { if (empty($file)) { continue; diff --git a/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php b/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php --- a/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php +++ b/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php @@ -443,8 +443,9 @@ $user = $this->getUser(); $edit = $user && ($comment->getAuthorPHID() == $user->getPHID()) && - ($comment->isDraft()); - $allow_reply = (bool)$user; + ($comment->isDraft()) + && $this->getShowEditAndReplyLinks(); + $allow_reply = (bool)$user && $this->getShowEditAndReplyLinks(); return id(new DifferentialInlineCommentView()) ->setInlineComment($comment) diff --git a/src/applications/differential/render/DifferentialChangesetRenderer.php b/src/applications/differential/render/DifferentialChangesetRenderer.php --- a/src/applications/differential/render/DifferentialChangesetRenderer.php +++ b/src/applications/differential/render/DifferentialChangesetRenderer.php @@ -29,10 +29,19 @@ private $mask; private $depths; private $originalCharacterEncoding; + private $showEditAndReplyLinks; private $oldFile = false; private $newFile = false; + public function setShowEditAndReplyLinks($bool) { + $this->showEditAndReplyLinks = $bool; + return $this; + } + public function getShowEditAndReplyLinks() { + return $this->showEditAndReplyLinks; + } + public function setOriginalCharacterEncoding($original_character_encoding) { $this->originalCharacterEncoding = $original_character_encoding; return $this; diff --git a/src/applications/phriction/controller/PhrictionDiffController.php b/src/applications/phriction/controller/PhrictionDiffController.php --- a/src/applications/phriction/controller/PhrictionDiffController.php +++ b/src/applications/phriction/controller/PhrictionDiffController.php @@ -71,6 +71,7 @@ $whitespace_mode = DifferentialChangesetParser::WHITESPACE_SHOW_ALL; $parser = new DifferentialChangesetParser(); + $parser->setUser($user); $parser->setChangeset($changeset); $parser->setRenderingReference("{$l},{$r}"); $parser->setWhitespaceMode($whitespace_mode); diff --git a/src/applications/transactions/view/PhabricatorApplicationTransactionTextDiffDetailView.php b/src/applications/transactions/view/PhabricatorApplicationTransactionTextDiffDetailView.php --- a/src/applications/transactions/view/PhabricatorApplicationTransactionTextDiffDetailView.php +++ b/src/applications/transactions/view/PhabricatorApplicationTransactionTextDiffDetailView.php @@ -43,6 +43,7 @@ $markup_engine->setViewer($this->getUser()); $parser = new DifferentialChangesetParser(); + $parser->setUser($this->getUser()); $parser->setChangeset($changeset); $parser->setMarkupEngine($markup_engine); $parser->setWhitespaceMode($whitespace_mode);