1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-30 01:10:58 +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:
epriestley 2013-07-24 14:12:39 -07:00
parent 3160bb0932
commit db3a0c90bb
7 changed files with 52 additions and 32 deletions

View file

@ -1366,6 +1366,7 @@ phutil_register_library_map(array(
'PhabricatorPeopleLdapController' => 'applications/people/controller/PhabricatorPeopleLdapController.php',
'PhabricatorPeopleListController' => 'applications/people/controller/PhabricatorPeopleListController.php',
'PhabricatorPeopleLogsController' => 'applications/people/controller/PhabricatorPeopleLogsController.php',
'PhabricatorPeoplePHIDTypeExternal' => 'applications/people/phid/PhabricatorPeoplePHIDTypeExternal.php',
'PhabricatorPeopleProfileController' => 'applications/people/controller/PhabricatorPeopleProfileController.php',
'PhabricatorPeopleProfileEditController' => 'applications/people/controller/PhabricatorPeopleProfileEditController.php',
'PhabricatorPeopleProfilePictureController' => 'applications/people/controller/PhabricatorPeopleProfilePictureController.php',
@ -3387,6 +3388,7 @@ phutil_register_library_map(array(
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'PhabricatorPeopleLogsController' => 'PhabricatorPeopleController',
'PhabricatorPeoplePHIDTypeExternal' => 'PhabricatorPHIDType',
'PhabricatorPeopleProfileController' => 'PhabricatorPeopleController',
'PhabricatorPeopleProfileEditController' => 'PhabricatorPeopleController',
'PhabricatorPeopleProfilePictureController' => 'PhabricatorPeopleController',

View file

@ -68,10 +68,6 @@ final class PhabricatorExternalAccountQuery
}
public function willFilterPage(array $accounts) {
if (!$accounts) {
return $accounts;
}
if ($this->needImages) {
$file_phids = mpull($accounts, 'getProfileImagePHID');
$file_phids = array_filter($file_phids);

View file

@ -28,14 +28,15 @@ final class PhabricatorMetaMTAActorQuery extends PhabricatorQuery {
$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) {
switch ($type) {
case PhabricatorPHIDConstants::PHID_TYPE_USER:
$this->loadUserActors($actors, $phids);
break;
case PhabricatorPHIDConstants::PHID_TYPE_XUSR:
case PhabricatorPeoplePHIDTypeExternal::TYPECONST:
$this->loadExternalUserActors($actors, $phids);
break;
case PhabricatorMailingListPHIDTypeList::TYPECONST:

View file

@ -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;
}
}

View file

@ -33,7 +33,7 @@ final class PhabricatorExternalAccount extends PhabricatorUserDAO
public function generatePHID() {
return PhabricatorPHID::generateNewPHID(
PhabricatorPHIDConstants::PHID_TYPE_XUSR);
PhabricatorPeoplePHIDTypeExternal::TYPECONST);
}
public function getConfiguration() {

View file

@ -30,7 +30,6 @@ final class PhabricatorPHIDConstants {
const PHID_TYPE_XACT = 'XACT';
const PHID_TYPE_XCMT = 'XCMT';
const PHID_TYPE_XUSR = 'XUSR';
const PHID_TYPE_BOOK = 'BOOK';
const PHID_TYPE_ATOM = 'ATOM';

View file

@ -114,13 +114,6 @@ final class PhabricatorObjectHandleData {
->execute();
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:
$legds = id(new LegalpadDocumentQuery())
->needDocumentBodies(true)
@ -327,23 +320,6 @@ final class PhabricatorObjectHandleData {
}
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:
foreach ($phids as $phid) {
$handle = new PhabricatorObjectHandle();