mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-06 05:36:13 +01:00
65904d7c51
Summary: Depends on D19576. Ref T13164. See PHI642. This adds an EditEngine for users and a `user.edit` modern API method. For now, all it supports is editing real name, blurb, title, and icon (same as "Edit Profile" from the UI). Test Plan: - Edited my stuff via the new API method. - Tried to edit another user, got rejected by policies. - Tried to create a user, got rejected by policies. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13164 Differential Revision: https://secure.phabricator.com/D19577
89 lines
2 KiB
PHP
89 lines
2 KiB
PHP
<?php
|
|
|
|
final class PhabricatorUserRealNameField
|
|
extends PhabricatorUserCustomField {
|
|
|
|
private $value;
|
|
|
|
public function getFieldKey() {
|
|
return 'user:realname';
|
|
}
|
|
|
|
public function getModernFieldKey() {
|
|
return 'realName';
|
|
}
|
|
|
|
public function getFieldKeyForConduit() {
|
|
return $this->getModernFieldKey();
|
|
}
|
|
|
|
public function getFieldName() {
|
|
return pht('Real Name');
|
|
}
|
|
|
|
public function getFieldDescription() {
|
|
return pht('Stores the real name of the user, like "Abraham Lincoln".');
|
|
}
|
|
|
|
public function canDisableField() {
|
|
return false;
|
|
}
|
|
|
|
public function shouldAppearInApplicationTransactions() {
|
|
return true;
|
|
}
|
|
|
|
public function shouldAppearInEditView() {
|
|
return true;
|
|
}
|
|
|
|
public function readValueFromObject(PhabricatorCustomFieldInterface $object) {
|
|
$this->value = $object->getRealName();
|
|
}
|
|
|
|
public function getOldValueForApplicationTransactions() {
|
|
return $this->getObject()->getRealName();
|
|
}
|
|
|
|
public function getNewValueForApplicationTransactions() {
|
|
if (!$this->isEditable()) {
|
|
return $this->getObject()->getRealName();
|
|
}
|
|
return $this->value;
|
|
}
|
|
|
|
public function applyApplicationTransactionInternalEffects(
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
$this->getObject()->setRealName($xaction->getNewValue());
|
|
}
|
|
|
|
public function readValueFromRequest(AphrontRequest $request) {
|
|
$this->value = $request->getStr($this->getFieldKey());
|
|
}
|
|
|
|
public function setValueFromStorage($value) {
|
|
$this->value = $value;
|
|
return $this;
|
|
}
|
|
|
|
public function renderEditControl(array $handles) {
|
|
return id(new AphrontFormTextControl())
|
|
->setName($this->getFieldKey())
|
|
->setValue($this->value)
|
|
->setLabel($this->getFieldName())
|
|
->setDisabled(!$this->isEditable());
|
|
}
|
|
|
|
private function isEditable() {
|
|
return PhabricatorEnv::getEnvConfig('account.editable');
|
|
}
|
|
|
|
public function shouldAppearInConduitTransactions() {
|
|
return true;
|
|
}
|
|
|
|
protected function newConduitEditParameterType() {
|
|
return new ConduitStringParameterType();
|
|
}
|
|
|
|
}
|