Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/query/PhabricatorExternalAccountQuery.php
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | public function withAccountSecrets(array $secrets) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function needImages($need) { | public function needImages($need) { | ||||
$this->needImages = $need; | $this->needImages = $need; | ||||
return $this; | return $this; | ||||
} | } | ||||
protected function loadPage() { | public function newResultObject() { | ||||
$table = new PhabricatorExternalAccount(); | return new PhabricatorExternalAccount(); | ||||
$conn_r = $table->establishConnection('r'); | } | ||||
$data = queryfx_all( | |||||
$conn_r, | |||||
'SELECT * FROM %T %Q %Q %Q', | |||||
$table->getTableName(), | |||||
$this->buildWhereClause($conn_r), | |||||
$this->buildOrderClause($conn_r), | |||||
$this->buildLimitClause($conn_r)); | |||||
return $table->loadAllFromArray($data); | protected function loadPage() { | ||||
return $this->loadStandardPage($this->newResultObject()); | |||||
} | } | ||||
protected function willFilterPage(array $accounts) { | protected function willFilterPage(array $accounts) { | ||||
if ($this->needImages) { | if ($this->needImages) { | ||||
$file_phids = mpull($accounts, 'getProfileImagePHID'); | $file_phids = mpull($accounts, 'getProfileImagePHID'); | ||||
$file_phids = array_filter($file_phids); | $file_phids = array_filter($file_phids); | ||||
if ($file_phids) { | if ($file_phids) { | ||||
Show All 25 Lines | if ($this->needImages) { | ||||
$account->attachProfileImageFile($default_file); | $account->attachProfileImageFile($default_file); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
return $accounts; | return $accounts; | ||||
} | } | ||||
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
$where = array(); | $where = parent::buildWhereClauseParts($conn); | ||||
$where[] = $this->buildPagingClause($conn_r); | |||||
if ($this->ids) { | if ($this->ids !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn, | ||||
'id IN (%Ld)', | 'id IN (%Ld)', | ||||
$this->ids); | $this->ids); | ||||
} | } | ||||
if ($this->phids) { | if ($this->phids !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn, | ||||
'phid IN (%Ls)', | 'phid IN (%Ls)', | ||||
$this->phids); | $this->phids); | ||||
} | } | ||||
if ($this->accountTypes) { | if ($this->accountTypes !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn, | ||||
'accountType IN (%Ls)', | 'accountType IN (%Ls)', | ||||
$this->accountTypes); | $this->accountTypes); | ||||
} | } | ||||
if ($this->accountDomains) { | if ($this->accountDomains !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn, | ||||
'accountDomain IN (%Ls)', | 'accountDomain IN (%Ls)', | ||||
$this->accountDomains); | $this->accountDomains); | ||||
} | } | ||||
if ($this->accountIDs) { | if ($this->accountIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn, | ||||
'accountID IN (%Ls)', | 'accountID IN (%Ls)', | ||||
$this->accountIDs); | $this->accountIDs); | ||||
} | } | ||||
if ($this->userPHIDs) { | if ($this->userPHIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn, | ||||
'userPHID IN (%Ls)', | 'userPHID IN (%Ls)', | ||||
$this->userPHIDs); | $this->userPHIDs); | ||||
} | } | ||||
if ($this->accountSecrets) { | if ($this->accountSecrets !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn, | ||||
'accountSecret IN (%Ls)', | 'accountSecret IN (%Ls)', | ||||
$this->accountSecrets); | $this->accountSecrets); | ||||
} | } | ||||
return $this->formatWhereClause($where); | return $where; | ||||
} | } | ||||
public function getQueryApplicationClass() { | public function getQueryApplicationClass() { | ||||
return 'PhabricatorPeopleApplication'; | return 'PhabricatorPeopleApplication'; | ||||
} | } | ||||
/** | /** | ||||
* Attempts to find an external account and if none exists creates a new | * Attempts to find an external account and if none exists creates a new | ||||
Show All 30 Lines |