mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 08:42:41 +01:00
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
This commit is contained in:
parent
5ce7f803f9
commit
c25595417f
7 changed files with 65 additions and 1 deletions
6
resources/sql/autopatches/20220401.phameinteract.03.sql
Normal file
6
resources/sql/autopatches/20220401.phameinteract.03.sql
Normal file
|
@ -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 = '';
|
|
@ -21,8 +21,10 @@ final class PhameBlogEditor
|
||||||
|
|
||||||
public function getTransactionTypes() {
|
public function getTransactionTypes() {
|
||||||
$types = parent::getTransactionTypes();
|
$types = parent::getTransactionTypes();
|
||||||
|
|
||||||
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
||||||
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||||
|
$types[] = PhabricatorTransactions::TYPE_INTERACT_POLICY;
|
||||||
|
|
||||||
return $types;
|
return $types;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ final class PhameBlog extends PhameDAO
|
||||||
protected $creatorPHID;
|
protected $creatorPHID;
|
||||||
protected $viewPolicy;
|
protected $viewPolicy;
|
||||||
protected $editPolicy;
|
protected $editPolicy;
|
||||||
|
protected $interactPolicy;
|
||||||
protected $status;
|
protected $status;
|
||||||
protected $mailKey;
|
protected $mailKey;
|
||||||
protected $profileImagePHID;
|
protected $profileImagePHID;
|
||||||
|
@ -56,6 +57,7 @@ final class PhameBlog extends PhameDAO
|
||||||
|
|
||||||
'editPolicy' => 'policy',
|
'editPolicy' => 'policy',
|
||||||
'viewPolicy' => 'policy',
|
'viewPolicy' => 'policy',
|
||||||
|
'interactPolicy' => 'policy',
|
||||||
),
|
),
|
||||||
self::CONFIG_KEY_SCHEMA => array(
|
self::CONFIG_KEY_SCHEMA => array(
|
||||||
'key_phid' => null,
|
'key_phid' => null,
|
||||||
|
@ -88,7 +90,9 @@ final class PhameBlog extends PhameDAO
|
||||||
->setCreatorPHID($actor->getPHID())
|
->setCreatorPHID($actor->getPHID())
|
||||||
->setStatus(self::STATUS_ACTIVE)
|
->setStatus(self::STATUS_ACTIVE)
|
||||||
->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy())
|
->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy())
|
||||||
->setEditPolicy(PhabricatorPolicies::POLICY_USER);
|
->setEditPolicy(PhabricatorPolicies::POLICY_USER)
|
||||||
|
->setInteractPolicy(PhabricatorPolicies::POLICY_USER);
|
||||||
|
|
||||||
return $blog;
|
return $blog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,6 +233,7 @@ final class PhameBlog extends PhameDAO
|
||||||
public function getCapabilities() {
|
public function getCapabilities() {
|
||||||
return array(
|
return array(
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||||||
|
PhabricatorPolicyCapability::CAN_INTERACT,
|
||||||
PhabricatorPolicyCapability::CAN_EDIT,
|
PhabricatorPolicyCapability::CAN_EDIT,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -238,6 +243,8 @@ final class PhameBlog extends PhameDAO
|
||||||
switch ($capability) {
|
switch ($capability) {
|
||||||
case PhabricatorPolicyCapability::CAN_VIEW:
|
case PhabricatorPolicyCapability::CAN_VIEW:
|
||||||
return $this->getViewPolicy();
|
return $this->getViewPolicy();
|
||||||
|
case PhabricatorPolicyCapability::CAN_INTERACT:
|
||||||
|
return $this->getInteractPolicy();
|
||||||
case PhabricatorPolicyCapability::CAN_EDIT:
|
case PhabricatorPolicyCapability::CAN_EDIT:
|
||||||
return $this->getEditPolicy();
|
return $this->getEditPolicy();
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,16 @@ final class PhabricatorPolicyEditEngineExtension
|
||||||
'description.conduit' => pht('Change the join policy of the object.'),
|
'description.conduit' => pht('Change the join policy of the object.'),
|
||||||
'edit' => 'join',
|
'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) {
|
if ($object instanceof PhabricatorPolicyCodexInterface) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ final class PhabricatorTransactions extends Phobject {
|
||||||
const TYPE_VIEW_POLICY = 'core:view-policy';
|
const TYPE_VIEW_POLICY = 'core:view-policy';
|
||||||
const TYPE_EDIT_POLICY = 'core:edit-policy';
|
const TYPE_EDIT_POLICY = 'core:edit-policy';
|
||||||
const TYPE_JOIN_POLICY = 'core:join-policy';
|
const TYPE_JOIN_POLICY = 'core:join-policy';
|
||||||
|
const TYPE_INTERACT_POLICY = 'core:interact-policy';
|
||||||
const TYPE_EDGE = 'core:edge';
|
const TYPE_EDGE = 'core:edge';
|
||||||
const TYPE_CUSTOMFIELD = 'core:customfield';
|
const TYPE_CUSTOMFIELD = 'core:customfield';
|
||||||
const TYPE_TOKEN = 'token:give';
|
const TYPE_TOKEN = 'token:give';
|
||||||
|
|
|
@ -428,6 +428,11 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return $object->getJoinPolicy();
|
return $object->getJoinPolicy();
|
||||||
|
case PhabricatorTransactions::TYPE_INTERACT_POLICY:
|
||||||
|
if ($this->getIsNewObject()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $object->getInteractPolicy();
|
||||||
case PhabricatorTransactions::TYPE_SPACE:
|
case PhabricatorTransactions::TYPE_SPACE:
|
||||||
if ($this->getIsNewObject()) {
|
if ($this->getIsNewObject()) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -502,6 +507,7 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
||||||
|
case PhabricatorTransactions::TYPE_INTERACT_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_TOKEN:
|
case PhabricatorTransactions::TYPE_TOKEN:
|
||||||
case PhabricatorTransactions::TYPE_INLINESTATE:
|
case PhabricatorTransactions::TYPE_INLINESTATE:
|
||||||
case PhabricatorTransactions::TYPE_SUBTYPE:
|
case PhabricatorTransactions::TYPE_SUBTYPE:
|
||||||
|
@ -658,6 +664,7 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
||||||
|
case PhabricatorTransactions::TYPE_INTERACT_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
||||||
case PhabricatorTransactions::TYPE_INLINESTATE:
|
case PhabricatorTransactions::TYPE_INLINESTATE:
|
||||||
case PhabricatorTransactions::TYPE_EDGE:
|
case PhabricatorTransactions::TYPE_EDGE:
|
||||||
|
@ -722,6 +729,7 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
||||||
|
case PhabricatorTransactions::TYPE_INTERACT_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_INLINESTATE:
|
case PhabricatorTransactions::TYPE_INLINESTATE:
|
||||||
case PhabricatorTransactions::TYPE_SPACE:
|
case PhabricatorTransactions::TYPE_SPACE:
|
||||||
case PhabricatorTransactions::TYPE_COMMENT:
|
case PhabricatorTransactions::TYPE_COMMENT:
|
||||||
|
@ -776,6 +784,9 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
||||||
$object->setJoinPolicy($xaction->getNewValue());
|
$object->setJoinPolicy($xaction->getNewValue());
|
||||||
break;
|
break;
|
||||||
|
case PhabricatorTransactions::TYPE_INTERACT_POLICY:
|
||||||
|
$object->setInteractPolicy($xaction->getNewValue());
|
||||||
|
break;
|
||||||
case PhabricatorTransactions::TYPE_SPACE:
|
case PhabricatorTransactions::TYPE_SPACE:
|
||||||
$object->setSpacePHID($xaction->getNewValue());
|
$object->setSpacePHID($xaction->getNewValue());
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -350,6 +350,7 @@ abstract class PhabricatorApplicationTransaction
|
||||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
||||||
|
case PhabricatorTransactions::TYPE_INTERACT_POLICY:
|
||||||
if (!PhabricatorPolicyQuery::isSpecialPolicy($old)) {
|
if (!PhabricatorPolicyQuery::isSpecialPolicy($old)) {
|
||||||
$phids[] = array($old);
|
$phids[] = array($old);
|
||||||
}
|
}
|
||||||
|
@ -479,6 +480,7 @@ abstract class PhabricatorApplicationTransaction
|
||||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
||||||
|
case PhabricatorTransactions::TYPE_INTERACT_POLICY:
|
||||||
return 'fa-lock';
|
return 'fa-lock';
|
||||||
case PhabricatorTransactions::TYPE_EDGE:
|
case PhabricatorTransactions::TYPE_EDGE:
|
||||||
switch ($this->getMetadataValue('edge:type')) {
|
switch ($this->getMetadataValue('edge:type')) {
|
||||||
|
@ -590,6 +592,7 @@ abstract class PhabricatorApplicationTransaction
|
||||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
||||||
|
case PhabricatorTransactions::TYPE_INTERACT_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_SPACE:
|
case PhabricatorTransactions::TYPE_SPACE:
|
||||||
break;
|
break;
|
||||||
case PhabricatorTransactions::TYPE_SUBTYPE:
|
case PhabricatorTransactions::TYPE_SUBTYPE:
|
||||||
|
@ -634,6 +637,7 @@ abstract class PhabricatorApplicationTransaction
|
||||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
||||||
|
case PhabricatorTransactions::TYPE_INTERACT_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_SPACE:
|
case PhabricatorTransactions::TYPE_SPACE:
|
||||||
if ($this->getIsCreateTransaction()) {
|
if ($this->getIsCreateTransaction()) {
|
||||||
break;
|
break;
|
||||||
|
@ -887,6 +891,10 @@ abstract class PhabricatorApplicationTransaction
|
||||||
return pht(
|
return pht(
|
||||||
'This %s already has that join policy.',
|
'This %s already has that join policy.',
|
||||||
$this->getApplicationObjectTypeName());
|
$this->getApplicationObjectTypeName());
|
||||||
|
case PhabricatorTransactions::TYPE_INTERACT_POLICY:
|
||||||
|
return pht(
|
||||||
|
'This %s already has that interact policy.',
|
||||||
|
$this->getApplicationObjectTypeName());
|
||||||
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
||||||
return pht(
|
return pht(
|
||||||
'All users are already subscribed to this %s.',
|
'All users are already subscribed to this %s.',
|
||||||
|
@ -964,6 +972,19 @@ abstract class PhabricatorApplicationTransaction
|
||||||
$this->renderPolicyName($old, 'old'),
|
$this->renderPolicyName($old, 'old'),
|
||||||
$this->renderPolicyName($new, 'new'));
|
$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:
|
case PhabricatorTransactions::TYPE_SPACE:
|
||||||
if ($this->getIsCreateTransaction()) {
|
if ($this->getIsCreateTransaction()) {
|
||||||
return pht(
|
return pht(
|
||||||
|
@ -1204,6 +1225,11 @@ abstract class PhabricatorApplicationTransaction
|
||||||
'%s changed the join policy for %s.',
|
'%s changed the join policy for %s.',
|
||||||
$this->renderHandleLink($author_phid),
|
$this->renderHandleLink($author_phid),
|
||||||
$this->renderHandleLink($object_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:
|
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
||||||
return pht(
|
return pht(
|
||||||
'%s updated subscribers of %s.',
|
'%s updated subscribers of %s.',
|
||||||
|
@ -1426,6 +1452,7 @@ abstract class PhabricatorApplicationTransaction
|
||||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
||||||
|
case PhabricatorTransactions::TYPE_INTERACT_POLICY:
|
||||||
return pht('Changed Policy');
|
return pht('Changed Policy');
|
||||||
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
||||||
return pht('Changed Subscribers');
|
return pht('Changed Subscribers');
|
||||||
|
|
Loading…
Reference in a new issue