From 904eedc446902b54a93634648da3ed7849b2ecdf Mon Sep 17 00:00:00 2001 From: Welling Guzman Date: Tue, 13 Mar 2018 13:22:33 -0400 Subject: [PATCH] Change require_activity_message to explain --- .../20180220023226_create_permissions_table.php | 2 +- src/core/Directus/Permissions/Acl.php | 8 ++++---- src/core/Directus/Services/AbstractService.php | 2 +- tests/api/AclTest.php | 16 ++++++++-------- tests/io/ActivityMessageTest.php | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/migrations/db/schemas/20180220023226_create_permissions_table.php b/migrations/db/schemas/20180220023226_create_permissions_table.php index bd07ab73b1..f7d787285b 100644 --- a/migrations/db/schemas/20180220023226_create_permissions_table.php +++ b/migrations/db/schemas/20180220023226_create_permissions_table.php @@ -67,7 +67,7 @@ public function change() 'null' => false, 'default' => false, ]); - $table->addColumn('require_activity_message', 'boolean', [ + $table->addColumn('explain', 'boolean', [ 'signed' => false, 'null' => false, 'default' => false diff --git a/src/core/Directus/Permissions/Acl.php b/src/core/Directus/Permissions/Acl.php index 60cf0f8ffb..4245ae425f 100644 --- a/src/core/Directus/Permissions/Acl.php +++ b/src/core/Directus/Permissions/Acl.php @@ -568,21 +568,21 @@ public function canAlter($collection) } /** - * Checks whether a given collection requires activity message + * Checks whether a given collection requires explanation message * * @param string $collection * @param string|int|null $status * * @return bool */ - public function requireActivityMessage($collection, $status = null) + public function requireExplain($collection, $status = null) { $permission = $this->getPermission($collection, $status); - if (!array_key_exists('require_activity_message', $permission)) { + if (!array_key_exists('explain', $permission)) { return false; } - return $permission['require_activity_message'] === 1; + return $permission['explain'] === 1; } /** diff --git a/src/core/Directus/Services/AbstractService.php b/src/core/Directus/Services/AbstractService.php index 46a351ad95..43438bbe4b 100644 --- a/src/core/Directus/Services/AbstractService.php +++ b/src/core/Directus/Services/AbstractService.php @@ -317,7 +317,7 @@ protected function validatePayload($collection, $fields, array $payload, array $ protected function enforcePermissions($collection, array $payload, array $params) { $acl = $this->getAcl(); - $requiredActivityMessage = $acl->requireActivityMessage($collection); + $requiredActivityMessage = $acl->requireExplain($collection); if ($requiredActivityMessage && empty($params['message'])) { throw new ForbiddenException('Activity message required for collection: ' . $collection); diff --git a/tests/api/AclTest.php b/tests/api/AclTest.php index 57112e1990..fb67ea569e 100644 --- a/tests/api/AclTest.php +++ b/tests/api/AclTest.php @@ -27,7 +27,7 @@ public function setUp() 'create' => 1, 'update' => 3, 'delete' => 3, - 'require_activity_message' => 0 + 'explain' => 0 ] ], 'products' => [ @@ -56,7 +56,7 @@ public function setUp() 'read' => 2, 'update' => 0, 'delete' => 0, - 'require_activity_message' => 1 + 'explain' => 1 ], [ 'id' => 21, @@ -100,7 +100,7 @@ public function setUp() 'read' => 0, 'update' => 0, 'delete' => 0, - 'require_activity_message' => 1 + 'explain' => 1 ] ], 'directus_collection_presets' => [ @@ -306,10 +306,10 @@ public function testCanDo() public function testRequireMessageActivity() { - $this->assertFalse($this->acl->requireActivityMessage('directus_files')); - $this->assertFalse($this->acl->requireActivityMessage('test_table')); - $this->assertTrue($this->acl->requireActivityMessage('products', 1)); - $this->assertTrue($this->acl->requireActivityMessage('forbid', 0)); + $this->assertFalse($this->acl->requireExplain('directus_files')); + $this->assertFalse($this->acl->requireExplain('test_table')); + $this->assertTrue($this->acl->requireExplain('products', 1)); + $this->assertTrue($this->acl->requireExplain('forbid', 0)); } /** @@ -479,7 +479,7 @@ public function testStatusPermission() 'read' => 3, 'update' => 3, 'delete' => 3, - 'require_activity_message' => 1 + 'explain' => 1 ], [ 'id' => 2, diff --git a/tests/io/ActivityMessageTest.php b/tests/io/ActivityMessageTest.php index 4660fb25c1..4d6de6b51b 100644 --- a/tests/io/ActivityMessageTest.php +++ b/tests/io/ActivityMessageTest.php @@ -374,7 +374,7 @@ protected function setFlag($collection, $value) $data = [ 'collection' => $collection, 'group' => 1, - 'require_activity_message' => $value ? 1 : 0 + 'explain' => $value ? 1 : 0 ]; $options = ['query' => ['access_token' => 'token', 'message' => 'setting flag']];