1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 22:10:55 +01:00

Update some inline comment logic to use more modern "Viewer"-oriented calls/variables

Summary:
Ref T13195. Ref T8573. The inline comment controllers currently use outdated `$user = $this->getRequest()->getUser()` calls.

Instead, use `$viewer = $this->getViewer()`.

This is just a small consistency update with no behavioral changes.

Test Plan: Viewed and added inlines in Differential and Diffusion.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13195, T8573

Differential Revision: https://secure.phabricator.com/D19633
This commit is contained in:
epriestley 2018-09-04 11:26:30 -07:00
parent dc0924deed
commit 650e74933a
3 changed files with 19 additions and 23 deletions

View file

@ -77,19 +77,17 @@ final class DifferentialInlineCommentEditController
} }
protected function loadCommentForEdit($id) { protected function loadCommentForEdit($id) {
$request = $this->getRequest(); $viewer = $this->getViewer();
$user = $request->getUser();
$inline = $this->loadComment($id); $inline = $this->loadComment($id);
if (!$this->canEditInlineComment($user, $inline)) { if (!$this->canEditInlineComment($viewer, $inline)) {
throw new Exception(pht('That comment is not editable!')); throw new Exception(pht('That comment is not editable!'));
} }
return $inline; return $inline;
} }
protected function loadCommentForDone($id) { protected function loadCommentForDone($id) {
$request = $this->getRequest(); $viewer = $this->getViewer();
$viewer = $request->getUser();
$inline = $this->loadComment($id); $inline = $this->loadComment($id);
if (!$inline) { if (!$inline) {
@ -128,11 +126,11 @@ final class DifferentialInlineCommentEditController
} }
private function canEditInlineComment( private function canEditInlineComment(
PhabricatorUser $user, PhabricatorUser $viewer,
DifferentialInlineComment $inline) { DifferentialInlineComment $inline) {
// Only the author may edit a comment. // Only the author may edit a comment.
if ($inline->getAuthorPHID() != $user->getPHID()) { if ($inline->getAuthorPHID() != $viewer->getPHID()) {
return false; return false;
} }

View file

@ -50,19 +50,17 @@ final class DiffusionInlineCommentController
} }
protected function loadCommentForEdit($id) { protected function loadCommentForEdit($id) {
$request = $this->getRequest(); $viewer = $this->getViewer();
$user = $request->getUser();
$inline = $this->loadComment($id); $inline = $this->loadComment($id);
if (!$this->canEditInlineComment($user, $inline)) { if (!$this->canEditInlineComment($viewer, $inline)) {
throw new Exception(pht('That comment is not editable!')); throw new Exception(pht('That comment is not editable!'));
} }
return $inline; return $inline;
} }
protected function loadCommentForDone($id) { protected function loadCommentForDone($id) {
$request = $this->getRequest(); $viewer = $this->getViewer();
$viewer = $request->getUser();
$inline = $this->loadComment($id); $inline = $this->loadComment($id);
if (!$inline) { if (!$inline) {
@ -86,11 +84,11 @@ final class DiffusionInlineCommentController
} }
private function canEditInlineComment( private function canEditInlineComment(
PhabricatorUser $user, PhabricatorUser $viewer,
PhabricatorAuditInlineComment $inline) { PhabricatorAuditInlineComment $inline) {
// Only the author may edit a comment. // Only the author may edit a comment.
if ($inline->getAuthorPHID() != $user->getPHID()) { if ($inline->getAuthorPHID() != $viewer->getPHID()) {
return false; return false;
} }

View file

@ -88,7 +88,7 @@ abstract class PhabricatorInlineCommentController
public function processRequest() { public function processRequest() {
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $viewer = $this->getViewer();
$this->readRequestParameters(); $this->readRequestParameters();
@ -221,7 +221,7 @@ abstract class PhabricatorInlineCommentController
$inline = $this->createComment() $inline = $this->createComment()
->setChangesetID($this->getChangesetID()) ->setChangesetID($this->getChangesetID())
->setAuthorPHID($user->getPHID()) ->setAuthorPHID($viewer->getPHID())
->setLineNumber($this->getLineNumber()) ->setLineNumber($this->getLineNumber())
->setLineLength($this->getLineLength()) ->setLineLength($this->getLineLength())
->setIsNewFile($this->getIsNewFile()) ->setIsNewFile($this->getIsNewFile())
@ -313,10 +313,10 @@ abstract class PhabricatorInlineCommentController
private function buildEditDialog() { private function buildEditDialog() {
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $viewer = $this->getViewer();
$edit_dialog = id(new PHUIDiffInlineCommentEditView()) $edit_dialog = id(new PHUIDiffInlineCommentEditView())
->setUser($user) ->setUser($viewer)
->setSubmitURI($request->getRequestURI()) ->setSubmitURI($request->getRequestURI())
->setIsOnRight($this->getIsOnRight()) ->setIsOnRight($this->getIsOnRight())
->setIsNewFile($this->getIsNewFile()) ->setIsNewFile($this->getIsNewFile())
@ -342,22 +342,22 @@ abstract class PhabricatorInlineCommentController
$on_right) { $on_right) {
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $viewer = $this->getViewer();
$engine = new PhabricatorMarkupEngine(); $engine = new PhabricatorMarkupEngine();
$engine->setViewer($user); $engine->setViewer($viewer);
$engine->addObject( $engine->addObject(
$inline, $inline,
PhabricatorInlineCommentInterface::MARKUP_FIELD_BODY); PhabricatorInlineCommentInterface::MARKUP_FIELD_BODY);
$engine->process(); $engine->process();
$phids = array($user->getPHID()); $phids = array($viewer->getPHID());
$handles = $this->loadViewerHandles($phids); $handles = $this->loadViewerHandles($phids);
$object_owner_phid = $this->loadObjectOwnerPHID($inline); $object_owner_phid = $this->loadObjectOwnerPHID($inline);
$view = id(new PHUIDiffInlineCommentDetailView()) $view = id(new PHUIDiffInlineCommentDetailView())
->setUser($user) ->setUser($viewer)
->setInlineComment($inline) ->setInlineComment($inline)
->setIsOnRight($on_right) ->setIsOnRight($on_right)
->setMarkupEngine($engine) ->setMarkupEngine($engine)
@ -378,7 +378,7 @@ abstract class PhabricatorInlineCommentController
private function renderTextArea($text) { private function renderTextArea($text) {
return id(new PhabricatorRemarkupControl()) return id(new PhabricatorRemarkupControl())
->setUser($this->getRequest()->getUser()) ->setViewer($this->getViewer())
->setSigil('differential-inline-comment-edit-textarea') ->setSigil('differential-inline-comment-edit-textarea')
->setName('text') ->setName('text')
->setValue($text) ->setValue($text)