Skip to content

Commit

Permalink
Change require_activity_message to explain
Browse files Browse the repository at this point in the history
  • Loading branch information
wellingguzman committed Mar 13, 2018
1 parent 399bb79 commit 904eedc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/core/Directus/Permissions/Acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/core/Directus/Services/AbstractService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 8 additions & 8 deletions tests/api/AclTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function setUp()
'create' => 1,
'update' => 3,
'delete' => 3,
'require_activity_message' => 0
'explain' => 0
]
],
'products' => [
Expand Down Expand Up @@ -56,7 +56,7 @@ public function setUp()
'read' => 2,
'update' => 0,
'delete' => 0,
'require_activity_message' => 1
'explain' => 1
],
[
'id' => 21,
Expand Down Expand Up @@ -100,7 +100,7 @@ public function setUp()
'read' => 0,
'update' => 0,
'delete' => 0,
'require_activity_message' => 1
'explain' => 1
]
],
'directus_collection_presets' => [
Expand Down Expand Up @@ -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));
}

/**
Expand Down Expand Up @@ -479,7 +479,7 @@ public function testStatusPermission()
'read' => 3,
'update' => 3,
'delete' => 3,
'require_activity_message' => 1
'explain' => 1
],
[
'id' => 2,
Expand Down
2 changes: 1 addition & 1 deletion tests/io/ActivityMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']];

Expand Down

0 comments on commit 904eedc

Please sign in to comment.