Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91199385
RevisionAuthorPolicyRule.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
Fri, Nov 8, 21:59
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Nov 10, 21:59 (2 d)
Engine
blob
Format
Raw Data
Handle
22216489
Attached To
rPH Phabricator
RevisionAuthorPolicyRule.php
View Options
<?php
final
class
RevisionAuthorPolicyRule
extends
PhabricatorPolicyRule
{
public
function
getObjectPolicyKey
()
{
return
'revision.author'
;
}
public
function
getObjectPolicyName
()
{
return
pht
(
'Revision Author'
);
}
public
function
getPolicyExplanation
()
{
return
pht
(
'The author of this revision can take this action.'
);
}
public
function
getRuleDescription
()
{
return
pht
(
'revision author'
);
}
public
function
canApplyToObject
(
PhabricatorPolicyInterface
$object
)
{
return
(
$object
instanceof
DifferentialRevision
);
}
public
function
applyRule
(
PhabricatorUser
$viewer
,
$value
,
PhabricatorPolicyInterface
$object
)
{
$viewer_phid
=
$viewer
->
getPHID
();
if
(!
$viewer_phid
)
{
return
false
;
}
// Get the revision author
$rev
=
id
(
new
DifferentialRevisionQuery
())
->
setViewer
(
PhabricatorUser
::
getOmnipotentUser
())
->
withPHIDs
(
array
(
$object
->
getPHID
()))
->
executeOne
();
// Allow the author
if
(
$rev
&&
$rev
->
getAuthorPHID
()
===
$viewer
->
getPHID
()){
return
true
;
}
return
false
;
}
public
function
getValueControlType
()
{
return
self
::
CONTROL_TYPE_NONE
;
}
}
Event Timeline
Log In to Comment