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

Playlists: Fix for disable manual changes to media assignments on dynamic playlists #2711

Merged
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
8 changes: 8 additions & 0 deletions lib/Controller/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,14 @@ public function add(Request $request, Response $response)
$folderId = $this->getUser()->homeFolderId;
}

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');
}
}

$options = array_merge([
'oldMediaId' => null,
'updateInLayouts' => 0,
Expand Down
28 changes: 28 additions & 0 deletions lib/Controller/Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ public function addWidget(Request $request, Response $response, $type, $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');
}

// Load some information about this playlist
// loadWidgets = true to keep the ordering correct
$playlist->load([
Expand Down Expand Up @@ -466,6 +470,10 @@ public function editWidget(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');
}

$module = $this->moduleFactory->getByType($widget->type);

// Handle common parameters.
Expand Down Expand Up @@ -679,6 +687,10 @@ public function deleteWidget(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');
}

// Delete clears these, so cache them.
$widgetMedia = $widget->mediaIds;

Expand Down Expand Up @@ -837,6 +849,10 @@ public function editWidgetTransition(Request $request, Response $response, $type
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');
}

$widget->load();
$sanitizedParams = $this->getSanitizer($request->getParams());

Expand Down Expand Up @@ -1002,6 +1018,10 @@ public function widgetAudio(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');
}

// Are we allowed to do this?
if ($widget->type === 'subplaylist') {
throw new InvalidArgumentException(
Expand Down Expand Up @@ -1091,6 +1111,10 @@ public function widgetAudioDelete(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');
}

$widget->load();

foreach ($widget->audio as $audio) {
Expand Down Expand Up @@ -1529,6 +1553,10 @@ public function widgetExpiry(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');
}

$widget->load();

// Pull in the parameters we are expecting from the form.
Expand Down
Loading