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

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

+33 -5
+2
resources/sql/autopatches/20180730.phriction.01.spaces.sql
··· 1 + ALTER TABLE {$NAMESPACE}_phriction.phriction_document 2 + ADD spacePHID VARBINARY(64) DEFAULT NULL;
+1
src/__phutil_library_map__.php
··· 11129 11129 'PhabricatorApplicationTransactionInterface', 11130 11130 'PhabricatorConduitResultInterface', 11131 11131 'PhabricatorPolicyCodexInterface', 11132 + 'PhabricatorSpacesInterface', 11132 11133 ), 11133 11134 'PhrictionDocumentAuthorHeraldField' => 'PhrictionDocumentHeraldField', 11134 11135 'PhrictionDocumentContentHeraldField' => 'PhrictionDocumentHeraldField',
+9
src/applications/phriction/controller/PhrictionEditController.php
··· 121 121 $v_projects = array_reverse($v_projects); 122 122 } 123 123 124 + $v_space = $document->getSpacePHID(); 125 + 124 126 if ($request->isFormPost()) { 125 127 126 128 $title = $request->getStr('title'); ··· 131 133 $v_edit = $request->getStr('editPolicy'); 132 134 $v_cc = $request->getArr('cc'); 133 135 $v_projects = $request->getArr('projects'); 136 + $v_space = $request->getStr('spacePHID'); 134 137 135 138 $xactions = array(); 136 139 $xactions[] = id(new PhrictionTransaction()) ··· 147 150 ->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY) 148 151 ->setNewValue($v_edit); 149 152 $xactions[] = id(new PhrictionTransaction()) 153 + ->setTransactionType(PhabricatorTransactions::TYPE_SPACE) 154 + ->setNewValue($v_space); 155 + $xactions[] = id(new PhrictionTransaction()) 150 156 ->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS) 151 157 ->setNewValue(array('=' => $v_cc)); 152 158 ··· 192 198 193 199 $document->setViewPolicy($v_view); 194 200 $document->setEditPolicy($v_edit); 201 + $document->setSpacePHID($v_space); 195 202 } 196 203 } 197 204 ··· 267 274 ->setDatasource(new PhabricatorMetaMTAMailableDatasource())) 268 275 ->appendChild( 269 276 id(new AphrontFormPolicyControl()) 277 + ->setViewer($viewer) 270 278 ->setName('viewPolicy') 279 + ->setSpacePHID($v_space) 271 280 ->setPolicyObject($document) 272 281 ->setCapability($view_capability) 273 282 ->setPolicies($policies)
+1
src/applications/phriction/query/PhrictionDocumentSearchEngine.php
··· 131 131 132 132 $item = id(new PHUIObjectItemView()) 133 133 ->setHeader($content->getTitle()) 134 + ->setObject($document) 134 135 ->setHref($slug_uri) 135 136 ->addByline($byline) 136 137 ->addIcon('none', $updated);
+20 -5
src/applications/phriction/storage/PhrictionDocument.php
··· 12 12 PhabricatorProjectInterface, 13 13 PhabricatorApplicationTransactionInterface, 14 14 PhabricatorConduitResultInterface, 15 - PhabricatorPolicyCodexInterface { 15 + PhabricatorPolicyCodexInterface, 16 + PhabricatorSpacesInterface { 16 17 17 18 protected $slug; 18 19 protected $depth; ··· 21 22 protected $mailKey; 22 23 protected $viewPolicy; 23 24 protected $editPolicy; 25 + protected $spacePHID; 24 26 25 27 private $contentObject = self::ATTACHABLE; 26 28 private $ancestors = array(); ··· 81 83 } 82 84 83 85 if ($parent_doc) { 84 - $document->setViewPolicy($parent_doc->getViewPolicy()); 85 - $document->setEditPolicy($parent_doc->getEditPolicy()); 86 + $document 87 + ->setViewPolicy($parent_doc->getViewPolicy()) 88 + ->setEditPolicy($parent_doc->getEditPolicy()) 89 + ->setSpacePHID($parent_doc->getSpacePHID()); 86 90 } else { 87 91 $default_view_policy = PhabricatorPolicies::getMostOpenPolicy(); 88 - $document->setViewPolicy($default_view_policy); 89 - $document->setEditPolicy(PhabricatorPolicies::POLICY_USER); 92 + $document 93 + ->setViewPolicy($default_view_policy) 94 + ->setEditPolicy(PhabricatorPolicies::POLICY_USER) 95 + ->setSpacePHID($actor->getDefaultSpacePHID()); 90 96 } 91 97 92 98 return $document; ··· 200 206 public function hasAutomaticCapability($capability, PhabricatorUser $user) { 201 207 return false; 202 208 } 209 + 210 + 211 + /* -( PhabricatorSpacesInterface )----------------------------------------- */ 212 + 213 + 214 + public function getSpacePHID() { 215 + return $this->spacePHID; 216 + } 217 + 203 218 204 219 205 220 /* -( PhabricatorSubscribableInterface )----------------------------------- */