Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96575689
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, Dec 28, 09:44
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Dec 30, 09:44 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23175945
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