Skip to content

Commit

Permalink
fix subquery fields
Browse files Browse the repository at this point in the history
  • Loading branch information
kingjia90 authored and dvesh3 committed Nov 7, 2023
1 parent b3e9595 commit 02eaa0b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,12 @@ public function gridProxyAction(Request $request, Service $service, EventDispatc
$list->setObjectTypes(['object', 'folder', 'variant']);

$conditionFilters = [];
$idField = DataObjectService::getVersionDependentDatabaseColumnName('id');
$keyColumn = DataObjectService::getVersionDependentDatabaseColumnName('key');
$pathColumn = DataObjectService::getVersionDependentDatabaseColumnName('path');

// this is necessary to properly reference the columns from main query in the workspaces related sub-query
$listingTableName = $list->getDao()->getTableName();
$idField = $listingTableName . '.' . DataObjectService::getVersionDependentDatabaseColumnName('id');
$keyColumn = $listingTableName . '.' . DataObjectService::getVersionDependentDatabaseColumnName('key');
$pathColumn = $listingTableName . '.' . DataObjectService::getVersionDependentDatabaseColumnName('path');
if (!$this->getPimcoreUser()->isAdmin()) {
$userIds = $this->getPimcoreUser()->getRoles();
$userIds[] = $this->getPimcoreUser()->getId();
Expand All @@ -157,11 +160,9 @@ public function gridProxyAction(Request $request, Service $service, EventDispatc

if (!empty($ids)) {
$conditionFilters[] = $idField . ' IN (' . implode(',', $ids) . ')';
//$list->setCondition($idField . " IN (" . implode(",", $ids) . ")");
$list->setOrderKey(' FIELD(' . $idField . ', ' . implode(',', $ids) . ')', false);
} else {
$conditionFilters[] = '1=2';
//$list->setCondition("1=2");
}

$list->setCondition(implode(' AND ', $conditionFilters));
Expand Down

0 comments on commit 02eaa0b

Please sign in to comment.