@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.

Give Pholio mocks a configurable edit policy

Summary:
Ref T4566. Currently, mocks have a conservative (author only), immutable default edit policy.

Instead:

- Let the edit policy be changed.
- Default the edit policy to "all users", similar to other applications.
- Add an application-level setting for it.
- Migrate existing edit policies to be consistent with the old policy (just the author).

This stops short of adding a separate "owner" and letting that be changed, since Pholio doesn't really have any review/approve type features (at least, so far). We can look at doing this if we get more feedback about it, or if we make owners more meaningful (e.g., add more "review-like" process to mocks).

Test Plan:
- Ran migration scripts.
- Confirmed existing mocks retained their effective policies (author only).
- Created a new mock, saw edit policy.
- Changed edit policy.
- Changed global edit policy default.
- Tried to edit a mock I couldn't edit.

Reviewers: chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T4566

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

+43 -6
+2 -2
resources/celerity/map.php
··· 81 81 'rsrc/css/application/phame/phame.css' => '19ecc703', 82 82 'rsrc/css/application/pholio/pholio-edit.css' => '90616955', 83 83 'rsrc/css/application/pholio/pholio-inline-comments.css' => '3d5a5590', 84 - 'rsrc/css/application/pholio/pholio.css' => '5bd4c882', 84 + 'rsrc/css/application/pholio/pholio.css' => 'e94312dd', 85 85 'rsrc/css/application/phortune/phortune-credit-card-form.css' => 'b25b4beb', 86 86 'rsrc/css/application/phrequent/phrequent.css' => 'ffc185ad', 87 87 'rsrc/css/application/phriction/phriction-document-css.css' => '7d7f0071', ··· 748 748 'phabricator-uiexample-reactor-sendproperties' => '551add57', 749 749 'phabricator-zindex-css' => 'efb673ac', 750 750 'phame-css' => '19ecc703', 751 - 'pholio-css' => '5bd4c882', 751 + 'pholio-css' => 'e94312dd', 752 752 'pholio-edit-css' => '90616955', 753 753 'pholio-inline-comments-css' => '3d5a5590', 754 754 'phortune-credit-card-form' => '2290aeef',
+2
resources/sql/autopatches/20140615.pholioedit.1.sql
··· 1 + ALTER TABLE {$NAMESPACE}_pholio.pholio_mock 2 + ADD editPolicy VARCHAR(64) NOT NULL COLLATE utf8_bin;
+2
resources/sql/autopatches/20140615.pholioedit.2.sql
··· 1 + UPDATE {$NAMESPACE}_pholio.pholio_mock 2 + SET editPolicy = authorPHID WHERE editPolicy = '';
+2
src/__phutil_library_map__.php
··· 2405 2405 'PhluxVariableQuery' => 'applications/phlux/query/PhluxVariableQuery.php', 2406 2406 'PhluxViewController' => 'applications/phlux/controller/PhluxViewController.php', 2407 2407 'PholioActionMenuEventListener' => 'applications/pholio/event/PholioActionMenuEventListener.php', 2408 + 'PholioCapabilityDefaultEdit' => 'applications/pholio/capability/PholioCapabilityDefaultEdit.php', 2408 2409 'PholioCapabilityDefaultView' => 'applications/pholio/capability/PholioCapabilityDefaultView.php', 2409 2410 'PholioConstants' => 'applications/pholio/constants/PholioConstants.php', 2410 2411 'PholioController' => 'applications/pholio/controller/PholioController.php', ··· 5303 5304 'PhluxVariableQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 5304 5305 'PhluxViewController' => 'PhluxController', 5305 5306 'PholioActionMenuEventListener' => 'PhabricatorEventListener', 5307 + 'PholioCapabilityDefaultEdit' => 'PhabricatorPolicyCapability', 5306 5308 'PholioCapabilityDefaultView' => 'PhabricatorPolicyCapability', 5307 5309 'PholioController' => 'PhabricatorController', 5308 5310 'PholioDAO' => 'PhabricatorLiskDAO',
+2 -2
src/applications/pholio/application/PhabricatorApplicationPholio.php
··· 72 72 73 73 protected function getCustomCapabilities() { 74 74 return array( 75 - PholioCapabilityDefaultView::CAPABILITY => array( 76 - ), 75 + PholioCapabilityDefaultView::CAPABILITY => array(), 76 + PholioCapabilityDefaultEdit::CAPABILITY => array(), 77 77 ); 78 78 } 79 79
+16
src/applications/pholio/capability/PholioCapabilityDefaultEdit.php
··· 1 + <?php 2 + 3 + final class PholioCapabilityDefaultEdit 4 + extends PhabricatorPolicyCapability { 5 + 6 + const CAPABILITY = 'pholio.default.edit'; 7 + 8 + public function getCapabilityKey() { 9 + return self::CAPABILITY; 10 + } 11 + 12 + public function getCapabilityName() { 13 + return pht('Default Edit Policy'); 14 + } 15 + 16 + }
+12
src/applications/pholio/controller/PholioMockEditController.php
··· 65 65 $v_desc = $mock->getDescription(); 66 66 $v_status = $mock->getStatus(); 67 67 $v_view = $mock->getViewPolicy(); 68 + $v_edit = $mock->getEditPolicy(); 68 69 $v_cc = PhabricatorSubscribersQuery::loadSubscribersForPHID( 69 70 $mock->getPHID()); 70 71 ··· 75 76 $type_desc = PholioTransactionType::TYPE_DESCRIPTION; 76 77 $type_status = PholioTransactionType::TYPE_STATUS; 77 78 $type_view = PhabricatorTransactions::TYPE_VIEW_POLICY; 79 + $type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY; 78 80 $type_cc = PhabricatorTransactions::TYPE_SUBSCRIBERS; 79 81 80 82 $v_name = $request->getStr('name'); 81 83 $v_desc = $request->getStr('description'); 82 84 $v_status = $request->getStr('status'); 83 85 $v_view = $request->getStr('can_view'); 86 + $v_edit = $request->getStr('can_edit'); 84 87 $v_cc = $request->getArr('cc'); 85 88 $v_projects = $request->getArr('projects'); 86 89 ··· 89 92 $mock_xactions[$type_desc] = $v_desc; 90 93 $mock_xactions[$type_status] = $v_status; 91 94 $mock_xactions[$type_view] = $v_view; 95 + $mock_xactions[$type_edit] = $v_edit; 92 96 $mock_xactions[$type_cc] = array('=' => $v_cc); 93 97 94 98 if (!strlen($request->getStr('name'))) { ··· 242 246 243 247 // NOTE: Make this show up correctly on the rendered form. 244 248 $mock->setViewPolicy($v_view); 249 + $mock->setEditPolicy($v_edit); 245 250 246 251 $handles = id(new PhabricatorHandleQuery()) 247 252 ->setViewer($user) ··· 359 364 ->setPolicyObject($mock) 360 365 ->setPolicies($policies) 361 366 ->setName('can_view')) 367 + ->appendChild( 368 + id(new AphrontFormPolicyControl()) 369 + ->setUser($user) 370 + ->setCapability(PhabricatorPolicyCapability::CAN_EDIT) 371 + ->setPolicyObject($mock) 372 + ->setPolicies($policies) 373 + ->setName('can_edit')) 362 374 ->appendChild( 363 375 id(new AphrontFormMarkupControl()) 364 376 ->setValue($list_control))
+5 -2
src/applications/pholio/storage/PholioMock.php
··· 14 14 15 15 protected $authorPHID; 16 16 protected $viewPolicy; 17 + protected $editPolicy; 17 18 18 19 protected $name; 19 20 protected $originalName; ··· 34 35 ->executeOne(); 35 36 36 37 $view_policy = $app->getPolicy(PholioCapabilityDefaultView::CAPABILITY); 38 + $edit_policy = $app->getPolicy(PholioCapabilityDefaultEdit::CAPABILITY); 37 39 38 40 return id(new PholioMock()) 39 41 ->setAuthorPHID($actor->getPHID()) 40 42 ->attachImages(array()) 41 - ->setViewPolicy($view_policy); 43 + ->setViewPolicy($view_policy) 44 + ->setEditPolicy($edit_policy); 42 45 } 43 46 44 47 public function getMonogram() { ··· 178 181 case PhabricatorPolicyCapability::CAN_VIEW: 179 182 return $this->getViewPolicy(); 180 183 case PhabricatorPolicyCapability::CAN_EDIT: 181 - return PhabricatorPolicies::POLICY_NOONE; 184 + return $this->getEditPolicy(); 182 185 } 183 186 } 184 187