diff --git a/resources/sql/autopatches/20220401.phameinteract.03.sql b/resources/sql/autopatches/20220401.phameinteract.03.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20220401.phameinteract.03.sql @@ -0,0 +1,6 @@ +ALTER TABLE {$NAMESPACE}_phame.phame_blog + ADD interactPolicy VARBINARY(64) NOT NULL; + +UPDATE {$NAMESPACE}_phame.phame_blog + SET interactPolicy = 'users' + WHERE interactPolicy = ''; diff --git a/src/applications/phame/editor/PhameBlogEditor.php b/src/applications/phame/editor/PhameBlogEditor.php --- a/src/applications/phame/editor/PhameBlogEditor.php +++ b/src/applications/phame/editor/PhameBlogEditor.php @@ -21,8 +21,10 @@ public function getTransactionTypes() { $types = parent::getTransactionTypes(); + $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; + $types[] = PhabricatorTransactions::TYPE_INTERACT_POLICY; return $types; } diff --git a/src/applications/phame/storage/PhameBlog.php b/src/applications/phame/storage/PhameBlog.php --- a/src/applications/phame/storage/PhameBlog.php +++ b/src/applications/phame/storage/PhameBlog.php @@ -24,6 +24,7 @@ protected $creatorPHID; protected $viewPolicy; protected $editPolicy; + protected $interactPolicy; protected $status; protected $mailKey; protected $profileImagePHID; @@ -56,6 +57,7 @@ 'editPolicy' => 'policy', 'viewPolicy' => 'policy', + 'interactPolicy' => 'policy', ), self::CONFIG_KEY_SCHEMA => array( 'key_phid' => null, @@ -88,7 +90,9 @@ ->setCreatorPHID($actor->getPHID()) ->setStatus(self::STATUS_ACTIVE) ->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy()) - ->setEditPolicy(PhabricatorPolicies::POLICY_USER); + ->setEditPolicy(PhabricatorPolicies::POLICY_USER) + ->setInteractPolicy(PhabricatorPolicies::POLICY_USER); + return $blog; } @@ -229,6 +233,7 @@ public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, + PhabricatorPolicyCapability::CAN_INTERACT, PhabricatorPolicyCapability::CAN_EDIT, ); } @@ -238,6 +243,8 @@ switch ($capability) { case PhabricatorPolicyCapability::CAN_VIEW: return $this->getViewPolicy(); + case PhabricatorPolicyCapability::CAN_INTERACT: + return $this->getInteractPolicy(); case PhabricatorPolicyCapability::CAN_EDIT: return $this->getEditPolicy(); } diff --git a/src/applications/policy/editor/PhabricatorPolicyEditEngineExtension.php b/src/applications/policy/editor/PhabricatorPolicyEditEngineExtension.php --- a/src/applications/policy/editor/PhabricatorPolicyEditEngineExtension.php +++ b/src/applications/policy/editor/PhabricatorPolicyEditEngineExtension.php @@ -66,6 +66,16 @@ 'description.conduit' => pht('Change the join policy of the object.'), 'edit' => 'join', ), + PhabricatorTransactions::TYPE_INTERACT_POLICY => array( + 'key' => 'policy.interact', + 'aliases' => array('interact'), + 'capability' => PhabricatorPolicyCapability::CAN_INTERACT, + 'label' => pht('Interact Policy'), + 'description' => pht('Controls who can interact with the object.'), + 'description.conduit' + => pht('Change the interaction policy of the object.'), + 'edit' => 'interact', + ), ); if ($object instanceof PhabricatorPolicyCodexInterface) { diff --git a/src/applications/transactions/constants/PhabricatorTransactions.php b/src/applications/transactions/constants/PhabricatorTransactions.php --- a/src/applications/transactions/constants/PhabricatorTransactions.php +++ b/src/applications/transactions/constants/PhabricatorTransactions.php @@ -7,6 +7,7 @@ const TYPE_VIEW_POLICY = 'core:view-policy'; const TYPE_EDIT_POLICY = 'core:edit-policy'; const TYPE_JOIN_POLICY = 'core:join-policy'; + const TYPE_INTERACT_POLICY = 'core:interact-policy'; const TYPE_EDGE = 'core:edge'; const TYPE_CUSTOMFIELD = 'core:customfield'; const TYPE_TOKEN = 'token:give'; diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php @@ -428,6 +428,11 @@ return null; } return $object->getJoinPolicy(); + case PhabricatorTransactions::TYPE_INTERACT_POLICY: + if ($this->getIsNewObject()) { + return null; + } + return $object->getInteractPolicy(); case PhabricatorTransactions::TYPE_SPACE: if ($this->getIsNewObject()) { return null; @@ -502,6 +507,7 @@ case PhabricatorTransactions::TYPE_VIEW_POLICY: case PhabricatorTransactions::TYPE_EDIT_POLICY: case PhabricatorTransactions::TYPE_JOIN_POLICY: + case PhabricatorTransactions::TYPE_INTERACT_POLICY: case PhabricatorTransactions::TYPE_TOKEN: case PhabricatorTransactions::TYPE_INLINESTATE: case PhabricatorTransactions::TYPE_SUBTYPE: @@ -658,6 +664,7 @@ case PhabricatorTransactions::TYPE_VIEW_POLICY: case PhabricatorTransactions::TYPE_EDIT_POLICY: case PhabricatorTransactions::TYPE_JOIN_POLICY: + case PhabricatorTransactions::TYPE_INTERACT_POLICY: case PhabricatorTransactions::TYPE_SUBSCRIBERS: case PhabricatorTransactions::TYPE_INLINESTATE: case PhabricatorTransactions::TYPE_EDGE: @@ -722,6 +729,7 @@ case PhabricatorTransactions::TYPE_VIEW_POLICY: case PhabricatorTransactions::TYPE_EDIT_POLICY: case PhabricatorTransactions::TYPE_JOIN_POLICY: + case PhabricatorTransactions::TYPE_INTERACT_POLICY: case PhabricatorTransactions::TYPE_INLINESTATE: case PhabricatorTransactions::TYPE_SPACE: case PhabricatorTransactions::TYPE_COMMENT: @@ -776,6 +784,9 @@ case PhabricatorTransactions::TYPE_JOIN_POLICY: $object->setJoinPolicy($xaction->getNewValue()); break; + case PhabricatorTransactions::TYPE_INTERACT_POLICY: + $object->setInteractPolicy($xaction->getNewValue()); + break; case PhabricatorTransactions::TYPE_SPACE: $object->setSpacePHID($xaction->getNewValue()); break; diff --git a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php --- a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php +++ b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php @@ -350,6 +350,7 @@ case PhabricatorTransactions::TYPE_EDIT_POLICY: case PhabricatorTransactions::TYPE_VIEW_POLICY: case PhabricatorTransactions::TYPE_JOIN_POLICY: + case PhabricatorTransactions::TYPE_INTERACT_POLICY: if (!PhabricatorPolicyQuery::isSpecialPolicy($old)) { $phids[] = array($old); } @@ -479,6 +480,7 @@ case PhabricatorTransactions::TYPE_VIEW_POLICY: case PhabricatorTransactions::TYPE_EDIT_POLICY: case PhabricatorTransactions::TYPE_JOIN_POLICY: + case PhabricatorTransactions::TYPE_INTERACT_POLICY: return 'fa-lock'; case PhabricatorTransactions::TYPE_EDGE: switch ($this->getMetadataValue('edge:type')) { @@ -590,6 +592,7 @@ case PhabricatorTransactions::TYPE_VIEW_POLICY: case PhabricatorTransactions::TYPE_EDIT_POLICY: case PhabricatorTransactions::TYPE_JOIN_POLICY: + case PhabricatorTransactions::TYPE_INTERACT_POLICY: case PhabricatorTransactions::TYPE_SPACE: break; case PhabricatorTransactions::TYPE_SUBTYPE: @@ -634,6 +637,7 @@ case PhabricatorTransactions::TYPE_VIEW_POLICY: case PhabricatorTransactions::TYPE_EDIT_POLICY: case PhabricatorTransactions::TYPE_JOIN_POLICY: + case PhabricatorTransactions::TYPE_INTERACT_POLICY: case PhabricatorTransactions::TYPE_SPACE: if ($this->getIsCreateTransaction()) { break; @@ -887,6 +891,10 @@ return pht( 'This %s already has that join policy.', $this->getApplicationObjectTypeName()); + case PhabricatorTransactions::TYPE_INTERACT_POLICY: + return pht( + 'This %s already has that interact policy.', + $this->getApplicationObjectTypeName()); case PhabricatorTransactions::TYPE_SUBSCRIBERS: return pht( 'All users are already subscribed to this %s.', @@ -964,6 +972,19 @@ $this->renderPolicyName($old, 'old'), $this->renderPolicyName($new, 'new')); } + case PhabricatorTransactions::TYPE_INTERACT_POLICY: + if ($this->getIsCreateTransaction()) { + return pht( + '%s created this object with interact policy "%s".', + $this->renderHandleLink($author_phid), + $this->renderPolicyName($new, 'new')); + } else { + return pht( + '%s changed the interact policy from "%s" to "%s".', + $this->renderHandleLink($author_phid), + $this->renderPolicyName($old, 'old'), + $this->renderPolicyName($new, 'new')); + } case PhabricatorTransactions::TYPE_SPACE: if ($this->getIsCreateTransaction()) { return pht( @@ -1204,6 +1225,11 @@ '%s changed the join policy for %s.', $this->renderHandleLink($author_phid), $this->renderHandleLink($object_phid)); + case PhabricatorTransactions::TYPE_INTERACT_POLICY: + return pht( + '%s changed the interact policy for %s.', + $this->renderHandleLink($author_phid), + $this->renderHandleLink($object_phid)); case PhabricatorTransactions::TYPE_SUBSCRIBERS: return pht( '%s updated subscribers of %s.', @@ -1426,6 +1452,7 @@ case PhabricatorTransactions::TYPE_VIEW_POLICY: case PhabricatorTransactions::TYPE_EDIT_POLICY: case PhabricatorTransactions::TYPE_JOIN_POLICY: + case PhabricatorTransactions::TYPE_INTERACT_POLICY: return pht('Changed Policy'); case PhabricatorTransactions::TYPE_SUBSCRIBERS: return pht('Changed Subscribers');