3 final class PhabricatorStandardCustomFieldCredential
4 extends PhabricatorStandardCustomField
{
6 public function getFieldType() {
10 public function buildFieldIndexes() {
13 $value = $this->getFieldValue();
15 $indexes[] = $this->newStringIndex($value);
21 public function renderEditControl(array $handles) {
22 $provides_type = $this->getFieldConfigValue('credential.provides');
23 $credential_type = $this->getFieldConfigValue('credential.type');
25 $all_types = PassphraseCredentialType
::getAllProvidesTypes();
26 if (!in_array($provides_type, $all_types)) {
27 $provides_type = PassphrasePasswordCredentialType
::PROVIDES_TYPE
;
30 $credentials = id(new PassphraseCredentialQuery())
31 ->setViewer($this->getViewer())
32 ->withIsDestroyed(false)
33 ->withProvidesTypes(array($provides_type))
36 return id(new PassphraseCredentialControl())
37 ->setViewer($this->getViewer())
38 ->setLabel($this->getFieldName())
39 ->setName($this->getFieldKey())
40 ->setCaption($this->getCaption())
41 ->setAllowNull(!$this->getRequired())
42 ->setCredentialType($credential_type)
43 ->setValue($this->getFieldValue())
44 ->setError($this->getFieldError())
45 ->setOptions($credentials);
48 public function getRequiredHandlePHIDsForPropertyView() {
49 $value = $this->getFieldValue();
56 public function renderPropertyViewValue(array $handles) {
57 $value = $this->getFieldValue();
59 return $handles[$value]->renderLink();
64 public function validateApplicationTransactions(
65 PhabricatorApplicationTransactionEditor
$editor,
69 $errors = parent
::validateApplicationTransactions(
74 $ok = PassphraseCredentialControl
::validateTransactions(
79 foreach ($xactions as $xaction) {
80 $errors[] = new PhabricatorApplicationTransactionValidationError(
84 'The selected credential does not exist, or you do not have '.
85 'permission to use it.'),
87 $this->setFieldError(pht('Invalid'));
94 public function getApplicationTransactionRequiredHandlePHIDs(
95 PhabricatorApplicationTransaction
$xaction) {
97 $old = $xaction->getOldValue();
98 $new = $xaction->getNewValue();
109 public function getApplicationTransactionTitle(
110 PhabricatorApplicationTransaction
$xaction) {
111 $author_phid = $xaction->getAuthorPHID();
113 $old = $xaction->getOldValue();
114 $new = $xaction->getNewValue();
118 '%s removed %s as %s.',
119 $xaction->renderHandleLink($author_phid),
120 $xaction->renderHandleLink($old),
121 $this->getFieldName());
122 } else if ($new && !$old) {
125 $xaction->renderHandleLink($author_phid),
126 $this->getFieldName(),
127 $xaction->renderHandleLink($new));
130 '%s changed %s from %s to %s.',
131 $xaction->renderHandleLink($author_phid),
132 $this->getFieldName(),
133 $xaction->renderHandleLink($old),
134 $xaction->renderHandleLink($new));
139 protected function getHTTPParameterType() {
140 return new AphrontPHIDHTTPParameterType();
143 protected function newConduitSearchParameterType() {
144 return new ConduitPHIDParameterType();
147 protected function newConduitEditParameterType() {
148 return new ConduitPHIDParameterType();