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

Add "Title" and "Blurb" to new profile editor

Summary:
Ref T1703.

- Adds "Title".
- Adds "Blurb".
- Adds `user.fields` config for selecting and reordering. This will get UI in the next patch.

Test Plan:
{F45689}

{F45690}

Edited the fields, too.

Reviewers: chad

Reviewed By: chad

CC: aran

Maniphest Tasks: T1703

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

+142 -2
+6
src/__phutil_library_map__.php
··· 1544 1544 'PhabricatorUITooltipExample' => 'applications/uiexample/examples/PhabricatorUITooltipExample.php', 1545 1545 'PhabricatorUnitsTestCase' => 'view/__tests__/PhabricatorUnitsTestCase.php', 1546 1546 'PhabricatorUser' => 'applications/people/storage/PhabricatorUser.php', 1547 + 'PhabricatorUserBlurbField' => 'applications/people/customfield/PhabricatorUserBlurbField.php', 1548 + 'PhabricatorUserConfigOptions' => 'applications/people/config/PhabricatorUserConfigOptions.php', 1547 1549 'PhabricatorUserCustomField' => 'applications/people/customfield/PhabricatorUserCustomField.php', 1548 1550 'PhabricatorUserCustomFieldInterface' => 'applications/people/customfield/PhabricatorUserCustomFieldInterface.php', 1549 1551 'PhabricatorUserDAO' => 'applications/people/storage/PhabricatorUserDAO.php', ··· 1562 1564 'PhabricatorUserStatusInvalidEpochException' => 'applications/people/exception/PhabricatorUserStatusInvalidEpochException.php', 1563 1565 'PhabricatorUserStatusOverlapException' => 'applications/people/exception/PhabricatorUserStatusOverlapException.php', 1564 1566 'PhabricatorUserTestCase' => 'applications/people/storage/__tests__/PhabricatorUserTestCase.php', 1567 + 'PhabricatorUserTitleField' => 'applications/people/customfield/PhabricatorUserTitleField.php', 1565 1568 'PhabricatorUserTransaction' => 'applications/people/storage/PhabricatorUserTransaction.php', 1566 1569 'PhabricatorWorkboardExample' => 'applications/uiexample/examples/PhabricatorWorkboardExample.php', 1567 1570 'PhabricatorWorkboardView' => 'view/layout/PhabricatorWorkboardView.php', ··· 3385 3388 2 => 'PhabricatorPolicyInterface', 3386 3389 3 => 'PhabricatorCustomFieldInterface', 3387 3390 ), 3391 + 'PhabricatorUserBlurbField' => 'PhabricatorUserCustomField', 3392 + 'PhabricatorUserConfigOptions' => 'PhabricatorApplicationConfigOptions', 3388 3393 'PhabricatorUserCustomField' => 3389 3394 array( 3390 3395 0 => 'PhabricatorCustomField', ··· 3406 3411 'PhabricatorUserStatusInvalidEpochException' => 'Exception', 3407 3412 'PhabricatorUserStatusOverlapException' => 'Exception', 3408 3413 'PhabricatorUserTestCase' => 'PhabricatorTestCase', 3414 + 'PhabricatorUserTitleField' => 'PhabricatorUserCustomField', 3409 3415 'PhabricatorUserTransaction' => 'PhabricatorApplicationTransaction', 3410 3416 'PhabricatorWorkboardExample' => 'PhabricatorUIExample', 3411 3417 'PhabricatorWorkboardView' => 'AphrontView',
+34
src/applications/people/config/PhabricatorUserConfigOptions.php
··· 1 + <?php 2 + 3 + final class PhabricatorUserConfigOptions 4 + extends PhabricatorApplicationConfigOptions { 5 + 6 + public function getName() { 7 + return pht("User Profiles"); 8 + } 9 + 10 + public function getDescription() { 11 + return pht("User profiles configuration."); 12 + } 13 + 14 + public function getOptions() { 15 + 16 + $default = array( 17 + id(new PhabricatorUserRealNameField())->getFieldKey() => true, 18 + id(new PhabricatorUserTitleField())->getFieldKey() => true, 19 + id(new PhabricatorUserBlurbField())->getFieldKey() => true, 20 + ); 21 + 22 + foreach ($default as $key => $enabled) { 23 + $default[$key] = array( 24 + 'disabled' => !$enabled, 25 + ); 26 + } 27 + 28 + return array( 29 + $this->newOption('user.fields', 'wild', $default) 30 + ->setDescription(pht("Select and reorder user profile fields.")), 31 + ); 32 + } 33 + 34 + }
+48
src/applications/people/customfield/PhabricatorUserBlurbField.php
··· 1 + <?php 2 + 3 + final class PhabricatorUserBlurbField 4 + extends PhabricatorUserCustomField { 5 + 6 + private $value; 7 + 8 + public function getFieldKey() { 9 + return 'user:blurb'; 10 + } 11 + 12 + public function getFieldName() { 13 + return pht('Blurb'); 14 + } 15 + 16 + public function getFieldDescription() { 17 + return pht('Short user summary.'); 18 + } 19 + 20 + protected function didSetObject(PhabricatorCustomFieldInterface $object) { 21 + $this->value = $object->loadUserProfile()->getBlurb(); 22 + } 23 + 24 + public function getOldValueForApplicationTransactions() { 25 + return $this->getObject()->loadUserProfile()->getBlurb(); 26 + } 27 + 28 + public function getNewValueForApplicationTransactions() { 29 + return $this->value; 30 + } 31 + 32 + public function applyApplicationTransactionInternalEffects( 33 + PhabricatorApplicationTransaction $xaction) { 34 + $this->getObject()->loadUserProfile()->setBlurb($xaction->getNewValue()); 35 + } 36 + 37 + public function setValueFromRequest(AphrontRequest $request) { 38 + $this->value = $request->getStr($this->getFieldKey()); 39 + } 40 + 41 + public function renderEditControl() { 42 + return id(new PhabricatorRemarkupControl()) 43 + ->setName($this->getFieldKey()) 44 + ->setValue($this->value) 45 + ->setLabel($this->getFieldName()); 46 + } 47 + 48 + }
+49
src/applications/people/customfield/PhabricatorUserTitleField.php
··· 1 + <?php 2 + 3 + final class PhabricatorUserTitleField 4 + extends PhabricatorUserCustomField { 5 + 6 + private $value; 7 + 8 + public function getFieldKey() { 9 + return 'user:title'; 10 + } 11 + 12 + public function getFieldName() { 13 + return pht('Title'); 14 + } 15 + 16 + public function getFieldDescription() { 17 + return pht('User title, like "CEO" or "Assistant to the Manager".'); 18 + } 19 + 20 + protected function didSetObject(PhabricatorCustomFieldInterface $object) { 21 + $this->value = $object->loadUserProfile()->getTitle(); 22 + } 23 + 24 + public function getOldValueForApplicationTransactions() { 25 + return $this->getObject()->loadUserProfile()->getTitle(); 26 + } 27 + 28 + public function getNewValueForApplicationTransactions() { 29 + return $this->value; 30 + } 31 + 32 + public function applyApplicationTransactionInternalEffects( 33 + PhabricatorApplicationTransaction $xaction) { 34 + $this->getObject()->loadUserProfile()->setTitle($xaction->getNewValue()); 35 + } 36 + 37 + public function setValueFromRequest(AphrontRequest $request) { 38 + $this->value = $request->getStr($this->getFieldKey()); 39 + } 40 + 41 + public function renderEditControl() { 42 + return id(new AphrontFormTextControl()) 43 + ->setName($this->getFieldKey()) 44 + ->setValue($this->value) 45 + ->setLabel($this->getFieldName()) 46 + ->setCaption(pht('Serious business title.')); 47 + } 48 + 49 + }
+5 -2
src/applications/people/storage/PhabricatorUser.php
··· 113 113 } 114 114 $result = parent::save(); 115 115 116 + if ($this->profile) { 117 + $this->profile->save(); 118 + } 119 + 116 120 $this->updateNameTokens(); 117 121 118 122 id(new PhabricatorSearchIndexer()) ··· 764 768 765 769 766 770 public function getCustomFieldSpecificationForRole($role) { 767 - return array(); 768 - // TODO: PhabricatorEnv::getEnvConfig('user.fields'); 771 + return PhabricatorEnv::getEnvConfig('user.fields'); 769 772 } 770 773 771 774 public function getCustomFieldBaseClass() {