Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/people/editor/PhabricatorUserEditEngine.php
12256 views
1
<?php
2
3
final class PhabricatorUserEditEngine
4
extends PhabricatorEditEngine {
5
6
const ENGINECONST = 'people.user';
7
8
public function isEngineConfigurable() {
9
return false;
10
}
11
12
public function getEngineName() {
13
return pht('Users');
14
}
15
16
public function getSummaryHeader() {
17
return pht('Configure User Forms');
18
}
19
20
public function getSummaryText() {
21
return pht('Configure creation and editing forms for users.');
22
}
23
24
public function getEngineApplicationClass() {
25
return 'PhabricatorPeopleApplication';
26
}
27
28
protected function newEditableObject() {
29
return new PhabricatorUser();
30
}
31
32
protected function newObjectQuery() {
33
return id(new PhabricatorPeopleQuery());
34
}
35
36
protected function getObjectCreateTitleText($object) {
37
return pht('Create New User');
38
}
39
40
protected function getObjectEditTitleText($object) {
41
return pht('Edit User: %s', $object->getUsername());
42
}
43
44
protected function getObjectEditShortText($object) {
45
return $object->getMonogram();
46
}
47
48
protected function getObjectCreateShortText() {
49
return pht('Create User');
50
}
51
52
protected function getObjectName() {
53
return pht('User');
54
}
55
56
protected function getObjectViewURI($object) {
57
return $object->getURI();
58
}
59
60
protected function getCreateNewObjectPolicy() {
61
// At least for now, forbid creating new users via EditEngine. This is
62
// primarily enforcing that "user.edit" can not create users via the API.
63
return PhabricatorPolicies::POLICY_NOONE;
64
}
65
66
protected function buildCustomEditFields($object) {
67
return array(
68
id(new PhabricatorBoolEditField())
69
->setKey('disabled')
70
->setOptions(pht('Active'), pht('Disabled'))
71
->setLabel(pht('Disabled'))
72
->setDescription(pht('Disable the user.'))
73
->setTransactionType(PhabricatorUserDisableTransaction::TRANSACTIONTYPE)
74
->setIsFormField(false)
75
->setConduitDescription(pht('Disable or enable the user.'))
76
->setConduitTypeDescription(pht('True to disable the user.'))
77
->setValue($object->getIsDisabled()),
78
id(new PhabricatorBoolEditField())
79
->setKey('approved')
80
->setOptions(pht('Approved'), pht('Unapproved'))
81
->setLabel(pht('Approved'))
82
->setDescription(pht('Approve the user.'))
83
->setTransactionType(PhabricatorUserApproveTransaction::TRANSACTIONTYPE)
84
->setIsFormField(false)
85
->setConduitDescription(pht('Approve or reject the user.'))
86
->setConduitTypeDescription(pht('True to approve the user.'))
87
->setValue($object->getIsApproved()),
88
);
89
}
90
91
}
92
93