Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library: fix filtering issue with media used as background images on layouts #2840

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading