Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php
12256 views
1
<?php
2
3
final class PhabricatorAuthProviderConfigTransaction
4
extends PhabricatorApplicationTransaction {
5
6
const TYPE_ENABLE = 'config:enable';
7
const TYPE_LOGIN = 'config:login';
8
const TYPE_REGISTRATION = 'config:registration';
9
const TYPE_LINK = 'config:link';
10
const TYPE_UNLINK = 'config:unlink';
11
const TYPE_TRUST_EMAILS = 'config:trustEmails';
12
const TYPE_AUTO_LOGIN = 'config:autoLogin';
13
const TYPE_PROPERTY = 'config:property';
14
15
const PROPERTY_KEY = 'auth:property';
16
17
public function getProvider() {
18
return $this->getObject()->getProvider();
19
}
20
21
public function getApplicationName() {
22
return 'auth';
23
}
24
25
public function getApplicationTransactionType() {
26
return PhabricatorAuthAuthProviderPHIDType::TYPECONST;
27
}
28
29
public function getIcon() {
30
$old = $this->getOldValue();
31
$new = $this->getNewValue();
32
33
switch ($this->getTransactionType()) {
34
case self::TYPE_ENABLE:
35
if ($new) {
36
return 'fa-check';
37
} else {
38
return 'fa-ban';
39
}
40
}
41
42
return parent::getIcon();
43
}
44
45
public function getColor() {
46
$old = $this->getOldValue();
47
$new = $this->getNewValue();
48
49
switch ($this->getTransactionType()) {
50
case self::TYPE_ENABLE:
51
if ($new) {
52
return 'green';
53
} else {
54
return 'indigo';
55
}
56
}
57
58
return parent::getColor();
59
}
60
61
public function getTitle() {
62
$author_phid = $this->getAuthorPHID();
63
64
$old = $this->getOldValue();
65
$new = $this->getNewValue();
66
67
switch ($this->getTransactionType()) {
68
case self::TYPE_ENABLE:
69
if ($old === null) {
70
return pht(
71
'%s created this provider.',
72
$this->renderHandleLink($author_phid));
73
} else if ($new) {
74
return pht(
75
'%s enabled this provider.',
76
$this->renderHandleLink($author_phid));
77
} else {
78
return pht(
79
'%s disabled this provider.',
80
$this->renderHandleLink($author_phid));
81
}
82
break;
83
case self::TYPE_LOGIN:
84
if ($new) {
85
return pht(
86
'%s enabled login.',
87
$this->renderHandleLink($author_phid));
88
} else {
89
return pht(
90
'%s disabled login.',
91
$this->renderHandleLink($author_phid));
92
}
93
break;
94
case self::TYPE_REGISTRATION:
95
if ($new) {
96
return pht(
97
'%s enabled registration.',
98
$this->renderHandleLink($author_phid));
99
} else {
100
return pht(
101
'%s disabled registration.',
102
$this->renderHandleLink($author_phid));
103
}
104
break;
105
case self::TYPE_LINK:
106
if ($new) {
107
return pht(
108
'%s enabled account linking.',
109
$this->renderHandleLink($author_phid));
110
} else {
111
return pht(
112
'%s disabled account linking.',
113
$this->renderHandleLink($author_phid));
114
}
115
break;
116
case self::TYPE_UNLINK:
117
if ($new) {
118
return pht(
119
'%s enabled account unlinking.',
120
$this->renderHandleLink($author_phid));
121
} else {
122
return pht(
123
'%s disabled account unlinking.',
124
$this->renderHandleLink($author_phid));
125
}
126
break;
127
case self::TYPE_TRUST_EMAILS:
128
if ($new) {
129
return pht(
130
'%s enabled email trust.',
131
$this->renderHandleLink($author_phid));
132
} else {
133
return pht(
134
'%s disabled email trust.',
135
$this->renderHandleLink($author_phid));
136
}
137
break;
138
case self::TYPE_AUTO_LOGIN:
139
if ($new) {
140
return pht(
141
'%s enabled auto login.',
142
$this->renderHandleLink($author_phid));
143
} else {
144
return pht(
145
'%s disabled auto login.',
146
$this->renderHandleLink($author_phid));
147
}
148
break;
149
case self::TYPE_PROPERTY:
150
$provider = $this->getProvider();
151
if ($provider) {
152
$title = $provider->renderConfigPropertyTransactionTitle($this);
153
if (strlen($title)) {
154
return $title;
155
}
156
}
157
158
return pht(
159
'%s edited a property of this provider.',
160
$this->renderHandleLink($author_phid));
161
break;
162
}
163
164
return parent::getTitle();
165
}
166
167
}
168
169