@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 Maniphest list page react to viewer capabilities

Summary:
Ref T603. Basically:

- Hide "Reports".
- Hide "batch edit" and "export to excel".
- Hide reprioritization controls.
- I left the edit controls, they show a "login to continue" dialog when hit.
- Allow tokenizer results to fill for public users.
- Fix a bug where membership in projects was computed incorrectly in certain cases.
- Add a unit test covering the project membership bug.

Test Plan: Viewed /maniphest/ when logged out, and while logged in.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T603

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

+62 -4
+2
src/__phutil_library_map__.php
··· 1453 1453 'PhabricatorPolicyCapability' => 'applications/policy/constants/PhabricatorPolicyCapability.php', 1454 1454 'PhabricatorPolicyConfigOptions' => 'applications/config/option/PhabricatorPolicyConfigOptions.php', 1455 1455 'PhabricatorPolicyConstants' => 'applications/policy/constants/PhabricatorPolicyConstants.php', 1456 + 'PhabricatorPolicyDataTestCase' => 'applications/policy/__tests__/PhabricatorPolicyDataTestCase.php', 1456 1457 'PhabricatorPolicyException' => 'applications/policy/exception/PhabricatorPolicyException.php', 1457 1458 'PhabricatorPolicyFilter' => 'applications/policy/filter/PhabricatorPolicyFilter.php', 1458 1459 'PhabricatorPolicyInterface' => 'applications/policy/interface/PhabricatorPolicyInterface.php', ··· 3599 3600 'PhabricatorPolicyAwareTestQuery' => 'PhabricatorPolicyAwareQuery', 3600 3601 'PhabricatorPolicyCapability' => 'PhabricatorPolicyConstants', 3601 3602 'PhabricatorPolicyConfigOptions' => 'PhabricatorApplicationConfigOptions', 3603 + 'PhabricatorPolicyDataTestCase' => 'PhabricatorTestCase', 3602 3604 'PhabricatorPolicyException' => 'Exception', 3603 3605 'PhabricatorPolicyQuery' => 'PhabricatorQuery', 3604 3606 'PhabricatorPolicyTestCase' => 'PhabricatorTestCase',
+5 -2
src/applications/maniphest/controller/ManiphestController.php
··· 20 20 ->setViewer($user) 21 21 ->addNavigationItems($nav->getMenu()); 22 22 23 - $nav->addLabel(pht('Reports')); 24 - $nav->addFilter('report', pht('Reports')); 23 + if ($user->isLoggedIn()) { 24 + // For now, don't give logged-out users access to reports. 25 + $nav->addLabel(pht('Reports')); 26 + $nav->addFilter('report', pht('Reports')); 27 + } 25 28 26 29 $nav->selectFilter(null); 27 30
+13
src/applications/maniphest/controller/ManiphestTaskListController.php
··· 49 49 $can_drag = ($order_parameter == 'priority') && 50 50 ($group_parameter == 'none' || $group_parameter == 'priority'); 51 51 52 + if (!$viewer->isLoggedIn()) { 53 + // TODO: (T603) Eventually, we conceivably need to make each task 54 + // draggable individually, since the user may be able to edit some but 55 + // not others. 56 + $can_drag = false; 57 + } 58 + 52 59 $result = array(); 53 60 54 61 $lists = array(); ··· 183 190 184 191 private function renderBatchEditor(PhabricatorSavedQuery $saved_query) { 185 192 $user = $this->getRequest()->getUser(); 193 + 194 + if (!$user->isLoggedIn()) { 195 + // Don't show the batch editor or excel export for logged-out users. 196 + // Technically we //could// let them export, but ehh. 197 + return null; 198 + } 186 199 187 200 Javelin::initBehavior( 188 201 'maniphest-batch-selector',
+34
src/applications/policy/__tests__/PhabricatorPolicyDataTestCase.php
··· 1 + <?php 2 + 3 + final class PhabricatorPolicyDataTestCase extends PhabricatorTestCase { 4 + 5 + protected function getPhabricatorTestCaseConfiguration() { 6 + return array( 7 + self::PHABRICATOR_TESTCONFIG_BUILD_STORAGE_FIXTURES => true, 8 + ); 9 + } 10 + 11 + public function testProjectPolicyMembership() { 12 + $author = $this->generateNewTestUser(); 13 + 14 + $proj_a = id(new PhabricatorProject()) 15 + ->setName('A') 16 + ->setAuthorPHID($author->getPHID()) 17 + ->save(); 18 + $proj_b = id(new PhabricatorProject()) 19 + ->setName('B') 20 + ->setAuthorPHID($author->getPHID()) 21 + ->save(); 22 + 23 + $proj_a->setViewPolicy($proj_b->getPHID())->save(); 24 + $proj_b->setViewPolicy($proj_a->getPHID())->save(); 25 + 26 + $user = new PhabricatorUser(); 27 + 28 + $results = id(new PhabricatorProjectQuery()) 29 + ->setViewer($user) 30 + ->execute(); 31 + 32 + $this->assertEqual(0, count($results)); 33 + } 34 + }
+1 -1
src/applications/policy/filter/PhabricatorPolicyFilter.php
··· 213 213 default: 214 214 $type = phid_get_type($policy); 215 215 if ($type == PhabricatorProjectPHIDTypeProject::TYPECONST) { 216 - if (isset($this->userProjects[$viewer->getPHID()][$policy])) { 216 + if (!empty($this->userProjects[$viewer->getPHID()][$policy])) { 217 217 return true; 218 218 } else { 219 219 $this->rejectObject($object, $policy, $capability);
+7 -1
src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php
··· 5 5 6 6 private $type; 7 7 8 + public function shouldAllowPublic() { 9 + return true; 10 + } 11 + 8 12 public function willProcessRequest(array $data) { 9 13 $this->type = $data['type']; 10 14 } ··· 230 234 } 231 235 232 236 if ($need_repos) { 233 - $repos = id(new PhabricatorRepository())->loadAll(); 237 + $repos = id(new PhabricatorRepositoryQuery()) 238 + ->setViewer($viewer) 239 + ->execute(); 234 240 foreach ($repos as $repo) { 235 241 $results[] = id(new PhabricatorTypeaheadResult()) 236 242 ->setName('r'.$repo->getCallsign().' ('.$repo->getName().')')