mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 05:50:55 +01:00
Add Spaces support to Phriction
Summary: Ref T13164. See PHI774. Fixes T12435. Since Phriction is hierarchical, there isn't a super strong motivation to support Spaces: you can generally set policies on a small number of documents to get the desired effective policy behavior. However, it still improves consistency and there's no reason //not// to support Spaces. In the case where you have some moderately weird/complex policy on one or more Spaces, using Spaces to define the policy behavior can make things a bit simpler and easier to understand. This probably doesn't actually fix whatever the root problem in T12435 was (complicated, non-hierarchical access policies?). See also a bunch of discussion in T12442. So we might end up going beyond this to address other use cases, but I think this is reasonable regardless. Test Plan: Created and edited Phriction documents and shifted them between Spaces. Searched by Space, etc. Reviewers: amckinley Reviewed By: amckinley Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13164, T12435 Differential Revision: https://secure.phabricator.com/D19553
This commit is contained in:
parent
8374201620
commit
8d8086fccf
5 changed files with 33 additions and 5 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE {$NAMESPACE}_phriction.phriction_document
|
||||||
|
ADD spacePHID VARBINARY(64) DEFAULT NULL;
|
|
@ -11129,6 +11129,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorApplicationTransactionInterface',
|
'PhabricatorApplicationTransactionInterface',
|
||||||
'PhabricatorConduitResultInterface',
|
'PhabricatorConduitResultInterface',
|
||||||
'PhabricatorPolicyCodexInterface',
|
'PhabricatorPolicyCodexInterface',
|
||||||
|
'PhabricatorSpacesInterface',
|
||||||
),
|
),
|
||||||
'PhrictionDocumentAuthorHeraldField' => 'PhrictionDocumentHeraldField',
|
'PhrictionDocumentAuthorHeraldField' => 'PhrictionDocumentHeraldField',
|
||||||
'PhrictionDocumentContentHeraldField' => 'PhrictionDocumentHeraldField',
|
'PhrictionDocumentContentHeraldField' => 'PhrictionDocumentHeraldField',
|
||||||
|
|
|
@ -121,6 +121,8 @@ final class PhrictionEditController
|
||||||
$v_projects = array_reverse($v_projects);
|
$v_projects = array_reverse($v_projects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$v_space = $document->getSpacePHID();
|
||||||
|
|
||||||
if ($request->isFormPost()) {
|
if ($request->isFormPost()) {
|
||||||
|
|
||||||
$title = $request->getStr('title');
|
$title = $request->getStr('title');
|
||||||
|
@ -131,6 +133,7 @@ final class PhrictionEditController
|
||||||
$v_edit = $request->getStr('editPolicy');
|
$v_edit = $request->getStr('editPolicy');
|
||||||
$v_cc = $request->getArr('cc');
|
$v_cc = $request->getArr('cc');
|
||||||
$v_projects = $request->getArr('projects');
|
$v_projects = $request->getArr('projects');
|
||||||
|
$v_space = $request->getStr('spacePHID');
|
||||||
|
|
||||||
$xactions = array();
|
$xactions = array();
|
||||||
$xactions[] = id(new PhrictionTransaction())
|
$xactions[] = id(new PhrictionTransaction())
|
||||||
|
@ -146,6 +149,9 @@ final class PhrictionEditController
|
||||||
$xactions[] = id(new PhrictionTransaction())
|
$xactions[] = id(new PhrictionTransaction())
|
||||||
->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)
|
->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)
|
||||||
->setNewValue($v_edit);
|
->setNewValue($v_edit);
|
||||||
|
$xactions[] = id(new PhrictionTransaction())
|
||||||
|
->setTransactionType(PhabricatorTransactions::TYPE_SPACE)
|
||||||
|
->setNewValue($v_space);
|
||||||
$xactions[] = id(new PhrictionTransaction())
|
$xactions[] = id(new PhrictionTransaction())
|
||||||
->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)
|
->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)
|
||||||
->setNewValue(array('=' => $v_cc));
|
->setNewValue(array('=' => $v_cc));
|
||||||
|
@ -192,6 +198,7 @@ final class PhrictionEditController
|
||||||
|
|
||||||
$document->setViewPolicy($v_view);
|
$document->setViewPolicy($v_view);
|
||||||
$document->setEditPolicy($v_edit);
|
$document->setEditPolicy($v_edit);
|
||||||
|
$document->setSpacePHID($v_space);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +274,9 @@ final class PhrictionEditController
|
||||||
->setDatasource(new PhabricatorMetaMTAMailableDatasource()))
|
->setDatasource(new PhabricatorMetaMTAMailableDatasource()))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormPolicyControl())
|
id(new AphrontFormPolicyControl())
|
||||||
|
->setViewer($viewer)
|
||||||
->setName('viewPolicy')
|
->setName('viewPolicy')
|
||||||
|
->setSpacePHID($v_space)
|
||||||
->setPolicyObject($document)
|
->setPolicyObject($document)
|
||||||
->setCapability($view_capability)
|
->setCapability($view_capability)
|
||||||
->setPolicies($policies)
|
->setPolicies($policies)
|
||||||
|
|
|
@ -131,6 +131,7 @@ final class PhrictionDocumentSearchEngine
|
||||||
|
|
||||||
$item = id(new PHUIObjectItemView())
|
$item = id(new PHUIObjectItemView())
|
||||||
->setHeader($content->getTitle())
|
->setHeader($content->getTitle())
|
||||||
|
->setObject($document)
|
||||||
->setHref($slug_uri)
|
->setHref($slug_uri)
|
||||||
->addByline($byline)
|
->addByline($byline)
|
||||||
->addIcon('none', $updated);
|
->addIcon('none', $updated);
|
||||||
|
|
|
@ -12,7 +12,8 @@ final class PhrictionDocument extends PhrictionDAO
|
||||||
PhabricatorProjectInterface,
|
PhabricatorProjectInterface,
|
||||||
PhabricatorApplicationTransactionInterface,
|
PhabricatorApplicationTransactionInterface,
|
||||||
PhabricatorConduitResultInterface,
|
PhabricatorConduitResultInterface,
|
||||||
PhabricatorPolicyCodexInterface {
|
PhabricatorPolicyCodexInterface,
|
||||||
|
PhabricatorSpacesInterface {
|
||||||
|
|
||||||
protected $slug;
|
protected $slug;
|
||||||
protected $depth;
|
protected $depth;
|
||||||
|
@ -21,6 +22,7 @@ final class PhrictionDocument extends PhrictionDAO
|
||||||
protected $mailKey;
|
protected $mailKey;
|
||||||
protected $viewPolicy;
|
protected $viewPolicy;
|
||||||
protected $editPolicy;
|
protected $editPolicy;
|
||||||
|
protected $spacePHID;
|
||||||
|
|
||||||
private $contentObject = self::ATTACHABLE;
|
private $contentObject = self::ATTACHABLE;
|
||||||
private $ancestors = array();
|
private $ancestors = array();
|
||||||
|
@ -81,12 +83,16 @@ final class PhrictionDocument extends PhrictionDAO
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($parent_doc) {
|
if ($parent_doc) {
|
||||||
$document->setViewPolicy($parent_doc->getViewPolicy());
|
$document
|
||||||
$document->setEditPolicy($parent_doc->getEditPolicy());
|
->setViewPolicy($parent_doc->getViewPolicy())
|
||||||
|
->setEditPolicy($parent_doc->getEditPolicy())
|
||||||
|
->setSpacePHID($parent_doc->getSpacePHID());
|
||||||
} else {
|
} else {
|
||||||
$default_view_policy = PhabricatorPolicies::getMostOpenPolicy();
|
$default_view_policy = PhabricatorPolicies::getMostOpenPolicy();
|
||||||
$document->setViewPolicy($default_view_policy);
|
$document
|
||||||
$document->setEditPolicy(PhabricatorPolicies::POLICY_USER);
|
->setViewPolicy($default_view_policy)
|
||||||
|
->setEditPolicy(PhabricatorPolicies::POLICY_USER)
|
||||||
|
->setSpacePHID($actor->getDefaultSpacePHID());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $document;
|
return $document;
|
||||||
|
@ -202,6 +208,15 @@ final class PhrictionDocument extends PhrictionDAO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -( PhabricatorSpacesInterface )----------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
public function getSpacePHID() {
|
||||||
|
return $this->spacePHID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* -( PhabricatorSubscribableInterface )----------------------------------- */
|
/* -( PhabricatorSubscribableInterface )----------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue