Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/almanac/editor/AlmanacServiceEditor.php
12256 views
1
<?php
2
3
final class AlmanacServiceEditor
4
extends AlmanacEditor {
5
6
public function getEditorObjectsDescription() {
7
return pht('Almanac Service');
8
}
9
10
public function getCreateObjectTitle($author, $object) {
11
return pht('%s created this service.', $author);
12
}
13
14
public function getCreateObjectTitleForFeed($author, $object) {
15
return pht('%s created %s.', $author, $object);
16
}
17
18
public function getTransactionTypes() {
19
$types = parent::getTransactionTypes();
20
21
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
22
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
23
24
return $types;
25
}
26
27
protected function validateAllTransactions(
28
PhabricatorLiskDAO $object,
29
array $xactions) {
30
31
$errors = parent::validateAllTransactions($object, $xactions);
32
33
if ($object->isClusterService()) {
34
$can_manage = PhabricatorPolicyFilter::hasCapability(
35
$this->getActor(),
36
new PhabricatorAlmanacApplication(),
37
AlmanacManageClusterServicesCapability::CAPABILITY);
38
if (!$can_manage) {
39
$errors[] = new PhabricatorApplicationTransactionValidationError(
40
null,
41
pht('Restricted'),
42
pht('You do not have permission to manage cluster services.'),
43
null);
44
}
45
}
46
47
return $errors;
48
}
49
50
}
51
52