@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Make policy violation dialog more flexible

Summary:
Ref T8424. When users are rejected because they can't see the space an object is in, this isn't really a capability rejection. Don't require a capability when rejecting objects.

This mostly simplifies upcoming changes.

Test Plan:
- Viewed a capability exception dialog, it looked the same as always.
- (After additional changes, viewed a space exception dialog.)

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8424

Differential Revision: https://secure.phabricator.com/D13155

+46 -35
+17 -14
src/aphront/configuration/AphrontDefaultApplicationConfiguration.php
··· 164 164 return $login_controller->handleRequest($request); 165 165 } 166 166 167 - $list = $ex->getMoreInfo(); 168 - foreach ($list as $key => $item) { 169 - $list[$key] = phutil_tag('li', array(), $item); 170 - } 171 - if ($list) { 172 - $list = phutil_tag('ul', array(), $list); 173 - } 174 - 175 167 $content = array( 176 168 phutil_tag( 177 169 'div', ··· 179 171 'class' => 'aphront-policy-rejection', 180 172 ), 181 173 $ex->getRejection()), 182 - phutil_tag( 174 + ); 175 + 176 + if ($ex->getCapabilityName()) { 177 + $list = $ex->getMoreInfo(); 178 + foreach ($list as $key => $item) { 179 + $list[$key] = phutil_tag('li', array(), $item); 180 + } 181 + if ($list) { 182 + $list = phutil_tag('ul', array(), $list); 183 + } 184 + 185 + $content[] = phutil_tag( 183 186 'div', 184 187 array( 185 188 'class' => 'aphront-capability-details', 186 189 ), 187 - pht('Users with the "%s" capability:', $ex->getCapabilityName())), 188 - $list, 189 - ); 190 + pht('Users with the "%s" capability:', $ex->getCapabilityName())); 191 + 192 + $content[] = $list; 193 + } 190 194 191 - $dialog = new AphrontDialogView(); 192 - $dialog 195 + $dialog = id(new AphrontDialogView()) 193 196 ->setTitle($ex->getTitle()) 194 197 ->setClass('aphront-access-dialog') 195 198 ->setUser($user)
+29 -21
src/applications/policy/filter/PhabricatorPolicyFilter.php
··· 547 547 548 548 $details = array_filter(array_merge(array($more), (array)$exceptions)); 549 549 550 - // NOTE: Not every type of policy object has a real PHID; just load an 551 - // empty handle if a real PHID isn't available. 552 - $phid = nonempty($object->getPHID(), PhabricatorPHIDConstants::PHID_VOID); 553 - 554 - $handle = id(new PhabricatorHandleQuery()) 555 - ->setViewer($this->viewer) 556 - ->withPHIDs(array($phid)) 557 - ->executeOne(); 558 - 559 - $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); 560 - if ($is_serious) { 561 - $title = pht( 562 - 'Access Denied: %s', 563 - $handle->getObjectName()); 564 - } else { 565 - $title = pht( 566 - 'You Shall Not Pass: %s', 567 - $handle->getObjectName()); 568 - } 550 + $access_denied = $this->renderAccessDenied($object); 569 551 570 552 $full_message = pht( 571 553 '[%s] (%s) %s // %s', 572 - $title, 554 + $access_denied, 573 555 $capability_name, 574 556 $rejection, 575 557 implode(' ', $details)); 576 558 577 559 $exception = id(new PhabricatorPolicyException($full_message)) 578 - ->setTitle($title) 560 + ->setTitle($access_denied) 579 561 ->setRejection($rejection) 580 562 ->setCapabilityName($capability_name) 581 563 ->setMoreInfo($details); ··· 666 648 } else { 667 649 return $object->getPolicy($capability); 668 650 } 651 + } 652 + 653 + private function renderAccessDenied(PhabricatorPolicyInterface $object) { 654 + // NOTE: Not every type of policy object has a real PHID; just load an 655 + // empty handle if a real PHID isn't available. 656 + $phid = nonempty($object->getPHID(), PhabricatorPHIDConstants::PHID_VOID); 657 + 658 + $handle = id(new PhabricatorHandleQuery()) 659 + ->setViewer($this->viewer) 660 + ->withPHIDs(array($phid)) 661 + ->executeOne(); 662 + 663 + $object_name = $handle->getObjectName(); 664 + 665 + $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); 666 + if ($is_serious) { 667 + $access_denied = pht( 668 + 'Access Denied: %s', 669 + $object_name); 670 + } else { 671 + $access_denied = pht( 672 + 'You Shall Not Pass: %s', 673 + $object_name); 674 + } 675 + 676 + return $access_denied; 669 677 } 670 678 671 679 }