@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Move PhabricatorUser to new phid stuff

Summary: Ref T2715. Had to start loading status information in the query class. Debated trying to clean up some of the attach / load stuff but decided to just add status under the new paradigm for now.

Test Plan: phid.query also made a status and checked that out. also played in conpherence.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2715

Differential Revision: https://secure.phabricator.com/D6585

+116 -90
+2
src/__phutil_library_map__.php
··· 1375 1375 'PhabricatorPeopleListController' => 'applications/people/controller/PhabricatorPeopleListController.php', 1376 1376 'PhabricatorPeopleLogsController' => 'applications/people/controller/PhabricatorPeopleLogsController.php', 1377 1377 'PhabricatorPeoplePHIDTypeExternal' => 'applications/people/phid/PhabricatorPeoplePHIDTypeExternal.php', 1378 + 'PhabricatorPeoplePHIDTypeUser' => 'applications/people/phid/PhabricatorPeoplePHIDTypeUser.php', 1378 1379 'PhabricatorPeopleProfileController' => 'applications/people/controller/PhabricatorPeopleProfileController.php', 1379 1380 'PhabricatorPeopleProfileEditController' => 'applications/people/controller/PhabricatorPeopleProfileEditController.php', 1380 1381 'PhabricatorPeopleProfilePictureController' => 'applications/people/controller/PhabricatorPeopleProfilePictureController.php', ··· 3410 3411 ), 3411 3412 'PhabricatorPeopleLogsController' => 'PhabricatorPeopleController', 3412 3413 'PhabricatorPeoplePHIDTypeExternal' => 'PhabricatorPHIDType', 3414 + 'PhabricatorPeoplePHIDTypeUser' => 'PhabricatorPHIDType', 3413 3415 'PhabricatorPeopleProfileController' => 'PhabricatorPeopleController', 3414 3416 'PhabricatorPeopleProfileEditController' => 'PhabricatorPeopleController', 3415 3417 'PhabricatorPeopleProfilePictureController' => 'PhabricatorPeopleController',
+1 -1
src/applications/audit/controller/PhabricatorAuditListController.php
··· 219 219 case 'active': 220 220 case 'user': 221 221 case 'author': 222 - if ($type !== PhabricatorPHIDConstants::PHID_TYPE_USER) { 222 + if ($type !== PhabricatorPeoplePHIDTypeUser::TYPECONST) { 223 223 throw new Exception("PHID must be a user PHID!"); 224 224 } 225 225 break;
+1 -1
src/applications/differential/mail/DifferentialMail.php
··· 142 142 continue; 143 143 } 144 144 $type = $reason_handles[$relation['reasonPHID']]->getType(); 145 - if ($type == PhabricatorPHIDConstants::PHID_TYPE_USER) { 145 + if ($type == PhabricatorPeoplePHIDTypeUser::TYPECONST) { 146 146 $explicit_cc[] = $relation['objectPHID']; 147 147 } 148 148 }
+4 -4
src/applications/differential/search/DifferentialSearchIndexer.php
··· 41 41 $doc->addRelationship( 42 42 PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, 43 43 $rev->getAuthorPHID(), 44 - PhabricatorPHIDConstants::PHID_TYPE_USER, 44 + PhabricatorPeoplePHIDTypeUser::TYPECONST, 45 45 $rev->getDateCreated()); 46 46 47 47 if ($rev->getStatus() != ArcanistDifferentialRevisionStatus::CLOSED && ··· 79 79 $doc->addRelationship( 80 80 PhabricatorSearchRelationship::RELATIONSHIP_TOUCH, 81 81 $touch, 82 - PhabricatorPHIDConstants::PHID_TYPE_USER, 82 + PhabricatorPeoplePHIDTypeUser::TYPECONST, 83 83 $time); 84 84 } 85 85 ··· 92 92 $doc->addRelationship( 93 93 PhabricatorSearchRelationship::RELATIONSHIP_OWNER, 94 94 $phid, 95 - PhabricatorPHIDConstants::PHID_TYPE_USER, 95 + PhabricatorPeoplePHIDTypeUser::TYPECONST, 96 96 $rev->getDateModified()); // Bogus timestamp. 97 97 } 98 98 } else { 99 99 $doc->addRelationship( 100 100 PhabricatorSearchRelationship::RELATIONSHIP_OWNER, 101 101 $rev->getAuthorPHID(), 102 - PhabricatorPHIDConstants::PHID_TYPE_USER, 102 + PhabricatorPeoplePHIDTypeUser::TYPECONST, 103 103 $rev->getDateCreated()); 104 104 } 105 105
+2 -2
src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php
··· 105 105 $owner_phid = $request->getValue('ownerPHID'); 106 106 if ($owner_phid !== null) { 107 107 $this->validatePHIDList(array($owner_phid), 108 - PhabricatorPHIDConstants::PHID_TYPE_USER, 108 + PhabricatorPeoplePHIDTypeUser::TYPECONST, 109 109 'ownerPHID'); 110 110 $changes[ManiphestTransactionType::TYPE_OWNER] = $owner_phid; 111 111 } ··· 113 113 $ccs = $request->getValue('ccPHIDs'); 114 114 if ($ccs !== null) { 115 115 $this->validatePHIDList($ccs, 116 - PhabricatorPHIDConstants::PHID_TYPE_USER, 116 + PhabricatorPeoplePHIDTypeUser::TYPECONST, 117 117 'ccPHIDS'); 118 118 $changes[ManiphestTransactionType::TYPE_CCS] = $ccs; 119 119 }
+3 -3
src/applications/maniphest/search/ManiphestSearchIndexer.php
··· 27 27 $doc->addRelationship( 28 28 PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, 29 29 $task->getAuthorPHID(), 30 - PhabricatorPHIDConstants::PHID_TYPE_USER, 30 + PhabricatorPeoplePHIDTypeUser::TYPECONST, 31 31 $task->getDateCreated()); 32 32 33 33 if ($task->getStatus() == ManiphestTaskStatus::STATUS_OPEN) { ··· 88 88 $doc->addRelationship( 89 89 PhabricatorSearchRelationship::RELATIONSHIP_OWNER, 90 90 $owner->getNewValue(), 91 - PhabricatorPHIDConstants::PHID_TYPE_USER, 91 + PhabricatorPeoplePHIDTypeUser::TYPECONST, 92 92 $owner->getDateCreated()); 93 93 } else { 94 94 $doc->addRelationship( ··· 104 104 $doc->addRelationship( 105 105 PhabricatorSearchRelationship::RELATIONSHIP_TOUCH, 106 106 $touch, 107 - PhabricatorPHIDConstants::PHID_TYPE_USER, 107 + PhabricatorPeoplePHIDTypeUser::TYPECONST, 108 108 $time); 109 109 } 110 110
+1 -1
src/applications/metamta/query/PhabricatorMetaMTAActorQuery.php
··· 33 33 34 34 foreach ($type_map as $type => $phids) { 35 35 switch ($type) { 36 - case PhabricatorPHIDConstants::PHID_TYPE_USER: 36 + case PhabricatorPeoplePHIDTypeUser::TYPECONST: 37 37 $this->loadUserActors($actors, $phids); 38 38 break; 39 39 case PhabricatorPeoplePHIDTypeExternal::TYPECONST:
+1 -1
src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php
··· 280 280 PhabricatorObjectHandle $handle, 281 281 $prefix) { 282 282 283 - if ($handle->getType() != PhabricatorPHIDConstants::PHID_TYPE_USER) { 283 + if ($handle->getType() != PhabricatorPeoplePHIDTypeUser::TYPECONST) { 284 284 // You must be a real user to get a private reply handler address. 285 285 return null; 286 286 }
+1 -1
src/applications/owners/conduit/ConduitAPI_owners_query_Method.php
··· 44 44 45 45 protected static function queryByOwner($owner) { 46 46 $is_valid_phid = 47 - phid_get_type($owner) == PhabricatorPHIDConstants::PHID_TYPE_USER || 47 + phid_get_type($owner) == PhabricatorPeoplePHIDTypeUser::TYPECONST || 48 48 phid_get_type($owner) == PhabricatorProjectPHIDTypeProject::TYPECONST; 49 49 50 50 if (!$is_valid_phid) {
+1 -1
src/applications/owners/storage/PhabricatorOwnersOwner.php
··· 38 38 $all_phids = phid_group_by_type(mpull($owners, 'getUserPHID')); 39 39 40 40 $user_phids = idx($all_phids, 41 - PhabricatorPHIDConstants::PHID_TYPE_USER, 41 + PhabricatorPeoplePHIDTypeUser::TYPECONST, 42 42 array()); 43 43 44 44 $users_in_project_phids = array();
+52
src/applications/people/phid/PhabricatorPeoplePHIDTypeUser.php
··· 1 + <?php 2 + 3 + final class PhabricatorPeoplePHIDTypeUser extends PhabricatorPHIDType { 4 + 5 + const TYPECONST = 'USER'; 6 + 7 + public function getTypeConstant() { 8 + return self::TYPECONST; 9 + } 10 + 11 + public function getTypeName() { 12 + return pht('Phabricator User'); 13 + } 14 + 15 + public function newObject() { 16 + return new PhabricatorUser(); 17 + } 18 + 19 + public function loadObjects( 20 + PhabricatorObjectQuery $query, 21 + array $phids) { 22 + 23 + return id(new PhabricatorPeopleQuery()) 24 + ->needProfileImage(true) 25 + ->needStatus(true) 26 + ->setViewer($query->getViewer()) 27 + ->withPHIDs($phids) 28 + ->execute(); 29 + } 30 + 31 + public function loadHandles( 32 + PhabricatorHandleQuery $query, 33 + array $handles, 34 + array $objects) { 35 + 36 + foreach ($handles as $phid => $handle) { 37 + $user = $objects[$phid]; 38 + $handle->setName($user->getUsername()); 39 + $handle->setURI('/p/'.$user->getUsername().'/'); 40 + $handle->setFullName( 41 + $user->getUsername().' ('.$user->getRealName().')'); 42 + $handle->setImageURI($user->loadProfileImageURI()); 43 + if ($user->hasStatus()) { 44 + $status = $user->getStatus(); 45 + $handle->setStatus($status->getTextStatus()); 46 + $handle->setTitle($status->getTerseSummary($query->getViewer())); 47 + } 48 + } 49 + 50 + } 51 + 52 + }
+18
src/applications/people/query/PhabricatorPeopleQuery.php
··· 18 18 private $needPrimaryEmail; 19 19 private $needProfile; 20 20 private $needProfileImage; 21 + private $needStatus; 21 22 22 23 public function withIDs(array $ids) { 23 24 $this->ids = $ids; ··· 89 90 return $this; 90 91 } 91 92 93 + public function needStatus($need) { 94 + $this->needStatus = $need; 95 + return $this; 96 + } 97 + 92 98 public function loadPage() { 93 99 $table = new PhabricatorUser(); 94 100 $conn_r = $table->establishConnection('r'); ··· 140 146 $profile_image_uri = PhabricatorUser::getDefaultProfileImageURI(); 141 147 } 142 148 $user->attachProfileImageURI($profile_image_uri); 149 + } 150 + } 151 + 152 + if ($this->needStatus) { 153 + $user_list = mpull($users, null, 'getPHID'); 154 + $statuses = id(new PhabricatorUserStatus())->loadCurrentStatuses( 155 + array_keys($user_list)); 156 + foreach ($user_list as $phid => $user) { 157 + $status = idx($statuses, $phid); 158 + if ($status) { 159 + $user->attachStatus($status); 160 + } 143 161 } 144 162 } 145 163
+2 -2
src/applications/people/search/PhabricatorUserSearchIndexer.php
··· 12 12 13 13 $doc = new PhabricatorSearchAbstractDocument(); 14 14 $doc->setPHID($user->getPHID()); 15 - $doc->setDocumentType(PhabricatorPHIDConstants::PHID_TYPE_USER); 15 + $doc->setDocumentType(PhabricatorPeoplePHIDTypeUser::TYPECONST); 16 16 $doc->setDocumentTitle($user->getUserName().' ('.$user->getRealName().')'); 17 17 $doc->setDocumentCreated($user->getDateCreated()); 18 18 $doc->setDocumentModified($user->getDateModified()); ··· 24 24 $doc->addRelationship( 25 25 PhabricatorSearchRelationship::RELATIONSHIP_OPEN, 26 26 $user->getPHID(), 27 - PhabricatorPHIDConstants::PHID_TYPE_USER, 27 + PhabricatorPeoplePHIDTypeUser::TYPECONST, 28 28 time()); 29 29 } 30 30
+16 -2
src/applications/people/storage/PhabricatorUser.php
··· 32 32 33 33 private $profileImage = null; 34 34 private $profile = null; 35 - private $status = null; 35 + private $status = self::ATTACHABLE; 36 36 private $preferences = null; 37 37 private $omnipotent = false; 38 38 private $customFields = array(); ··· 65 65 66 66 public function generatePHID() { 67 67 return PhabricatorPHID::generateNewPHID( 68 - PhabricatorPHIDConstants::PHID_TYPE_USER); 68 + PhabricatorPeoplePHIDTypeUser::TYPECONST); 69 69 } 70 70 71 71 public function setPassword(PhutilOpaqueEnvelope $envelope) { ··· 660 660 661 661 public static function getDefaultProfileImageURI() { 662 662 return celerity_get_resource_uri('/rsrc/image/avatar.png'); 663 + } 664 + 665 + public function attachStatus(PhabricatorUserStatus $status) { 666 + $this->status = $status; 667 + return $this; 668 + } 669 + 670 + public function getStatus() { 671 + $this->assertAttached($this->status); 672 + return $this->status; 673 + } 674 + 675 + public function hasStatus() { 676 + return $this->status !== self::ATTACHABLE; 663 677 } 664 678 665 679 public function attachProfileImageURI($uri) {
+1 -1
src/applications/people/storage/PhabricatorUserTransaction.php
··· 8 8 } 9 9 10 10 public function getApplicationTransactionType() { 11 - return PhabricatorPHIDConstants::PHID_TYPE_USER; 11 + return PhabricatorPeoplePHIDTypeUser::TYPECONST; 12 12 } 13 13 14 14 public function getApplicationTransactionCommentObject() {
+2 -6
src/applications/phid/PhabricatorObjectHandle.php
··· 107 107 return $this->getPHIDType()->getTypeName(); 108 108 } 109 109 110 - static $map = array( 111 - PhabricatorPHIDConstants::PHID_TYPE_USER => 'User', 112 - ); 113 - 114 - return idx($map, $this->getType(), $this->getType()); 110 + return $this->getType(); 115 111 } 116 112 117 113 ··· 201 197 202 198 public function getLinkName() { 203 199 switch ($this->getType()) { 204 - case PhabricatorPHIDConstants::PHID_TYPE_USER: 200 + case PhabricatorPeoplePHIDTypeUser::TYPECONST: 205 201 $name = $this->getName(); 206 202 break; 207 203 default:
-55
src/applications/phid/handle/PhabricatorObjectHandleData.php
··· 48 48 49 49 switch ($type) { 50 50 51 - case PhabricatorPHIDConstants::PHID_TYPE_USER: 52 - // TODO: Update query + Batch User Images 53 - $user_dao = new PhabricatorUser(); 54 - $users = $user_dao->loadAllWhere( 55 - 'phid in (%Ls)', 56 - $phids); 57 - return mpull($users, null, 'getPHID'); 58 - 59 51 case PhabricatorPHIDConstants::PHID_TYPE_APRJ: 60 52 $project_dao = new PhabricatorRepositoryArcanistProject(); 61 53 $projects = $project_dao->loadAllWhere( ··· 140 132 default: 141 133 $handle->setName('Foul Magicks'); 142 134 break; 143 - } 144 - $handles[$phid] = $handle; 145 - } 146 - break; 147 - 148 - case PhabricatorPHIDConstants::PHID_TYPE_USER: 149 - $image_phids = mpull($objects, 'getProfileImagePHID'); 150 - $image_phids = array_unique(array_filter($image_phids)); 151 - 152 - $images = array(); 153 - if ($image_phids) { 154 - $images = id(new PhabricatorFile())->loadAllWhere( 155 - 'phid IN (%Ls)', 156 - $image_phids); 157 - $images = mpull($images, 'getBestURI', 'getPHID'); 158 - } 159 - 160 - $statuses = id(new PhabricatorUserStatus())->loadCurrentStatuses( 161 - $phids); 162 - 163 - foreach ($phids as $phid) { 164 - $handle = new PhabricatorObjectHandle(); 165 - $handle->setPHID($phid); 166 - $handle->setType($type); 167 - if (empty($objects[$phid])) { 168 - $handle->setName('Unknown User'); 169 - } else { 170 - $user = $objects[$phid]; 171 - $handle->setName($user->getUsername()); 172 - $handle->setURI('/p/'.$user->getUsername().'/'); 173 - $handle->setFullName( 174 - $user->getUsername().' ('.$user->getRealName().')'); 175 - $handle->setComplete(true); 176 - if (isset($statuses[$phid])) { 177 - $handle->setStatus($statuses[$phid]->getTextStatus()); 178 - $handle->setTitle( 179 - $statuses[$phid]->getTerseSummary($this->viewer)); 180 - } 181 - $handle->setDisabled($user->getIsDisabled()); 182 - 183 - $img_uri = idx($images, $user->getProfileImagePHID()); 184 - if ($img_uri) { 185 - $handle->setImageURI($img_uri); 186 - } else { 187 - $handle->setImageURI( 188 - PhabricatorUser::getDefaultProfileImageURI()); 189 - } 190 135 } 191 136 $handles[$phid] = $handle; 192 137 }
+1 -1
src/applications/pholio/search/PholioSearchIndexer.php
··· 26 26 $doc->addRelationship( 27 27 PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, 28 28 $mock->getAuthorPHID(), 29 - PhabricatorPHIDConstants::PHID_TYPE_USER, 29 + PhabricatorPeoplePHIDTypeUser::TYPECONST, 30 30 $mock->getDateCreated()); 31 31 32 32 return $doc;
+1 -1
src/applications/phriction/search/PhrictionSearchIndexer.php
··· 34 34 $doc->addRelationship( 35 35 PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, 36 36 $content->getAuthorPHID(), 37 - PhabricatorPHIDConstants::PHID_TYPE_USER, 37 + PhabricatorPeoplePHIDTypeUser::TYPECONST, 38 38 $content->getDateCreated()); 39 39 40 40 if ($document->getStatus() == PhrictionDocumentStatus::STATUS_EXISTS) {
+2 -2
src/applications/policy/filter/PhabricatorPolicyFilter.php
··· 209 209 } else { 210 210 $this->rejectObject($object, $policy, $capability); 211 211 } 212 - } else if ($type == PhabricatorPHIDConstants::PHID_TYPE_USER) { 212 + } else if ($type == PhabricatorPeoplePHIDTypeUser::TYPECONST) { 213 213 if ($viewer->getPHID() == $policy) { 214 214 return true; 215 215 } else { ··· 271 271 if ($type == PhabricatorProjectPHIDTypeProject::TYPECONST) { 272 272 $who = "To {$verb} this object, you must be a member of project ". 273 273 "'".$handle->getFullName()."'."; 274 - } else if ($type == PhabricatorPHIDConstants::PHID_TYPE_USER) { 274 + } else if ($type == PhabricatorPeoplePHIDTypeUser::TYPECONST) { 275 275 $who = "Only '".$handle->getFullName()."' can {$verb} this object."; 276 276 } else { 277 277 $who = "It is unclear who can {$verb} this object.";
+1 -1
src/applications/ponder/search/PonderSearchIndexer.php
··· 26 26 $doc->addRelationship( 27 27 PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, 28 28 $question->getAuthorPHID(), 29 - PhabricatorPHIDConstants::PHID_TYPE_USER, 29 + PhabricatorPeoplePHIDTypeUser::TYPECONST, 30 30 $question->getDateCreated()); 31 31 32 32 $comments = $question->getComments();
+1 -1
src/applications/repository/search/PhabricatorRepositoryCommitSearchIndexer.php
··· 43 43 $doc->addRelationship( 44 44 PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, 45 45 $author_phid, 46 - PhabricatorPHIDConstants::PHID_TYPE_USER, 46 + PhabricatorPeoplePHIDTypeUser::TYPECONST, 47 47 $date_created); 48 48 } 49 49
+1 -1
src/applications/search/index/PhabricatorSearchAbstractDocument.php
··· 19 19 PhabricatorRepositoryPHIDTypeCommit::TYPECONST => 'Repository Commits', 20 20 ManiphestPHIDTypeTask::TYPECONST => 'Maniphest Tasks', 21 21 PhrictionPHIDTypeDocument::TYPECONST => 'Phriction Documents', 22 - PhabricatorPHIDConstants::PHID_TYPE_USER => 'Phabricator Users', 22 + PhabricatorPeoplePHIDTypeUser::TYPECONST => 'Phabricator Users', 23 23 PonderPHIDTypeQuestion::TYPECONST => 'Ponder Questions', 24 24 ); 25 25 }
+1 -1
src/applications/uiexample/examples/PhabricatorHovercardExample.php
··· 53 53 54 54 $user_handle = $this->createBasicDummyHandle( 55 55 'gwashington', 56 - PhabricatorPHIDConstants::PHID_TYPE_USER, 56 + PhabricatorPeoplePHIDTypeUser::TYPECONST, 57 57 'George Washington'); 58 58 $user_handle->setImageURI( 59 59 celerity_get_resource_uri('/rsrc/image/people/washington.png'));
-1
src/infrastructure/edges/constants/PhabricatorEdgeConfig.php
··· 154 154 } 155 155 156 156 static $class_map = array( 157 - PhabricatorPHIDConstants::PHID_TYPE_USER => 'PhabricatorUser', 158 157 PhabricatorPHIDConstants::PHID_TYPE_TOBJ => 'HarbormasterObject', 159 158 PhabricatorPHIDConstants::PHID_TYPE_ANSW => 'PonderAnswer', 160 159 PhabricatorPHIDConstants::PHID_TYPE_ACNT => 'PhortuneAccount',