diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 02e3c406b..5ab4c5071 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -51,20 +51,6 @@ class PreferenceController extends Zend_Controller_Action Application_Model_Preference::SetWeekStartDay($values["weekStartDay"]); Application_Model_Preference::setRadioPageDisplayLoginButton($values["radioPageLoginButton"]); - if (!Application_Model_Preference::getStationPodcastPrivacy() && $values["stationPodcastPrivacy"] == 1) { - // Refresh the download key when enabling privacy - Application_Model_Preference::setStationPodcastDownloadKey(); - } - - // Append sharing token (download key) to Station podcast URL - $stationPodcast = PodcastQuery::create()->findOneByDbId(Application_Model_Preference::getStationPodcastId()); - $key = Application_Model_Preference::getStationPodcastDownloadKey(); - $url = Application_Common_HTTPHelper::getStationUrl() . - (((int) $values["stationPodcastPrivacy"]) ? "feeds/station-rss?sharing_token=$key" : "feeds/station-rss"); - $stationPodcast->setDbUrl($url)->save(); - Application_Model_Preference::setStationPodcastPrivacy($values["stationPodcastPrivacy"]); - - $logoUploadElement = $form->getSubForm('preferences_general')->getElement('stationLogo'); $logoUploadElement->receive(); $imagePath = $logoUploadElement->getFileName(); @@ -97,6 +83,28 @@ class PreferenceController extends Zend_Controller_Action $this->view->form = $form; } + public function stationPodcastSettingsAction() { + $this->view->layout()->disableLayout(); + $this->_helper->viewRenderer->setNoRender(true); + + $values = json_decode($this->getRequest()->getRawBody()); + + if (!Application_Model_Preference::getStationPodcastPrivacy() && $values->stationPodcastPrivacy == 1) { + // Refresh the download key when enabling privacy + Application_Model_Preference::setStationPodcastDownloadKey(); + } + + // Append sharing token (download key) to Station podcast URL + $stationPodcast = PodcastQuery::create()->findOneByDbId(Application_Model_Preference::getStationPodcastId()); + $key = Application_Model_Preference::getStationPodcastDownloadKey(); + $url = Application_Common_HTTPHelper::getStationUrl() . + (((int) $values->stationPodcastPrivacy) ? "feeds/station-rss?sharing_token=$key" : "feeds/station-rss"); + $stationPodcast->setDbUrl($url)->save(); + Application_Model_Preference::setStationPodcastPrivacy($values->stationPodcastPrivacy); + + $this->_helper->json->sendJson(array("url" => $url)); + } + public function supportSettingAction() { $CC_CONFIG = Config::getConfig(); diff --git a/airtime_mvc/application/views/scripts/podcast/station.phtml b/airtime_mvc/application/views/scripts/podcast/station.phtml index e14e04771..a271bf4ed 100644 --- a/airtime_mvc/application/views/scripts/podcast/station.phtml +++ b/airtime_mvc/application/views/scripts/podcast/station.phtml @@ -5,9 +5,13 @@

+ +
form->getElement('csrf') ?> @@ -87,7 +91,7 @@ - + diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index 50216b109..c9652e9fe 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -4001,6 +4001,10 @@ li .ui-state-hover { flex: 1 100%; } +.station_podcast_wrapper { + min-width: 50%; +} + .angular_wrapper legend { background-color: #242424; color: #efefef; diff --git a/airtime_mvc/public/js/airtime/library/podcast.js b/airtime_mvc/public/js/airtime/library/podcast.js index 01fadfa13..75ea8d5ed 100644 --- a/airtime_mvc/public/js/airtime/library/podcast.js +++ b/airtime_mvc/public/js/airtime/library/podcast.js @@ -34,14 +34,18 @@ var AIRTIME = (function (AIRTIME) { $scope.csrf = jQuery("#csrf").val(); view.find("table").attr("id", "podcast_episodes_" + podcast.id); + self.onSaveCallback = function () { + AIRTIME.library.podcastDataTable.fnDraw(); + tab.close(); + }; + /** * Save and update the podcast object. */ $scope.savePodcast = function () { $http.put(endpoint + $scope.podcast.id, {csrf_token: $scope.csrf, podcast: $scope.podcast}) .success(function () { - AIRTIME.library.podcastDataTable.fnDraw(); - !tab || tab.close(); + self.onSaveCallback(); }); }; @@ -96,7 +100,20 @@ var AIRTIME = (function (AIRTIME) { function StationPodcastController($scope, $http, podcast, tab) { // Super call to parent controller PodcastController.call(this, $scope, $http, podcast, tab); - + this.onSaveCallback = function () { + $http({ + method: 'POST', + url: '/preference/station-podcast-settings', + headers: {'Content-Type': 'application/x-www-form-urlencoded'}, + data: { stationPodcastPrivacy: $("#podcast-settings").find("input:checked").val() } + }).success(function (data) { + $("#preferences_podcast-stationPodcastFeedUrl").val(data.url); + $(".success").text($.i18n._("Podcast settings saved")).slideDown("fast"); + setTimeout(function () { + $(".success").slideUp("fast"); + }, 2000); + }); + }; return this; }