1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-22 12:41:19 +01:00
phorge-phorge/src/applications/people/customfield/PhabricatorUserTitleField.php
epriestley 06aa207960 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
2016-01-24 09:58:01 -08:00

60 lines
1.4 KiB
PHP

<?php
final class PhabricatorUserTitleField
extends PhabricatorUserCustomField {
private $value;
public function getFieldKey() {
return 'user:title';
}
public function getFieldName() {
return pht('Title');
}
public function getFieldDescription() {
return pht('User title, like "CEO" or "Assistant to the Manager".');
}
public function canDisableField() {
return false;
}
public function shouldAppearInApplicationTransactions() {
return true;
}
public function shouldAppearInEditView() {
return true;
}
public function readValueFromObject(PhabricatorCustomFieldInterface $object) {
$this->value = $object->loadUserProfile()->getTitle();
}
public function getOldValueForApplicationTransactions() {
return $this->getObject()->loadUserProfile()->getTitle();
}
public function getNewValueForApplicationTransactions() {
return $this->value;
}
public function applyApplicationTransactionInternalEffects(
PhabricatorApplicationTransaction $xaction) {
$this->getObject()->loadUserProfile()->setTitle($xaction->getNewValue());
}
public function readValueFromRequest(AphrontRequest $request) {
$this->value = $request->getStr($this->getFieldKey());
}
public function renderEditControl(array $handles) {
return id(new AphrontFormTextControl())
->setName($this->getFieldKey())
->setValue($this->value)
->setLabel($this->getFieldName());
}
}