Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/passphrase/policyrule/PassphraseCredentialAuthorPolicyRule.php
12256 views
1
<?php
2
3
final class PassphraseCredentialAuthorPolicyRule
4
extends PhabricatorPolicyRule {
5
6
public function getObjectPolicyKey() {
7
return 'passphrase.author';
8
}
9
10
public function getObjectPolicyName() {
11
return pht('Credential Author');
12
}
13
14
public function getPolicyExplanation() {
15
return pht('The author of this credential can take this action.');
16
}
17
18
public function getRuleDescription() {
19
return pht('credential author');
20
}
21
22
public function canApplyToObject(PhabricatorPolicyInterface $object) {
23
return ($object instanceof PassphraseCredential);
24
}
25
26
public function applyRule(
27
PhabricatorUser $viewer,
28
$value,
29
PhabricatorPolicyInterface $object) {
30
31
$author_phid = $object->getAuthorPHID();
32
if (!$author_phid) {
33
return false;
34
}
35
36
$viewer_phid = $viewer->getPHID();
37
if (!$viewer_phid) {
38
return false;
39
}
40
41
return ($viewer_phid == $author_phid);
42
}
43
44
public function getValueControlType() {
45
return self::CONTROL_TYPE_NONE;
46
}
47
48
}
49
50