Skip to content

Commit

Permalink
Library: fix filtering issue with media used as background images on …
Browse files Browse the repository at this point in the history
  • Loading branch information
dasgarner authored Dec 24, 2024
1 parent 9b5c816 commit 35d5ac5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions lib/Factory/MediaFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -791,24 +791,33 @@ public function query($sortOrder = null, $filterBy = [])
ON widget.widgetId = lkwidgetmedia.widgetId
WHERE region.layoutId = :layoutId ';

// include Media only for non dynamic Playlists #2392
// include Media only for non-dynamic Playlists #2392
if ($sanitizedFilter->getInt('excludeDynamicPlaylistMedia') === 1) {
$body .= ' AND lkplaylistplaylist.childId IN (SELECT playlistId FROM playlist WHERE playlist.playlistId = lkplaylistplaylist.childId AND playlist.isDynamic = 0) ';
$body .= ' AND lkplaylistplaylist.childId IN (
SELECT playlistId
FROM playlist
WHERE playlist.playlistId = lkplaylistplaylist.childId
AND playlist.isDynamic = 0
) ';
}

if ($sanitizedFilter->getInt('widgetId') !== null) {
$body .= ' AND `widget`.widgetId = :widgetId ';
$params['widgetId'] = $sanitizedFilter->getInt('widgetId');
}

if ($sanitizedFilter->getInt('includeLayoutBackgroundImage') === 1) {
$body .= ' UNION ALL
SELECT `layout`.backgroundImageId AS mediaId
FROM `layout`
WHERE `layout`.layoutId = :layoutId
';
}

$body .= ' )
AND media.type <> \'module\'
';

if ($sanitizedFilter->getInt('includeLayoutBackgroundImage') === 1) {
$body .= ' OR media.mediaId IN ( SELECT `layout`.backgroundImageId FROM `layout` WHERE `layout`.layoutId = :layoutId ) ';
}

$params['layoutId'] = $sanitizedFilter->getInt('layoutId');
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Factory/ModuleTemplateFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public function loadUserTemplates($sortOrder = [], $filterBy = []): array
$template->templateId = $row['templateId'];
$template->dataType = $row['dataType'];
$template->isEnabled = $row['enabled'] == 1;
$template->ownerId = intval($row['ownerId']);
$template->ownerId = intval($row['ownerId'] ?? 0);
$template->groupsWithPermissions = $row['groupsWithPermissions'];
$templates[] = $template;
}
Expand Down

0 comments on commit 35d5ac5

Please sign in to comment.