Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/query/PhabricatorProjectQuery.php
| Show First 20 Lines • Show All 220 Lines • ▼ Show 20 Lines | protected function willFilterPage(array $projects) { | ||||
| } | } | ||||
| $edge_query = id(new PhabricatorEdgeQuery()) | $edge_query = id(new PhabricatorEdgeQuery()) | ||||
| ->withSourcePHIDs($all_sources) | ->withSourcePHIDs($all_sources) | ||||
| ->withEdgeTypes($types); | ->withEdgeTypes($types); | ||||
| // If we only need to know if the viewer is a member, we can restrict | // If we only need to know if the viewer is a member, we can restrict | ||||
| // the query to just their PHID. | // the query to just their PHID. | ||||
| $any_edges = true; | |||||
| if (!$this->needMembers && !$this->needWatchers) { | if (!$this->needMembers && !$this->needWatchers) { | ||||
| if ($viewer_phid) { | |||||
| $edge_query->withDestinationPHIDs(array($viewer_phid)); | $edge_query->withDestinationPHIDs(array($viewer_phid)); | ||||
| } else { | |||||
| // If we don't need members or watchers and don't have a viewer PHID | |||||
| // (viewer is logged-out or omnipotent), they'll never be a member | |||||
| // so we don't need to issue this query at all. | |||||
| $any_edges = false; | |||||
| } | |||||
| } | } | ||||
| if ($any_edges) { | |||||
| $edge_query->execute(); | $edge_query->execute(); | ||||
| } | |||||
| $membership_projects = array(); | $membership_projects = array(); | ||||
| foreach ($projects as $project) { | foreach ($projects as $project) { | ||||
| $project_phid = $project->getPHID(); | $project_phid = $project->getPHID(); | ||||
| if ($project->isMilestone()) { | if ($project->isMilestone()) { | ||||
| $source_phids = array($project->getParentProjectPHID()); | $source_phids = array($project->getParentProjectPHID()); | ||||
| } else { | } else { | ||||
| $source_phids = array($project_phid); | $source_phids = array($project_phid); | ||||
| } | } | ||||
| if ($any_edges) { | |||||
| $member_phids = $edge_query->getDestinationPHIDs( | $member_phids = $edge_query->getDestinationPHIDs( | ||||
| $source_phids, | $source_phids, | ||||
| array($member_type)); | array($member_type)); | ||||
| } else { | |||||
| $member_phids = array(); | |||||
| } | |||||
| if (in_array($viewer_phid, $member_phids)) { | if (in_array($viewer_phid, $member_phids)) { | ||||
| $membership_projects[$project_phid] = $project; | $membership_projects[$project_phid] = $project; | ||||
| } | } | ||||
| if ($this->needMembers) { | if ($this->needMembers) { | ||||
| $project->attachMemberPHIDs($member_phids); | $project->attachMemberPHIDs($member_phids); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 413 Lines • Show Last 20 Lines | |||||