@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.

Allow users to have profile icons

Summary: Ref T10054. This primarily improves aesthetics and consistency for member/wathcher lists in projects.

Test Plan:
{F1068873}

{F1068874}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10054

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

+249 -8
+2
resources/sql/autopatches/20160124.people.1.icon.sql
··· 1 + ALTER TABLE {$NAMESPACE}_user.user_profile 2 + ADD icon VARCHAR(32) NOT NULL COLLATE {$COLLATE_TEXT};
+2
resources/sql/autopatches/20160124.people.2.icondefault.sql
··· 1 + UPDATE {$NAMESPACE}_user.user_profile 2 + SET icon = 'person' WHERE icon = '';
+4
src/__phutil_library_map__.php
··· 2737 2737 'PhabricatorPeopleEmpowerController' => 'applications/people/controller/PhabricatorPeopleEmpowerController.php', 2738 2738 'PhabricatorPeopleExternalPHIDType' => 'applications/people/phid/PhabricatorPeopleExternalPHIDType.php', 2739 2739 'PhabricatorPeopleHovercardEngineExtension' => 'applications/people/engineextension/PhabricatorPeopleHovercardEngineExtension.php', 2740 + 'PhabricatorPeopleIconSet' => 'applications/people/icon/PhabricatorPeopleIconSet.php', 2740 2741 'PhabricatorPeopleInviteController' => 'applications/people/controller/PhabricatorPeopleInviteController.php', 2741 2742 'PhabricatorPeopleInviteListController' => 'applications/people/controller/PhabricatorPeopleInviteListController.php', 2742 2743 'PhabricatorPeopleInviteSendController' => 'applications/people/controller/PhabricatorPeopleInviteSendController.php', ··· 3366 3367 'PhabricatorUserEmail' => 'applications/people/storage/PhabricatorUserEmail.php', 3367 3368 'PhabricatorUserEmailTestCase' => 'applications/people/storage/__tests__/PhabricatorUserEmailTestCase.php', 3368 3369 'PhabricatorUserFulltextEngine' => 'applications/people/search/PhabricatorUserFulltextEngine.php', 3370 + 'PhabricatorUserIconField' => 'applications/people/customfield/PhabricatorUserIconField.php', 3369 3371 'PhabricatorUserLog' => 'applications/people/storage/PhabricatorUserLog.php', 3370 3372 'PhabricatorUserLogView' => 'applications/people/view/PhabricatorUserLogView.php', 3371 3373 'PhabricatorUserPHIDResolver' => 'applications/phid/resolver/PhabricatorUserPHIDResolver.php', ··· 7102 7104 'PhabricatorPeopleEmpowerController' => 'PhabricatorPeopleController', 7103 7105 'PhabricatorPeopleExternalPHIDType' => 'PhabricatorPHIDType', 7104 7106 'PhabricatorPeopleHovercardEngineExtension' => 'PhabricatorHovercardEngineExtension', 7107 + 'PhabricatorPeopleIconSet' => 'PhabricatorIconSet', 7105 7108 'PhabricatorPeopleInviteController' => 'PhabricatorPeopleController', 7106 7109 'PhabricatorPeopleInviteListController' => 'PhabricatorPeopleInviteController', 7107 7110 'PhabricatorPeopleInviteSendController' => 'PhabricatorPeopleInviteController', ··· 7853 7856 'PhabricatorUserEmail' => 'PhabricatorUserDAO', 7854 7857 'PhabricatorUserEmailTestCase' => 'PhabricatorTestCase', 7855 7858 'PhabricatorUserFulltextEngine' => 'PhabricatorFulltextEngine', 7859 + 'PhabricatorUserIconField' => 'PhabricatorUserCustomField', 7856 7860 'PhabricatorUserLog' => array( 7857 7861 'PhabricatorUserDAO', 7858 7862 'PhabricatorPolicyInterface',
+1
src/applications/people/config/PhabricatorUserConfigOptions.php
··· 24 24 $default = array( 25 25 id(new PhabricatorUserRealNameField())->getFieldKey() => true, 26 26 id(new PhabricatorUserTitleField())->getFieldKey() => true, 27 + id(new PhabricatorUserIconField())->getFieldKey() => true, 27 28 id(new PhabricatorUserSinceField())->getFieldKey() => true, 28 29 id(new PhabricatorUserRolesField())->getFieldKey() => true, 29 30 id(new PhabricatorUserStatusField())->getFieldKey() => true,
+6 -1
src/applications/people/controller/PhabricatorPeopleProfileViewController.php
··· 27 27 $profile = $user->loadUserProfile(); 28 28 $picture = $user->getProfileImageURI(); 29 29 30 + $profile_icon = PhabricatorPeopleIconSet::getIconIcon($profile->getIcon()); 31 + $profile_icon = id(new PHUIIconView()) 32 + ->setIconFont($profile_icon.' grey'); 33 + $profile_title = $profile->getDisplayTitle(); 34 + 30 35 $header = id(new PHUIHeaderView()) 31 36 ->setHeader($user->getFullName()) 32 - ->setSubheader($profile->getTitle()) 37 + ->setSubheader(array($profile_icon, $profile_title)) 33 38 ->setImage($picture); 34 39 35 40 $actions = id(new PhabricatorActionListView())
+61
src/applications/people/customfield/PhabricatorUserIconField.php
··· 1 + <?php 2 + 3 + final class PhabricatorUserIconField 4 + extends PhabricatorUserCustomField { 5 + 6 + private $value; 7 + 8 + public function getFieldKey() { 9 + return 'user:icon'; 10 + } 11 + 12 + public function getFieldName() { 13 + return pht('Icon'); 14 + } 15 + 16 + public function getFieldDescription() { 17 + return pht('User icon to accompany their title.'); 18 + } 19 + 20 + public function canDisableField() { 21 + return false; 22 + } 23 + 24 + public function shouldAppearInApplicationTransactions() { 25 + return true; 26 + } 27 + 28 + public function shouldAppearInEditView() { 29 + return true; 30 + } 31 + 32 + public function readValueFromObject(PhabricatorCustomFieldInterface $object) { 33 + $this->value = $object->loadUserProfile()->getIcon(); 34 + } 35 + 36 + public function getOldValueForApplicationTransactions() { 37 + return $this->getObject()->loadUserProfile()->getIcon(); 38 + } 39 + 40 + public function getNewValueForApplicationTransactions() { 41 + return $this->value; 42 + } 43 + 44 + public function applyApplicationTransactionInternalEffects( 45 + PhabricatorApplicationTransaction $xaction) { 46 + $this->getObject()->loadUserProfile()->setIcon($xaction->getNewValue()); 47 + } 48 + 49 + public function readValueFromRequest(AphrontRequest $request) { 50 + $this->value = $request->getStr($this->getFieldKey()); 51 + } 52 + 53 + public function renderEditControl(array $handles) { 54 + return id(new PHUIFormIconSetControl()) 55 + ->setName($this->getFieldKey()) 56 + ->setValue($this->value) 57 + ->setLabel($this->getFieldName()) 58 + ->setIconSet(new PhabricatorPeopleIconSet()); 59 + } 60 + 61 + }
+1 -2
src/applications/people/customfield/PhabricatorUserTitleField.php
··· 54 54 return id(new AphrontFormTextControl()) 55 55 ->setName($this->getFieldKey()) 56 56 ->setValue($this->value) 57 - ->setLabel($this->getFieldName()) 58 - ->setCaption(pht('Serious business title.')); 57 + ->setLabel($this->getFieldName()); 59 58 } 60 59 61 60 }
+120
src/applications/people/icon/PhabricatorPeopleIconSet.php
··· 1 + <?php 2 + 3 + final class PhabricatorPeopleIconSet 4 + extends PhabricatorIconSet { 5 + 6 + const ICONSETKEY = 'people'; 7 + 8 + public function getSelectIconTitleText() { 9 + return pht('Choose User Icon'); 10 + } 11 + 12 + protected function newIcons() { 13 + $specifications = self::getIconSpecifications(); 14 + 15 + $icons = array(); 16 + foreach ($specifications as $spec) { 17 + $icons[] = id(new PhabricatorIconSetIcon()) 18 + ->setKey($spec['key']) 19 + ->setIcon($spec['icon']) 20 + ->setLabel($spec['name']); 21 + } 22 + 23 + return $icons; 24 + } 25 + 26 + public static function getDefaultIconKey() { 27 + $specifications = self::getIconSpecifications(); 28 + 29 + foreach ($specifications as $spec) { 30 + if (idx($spec, 'default')) { 31 + return $spec['key']; 32 + } 33 + } 34 + 35 + return null; 36 + } 37 + 38 + public static function getIconIcon($key) { 39 + $specifications = self::getIconSpecifications(); 40 + $map = ipull($specifications, 'icon', 'key'); 41 + return idx($map, $key); 42 + } 43 + 44 + public static function getIconName($key) { 45 + $specifications = self::getIconSpecifications(); 46 + $map = ipull($specifications, 'name', 'key'); 47 + return idx($map, $key); 48 + } 49 + 50 + private static function getIconSpecifications() { 51 + return self::getDefaultSpecifications(); 52 + } 53 + 54 + private static function getDefaultSpecifications() { 55 + return array( 56 + array( 57 + 'key' => 'person', 58 + 'icon' => 'fa-user', 59 + 'name' => pht('User'), 60 + 'default' => true, 61 + ), 62 + array( 63 + 'key' => 'engineering', 64 + 'icon' => 'fa-code', 65 + 'name' => pht('Engineering'), 66 + ), 67 + array( 68 + 'key' => 'operations', 69 + 'icon' => 'fa-space-shuttle', 70 + 'name' => pht('Operations'), 71 + ), 72 + array( 73 + 'key' => 'resources', 74 + 'icon' => 'fa-heart', 75 + 'name' => pht('Resources'), 76 + ), 77 + array( 78 + 'key' => 'relationships', 79 + 'icon' => 'fa-glass', 80 + 'name' => pht('Relationships'), 81 + ), 82 + array( 83 + 'key' => 'administration', 84 + 'icon' => 'fa-fax', 85 + 'name' => pht('Administration'), 86 + ), 87 + array( 88 + 'key' => 'security', 89 + 'icon' => 'fa-shield', 90 + 'name' => pht('Security'), 91 + ), 92 + array( 93 + 'key' => 'logistics', 94 + 'icon' => 'fa-truck', 95 + 'name' => pht('Logistics'), 96 + ), 97 + array( 98 + 'key' => 'research', 99 + 'icon' => 'fa-flask', 100 + 'name' => pht('Research'), 101 + ), 102 + array( 103 + 'key' => 'analysis', 104 + 'icon' => 'fa-bar-chart-o', 105 + 'name' => pht('Analysis'), 106 + ), 107 + array( 108 + 'key' => 'executive', 109 + 'icon' => 'fa-angle-double-up', 110 + 'name' => pht('Executive'), 111 + ), 112 + array( 113 + 'key' => 'animal', 114 + 'icon' => 'fa-paw', 115 + 'name' => pht('Animal'), 116 + ), 117 + ); 118 + } 119 + 120 + }
+10
src/applications/people/phid/PhabricatorPeopleUserPHIDType.php
··· 26 26 27 27 return id(new PhabricatorPeopleQuery()) 28 28 ->withPHIDs($phids) 29 + ->needProfile(true) 29 30 ->needProfileImage(true) 30 31 ->needAvailability(true); 31 32 } ··· 46 47 47 48 if ($user->getIsMailingList()) { 48 49 $handle->setIcon('fa-envelope-o'); 50 + $handle->setSubtitle(pht('Mailing List')); 51 + } else { 52 + $profile = $user->getUserProfile(); 53 + $icon_key = $profile->getIcon(); 54 + $icon_icon = PhabricatorPeopleIconSet::getIconIcon($icon_key); 55 + $subtitle = $profile->getDisplayTitle(); 56 + 57 + $handle->setIcon($icon_icon); 58 + $handle->setSubtitle($subtitle); 49 59 } 50 60 51 61 $availability = null;
+4 -3
src/applications/people/query/PhabricatorPeopleQuery.php
··· 138 138 if ($this->needProfile) { 139 139 $user_list = mpull($users, null, 'getPHID'); 140 140 $profiles = new PhabricatorUserProfile(); 141 - $profiles = $profiles->loadAllWhere('userPHID IN (%Ls)', 141 + $profiles = $profiles->loadAllWhere( 142 + 'userPHID IN (%Ls)', 142 143 array_keys($user_list)); 143 144 144 145 $profiles = mpull($profiles, null, 'getUserPHID'); 145 146 foreach ($user_list as $user_phid => $user) { 146 147 $profile = idx($profiles, $user_phid); 148 + 147 149 if (!$profile) { 148 - $profile = new PhabricatorUserProfile(); 149 - $profile->setUserPHID($user_phid); 150 + $profile = PhabricatorUserProfile::initializeNewProfile($user); 150 151 } 151 152 152 153 $user->attachUserProfile($profile);
+1 -2
src/applications/people/storage/PhabricatorUser.php
··· 451 451 $this->getPHID()); 452 452 453 453 if (!$this->profile) { 454 - $profile_dao->setUserPHID($this->getPHID()); 455 - $this->profile = $profile_dao; 454 + $this->profile = PhabricatorUserProfile::initializeNewProfile($this); 456 455 } 457 456 458 457 return $this->profile;
+20
src/applications/people/storage/PhabricatorUserProfile.php
··· 6 6 protected $title; 7 7 protected $blurb; 8 8 protected $profileImagePHID; 9 + protected $icon; 10 + 11 + public static function initializeNewProfile(PhabricatorUser $user) { 12 + $default_icon = PhabricatorPeopleIconSet::getDefaultIconKey(); 13 + 14 + return id(new self()) 15 + ->setUserPHID($user->getPHID()) 16 + ->setIcon($default_icon); 17 + } 9 18 10 19 protected function getConfiguration() { 11 20 return array( ··· 13 22 'title' => 'text255', 14 23 'blurb' => 'text', 15 24 'profileImagePHID' => 'phid?', 25 + 'icon' => 'text32', 16 26 ), 17 27 self::CONFIG_KEY_SCHEMA => array( 18 28 'userPHID' => array( ··· 21 31 ), 22 32 ), 23 33 ) + parent::getConfiguration(); 34 + } 35 + 36 + public function getDisplayTitle() { 37 + $title = $this->getTitle(); 38 + if (strlen($title)) { 39 + return $title; 40 + } 41 + 42 + $icon_key = $this->getIcon(); 43 + return PhabricatorPeopleIconSet::getIconName($icon_key); 24 44 } 25 45 26 46 }
+10
src/applications/phid/PhabricatorObjectHandle.php
··· 27 27 private $complete; 28 28 private $objectName; 29 29 private $policyFiltered; 30 + private $subtitle; 30 31 31 32 public function setIcon($icon) { 32 33 $this->icon = $icon; ··· 42 43 return $this->icon; 43 44 } 44 45 return $this->getTypeIcon(); 46 + } 47 + 48 + public function setSubtitle($subtitle) { 49 + $this->subtitle = $subtitle; 50 + return $this; 51 + } 52 + 53 + public function getSubtitle() { 54 + return $this->subtitle; 45 55 } 46 56 47 57 public function setTagColor($color) {
+7
src/applications/project/view/PhabricatorProjectUserListView.php
··· 79 79 ->setHref($handle->getURI()) 80 80 ->setImageURI($handle->getImageURI()); 81 81 82 + $icon = id(new PHUIIconView()) 83 + ->setIconFont($handle->getIcon().' grey'); 84 + 85 + $subtitle = $handle->getSubtitle(); 86 + 87 + $item->addAttribute(array($icon, ' ', $subtitle)); 88 + 82 89 if ($can_edit && !$limit) { 83 90 $remove_uri = $this->getRemoveURI($user_phid); 84 91