diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 1b97672f8..219e35e01 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -38,6 +38,7 @@ class PreferenceController extends Zend_Controller_Action if ($form->isValid($values)) { Application_Model_Preference::SetHeadTitle($values["stationName"], $this->view); + Application_Model_Preference::SetStationDescription($values["stationDescription"]); Application_Model_Preference::SetDefaultCrossfadeDuration($values["stationDefaultCrossfadeDuration"]); Application_Model_Preference::SetDefaultFadeIn($values["stationDefaultFadeIn"]); Application_Model_Preference::SetDefaultFadeOut($values["stationDefaultFadeOut"]); @@ -49,7 +50,11 @@ class PreferenceController extends Zend_Controller_Action $logoUploadElement = $form->getSubForm('preferences_general')->getElement('stationLogo'); $logoUploadElement->receive(); $imagePath = $logoUploadElement->getFileName(); - Application_Model_Preference::SetStationLogo($imagePath); + + // Only update the image logo if the new logo is non-empty + if (!empty($imagePath) && $imagePath != "") { + Application_Model_Preference::SetStationLogo($imagePath); + } Application_Model_Preference::SetUploadToSoundcloudOption($values["UploadToSoundcloudOption"]); Application_Model_Preference::SetSoundCloudDownloadbleOption($values["SoundCloudDownloadbleOption"]); diff --git a/airtime_mvc/application/forms/AddShowStyle.php b/airtime_mvc/application/forms/AddShowStyle.php index d6e97e019..7d79a90e9 100644 --- a/airtime_mvc/application/forms/AddShowStyle.php +++ b/airtime_mvc/application/forms/AddShowStyle.php @@ -79,7 +79,7 @@ class Application_Form_AddShowStyle extends Zend_Form_SubForm ->addValidator('Count', false, 1) ->addValidator('Extension', false, 'jpg,jpeg,png,gif') ->addFilter('ImageSize'); - + $this->addElement($upload); // Add image preview @@ -93,6 +93,14 @@ class Application_Form_AddShowStyle extends Zend_Form_SubForm 'class' => 'big' )))); $preview->setAttrib('disabled','disabled'); + + $csrf_namespace = new Zend_Session_Namespace('csrf_namespace'); + $csrf_element = new Zend_Form_Element_Hidden('csrf'); + $csrf_element->setValue($csrf_namespace->authtoken) + ->setRequired('true') + ->removeDecorator('HtmlTag') + ->removeDecorator('Label'); + $this->addElement($csrf_element); } public function disable() diff --git a/airtime_mvc/application/forms/GeneralPreferences.php b/airtime_mvc/application/forms/GeneralPreferences.php index 420c2af71..b8a066e3e 100644 --- a/airtime_mvc/application/forms/GeneralPreferences.php +++ b/airtime_mvc/application/forms/GeneralPreferences.php @@ -49,6 +49,13 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm $stationLogoUpload->setAttrib('accept', 'image/*'); $this->addElement($stationLogoUpload); + $stationLogoRemove = new Zend_Form_Element_Button('stationLogoRemove'); + $stationLogoRemove->setLabel(_('Remove')); + $stationLogoRemove->setAttrib('class', 'btn'); + $stationLogoRemove->setAttrib('id', 'logo-remove-btn'); + $stationLogoRemove->setAttrib('onclick', 'removeLogo();'); + $this->addElement($stationLogoRemove); + //Default station crossfade duration $this->addElement('text', 'stationDefaultCrossfadeDuration', array( 'class' => 'input_text', diff --git a/airtime_mvc/application/views/scripts/form/preferences_general.phtml b/airtime_mvc/application/views/scripts/form/preferences_general.phtml index 65be0a13b..b93cb0a86 100644 --- a/airtime_mvc/application/views/scripts/form/preferences_general.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences_general.phtml @@ -7,10 +7,12 @@ element->getElement('stationLogo')->render() ?> - + element->getElement('stationLogoRemove')->render() ?> + +
- +
element->getElement('locale')->render() ?> diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index e99ac2f02..31a3f8383 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -2197,12 +2197,17 @@ dd.radio-inline-list, .preferences dd.radio-inline-list, .stream-config dd.radio height: 120px; } +.preferences #stationLogoRemove-label { + display: none; +} + .preferences #logo-remove-btn { float: right; + margin-bottom: 4px; } .preferences #Logo-img-container { - float: left; + margin-top: 30px; } #show_time_info { diff --git a/airtime_mvc/public/js/airtime/preferences/preferences.js b/airtime_mvc/public/js/airtime/preferences/preferences.js index 5af4893ee..1dffe24d2 100644 --- a/airtime_mvc/public/js/airtime/preferences/preferences.js +++ b/airtime_mvc/public/js/airtime/preferences/preferences.js @@ -115,6 +115,11 @@ function setSoundCloudCheckBoxListener() { }); } +function removeLogo() { + $.post(baseUrl+'Preference/remove-logo', function(json){}); + location.reload(); +} + $(document).ready(function() { $('.collapsible-header').live('click',function() { @@ -123,10 +128,6 @@ $(document).ready(function() { return false; }).next().hide(); - $('#logo-remove-btn').click(function() { - $.post(baseUrl+'Preference/remove-logo', function(json){}); - }); - /* No longer using AJAX for this form. Zend + our code makes it needlessly hard to deal with. -- Albert $('#pref_save').live('click', function() { var data = $('#pref_form').serialize(); diff --git a/airtime_mvc/public/js/airtime/schedule/add-show.js b/airtime_mvc/public/js/airtime/schedule/add-show.js index aee048fd8..a8c9f76e7 100644 --- a/airtime_mvc/public/js/airtime/schedule/add-show.js +++ b/airtime_mvc/public/js/airtime/schedule/add-show.js @@ -668,7 +668,7 @@ function setAddShowEvents(form) { var showId = $("#add_show_id").attr("value"); if (showId && $("#add_show_logo_current").attr("src") !== "") { - var action = '/rest/show-image?id=' + showId; + var action = '/rest/show-image?csrf_token=' + $('#csrf').val() + '&id=' + showId; $.ajax({ url: action, @@ -748,7 +748,7 @@ function setAddShowEvents(form) { data: {format: "json", data: data, hosts: hosts, days: days}, success: function(json) { if (json.showId && image) { // Successfully added the show, and it contains an image to upload - var imageAction = '/rest/show-image?id=' + json.showId; + var imageAction = '/rest/show-image?csrf_token=' + $('#csrf').val() + '&id=' + json.showId; // perform a second xhttprequest in order to send the show image $.ajax({