Skip to content

Commit

Permalink
Playlists: Updated validation for library and widgets in dynamic play…
Browse files Browse the repository at this point in the history
…lists
  • Loading branch information
mgbaybay committed Aug 22, 2024
1 parent 485f74e commit da53951
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
8 changes: 5 additions & 3 deletions lib/Controller/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -1168,10 +1168,12 @@ public function add(Request $request, Response $response)
$folderId = $this->getUser()->homeFolderId;
}

$playlist = $this->playlistFactory->getById($parsedBody->getInt('playlistId'));
if ($parsedBody->getInt('playlistId') !== null) {
$playlist = $this->playlistFactory->getById($parsedBody->getInt('playlistId'));

if ($playlist->isDynamic === 1) {
throw new InvalidArgumentException(__('This Playlist is dynamically managed so cannot accept manual assignments.'), 'isDynamic');
if ($playlist->isDynamic === 1) {
throw new InvalidArgumentException(__('This Playlist is dynamically managed so cannot accept manual assignments.'), 'isDynamic');
}
}

$options = array_merge([
Expand Down
8 changes: 0 additions & 8 deletions lib/Controller/Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -1666,10 +1666,6 @@ public function widgetSetRegion(Request $request, Response $response, $id)
throw new InvalidArgumentException(__('This Layout is not a Draft, please checkout.'), 'layoutId');
}

if ($playlist->isDynamic === 1) {
throw new InvalidArgumentException(__('This Playlist is dynamically managed so cannot accept manual assignments.'), 'isDynamic');
}

// Make sure we are on a Drawer Widget
$region = $this->regionFactory->getById($playlist->regionId);
if ($region->isDrawer !== 1) {
Expand Down Expand Up @@ -1752,10 +1748,6 @@ public function saveElements(Request $request, Response $response, $id)
throw new InvalidArgumentException(__('This Layout is not a Draft, please checkout.'), 'layoutId');
}

if ($playlist->isDynamic === 1) {
throw new InvalidArgumentException(__('This Playlist is dynamically managed so cannot accept manual assignments.'), 'isDynamic');
}

// Store the target regionId
$widget->load();

Expand Down

0 comments on commit da53951

Please sign in to comment.