@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

Give Phame blogs mutable interact policies

Summary:
Ref T13661.

I'm fairly sure these policies don't actually do anything (you can't "interact" with a blog) but the primarily support a Phame Post object policy of "Same as Parent Blog", which is the "natural" interact policy for a post.

Most of this is infrastructure support for mutable interact policies: today, only Maniphest has interact mutability and only via indirect effects (locking tasks), not through a directly mutable "Can Interact" policy.

Test Plan:
Ran storage upgrade, edited interact policy of a blog, saw appropriate persistence and transactions.

Created and edited a task to make sure there's no weird fallout from increasing what can be done with interact policies.

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13661

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

+65 -1
+6
resources/sql/autopatches/20220401.phameinteract.03.sql
··· 1 + ALTER TABLE {$NAMESPACE}_phame.phame_blog 2 + ADD interactPolicy VARBINARY(64) NOT NULL; 3 + 4 + UPDATE {$NAMESPACE}_phame.phame_blog 5 + SET interactPolicy = 'users' 6 + WHERE interactPolicy = '';
+2
src/applications/phame/editor/PhameBlogEditor.php
··· 21 21 22 22 public function getTransactionTypes() { 23 23 $types = parent::getTransactionTypes(); 24 + 24 25 $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; 25 26 $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; 27 + $types[] = PhabricatorTransactions::TYPE_INTERACT_POLICY; 26 28 27 29 return $types; 28 30 }
+8 -1
src/applications/phame/storage/PhameBlog.php
··· 24 24 protected $creatorPHID; 25 25 protected $viewPolicy; 26 26 protected $editPolicy; 27 + protected $interactPolicy; 27 28 protected $status; 28 29 protected $mailKey; 29 30 protected $profileImagePHID; ··· 56 57 57 58 'editPolicy' => 'policy', 58 59 'viewPolicy' => 'policy', 60 + 'interactPolicy' => 'policy', 59 61 ), 60 62 self::CONFIG_KEY_SCHEMA => array( 61 63 'key_phid' => null, ··· 88 90 ->setCreatorPHID($actor->getPHID()) 89 91 ->setStatus(self::STATUS_ACTIVE) 90 92 ->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy()) 91 - ->setEditPolicy(PhabricatorPolicies::POLICY_USER); 93 + ->setEditPolicy(PhabricatorPolicies::POLICY_USER) 94 + ->setInteractPolicy(PhabricatorPolicies::POLICY_USER); 95 + 92 96 return $blog; 93 97 } 94 98 ··· 229 233 public function getCapabilities() { 230 234 return array( 231 235 PhabricatorPolicyCapability::CAN_VIEW, 236 + PhabricatorPolicyCapability::CAN_INTERACT, 232 237 PhabricatorPolicyCapability::CAN_EDIT, 233 238 ); 234 239 } ··· 238 243 switch ($capability) { 239 244 case PhabricatorPolicyCapability::CAN_VIEW: 240 245 return $this->getViewPolicy(); 246 + case PhabricatorPolicyCapability::CAN_INTERACT: 247 + return $this->getInteractPolicy(); 241 248 case PhabricatorPolicyCapability::CAN_EDIT: 242 249 return $this->getEditPolicy(); 243 250 }
+10
src/applications/policy/editor/PhabricatorPolicyEditEngineExtension.php
··· 66 66 'description.conduit' => pht('Change the join policy of the object.'), 67 67 'edit' => 'join', 68 68 ), 69 + PhabricatorTransactions::TYPE_INTERACT_POLICY => array( 70 + 'key' => 'policy.interact', 71 + 'aliases' => array('interact'), 72 + 'capability' => PhabricatorPolicyCapability::CAN_INTERACT, 73 + 'label' => pht('Interact Policy'), 74 + 'description' => pht('Controls who can interact with the object.'), 75 + 'description.conduit' 76 + => pht('Change the interaction policy of the object.'), 77 + 'edit' => 'interact', 78 + ), 69 79 ); 70 80 71 81 if ($object instanceof PhabricatorPolicyCodexInterface) {
+1
src/applications/transactions/constants/PhabricatorTransactions.php
··· 7 7 const TYPE_VIEW_POLICY = 'core:view-policy'; 8 8 const TYPE_EDIT_POLICY = 'core:edit-policy'; 9 9 const TYPE_JOIN_POLICY = 'core:join-policy'; 10 + const TYPE_INTERACT_POLICY = 'core:interact-policy'; 10 11 const TYPE_EDGE = 'core:edge'; 11 12 const TYPE_CUSTOMFIELD = 'core:customfield'; 12 13 const TYPE_TOKEN = 'token:give';
+11
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 428 428 return null; 429 429 } 430 430 return $object->getJoinPolicy(); 431 + case PhabricatorTransactions::TYPE_INTERACT_POLICY: 432 + if ($this->getIsNewObject()) { 433 + return null; 434 + } 435 + return $object->getInteractPolicy(); 431 436 case PhabricatorTransactions::TYPE_SPACE: 432 437 if ($this->getIsNewObject()) { 433 438 return null; ··· 502 507 case PhabricatorTransactions::TYPE_VIEW_POLICY: 503 508 case PhabricatorTransactions::TYPE_EDIT_POLICY: 504 509 case PhabricatorTransactions::TYPE_JOIN_POLICY: 510 + case PhabricatorTransactions::TYPE_INTERACT_POLICY: 505 511 case PhabricatorTransactions::TYPE_TOKEN: 506 512 case PhabricatorTransactions::TYPE_INLINESTATE: 507 513 case PhabricatorTransactions::TYPE_SUBTYPE: ··· 658 664 case PhabricatorTransactions::TYPE_VIEW_POLICY: 659 665 case PhabricatorTransactions::TYPE_EDIT_POLICY: 660 666 case PhabricatorTransactions::TYPE_JOIN_POLICY: 667 + case PhabricatorTransactions::TYPE_INTERACT_POLICY: 661 668 case PhabricatorTransactions::TYPE_SUBSCRIBERS: 662 669 case PhabricatorTransactions::TYPE_INLINESTATE: 663 670 case PhabricatorTransactions::TYPE_EDGE: ··· 722 729 case PhabricatorTransactions::TYPE_VIEW_POLICY: 723 730 case PhabricatorTransactions::TYPE_EDIT_POLICY: 724 731 case PhabricatorTransactions::TYPE_JOIN_POLICY: 732 + case PhabricatorTransactions::TYPE_INTERACT_POLICY: 725 733 case PhabricatorTransactions::TYPE_INLINESTATE: 726 734 case PhabricatorTransactions::TYPE_SPACE: 727 735 case PhabricatorTransactions::TYPE_COMMENT: ··· 775 783 break; 776 784 case PhabricatorTransactions::TYPE_JOIN_POLICY: 777 785 $object->setJoinPolicy($xaction->getNewValue()); 786 + break; 787 + case PhabricatorTransactions::TYPE_INTERACT_POLICY: 788 + $object->setInteractPolicy($xaction->getNewValue()); 778 789 break; 779 790 case PhabricatorTransactions::TYPE_SPACE: 780 791 $object->setSpacePHID($xaction->getNewValue());
+27
src/applications/transactions/storage/PhabricatorApplicationTransaction.php
··· 350 350 case PhabricatorTransactions::TYPE_EDIT_POLICY: 351 351 case PhabricatorTransactions::TYPE_VIEW_POLICY: 352 352 case PhabricatorTransactions::TYPE_JOIN_POLICY: 353 + case PhabricatorTransactions::TYPE_INTERACT_POLICY: 353 354 if (!PhabricatorPolicyQuery::isSpecialPolicy($old)) { 354 355 $phids[] = array($old); 355 356 } ··· 479 480 case PhabricatorTransactions::TYPE_VIEW_POLICY: 480 481 case PhabricatorTransactions::TYPE_EDIT_POLICY: 481 482 case PhabricatorTransactions::TYPE_JOIN_POLICY: 483 + case PhabricatorTransactions::TYPE_INTERACT_POLICY: 482 484 return 'fa-lock'; 483 485 case PhabricatorTransactions::TYPE_EDGE: 484 486 switch ($this->getMetadataValue('edge:type')) { ··· 590 592 case PhabricatorTransactions::TYPE_VIEW_POLICY: 591 593 case PhabricatorTransactions::TYPE_EDIT_POLICY: 592 594 case PhabricatorTransactions::TYPE_JOIN_POLICY: 595 + case PhabricatorTransactions::TYPE_INTERACT_POLICY: 593 596 case PhabricatorTransactions::TYPE_SPACE: 594 597 break; 595 598 case PhabricatorTransactions::TYPE_SUBTYPE: ··· 634 637 case PhabricatorTransactions::TYPE_VIEW_POLICY: 635 638 case PhabricatorTransactions::TYPE_EDIT_POLICY: 636 639 case PhabricatorTransactions::TYPE_JOIN_POLICY: 640 + case PhabricatorTransactions::TYPE_INTERACT_POLICY: 637 641 case PhabricatorTransactions::TYPE_SPACE: 638 642 if ($this->getIsCreateTransaction()) { 639 643 break; ··· 887 891 return pht( 888 892 'This %s already has that join policy.', 889 893 $this->getApplicationObjectTypeName()); 894 + case PhabricatorTransactions::TYPE_INTERACT_POLICY: 895 + return pht( 896 + 'This %s already has that interact policy.', 897 + $this->getApplicationObjectTypeName()); 890 898 case PhabricatorTransactions::TYPE_SUBSCRIBERS: 891 899 return pht( 892 900 'All users are already subscribed to this %s.', ··· 964 972 $this->renderPolicyName($old, 'old'), 965 973 $this->renderPolicyName($new, 'new')); 966 974 } 975 + case PhabricatorTransactions::TYPE_INTERACT_POLICY: 976 + if ($this->getIsCreateTransaction()) { 977 + return pht( 978 + '%s created this object with interact policy "%s".', 979 + $this->renderHandleLink($author_phid), 980 + $this->renderPolicyName($new, 'new')); 981 + } else { 982 + return pht( 983 + '%s changed the interact policy from "%s" to "%s".', 984 + $this->renderHandleLink($author_phid), 985 + $this->renderPolicyName($old, 'old'), 986 + $this->renderPolicyName($new, 'new')); 987 + } 967 988 case PhabricatorTransactions::TYPE_SPACE: 968 989 if ($this->getIsCreateTransaction()) { 969 990 return pht( ··· 1204 1225 '%s changed the join policy for %s.', 1205 1226 $this->renderHandleLink($author_phid), 1206 1227 $this->renderHandleLink($object_phid)); 1228 + case PhabricatorTransactions::TYPE_INTERACT_POLICY: 1229 + return pht( 1230 + '%s changed the interact policy for %s.', 1231 + $this->renderHandleLink($author_phid), 1232 + $this->renderHandleLink($object_phid)); 1207 1233 case PhabricatorTransactions::TYPE_SUBSCRIBERS: 1208 1234 return pht( 1209 1235 '%s updated subscribers of %s.', ··· 1426 1452 case PhabricatorTransactions::TYPE_VIEW_POLICY: 1427 1453 case PhabricatorTransactions::TYPE_EDIT_POLICY: 1428 1454 case PhabricatorTransactions::TYPE_JOIN_POLICY: 1455 + case PhabricatorTransactions::TYPE_INTERACT_POLICY: 1429 1456 return pht('Changed Policy'); 1430 1457 case PhabricatorTransactions::TYPE_SUBSCRIBERS: 1431 1458 return pht('Changed Subscribers');