set auto-generated smartblock and playlist title directly from input

This commit is contained in:
ryan 2018-12-14 15:24:28 -06:00
parent 15b73580c1
commit 15cf291bc9
3 changed files with 53 additions and 40 deletions

View File

@ -198,14 +198,15 @@ class Rest_PodcastController extends Zend_Rest_Controller
public function smartblockAction() { public function smartblockAction() {
$title = $this->_getParam('title', []);
$id = $this->_getParam('id', []); $id = $this->_getParam('id', []);
if (!$id) { if (!$id) {
return; return;
} }
$podcast = Application_Service_PodcastService::getPodcastById($id); $podcast = Application_Service_PodcastService::getPodcastById($id);
logging::info($podcast); // logging::info($podcast);
Application_Service_PodcastService::createPodcastSmartblockAndPlaylist($podcast); Application_Service_PodcastService::createPodcastSmartblockAndPlaylist($podcast, $title);
} }

View File

@ -162,10 +162,11 @@ class Application_Service_PodcastService
/** /**
* @param $podcast * @param $podcast
* @param $title passed in directly from web UI input
* This will automatically create a smartblock and playlist for this podcast. * This will automatically create a smartblock and playlist for this podcast.
*/ */
public static function createPodcastSmartblockAndPlaylist($podcast) public static function createPodcastSmartblockAndPlaylist($podcast, $title)
{ {
if (is_array($podcast)) { if (is_array($podcast)) {
$newpodcast = new Podcast(); $newpodcast = new Podcast();
@ -175,7 +176,7 @@ class Application_Service_PodcastService
// Base class // Base class
$newBl = new Application_Model_Block(); $newBl = new Application_Model_Block();
$newBl->setCreator(Application_Model_User::getCurrentUser()->getId()); $newBl->setCreator(Application_Model_User::getCurrentUser()->getId());
$newBl->setName($podcast->getDbTitle()); $newBl->setName($title);
$newBl->setDescription('Auto-generated smartblock for podcast'); $newBl->setDescription('Auto-generated smartblock for podcast');
$newBl->saveType('dynamic'); $newBl->saveType('dynamic');
// limit the smartblock to 1 item // limit the smartblock to 1 item
@ -198,12 +199,12 @@ class Application_Service_PodcastService
$row = new CcBlockcriteria(); $row = new CcBlockcriteria();
$row->setDbCriteria('album_title'); $row->setDbCriteria('album_title');
$row->setDbModifier('is'); $row->setDbModifier('is');
$row->setDbValue($newBl->getName()); $row->setDbValue($title);
$row->setDbBlockId($newBl->getId()); $row->setDbBlockId($newBl->getId());
$row->save(); $row->save();
$newPl = new Application_Model_Playlist(); $newPl = new Application_Model_Playlist();
$newPl->setName($podcast->getDbTitle()); $newPl->setName($title);
$newPl->setCreator(Application_Model_User::getCurrentUser()->getId()); $newPl->setCreator(Application_Model_User::getCurrentUser()->getId());
$row = new CcPlaylistcontents(); $row = new CcPlaylistcontents();
$row->setDbBlockId($newBl->getId()); $row->setDbBlockId($newBl->getId());

View File

@ -54,7 +54,18 @@ var AIRTIME = (function (AIRTIME) {
* Generate a smartblock and playlist for this smartblock. * Generate a smartblock and playlist for this smartblock.
*/ */
$scope.createSmartblock = function () { $scope.createSmartblock = function () {
$.post(endpoint + "smartblock", {csrf_token: $("#csrf").val(), id: $scope.podcast.id}, callback); // send smarblock creation instruction to API
$.post(
endpoint + "smartblock",
{
csrf_token: $("#csrf").val(),
id: $scope.podcast.id,
title: $scope.podcast.title
},
callback
);
// save podcast
$scope.savePodcast();
}; };
/** /**
* Close the tab and discard any changes made to the podcast data. * Close the tab and discard any changes made to the podcast data.