mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-01 18:30:59 +01:00
Use Application PHIDs for XUSR
Summary: Ref T2715. XUSR -> apps Test Plan: `phid.query` Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2715 Differential Revision: https://secure.phabricator.com/D6558
This commit is contained in:
parent
3160bb0932
commit
db3a0c90bb
7 changed files with 52 additions and 32 deletions
|
@ -1366,6 +1366,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorPeopleLdapController' => 'applications/people/controller/PhabricatorPeopleLdapController.php',
|
'PhabricatorPeopleLdapController' => 'applications/people/controller/PhabricatorPeopleLdapController.php',
|
||||||
'PhabricatorPeopleListController' => 'applications/people/controller/PhabricatorPeopleListController.php',
|
'PhabricatorPeopleListController' => 'applications/people/controller/PhabricatorPeopleListController.php',
|
||||||
'PhabricatorPeopleLogsController' => 'applications/people/controller/PhabricatorPeopleLogsController.php',
|
'PhabricatorPeopleLogsController' => 'applications/people/controller/PhabricatorPeopleLogsController.php',
|
||||||
|
'PhabricatorPeoplePHIDTypeExternal' => 'applications/people/phid/PhabricatorPeoplePHIDTypeExternal.php',
|
||||||
'PhabricatorPeopleProfileController' => 'applications/people/controller/PhabricatorPeopleProfileController.php',
|
'PhabricatorPeopleProfileController' => 'applications/people/controller/PhabricatorPeopleProfileController.php',
|
||||||
'PhabricatorPeopleProfileEditController' => 'applications/people/controller/PhabricatorPeopleProfileEditController.php',
|
'PhabricatorPeopleProfileEditController' => 'applications/people/controller/PhabricatorPeopleProfileEditController.php',
|
||||||
'PhabricatorPeopleProfilePictureController' => 'applications/people/controller/PhabricatorPeopleProfilePictureController.php',
|
'PhabricatorPeopleProfilePictureController' => 'applications/people/controller/PhabricatorPeopleProfilePictureController.php',
|
||||||
|
@ -3387,6 +3388,7 @@ phutil_register_library_map(array(
|
||||||
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
||||||
),
|
),
|
||||||
'PhabricatorPeopleLogsController' => 'PhabricatorPeopleController',
|
'PhabricatorPeopleLogsController' => 'PhabricatorPeopleController',
|
||||||
|
'PhabricatorPeoplePHIDTypeExternal' => 'PhabricatorPHIDType',
|
||||||
'PhabricatorPeopleProfileController' => 'PhabricatorPeopleController',
|
'PhabricatorPeopleProfileController' => 'PhabricatorPeopleController',
|
||||||
'PhabricatorPeopleProfileEditController' => 'PhabricatorPeopleController',
|
'PhabricatorPeopleProfileEditController' => 'PhabricatorPeopleController',
|
||||||
'PhabricatorPeopleProfilePictureController' => 'PhabricatorPeopleController',
|
'PhabricatorPeopleProfilePictureController' => 'PhabricatorPeopleController',
|
||||||
|
|
|
@ -68,10 +68,6 @@ final class PhabricatorExternalAccountQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
public function willFilterPage(array $accounts) {
|
public function willFilterPage(array $accounts) {
|
||||||
if (!$accounts) {
|
|
||||||
return $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);
|
||||||
|
|
|
@ -28,14 +28,15 @@ final class PhabricatorMetaMTAActorQuery extends PhabricatorQuery {
|
||||||
$actors[$phid] = id(new PhabricatorMetaMTAActor())->setPHID($phid);
|
$actors[$phid] = id(new PhabricatorMetaMTAActor())->setPHID($phid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Move this to PhabricatorPHIDType.
|
// TODO: Move this to PhabricatorPHIDType, or the objects, or some
|
||||||
|
// interface.
|
||||||
|
|
||||||
foreach ($type_map as $type => $phids) {
|
foreach ($type_map as $type => $phids) {
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case PhabricatorPHIDConstants::PHID_TYPE_USER:
|
case PhabricatorPHIDConstants::PHID_TYPE_USER:
|
||||||
$this->loadUserActors($actors, $phids);
|
$this->loadUserActors($actors, $phids);
|
||||||
break;
|
break;
|
||||||
case PhabricatorPHIDConstants::PHID_TYPE_XUSR:
|
case PhabricatorPeoplePHIDTypeExternal::TYPECONST:
|
||||||
$this->loadExternalUserActors($actors, $phids);
|
$this->loadExternalUserActors($actors, $phids);
|
||||||
break;
|
break;
|
||||||
case PhabricatorMailingListPHIDTypeList::TYPECONST:
|
case PhabricatorMailingListPHIDTypeList::TYPECONST:
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorPeoplePHIDTypeExternal extends PhabricatorPHIDType {
|
||||||
|
|
||||||
|
const TYPECONST = 'XUSR';
|
||||||
|
|
||||||
|
public function getTypeConstant() {
|
||||||
|
return self::TYPECONST;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTypeName() {
|
||||||
|
return pht('External Account');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function newObject() {
|
||||||
|
return new PhabricatorExternalAccount();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadObjects(
|
||||||
|
PhabricatorObjectQuery $query,
|
||||||
|
array $phids) {
|
||||||
|
|
||||||
|
return id(new PhabricatorExternalAccountQuery())
|
||||||
|
->setViewer($query->getViewer())
|
||||||
|
->withPHIDs($phids)
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadHandles(
|
||||||
|
PhabricatorHandleQuery $query,
|
||||||
|
array $handles,
|
||||||
|
array $objects) {
|
||||||
|
|
||||||
|
foreach ($handles as $phid => $handle) {
|
||||||
|
$account = $objects[$phid];
|
||||||
|
|
||||||
|
$display_name = $account->getDisplayName();
|
||||||
|
$handle->setName($display_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canLoadNamedObject($name) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -33,7 +33,7 @@ final class PhabricatorExternalAccount extends PhabricatorUserDAO
|
||||||
|
|
||||||
public function generatePHID() {
|
public function generatePHID() {
|
||||||
return PhabricatorPHID::generateNewPHID(
|
return PhabricatorPHID::generateNewPHID(
|
||||||
PhabricatorPHIDConstants::PHID_TYPE_XUSR);
|
PhabricatorPeoplePHIDTypeExternal::TYPECONST);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getConfiguration() {
|
public function getConfiguration() {
|
||||||
|
|
|
@ -30,7 +30,6 @@ final class PhabricatorPHIDConstants {
|
||||||
|
|
||||||
const PHID_TYPE_XACT = 'XACT';
|
const PHID_TYPE_XACT = 'XACT';
|
||||||
const PHID_TYPE_XCMT = 'XCMT';
|
const PHID_TYPE_XCMT = 'XCMT';
|
||||||
const PHID_TYPE_XUSR = 'XUSR';
|
|
||||||
|
|
||||||
const PHID_TYPE_BOOK = 'BOOK';
|
const PHID_TYPE_BOOK = 'BOOK';
|
||||||
const PHID_TYPE_ATOM = 'ATOM';
|
const PHID_TYPE_ATOM = 'ATOM';
|
||||||
|
|
|
@ -114,13 +114,6 @@ final class PhabricatorObjectHandleData {
|
||||||
->execute();
|
->execute();
|
||||||
return mpull($posts, null, 'getPHID');
|
return mpull($posts, null, 'getPHID');
|
||||||
|
|
||||||
case PhabricatorPHIDConstants::PHID_TYPE_XUSR:
|
|
||||||
$xusr_dao = new PhabricatorExternalAccount();
|
|
||||||
$xusrs = $xusr_dao->loadAllWhere(
|
|
||||||
'phid in (%Ls)',
|
|
||||||
$phids);
|
|
||||||
return mpull($xusrs, null, 'getPHID');
|
|
||||||
|
|
||||||
case PhabricatorPHIDConstants::PHID_TYPE_LEGD:
|
case PhabricatorPHIDConstants::PHID_TYPE_LEGD:
|
||||||
$legds = id(new LegalpadDocumentQuery())
|
$legds = id(new LegalpadDocumentQuery())
|
||||||
->needDocumentBodies(true)
|
->needDocumentBodies(true)
|
||||||
|
@ -327,23 +320,6 @@ final class PhabricatorObjectHandleData {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PhabricatorPHIDConstants::PHID_TYPE_XUSR:
|
|
||||||
foreach ($phids as $phid) {
|
|
||||||
$handle = new PhabricatorObjectHandle();
|
|
||||||
$handle->setPHID($phid);
|
|
||||||
$handle->setType($type);
|
|
||||||
if (empty($objects[$phid])) {
|
|
||||||
$handle->setName('Unknown Display Name');
|
|
||||||
} else {
|
|
||||||
$xusr = $objects[$phid];
|
|
||||||
$display_name = $xusr->getDisplayName();
|
|
||||||
$handle->setName($display_name);
|
|
||||||
$handle->setFullName($display_name.' (External User)');
|
|
||||||
}
|
|
||||||
$handles[$phid] = $handle;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PhabricatorPHIDConstants::PHID_TYPE_LEGD:
|
case PhabricatorPHIDConstants::PHID_TYPE_LEGD:
|
||||||
foreach ($phids as $phid) {
|
foreach ($phids as $phid) {
|
||||||
$handle = new PhabricatorObjectHandle();
|
$handle = new PhabricatorObjectHandle();
|
||||||
|
|
Loading…
Reference in a new issue