Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/fund/editor/FundInitiativeEditEngine.php
12256 views
1
<?php
2
3
final class FundInitiativeEditEngine
4
extends PhabricatorEditEngine {
5
6
const ENGINECONST = 'fund.initiative';
7
8
public function getEngineName() {
9
return pht('Fund');
10
}
11
12
public function getEngineApplicationClass() {
13
return 'PhabricatorFundApplication';
14
}
15
16
public function getSummaryHeader() {
17
return pht('Configure Fund Forms');
18
}
19
20
public function getSummaryText() {
21
return pht('Configure creation and editing forms in Fund.');
22
}
23
24
public function isEngineConfigurable() {
25
return false;
26
}
27
28
protected function newEditableObject() {
29
return FundInitiative::initializeNewInitiative($this->getViewer());
30
}
31
32
protected function newObjectQuery() {
33
return new FundInitiativeQuery();
34
}
35
36
protected function getObjectCreateTitleText($object) {
37
return pht('Create New Initiative');
38
}
39
40
protected function getObjectEditTitleText($object) {
41
return pht('Edit Initiative: %s', $object->getName());
42
}
43
44
protected function getObjectEditShortText($object) {
45
return $object->getName();
46
}
47
48
protected function getObjectCreateShortText() {
49
return pht('Create Initiative');
50
}
51
52
protected function getObjectName() {
53
return pht('Initiative');
54
}
55
56
protected function getObjectCreateCancelURI($object) {
57
return $this->getApplication()->getApplicationURI('/');
58
}
59
60
protected function getEditorURI() {
61
return $this->getApplication()->getApplicationURI('edit/');
62
}
63
64
protected function getObjectViewURI($object) {
65
return $object->getViewURI();
66
}
67
68
protected function getCreateNewObjectPolicy() {
69
return $this->getApplication()->getPolicy(
70
FundCreateInitiativesCapability::CAPABILITY);
71
}
72
73
protected function buildCustomEditFields($object) {
74
$viewer = $this->getViewer();
75
$v_merchant = $object->getMerchantPHID();
76
77
$merchants = id(new PhortuneMerchantQuery())
78
->setViewer($viewer)
79
->requireCapabilities(
80
array(
81
PhabricatorPolicyCapability::CAN_VIEW,
82
PhabricatorPolicyCapability::CAN_EDIT,
83
))
84
->execute();
85
86
$merchant_options = array();
87
foreach ($merchants as $merchant) {
88
$merchant_options[$merchant->getPHID()] = pht(
89
'Merchant %d %s',
90
$merchant->getID(),
91
$merchant->getName());
92
}
93
94
if ($v_merchant && empty($merchant_options[$v_merchant])) {
95
$merchant_options = array(
96
$v_merchant => pht('(Restricted Merchant)'),
97
) + $merchant_options;
98
}
99
100
$merchant_instructions = null;
101
if (!$merchant_options) {
102
$merchant_instructions = pht(
103
'NOTE: You do not control any merchant accounts which can receive '.
104
'payments from this initiative. When you create an initiative, '.
105
'you need to specify a merchant account where funds will be paid '.
106
'to. Create a merchant account in the Phortune application before '.
107
'creating an initiative in Fund.');
108
}
109
110
return array(
111
id(new PhabricatorTextEditField())
112
->setKey('name')
113
->setLabel(pht('Name'))
114
->setDescription(pht('Initiative name.'))
115
->setConduitTypeDescription(pht('New initiative name.'))
116
->setTransactionType(
117
FundInitiativeNameTransaction::TRANSACTIONTYPE)
118
->setValue($object->getName())
119
->setIsRequired(true),
120
id(new PhabricatorSelectEditField())
121
->setKey('merchantPHID')
122
->setLabel(pht('Merchant'))
123
->setDescription(pht('Merchant operating the initiative.'))
124
->setConduitTypeDescription(pht('New initiative merchant.'))
125
->setControlInstructions($merchant_instructions)
126
->setValue($object->getMerchantPHID())
127
->setTransactionType(
128
FundInitiativeMerchantTransaction::TRANSACTIONTYPE)
129
->setOptions($merchant_options)
130
->setIsRequired(true),
131
id(new PhabricatorRemarkupEditField())
132
->setKey('description')
133
->setLabel(pht('Description'))
134
->setDescription(pht('Initiative long description.'))
135
->setConduitTypeDescription(pht('New initiative description.'))
136
->setTransactionType(
137
FundInitiativeDescriptionTransaction::TRANSACTIONTYPE)
138
->setValue($object->getDescription()),
139
id(new PhabricatorRemarkupEditField())
140
->setKey('risks')
141
->setLabel(pht('Risks/Challenges'))
142
->setDescription(pht('Initiative risks and challenges.'))
143
->setConduitTypeDescription(pht('Initiative risks and challenges.'))
144
->setTransactionType(
145
FundInitiativeRisksTransaction::TRANSACTIONTYPE)
146
->setValue($object->getRisks()),
147
148
);
149
150
}
151
152
}
153
154