Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/query/PhabricatorPeopleQuery.php
Show All 17 Lines | final class PhabricatorPeopleQuery | ||||
private $nameLike; | private $nameLike; | ||||
private $nameTokens; | private $nameTokens; | ||||
private $namePrefixes; | private $namePrefixes; | ||||
private $needPrimaryEmail; | private $needPrimaryEmail; | ||||
private $needProfile; | private $needProfile; | ||||
private $needProfileImage; | private $needProfileImage; | ||||
private $needAvailability; | private $needAvailability; | ||||
private $needBadges; | |||||
private $cacheKeys = array(); | private $cacheKeys = array(); | ||||
public function withIDs(array $ids) { | public function withIDs(array $ids) { | ||||
$this->ids = $ids; | $this->ids = $ids; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withPHIDs(array $phids) { | public function withPHIDs(array $phids) { | ||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | public function needProfileImage($need) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function needAvailability($need) { | public function needAvailability($need) { | ||||
$this->needAvailability = $need; | $this->needAvailability = $need; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function needBadges($need) { | |||||
$this->needBadges = $need; | |||||
return $this; | |||||
} | |||||
public function needUserSettings($need) { | public function needUserSettings($need) { | ||||
$cache_key = PhabricatorUserPreferencesCacheType::KEY_PREFERENCES; | $cache_key = PhabricatorUserPreferencesCacheType::KEY_PREFERENCES; | ||||
if ($need) { | if ($need) { | ||||
$this->cacheKeys[$cache_key] = true; | $this->cacheKeys[$cache_key] = true; | ||||
} else { | } else { | ||||
unset($this->cacheKeys[$cache_key]); | unset($this->cacheKeys[$cache_key]); | ||||
} | } | ||||
Show All 31 Lines | if ($this->needProfile) { | ||||
if (!$profile) { | if (!$profile) { | ||||
$profile = PhabricatorUserProfile::initializeNewProfile($user); | $profile = PhabricatorUserProfile::initializeNewProfile($user); | ||||
} | } | ||||
$user->attachUserProfile($profile); | $user->attachUserProfile($profile); | ||||
} | } | ||||
} | } | ||||
if ($this->needBadges) { | |||||
$awards = id(new PhabricatorBadgesAwardQuery()) | |||||
->setViewer($this->getViewer()) | |||||
->withRecipientPHIDs(mpull($users, 'getPHID')) | |||||
->execute(); | |||||
$awards = mgroup($awards, 'getRecipientPHID'); | |||||
foreach ($users as $user) { | |||||
$user_awards = idx($awards, $user->getPHID(), array()); | |||||
$badge_phids = mpull($user_awards, 'getBadgePHID'); | |||||
$user->attachBadgePHIDs($badge_phids); | |||||
} | |||||
} | |||||
if ($this->needAvailability) { | if ($this->needAvailability) { | ||||
$rebuild = array(); | $rebuild = array(); | ||||
foreach ($users as $user) { | foreach ($users as $user) { | ||||
$cache = $user->getAvailabilityCache(); | $cache = $user->getAvailabilityCache(); | ||||
if ($cache !== null) { | if ($cache !== null) { | ||||
$user->attachAvailability($cache); | $user->attachAvailability($cache); | ||||
} else { | } else { | ||||
$rebuild[] = $user; | $rebuild[] = $user; | ||||
▲ Show 20 Lines • Show All 432 Lines • Show Last 20 Lines |