Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96634301
PhabricatorPolicyExplainController.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
Sun, Dec 29, 07:24
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Dec 31, 07:24 (2 d)
Engine
blob
Format
Raw Data
Handle
23220331
Attached To
rPH Phabricator
PhabricatorPolicyExplainController.php
View Options
<?php
final
class
PhabricatorPolicyExplainController
extends
PhabricatorPolicyController
{
private
$phid
;
private
$capability
;
public
function
shouldAllowPublic
()
{
return
true
;
}
public
function
willProcessRequest
(
array
$data
)
{
$this
->
phid
=
$data
[
'phid'
];
$this
->
capability
=
$data
[
'capability'
];
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$viewer
=
$request
->
getUser
();
$phid
=
$this
->
phid
;
$capability
=
$this
->
capability
;
$object
=
id
(
new
PhabricatorObjectQuery
())
->
setViewer
(
$viewer
)
->
withPHIDs
(
array
(
$phid
))
->
executeOne
();
if
(!
$object
)
{
return
new
Aphront404Response
();
}
$policies
=
PhabricatorPolicyQuery
::
loadPolicies
(
$viewer
,
$object
);
$policy
=
idx
(
$policies
,
$capability
);
if
(!
$policy
)
{
return
new
Aphront404Response
();
}
$handle
=
id
(
new
PhabricatorHandleQuery
())
->
setViewer
(
$viewer
)
->
withPHIDs
(
array
(
$phid
))
->
executeOne
();
$object_uri
=
$handle
->
getURI
();
$explanation
=
$policy
->
getExplanation
(
$capability
);
$auto_info
=
(
array
)
$object
->
describeAutomaticCapability
(
$capability
);
foreach
(
$auto_info
as
$key
=>
$info
)
{
$auto_info
[
$key
]
=
phutil_tag
(
'li'
,
array
(),
$info
);
}
if
(
$auto_info
)
{
$auto_info
=
phutil_tag
(
'ul'
,
array
(),
$auto_info
);
}
$content
=
array
(
$explanation
,
$auto_info
,
);
$dialog
=
id
(
new
AphrontDialogView
())
->
setUser
(
$viewer
)
->
setClass
(
'aphront-access-dialog'
)
->
setTitle
(
pht
(
'Policy Details'
))
->
appendChild
(
$content
)
->
addCancelButton
(
$object_uri
,
pht
(
'Done'
));
return
id
(
new
AphrontDialogResponse
())->
setDialog
(
$dialog
);
}
}
Event Timeline
Log In to Comment