Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/people/customfield/PhabricatorUserRealNameField.php
12256 views
1
<?php
2
3
final class PhabricatorUserRealNameField
4
extends PhabricatorUserCustomField {
5
6
private $value;
7
8
public function getFieldKey() {
9
return 'user:realname';
10
}
11
12
public function getModernFieldKey() {
13
return 'realName';
14
}
15
16
public function getFieldKeyForConduit() {
17
return $this->getModernFieldKey();
18
}
19
20
public function getFieldName() {
21
return pht('Real Name');
22
}
23
24
public function getFieldDescription() {
25
return pht('Stores the real name of the user, like "Abraham Lincoln".');
26
}
27
28
public function canDisableField() {
29
return false;
30
}
31
32
public function shouldAppearInApplicationTransactions() {
33
return true;
34
}
35
36
public function shouldAppearInEditView() {
37
return true;
38
}
39
40
public function readValueFromObject(PhabricatorCustomFieldInterface $object) {
41
$this->value = $object->getRealName();
42
}
43
44
public function getOldValueForApplicationTransactions() {
45
return $this->getObject()->getRealName();
46
}
47
48
public function getNewValueForApplicationTransactions() {
49
if (!$this->isEditable()) {
50
return $this->getObject()->getRealName();
51
}
52
return $this->value;
53
}
54
55
public function applyApplicationTransactionInternalEffects(
56
PhabricatorApplicationTransaction $xaction) {
57
$this->getObject()->setRealName($xaction->getNewValue());
58
}
59
60
public function readValueFromRequest(AphrontRequest $request) {
61
$this->value = $request->getStr($this->getFieldKey());
62
}
63
64
public function setValueFromStorage($value) {
65
$this->value = $value;
66
return $this;
67
}
68
69
public function renderEditControl(array $handles) {
70
return id(new AphrontFormTextControl())
71
->setName($this->getFieldKey())
72
->setValue($this->value)
73
->setLabel($this->getFieldName())
74
->setDisabled(!$this->isEditable());
75
}
76
77
private function isEditable() {
78
return PhabricatorEnv::getEnvConfig('account.editable');
79
}
80
81
public function shouldAppearInConduitTransactions() {
82
return true;
83
}
84
85
protected function newConduitEditParameterType() {
86
return new ConduitStringParameterType();
87
}
88
89
}
90
91