Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F470936
PhabricatorPolicyRuleLegalpadSignature.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
PhabricatorPolicyRuleLegalpadSignature.php
View Options
<?php
final
class
PhabricatorPolicyRuleLegalpadSignature
extends
PhabricatorPolicyRule
{
private
$signatures
=
array
();
public
function
getRuleDescription
()
{
return
pht
(
'signers of legalpad documents'
);
}
public
function
willApplyRules
(
PhabricatorUser
$viewer
,
array
$values
)
{
$values
=
array_unique
(
array_filter
(
array_mergev
(
$values
)));
if
(!
$values
)
{
return
;
}
// TODO: This accepts signature of any version of the document, even an
// older version.
$documents
=
id
(
new
LegalpadDocumentQuery
())
->
setViewer
(
PhabricatorUser
::
getOmnipotentUser
())
->
withPHIDs
(
$values
)
->
withSignerPHIDs
(
array
(
$viewer
->
getPHID
()))
->
execute
();
$this
->
signatures
=
mpull
(
$documents
,
'getPHID'
,
'getPHID'
);
}
public
function
applyRule
(
PhabricatorUser
$viewer
,
$value
)
{
foreach
(
$value
as
$document_phid
)
{
if
(!
isset
(
$this
->
signatures
[
$document_phid
]))
{
return
false
;
}
}
return
true
;
}
public
function
getValueControlType
()
{
return
self
::
CONTROL_TYPE_TOKENIZER
;
}
public
function
getValueControlTemplate
()
{
$datasource
=
new
LegalpadDocumentDatasource
();
return
array
(
'markup'
=>
new
AphrontTokenizerTemplateView
(),
'uri'
=>
$datasource
->
getDatasourceURI
(),
'placeholder'
=>
$datasource
->
getPlaceholderText
(),
);
}
public
function
getRuleOrder
()
{
return
900
;
}
public
function
getValueForStorage
(
$value
)
{
PhutilTypeSpec
::
newFromString
(
'list<string>'
)->
check
(
$value
);
return
array_values
(
$value
);
}
public
function
getValueForDisplay
(
PhabricatorUser
$viewer
,
$value
)
{
$handles
=
id
(
new
PhabricatorHandleQuery
())
->
setViewer
(
$viewer
)
->
withPHIDs
(
$value
)
->
execute
();
return
mpull
(
$handles
,
'getFullName'
,
'getPHID'
);
}
public
function
ruleHasEffect
(
$value
)
{
return
(
bool
)
$value
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, May 6, 12:38 PM (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
82488
Default Alt Text
PhabricatorPolicyRuleLegalpadSignature.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment