Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/diff/query/PhabricatorDiffInlineCommentQuery.php
<?php | <?php | ||||
abstract class PhabricatorDiffInlineCommentQuery | abstract class PhabricatorDiffInlineCommentQuery | ||||
extends PhabricatorApplicationTransactionCommentQuery { | extends PhabricatorApplicationTransactionCommentQuery { | ||||
private $fixedStates; | private $fixedStates; | ||||
private $needReplyToComments; | private $needReplyToComments; | ||||
private $publishedComments; | private $publishedComments; | ||||
private $publishableComments; | private $publishableComments; | ||||
private $needHidden; | |||||
abstract protected function buildInlineCommentWhereClauseParts( | abstract protected function buildInlineCommentWhereClauseParts( | ||||
AphrontDatabaseConnection $conn); | AphrontDatabaseConnection $conn); | ||||
abstract public function withObjectPHIDs(array $phids); | abstract public function withObjectPHIDs(array $phids); | ||||
abstract protected function loadHiddenCommentIDs( | |||||
$viewer_phid, | |||||
array $comments); | |||||
public function withFixedStates(array $states) { | final public function withFixedStates(array $states) { | ||||
$this->fixedStates = $states; | $this->fixedStates = $states; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function needReplyToComments($need_reply_to) { | final public function needReplyToComments($need_reply_to) { | ||||
$this->needReplyToComments = $need_reply_to; | $this->needReplyToComments = $need_reply_to; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withPublishableComments($with_publishable) { | final public function withPublishableComments($with_publishable) { | ||||
$this->publishableComments = $with_publishable; | $this->publishableComments = $with_publishable; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withPublishedComments($with_published) { | final public function withPublishedComments($with_published) { | ||||
$this->publishedComments = $with_published; | $this->publishedComments = $with_published; | ||||
return $this; | return $this; | ||||
} | } | ||||
final public function needHidden($need_hidden) { | |||||
$this->needHidden = $need_hidden; | |||||
return $this; | |||||
} | |||||
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
$where = parent::buildWhereClauseParts($conn); | $where = parent::buildWhereClauseParts($conn); | ||||
$alias = $this->getPrimaryTableAlias(); | $alias = $this->getPrimaryTableAlias(); | ||||
foreach ($this->buildInlineCommentWhereClauseParts($conn) as $part) { | foreach ($this->buildInlineCommentWhereClauseParts($conn) as $part) { | ||||
$where[] = $part; | $where[] = $part; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | if ($this->needReplyToComments) { | ||||
$this->didRejectResult($comment); | $this->didRejectResult($comment); | ||||
unset($comments[$key]); | unset($comments[$key]); | ||||
continue; | continue; | ||||
} | } | ||||
$comment->attachReplyToComment($reply); | $comment->attachReplyToComment($reply); | ||||
} | } | ||||
} | } | ||||
if (!$comments) { | |||||
return $comments; | |||||
} | |||||
if ($this->needHidden) { | |||||
$viewer = $this->getViewer(); | |||||
$viewer_phid = $viewer->getPHID(); | |||||
if ($viewer_phid) { | |||||
$hidden = $this->loadHiddenCommentIDs( | |||||
$viewer_phid, | |||||
$comments); | |||||
} else { | |||||
$hidden = array(); | |||||
} | |||||
foreach ($comments as $inline) { | |||||
$inline->attachIsHidden(isset($hidden[$inline->getID()])); | |||||
} | |||||
} | |||||
return $comments; | return $comments; | ||||
} | } | ||||
} | } |