Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F72596959
PhabricatorStandardCustomFieldCredential.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Jul 16, 01:53
Size
3 KB
Mime Type
text/x-php
Expires
Thu, Jul 18, 01:53 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
19075249
Attached To
rPH Phabricator
PhabricatorStandardCustomFieldCredential.php
View Options
<?php
final
class
PhabricatorStandardCustomFieldCredential
extends
PhabricatorStandardCustomField
{
public
function
getFieldType
()
{
return
'credential'
;
}
public
function
buildFieldIndexes
()
{
$indexes
=
array
();
$value
=
$this
->
getFieldValue
();
if
(
strlen
(
$value
))
{
$indexes
[]
=
$this
->
newStringIndex
(
$value
);
}
return
$indexes
;
}
public
function
renderEditControl
(
array
$handles
)
{
$provides_type
=
$this
->
getFieldConfigValue
(
'credential.provides'
);
$credential_type
=
$this
->
getFieldConfigValue
(
'credential.type'
);
$all_types
=
PassphraseCredentialType
::
getAllProvidesTypes
();
if
(!
in_array
(
$provides_type
,
$all_types
))
{
$provides_type
=
PassphrasePasswordCredentialType
::
PROVIDES_TYPE
;
}
$credentials
=
id
(
new
PassphraseCredentialQuery
())
->
setViewer
(
$this
->
getViewer
())
->
withIsDestroyed
(
false
)
->
withProvidesTypes
(
array
(
$provides_type
))
->
execute
();
return
id
(
new
PassphraseCredentialControl
())
->
setLabel
(
$this
->
getFieldName
())
->
setName
(
$this
->
getFieldKey
())
->
setCaption
(
$this
->
getCaption
())
->
setAllowNull
(!
$this
->
getRequired
())
->
setCredentialType
(
$credential_type
)
->
setValue
(
$this
->
getFieldValue
())
->
setError
(
$this
->
getFieldError
())
->
setOptions
(
$credentials
);
}
public
function
getRequiredHandlePHIDsForPropertyView
()
{
$value
=
$this
->
getFieldValue
();
if
(
$value
)
{
return
array
(
$value
);
}
return
array
();
}
public
function
renderPropertyViewValue
(
array
$handles
)
{
$value
=
$this
->
getFieldValue
();
if
(
$value
)
{
return
$handles
[
$value
]->
renderLink
();
}
return
null
;
}
public
function
validateApplicationTransactions
(
PhabricatorApplicationTransactionEditor
$editor
,
$type
,
array
$xactions
)
{
$errors
=
parent
::
validateApplicationTransactions
(
$editor
,
$type
,
$xactions
);
$ok
=
PassphraseCredentialControl
::
validateTransactions
(
$this
->
getViewer
(),
$xactions
);
if
(!
$ok
)
{
foreach
(
$xactions
as
$xaction
)
{
$errors
[]
=
new
PhabricatorApplicationTransactionValidationError
(
$type
,
pht
(
'Invalid'
),
pht
(
'The selected credential does not exist, or you do not have '
.
'permission to use it.'
),
$xaction
);
$this
->
setFieldError
(
pht
(
'Invalid'
));
}
}
return
$errors
;
}
public
function
getApplicationTransactionRequiredHandlePHIDs
(
PhabricatorApplicationTransaction
$xaction
)
{
$phids
=
array
();
$old
=
$xaction
->
getOldValue
();
$new
=
$xaction
->
getNewValue
();
if
(
$old
)
{
$phids
[]
=
$old
;
}
if
(
$new
)
{
$phids
[]
=
$new
;
}
return
$phids
;
}
public
function
getApplicationTransactionTitle
(
PhabricatorApplicationTransaction
$xaction
)
{
$author_phid
=
$xaction
->
getAuthorPHID
();
$old
=
$xaction
->
getOldValue
();
$new
=
$xaction
->
getNewValue
();
if
(
$old
&&
!
$new
)
{
return
pht
(
'%s removed %s as %s.'
,
$xaction
->
renderHandleLink
(
$author_phid
),
$xaction
->
renderHandleLink
(
$old
),
$this
->
getFieldName
());
}
else
if
(
$new
&&
!
$old
)
{
return
pht
(
'%s set %s to %s.'
,
$xaction
->
renderHandleLink
(
$author_phid
),
$this
->
getFieldName
(),
$xaction
->
renderHandleLink
(
$new
));
}
else
{
return
pht
(
'%s changed %s from %s to %s.'
,
$xaction
->
renderHandleLink
(
$author_phid
),
$this
->
getFieldName
(),
$xaction
->
renderHandleLink
(
$old
),
$xaction
->
renderHandleLink
(
$new
));
}
}
protected
function
getHTTPParameterType
()
{
return
new
AphrontPHIDHTTPParameterType
();
}
protected
function
newConduitSearchParameterType
()
{
return
new
ConduitPHIDParameterType
();
}
protected
function
newConduitEditParameterType
()
{
return
new
ConduitPHIDParameterType
();
}
}
Event Timeline
Log In to Comment