Skip to content

Commit

Permalink
Remove unwanted files (directus#1609)
Browse files Browse the repository at this point in the history
  • Loading branch information
binal-7span authored and rijkvanzanten committed Jan 22, 2020
1 parent b513f23 commit 99af8b3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/core/Directus/Database/TableGateway/RelationalTableGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Directus\Exception\ErrorException;
use Directus\Exception\UnprocessableEntityException;
use Directus\Permissions\Exception\ForbiddenCollectionReadException;
use Directus\Permissions\Exception\ForbiddenFieldReadException;
use Directus\Exception\ErrorCodes;
use Directus\Permissions\Exception\PermissionException;
use Directus\Permissions\Exception\UnableFindOwnerItemsException;
use Directus\Util\ArrayUtils;
Expand All @@ -33,6 +33,7 @@ class RelationalTableGateway extends BaseTableGateway
const ACTIVITY_ENTRY_MODE_PARENT = 1;
const ACTIVITY_ENTRY_MODE_CHILD = 2;

protected $exceptionMessages = [];
protected $toManyCallStack = [];

/**
Expand Down Expand Up @@ -919,6 +920,8 @@ public function wrapData($data, $single = false, $meta = false)

$result['data'] = $data;

$result['messages'] = $this->exceptionMessages;

return $result;
}

Expand Down Expand Up @@ -1236,12 +1239,13 @@ public function fetchItems(array $params = [], \Closure $queryCallback = null)
foreach ($results as $index => &$item) {
$statusId = ArrayUtils::get($item, $statusField->getName());
$blacklist = $this->acl->getReadFieldBlacklist($this->table, $statusId);

$item = ArrayUtils::omit($item, $blacklist);

if (empty($item)) {
unset($results[$index]);
}
}

$results = array_values($results);
}

Expand Down Expand Up @@ -2076,7 +2080,14 @@ public function loadOneToManyRelationships($entries, $columns, array $params = [
}

$relatedTableName = $alias->getRelationship()->getCollectionMany();

if ($this->acl && !$this->acl->canReadOnce($relatedTableName)) {
$this->exceptionMessages[] = [
'type' => 'warning',
'message' => "Can't read `" . $relatedTableName . "`: read access to `" . $relatedTableName . "` collection denied",
'code' => ErrorCodes::WARNING_ACCESS_DENIED,
'fields' => [$alias->getName()],
];
continue;
}

Expand Down Expand Up @@ -2199,7 +2210,12 @@ public function loadManyToOneRelationships($entries, $columns, array $params = [
$primaryKeyName => $entry[$column->getName()]
];
}

$this->exceptionMessages[] = [
'type' => 'warning',
'message' => "Can't read `" . $relatedTable . "`: read access to `" . $relatedTable . "` collection denied",
'code' => ErrorCodes::WARNING_ACCESS_DENIED,
'fields' => [$column->getName()],
];
continue;
}

Expand Down
8 changes: 8 additions & 0 deletions src/core/Directus/Exception/ErrorCodes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Directus\Exception;

class ErrorCodes
{
const WARNING_ACCESS_DENIED = 18;
}

0 comments on commit 99af8b3

Please sign in to comment.