diff --git a/airtime_mvc/application/common/TaskManager.php b/airtime_mvc/application/common/TaskManager.php index 8a4702d26..18ebe98f7 100644 --- a/airtime_mvc/application/common/TaskManager.php +++ b/airtime_mvc/application/common/TaskManager.php @@ -247,7 +247,7 @@ class PodcastTask implements AirtimeTask { */ class StationPodcastTask implements AirtimeTask { - const STATION_PODCAST_RESET_TIMER_SECONDS = 2.628e+6; // 1 month + const STATION_PODCAST_RESET_TIMER_SECONDS = 2.628e+6; // 1 month XXX: should we use datetime roll for this instead? /** * Check whether or not the download counter for the station podcast should be reset diff --git a/airtime_mvc/application/controllers/FeedsController.php b/airtime_mvc/application/controllers/FeedsController.php index 9a583275a..4c538fa48 100644 --- a/airtime_mvc/application/controllers/FeedsController.php +++ b/airtime_mvc/application/controllers/FeedsController.php @@ -4,6 +4,12 @@ class FeedsController extends Zend_Controller_Action { public function stationRssAction() { + if (Application_Model_Preference::getStationPodcastPrivacy() + && $this->getRequest()->getParam("sharing_token") != Application_Model_Preference::getStationPodcastDownloadKey()) { + $this->getResponse() + ->setHttpResponseCode(401); + return; + } $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 683f86dce..812ece169 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -51,6 +51,12 @@ 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(); + } + Application_Model_Preference::setStationPodcastPrivacy($values["stationPodcastPrivacy"]); + $logoUploadElement = $form->getSubForm('preferences_general')->getElement('stationLogo'); $logoUploadElement->receive(); $imagePath = $logoUploadElement->getFileName(); diff --git a/airtime_mvc/application/forms/PodcastPreferences.php b/airtime_mvc/application/forms/PodcastPreferences.php new file mode 100644 index 000000000..8c6bc0075 --- /dev/null +++ b/airtime_mvc/application/forms/PodcastPreferences.php @@ -0,0 +1,31 @@ +setDecorators(array( + array('ViewScript', array('viewScript' => 'form/preferences_podcast.phtml')) + )); + + $isPrivate = Application_Model_Preference::getStationPodcastPrivacy(); + $stationPodcastPrivacy = new Zend_Form_Element_Radio('stationPodcastPrivacy'); + $stationPodcastPrivacy->setLabel(_('Station Podcast Feed Privacy')); + $stationPodcastPrivacy->setMultiOptions(array( + _("Public"), + _("Private"), + )); + $stationPodcastPrivacy->setValue($isPrivate); + $this->addElement($stationPodcastPrivacy); + + $key = Application_Model_Preference::getStationPodcastDownloadKey(); + $url = Application_Common_HTTPHelper::getStationUrl()."feeds/station-rss".($isPrivate ? "?sharing_token=$key" : ""); + $feedUrl = new Zend_Form_Element_Text("stationPodcastFeedUrl:"); + $feedUrl->setAttrib('class', 'input_text') + ->setAttrib('disabled', 'disabled') + ->setRequired(false) + ->setLabel(_("Station Podcast Feed URL")) + ->setValue($url); + $this->addElement($feedUrl); + } + +} \ No newline at end of file diff --git a/airtime_mvc/application/forms/Preferences.php b/airtime_mvc/application/forms/Preferences.php index cb201cd2b..e41361b6f 100644 --- a/airtime_mvc/application/forms/Preferences.php +++ b/airtime_mvc/application/forms/Preferences.php @@ -26,6 +26,10 @@ class Application_Form_Preferences extends Zend_Form $this->addSubForm($general_pref, 'preferences_general'); + // Station Podcast form + $podcastPreferences = new Application_Form_PodcastPreferences(); + $this->addSubForm($podcastPreferences, 'preferences_podcast'); + //tunein form $tuneinPreferences = new Application_Form_TuneInPreferences(); $this->addSubForm($tuneinPreferences, 'preferences_tunein'); diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 79900d3df..f41a17b5b 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -1564,4 +1564,12 @@ class Application_Model_Preference $c = self::getStationPodcastDownloadCounter(); self::setValue("station_podcast_download_counter", empty($c) ? 0 : --$c); } + + public static function getStationPodcastPrivacy() { + return self::getValue("station_podcast_privacy"); + } + + public static function setStationPodcastPrivacy($value) { + self::setValue("station_podcast_privacy", $value); + } } diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php index 51b964589..a0d49e6a3 100644 --- a/airtime_mvc/application/models/Scheduler.php +++ b/airtime_mvc/application/models/Scheduler.php @@ -120,7 +120,7 @@ class Application_Model_Scheduler } //a show has been deleted - if (count($instanceIds) !== count($showInstances)) { + if (count($instanceIds) !== count($showInstan0ces)) { throw new OutDatedScheduleException(_("The schedule you're viewing is out of date! (instance mismatch)")); } @@ -133,6 +133,7 @@ class Application_Model_Scheduler } } + foreach ($showInstances as $instance) { $id = $instance->getDbId(); diff --git a/airtime_mvc/application/modules/rest/controllers/MediaController.php b/airtime_mvc/application/modules/rest/controllers/MediaController.php index f24d081b9..b0357af5e 100644 --- a/airtime_mvc/application/modules/rest/controllers/MediaController.php +++ b/airtime_mvc/application/modules/rest/controllers/MediaController.php @@ -69,7 +69,7 @@ class Rest_MediaController extends Zend_Rest_Controller $this->getResponse() ->setHttpResponseCode(200); $inline = false; - // SAAS-1081 + // SAAS-1081 - download counter for station podcast downloads if ($key = $this->getRequest()->getParam("download_key", false)) { Application_Model_Preference::incrementStationPodcastDownloadCounter(); $counterIncremented = true; diff --git a/airtime_mvc/application/views/scripts/form/preferences.phtml b/airtime_mvc/application/views/scripts/form/preferences.phtml index 58fd10ea2..be2857db8 100644 --- a/airtime_mvc/application/views/scripts/form/preferences.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences.phtml @@ -3,6 +3,11 @@ element->getSubform('preferences_general') ?> +

+
+ element->getSubform('preferences_podcast') ?> +
+

element->getSubform('preferences_tunein') ?> diff --git a/airtime_mvc/application/views/scripts/form/preferences_general.phtml b/airtime_mvc/application/views/scripts/form/preferences_general.phtml index 77f4201f5..514afb9f2 100644 --- a/airtime_mvc/application/views/scripts/form/preferences_general.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences_general.phtml @@ -14,11 +14,7 @@
element->getView()->logoImg; - if ($logoImg === DEFAULT_LOGO_PLACEHOLDER) { - $src = DEFAULT_LOGO_FILE; - } else { - $src = "data:image/png;base64,".$logoImg; - } + $src = ($logoImg === DEFAULT_LOGO_PLACEHOLDER) ? DEFAULT_LOGO_FILE : "data:image/png;base64,".$logoImg; ?>
@@ -39,6 +35,5 @@ element->getElement('radioPageLoginButton')->renderViewHelper() ?> element->getElement('radioPageLoginButton')->renderLabel() ?> - diff --git a/airtime_mvc/application/views/scripts/form/preferences_podcast.phtml b/airtime_mvc/application/views/scripts/form/preferences_podcast.phtml new file mode 100644 index 000000000..d7feb4249 --- /dev/null +++ b/airtime_mvc/application/views/scripts/form/preferences_podcast.phtml @@ -0,0 +1,6 @@ +
+
+ element->getElement('stationPodcastPrivacy')->render() ?> + element->getElement('stationPodcastFeedUrl')->render() ?> +
+
diff --git a/airtime_mvc/public/js/airtime/library/publish.js b/airtime_mvc/public/js/airtime/library/publish.js index 85b760bca..00c5156b4 100644 --- a/airtime_mvc/public/js/airtime/library/publish.js +++ b/airtime_mvc/public/js/airtime/library/publish.js @@ -16,7 +16,6 @@ var AIRTIME = (function (AIRTIME) { //AngularJS app var publishApp = angular.module(PUBLISH_APP_NAME, []) .controller('RestController', function($scope, $http, mediaId, tab) { - $scope.publishSources = {}; $http.get(endpoint + mediaId, { csrf_token: jQuery("#csrf").val() })