Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92767352
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
Sat, Nov 23, 13:36
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Nov 25, 13:36 (2 d)
Engine
blob
Format
Raw Data
Handle
22508564
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