Add station podcast privacy toggle

This commit is contained in:
Duncan Sommerville 2015-10-21 17:30:24 -04:00
parent 92ffa955c3
commit 6580c12ad3
12 changed files with 71 additions and 10 deletions

View file

@ -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

View file

@ -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);

View file

@ -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();

View file

@ -0,0 +1,31 @@
<?php
class Application_Form_PodcastPreferences extends Zend_Form_SubForm {
public function init() {
$this->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);
}
}

View file

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

View file

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

View file

@ -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();

View file

@ -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;

View file

@ -3,6 +3,11 @@
<?php echo $this->element->getSubform('preferences_general') ?>
<h3 class="collapsible-header" id="podcast-heading"><span class="arrow-icon"></span><?php echo _("Station Podcast Settings"); ?></h3>
<div class="collapsible-content" id="podcast-settings">
<?php echo $this->element->getSubform('preferences_podcast') ?>
</div>
<h3 class="collapsible-header" id="tunein-pref-heading"><span class="arrow-icon"></span><?php echo _("TuneIn Settings"); ?></h3>
<div class="collapsible-content" id="tunein-settings">
<?php echo $this->element->getSubform('preferences_tunein') ?>

View file

@ -14,11 +14,7 @@
<div id="Logo-img-container">
<?php
$logoImg = $this->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;
?>
<img onError="this.onerror = '';this.style.visibility='hidden';$('#logo-remove-btn').hide();$('[id^=stationLogoRemove]').each(function(i,v){v.style.width=v.style.height=v.style.margin=v.style.padding='0px';});" id="logo-img" onload='resizeImg(this, 450, 450);' src="<?php echo $src ?>" />
</div>
@ -39,6 +35,5 @@
<?php echo $this->element->getElement('radioPageLoginButton')->renderViewHelper() ?>
<?php echo $this->element->getElement('radioPageLoginButton')->renderLabel() ?>
</dl>
</fieldset>

View file

@ -0,0 +1,6 @@
<fieldset class="padded">
<dl class="zend_form">
<?php echo $this->element->getElement('stationPodcastPrivacy')->render() ?>
<?php echo $this->element->getElement('stationPodcastFeedUrl')->render() ?>
</dl>
</fieldset>

View file

@ -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() })