Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15392535
D15268.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D15268.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -7305,6 +7305,7 @@
'PhabricatorApplicationTransactionInterface',
'PhabricatorPolicyInterface',
'PhabricatorDestructibleInterface',
+ 'PhabricatorExtendedPolicyInterface',
),
'PhabricatorProjectColumnDetailController' => 'PhabricatorProjectBoardController',
'PhabricatorProjectColumnEditController' => 'PhabricatorProjectBoardController',
diff --git a/src/applications/project/__tests__/PhabricatorProjectCoreTestCase.php b/src/applications/project/__tests__/PhabricatorProjectCoreTestCase.php
--- a/src/applications/project/__tests__/PhabricatorProjectCoreTestCase.php
+++ b/src/applications/project/__tests__/PhabricatorProjectCoreTestCase.php
@@ -1013,6 +1013,51 @@
$this->assertColumns($expect, $user, $board, $task);
}
+ public function testColumnExtendedPolicies() {
+ $user = $this->createUser();
+ $user->save();
+
+ $board = $this->createProject($user);
+ $column = $this->addColumn($user, $board, 0);
+
+ // At first, the user should be able to view and edit the column.
+ $column = $this->refreshColumn($user, $column);
+ $this->assertTrue((bool)$column);
+
+ $can_edit = PhabricatorPolicyFilter::hasCapability(
+ $user,
+ $column,
+ PhabricatorPolicyCapability::CAN_EDIT);
+ $this->assertTrue($can_edit);
+
+ // Now, set the project edit policy to "Members of Project". This should
+ // disable editing.
+ $members_policy = id(new PhabricatorProjectMembersPolicyRule())
+ ->getObjectPolicyFullKey();
+ $board->setEditPolicy($members_policy)->save();
+
+ $column = $this->refreshColumn($user, $column);
+ $this->assertTrue((bool)$column);
+
+ $can_edit = PhabricatorPolicyFilter::hasCapability(
+ $user,
+ $column,
+ PhabricatorPolicyCapability::CAN_EDIT);
+ $this->assertFalse($can_edit);
+
+ // Now, join the project. This should make the column editable again.
+ $this->joinProject($board, $user);
+
+ $column = $this->refreshColumn($user, $column);
+ $this->assertTrue((bool)$column);
+
+ $can_edit = PhabricatorPolicyFilter::hasCapability(
+ $user,
+ $column,
+ PhabricatorPolicyCapability::CAN_EDIT);
+ $this->assertTrue($can_edit);
+ }
+
private function moveToColumn(
PhabricatorUser $viewer,
PhabricatorProject $board,
@@ -1251,6 +1296,22 @@
}
}
+ private function refreshColumn(
+ PhabricatorUser $viewer,
+ PhabricatorProjectColumn $column) {
+
+ $results = id(new PhabricatorProjectColumnQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($column->getID()))
+ ->execute();
+
+ if ($results) {
+ return head($results);
+ } else {
+ return null;
+ }
+ }
+
private function createProject(
PhabricatorUser $user,
PhabricatorProject $parent = null,
diff --git a/src/applications/project/controller/PhabricatorProjectColumnDetailController.php b/src/applications/project/controller/PhabricatorProjectColumnDetailController.php
--- a/src/applications/project/controller/PhabricatorProjectColumnDetailController.php
+++ b/src/applications/project/controller/PhabricatorProjectColumnDetailController.php
@@ -73,8 +73,7 @@
$header = id(new PHUIHeaderView())
->setUser($viewer)
- ->setHeader($column->getDisplayName())
- ->setPolicyObject($column);
+ ->setHeader($column->getDisplayName());
if ($column->isHidden()) {
$header->setStatus('fa-ban', 'dark', pht('Hidden'));
diff --git a/src/applications/project/storage/PhabricatorProjectColumn.php b/src/applications/project/storage/PhabricatorProjectColumn.php
--- a/src/applications/project/storage/PhabricatorProjectColumn.php
+++ b/src/applications/project/storage/PhabricatorProjectColumn.php
@@ -5,7 +5,8 @@
implements
PhabricatorApplicationTransactionInterface,
PhabricatorPolicyInterface,
- PhabricatorDestructibleInterface {
+ PhabricatorDestructibleInterface,
+ PhabricatorExtendedPolicyInterface {
const STATUS_ACTIVE = 0;
const STATUS_HIDDEN = 1;
@@ -219,7 +220,14 @@
}
public function getPolicy($capability) {
- return $this->getProject()->getPolicy($capability);
+ // NOTE: Column policies are enforced as an extended policy which makes
+ // them the same as the project's policies.
+ switch ($capability) {
+ case PhabricatorPolicyCapability::CAN_VIEW:
+ return PhabricatorPolicies::getMostOpenPolicy();
+ case PhabricatorPolicyCapability::CAN_EDIT:
+ return PhabricatorPolicies::POLICY_USER;
+ }
}
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
@@ -233,6 +241,16 @@
}
+/* -( PhabricatorExtendedPolicyInterface )--------------------------------- */
+
+
+ public function getExtendedPolicy($capability, PhabricatorUser $viewer) {
+ return array(
+ array($this->getProject(), $capability),
+ );
+ }
+
+
/* -( PhabricatorDestructibleInterface )----------------------------------- */
public function destroyObjectPermanently(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 16, 3:48 PM (6 d, 1 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7390251
Default Alt Text
D15268.diff (5 KB)
Attached To
Mode
D15268: Use an extended policy to bind column and board policies together
Attached
Detach File
Event Timeline
Log In to Comment