diff --git a/lib/Controller/Library.php b/lib/Controller/Library.php index 2c3c217811..ff07ee7ff4 100644 --- a/lib/Controller/Library.php +++ b/lib/Controller/Library.php @@ -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, diff --git a/lib/Controller/Widget.php b/lib/Controller/Widget.php index bb1f0ded8e..abc8940a15 100644 --- a/lib/Controller/Widget.php +++ b/lib/Controller/Widget.php @@ -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([ @@ -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. @@ -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; @@ -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()); @@ -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( @@ -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) { @@ -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.