Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15464569
D20807.id49603.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D20807.id49603.diff
View Options
diff --git a/src/applications/policy/filter/PhabricatorPolicyFilter.php b/src/applications/policy/filter/PhabricatorPolicyFilter.php
--- a/src/applications/policy/filter/PhabricatorPolicyFilter.php
+++ b/src/applications/policy/filter/PhabricatorPolicyFilter.php
@@ -653,14 +653,42 @@
$view_capability);
}
+ // TODO: This is a bit clumsy. We're producing HTML and text versions of
+ // this message, but can't render the full policy rules in text today.
+ // Users almost never get a text-only version of this exception anyway.
+
+ $head = null;
+ $more = null;
+
if ($show_details) {
- $more = PhabricatorPolicy::getPolicyExplanation($viewer, $policy);
+ $head = PhabricatorPolicy::getPolicyExplanation($viewer, $policy);
+
+ $policy_type = PhabricatorPolicyPHIDTypePolicy::TYPECONST;
+ $is_custom = (phid_get_type($policy) === $policy_type);
+ if ($is_custom) {
+ $policy_map = PhabricatorPolicyQuery::loadPolicies(
+ $viewer,
+ $object);
+ if (isset($policy_map[$capability])) {
+ require_celerity_resource('phui-policy-section-view-css');
+
+ $more = id(new PhabricatorPolicyRulesView())
+ ->setViewer($viewer)
+ ->setPolicy($policy_map[$capability]);
+
+ $more = phutil_tag(
+ 'div',
+ array(
+ 'class' => 'phui-policy-section-view-rules',
+ ),
+ $more);
+ }
+ }
} else {
- $more = PhabricatorPolicy::getOpaquePolicyExplanation($viewer, $policy);
+ $head = PhabricatorPolicy::getOpaquePolicyExplanation($viewer, $policy);
}
- $more = (array)$more;
- $more = array_filter($more);
+ $head = (array)$head;
$exceptions = PhabricatorPolicy::getSpecialRules(
$object,
@@ -668,7 +696,10 @@
$capability,
true);
- $details = array_filter(array_merge($more, $exceptions));
+ $text_details = array_filter(array_merge($head, $exceptions));
+ $text_details = implode(' ', $text_details);
+
+ $html_details = array($head, $more, $exceptions);
$access_denied = $this->renderAccessDenied($object);
@@ -677,7 +708,7 @@
$access_denied,
$capability_name,
$rejection,
- implode(' ', $details));
+ $text_details);
$exception = id(new PhabricatorPolicyException($full_message))
->setTitle($access_denied)
@@ -685,7 +716,7 @@
->setRejection($rejection)
->setCapability($capability)
->setCapabilityName($capability_name)
- ->setMoreInfo($details);
+ ->setMoreInfo($html_details);
throw $exception;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Apr 3, 10:48 AM (3 d, 20 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7570955
Default Alt Text
D20807.id49603.diff (2 KB)
Attached To
Mode
D20807: When users encounter a policy exception for a non-view capability with a custom policy, inline the policy rules
Attached
Detach File
Event Timeline
Log In to Comment