Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/query/PhabricatorProjectQuery.php
<?php | <?php | ||||
final class PhabricatorProjectQuery | final class PhabricatorProjectQuery | ||||
extends PhabricatorCursorPagedPolicyAwareQuery { | extends PhabricatorCursorPagedPolicyAwareQuery { | ||||
private $ids; | private $ids; | ||||
private $phids; | private $phids; | ||||
private $memberPHIDs; | private $memberPHIDs; | ||||
private $nonMemberPHIDs; | |||||
private $slugs; | private $slugs; | ||||
private $phrictionSlugs; | private $phrictionSlugs; | ||||
private $names; | private $names; | ||||
private $datasourceQuery; | private $datasourceQuery; | ||||
private $icons; | private $icons; | ||||
private $colors; | private $colors; | ||||
private $status = 'status-any'; | private $status = 'status-any'; | ||||
Show All 23 Lines | public function withStatus($status) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withMemberPHIDs(array $member_phids) { | public function withMemberPHIDs(array $member_phids) { | ||||
$this->memberPHIDs = $member_phids; | $this->memberPHIDs = $member_phids; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withNonMemberPHIDs(array $phids) { | |||||
$this->nonMemberPHIDs = $phids; | |||||
return $this; | |||||
} | |||||
public function withSlugs(array $slugs) { | public function withSlugs(array $slugs) { | ||||
$this->slugs = $slugs; | $this->slugs = $slugs; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withPhrictionSlugs(array $slugs) { | public function withPhrictionSlugs(array $slugs) { | ||||
$this->phrictionSlugs = $slugs; | $this->phrictionSlugs = $slugs; | ||||
return $this; | return $this; | ||||
▲ Show 20 Lines • Show All 216 Lines • ▼ Show 20 Lines | private function buildWhereClause($conn_r) { | ||||
if ($this->memberPHIDs !== null) { | if ($this->memberPHIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn_r, | ||||
'e.dst IN (%Ls)', | 'e.dst IN (%Ls)', | ||||
$this->memberPHIDs); | $this->memberPHIDs); | ||||
} | } | ||||
if ($this->nonMemberPHIDs !== null) { | |||||
$where[] = qsprintf( | |||||
$conn_r, | |||||
'e.dst NOT IN(%Ls)', | |||||
$this->nonMemberPHIDs); | |||||
} | |||||
if ($this->slugs !== null) { | if ($this->slugs !== null) { | ||||
$slugs = array(); | $slugs = array(); | ||||
foreach ($this->slugs as $slug) { | foreach ($this->slugs as $slug) { | ||||
$slugs[] = rtrim(PhabricatorSlug::normalize($slug), '/'); | $slugs[] = rtrim(PhabricatorSlug::normalize($slug), '/'); | ||||
} | } | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn_r, | ||||
Show All 30 Lines | private function buildWhereClause($conn_r) { | ||||
} | } | ||||
$where[] = $this->buildPagingClause($conn_r); | $where[] = $this->buildPagingClause($conn_r); | ||||
return $this->formatWhereClause($where); | return $this->formatWhereClause($where); | ||||
} | } | ||||
private function buildGroupClause($conn_r) { | private function buildGroupClause($conn_r) { | ||||
if ($this->memberPHIDs || $this->datasourceQuery) { | if ($this->memberPHIDs || $this->datasourceQuery || $this->nonMemberPHIDs) { | ||||
return 'GROUP BY p.id'; | return 'GROUP BY p.id'; | ||||
} else { | } else { | ||||
return $this->buildApplicationSearchGroupClause($conn_r); | return $this->buildApplicationSearchGroupClause($conn_r); | ||||
} | } | ||||
} | } | ||||
private function buildJoinClause($conn_r) { | private function buildJoinClause($conn_r) { | ||||
$joins = array(); | $joins = array(); | ||||
if (!$this->needMembers !== null) { | if (!$this->needMembers !== null) { | ||||
$joins[] = qsprintf( | $joins[] = qsprintf( | ||||
$conn_r, | $conn_r, | ||||
'LEFT JOIN %T vm ON vm.src = p.phid AND vm.type = %d AND vm.dst = %s', | 'LEFT JOIN %T vm ON vm.src = p.phid AND vm.type = %d AND vm.dst = %s', | ||||
PhabricatorEdgeConfig::TABLE_NAME_EDGE, | PhabricatorEdgeConfig::TABLE_NAME_EDGE, | ||||
PhabricatorEdgeConfig::TYPE_PROJ_MEMBER, | PhabricatorEdgeConfig::TYPE_PROJ_MEMBER, | ||||
$this->getViewer()->getPHID()); | $this->getViewer()->getPHID()); | ||||
} | } | ||||
if ($this->memberPHIDs !== null) { | if ($this->memberPHIDs !== null || $this->nonMemberPHIDs !== null) { | ||||
$joins[] = qsprintf( | $joins[] = qsprintf( | ||||
$conn_r, | $conn_r, | ||||
'JOIN %T e ON e.src = p.phid AND e.type = %d', | 'JOIN %T e ON e.src = p.phid AND e.type = %d', | ||||
PhabricatorEdgeConfig::TABLE_NAME_EDGE, | PhabricatorEdgeConfig::TABLE_NAME_EDGE, | ||||
PhabricatorEdgeConfig::TYPE_PROJ_MEMBER); | PhabricatorEdgeConfig::TYPE_PROJ_MEMBER); | ||||
} | } | ||||
if ($this->slugs !== null) { | if ($this->slugs !== null) { | ||||
Show All 39 Lines |