From 457230ba07613af134b3f5d7bea7b5cb7b7ad9e9 Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Fri, 3 Jul 2015 13:32:41 -0400 Subject: [PATCH 1/7] SAAS-876 - Initial commit --- .../controllers/PreferenceController.php | 124 +++++++++--------- .../forms/LiveStreamingPreferences.php | 3 +- .../application/forms/StreamSetting.php | 11 ++ .../forms/StreamSettingSubForm.php | 38 +++--- airtime_mvc/application/models/Preference.php | 10 ++ .../scripts/form/stream-setting-form.phtml | 2 +- .../scripts/preference/stream-setting.phtml | 30 +++-- airtime_mvc/public/css/styles.css | 4 + .../js/airtime/preferences/streamsetting.js | 2 +- 9 files changed, 125 insertions(+), 99 deletions(-) diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 5803d3223..16c2bf2b3 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -148,9 +148,6 @@ class PreferenceController extends Zend_Controller_Action session_start(); //Open session for writing. - // get current settings - $setting = Application_Model_StreamSetting::getStreamSetting(); - $name_map = array( 'ogg' => 'Ogg Vorbis', 'fdkaac' => 'AAC+', @@ -159,55 +156,14 @@ class PreferenceController extends Zend_Controller_Action 'mp3' => 'MP3', ); - // get predefined type and bitrate from pref table - $temp_types = Application_Model_Preference::GetStreamType(); - $stream_types = array(); - foreach ($temp_types as $type) { - $type = strtolower(trim($type)); - if (isset($name_map[$type])) { - $name = $name_map[$type]; - } else { - $name = $type; - } - $stream_types[$type] = $name; - } - - $temp_bitrate = Application_Model_Preference::GetStreamBitrate(); - $max_bitrate = intval(Application_Model_Preference::GetMaxBitrate()); - $stream_bitrates = array(); - foreach ($temp_bitrate as $type) { - if (intval($type) <= $max_bitrate) { - $stream_bitrates[trim($type)] = strtoupper(trim($type))." kbit/s"; - } - } - $num_of_stream = intval(Application_Model_Preference::GetNumOfStreams()); $form = new Application_Form_StreamSetting(); - // $form->addElement('hash', 'csrf', array( - // 'salt' => 'unique' - // )); - $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'); $form->addElement($csrf_element); - $form->setSetting($setting); - $form->startFrom(); - - $live_stream_subform = new Application_Form_LiveStreamingPreferences(); - $form->addSubForm($live_stream_subform, "live_stream_subform"); - - for ($i=1; $i<=$num_of_stream; $i++) { - $subform = new Application_Form_StreamSettingSubForm(); - $subform->setPrefix($i); - $subform->setSetting($setting); - $subform->setStreamTypes($stream_types); - $subform->setStreamBitrates($stream_bitrates); - $subform->startForm(); - $form->addSubForm($subform, "s".$i."_subform"); - } if ($request->isPost()) { $params = $request->getPost(); /* Parse through post data and put in format @@ -245,7 +201,6 @@ class PreferenceController extends Zend_Controller_Action $values["s3_data"] = $s3_data; $values["s4_data"] = $s4_data; - $error = false; if ($form->isValid($values)) { $values['icecast_vorbis_metadata'] = $form->getValue('icecast_vorbis_metadata'); @@ -262,6 +217,7 @@ class PreferenceController extends Zend_Controller_Action $s4_set_admin_pass = !empty($values["s4_data"]["admin_pass"]); // this goes into cc_pref table + Application_Model_Preference::setUsingCustomStreamSettings($values['customStreamSettings']); Application_Model_Preference::SetStreamLabelFormat($values['streamFormat']); Application_Model_Preference::SetLiveStreamMasterUsername($values["master_username"]); Application_Model_Preference::SetLiveStreamMasterPassword($values["master_password"]); @@ -292,35 +248,73 @@ class PreferenceController extends Zend_Controller_Action Application_Model_StreamSetting::setLiquidsoapError($i, "waiting"); } - Application_Model_RabbitMq::SendMessageToPypo("update_stream_setting", $data); - - $live_stream_subform->updateVariables(); - $this->view->enable_stream_conf = Application_Model_Preference::GetEnableStreamConf(); - $this->view->form = $form; - $this->view->num_stream = $num_of_stream; + if (Application_Model_Preference::getUsingCustomStreamSettings()) { + Application_Model_RabbitMq::SendMessageToPypo("update_stream_setting", $data); + } $this->view->statusMsg = "
"._("Stream Setting Updated.")."
"; - $this->_helper->json->sendJson(array( - "valid"=>"true", - "html"=>$this->view->render('preference/stream-setting.phtml'), - "s1_set_admin_pass"=>$s1_set_admin_pass, - "s2_set_admin_pass"=>$s2_set_admin_pass, - "s3_set_admin_pass"=>$s3_set_admin_pass, - "s4_set_admin_pass"=>$s4_set_admin_pass, - )); - } else { - $live_stream_subform->updateVariables(); - $this->view->enable_stream_conf = Application_Model_Preference::GetEnableStreamConf(); - $this->view->form = $form; - $this->view->num_stream = $num_of_stream; - $this->_helper->json->sendJson(array("valid"=>"false", "html"=>$this->view->render('preference/stream-setting.phtml'))); } } + // get predefined type and bitrate from pref table + $temp_types = Application_Model_Preference::GetStreamType(); + $stream_types = array(); + foreach ($temp_types as $type) { + $type = strtolower(trim($type)); + if (isset($name_map[$type])) { + $name = $name_map[$type]; + } else { + $name = $type; + } + $stream_types[$type] = $name; + } + + $temp_bitrate = Application_Model_Preference::GetStreamBitrate(); + $max_bitrate = intval(Application_Model_Preference::GetMaxBitrate()); + $stream_bitrates = array(); + foreach ($temp_bitrate as $type) { + if (intval($type) <= $max_bitrate) { + $stream_bitrates[trim($type)] = strtoupper(trim($type))." kbit/s"; + } + } + + // get current settings + $setting = Application_Model_StreamSetting::getStreamSetting(); + + $form->setSetting($setting); + $form->startFrom(); + + $live_stream_subform = new Application_Form_LiveStreamingPreferences(); + $form->addSubForm($live_stream_subform, "live_stream_subform"); + + for ($i=1; $i<=$num_of_stream; $i++) { + $subform = new Application_Form_StreamSettingSubForm(); + $subform->setPrefix($i); + $subform->setSetting($setting); + $subform->setStreamTypes($stream_types); + $subform->setStreamBitrates($stream_bitrates); + $subform->startForm(); + $form->addSubForm($subform, "s".$i."_subform"); + } + $live_stream_subform->updateVariables(); $this->view->num_stream = $num_of_stream; $this->view->enable_stream_conf = Application_Model_Preference::GetEnableStreamConf(); $this->view->form = $form; + if ($request->isPost()) { + if ($form->isValid($values)) { + $this->_helper->json->sendJson(array( + "valid" => "true", + "html" => $this->view->render('preference/stream-setting.phtml'), + "s1_set_admin_pass" => $s1_set_admin_pass, + "s2_set_admin_pass" => $s2_set_admin_pass, + "s3_set_admin_pass" => $s3_set_admin_pass, + "s4_set_admin_pass" => $s4_set_admin_pass, + )); + } else { + $this->_helper->json->sendJson(array("valid" => "false", "html" => $this->view->render('preference/stream-setting.phtml'))); + } + } } public function serverBrowseAction() diff --git a/airtime_mvc/application/forms/LiveStreamingPreferences.php b/airtime_mvc/application/forms/LiveStreamingPreferences.php index f22ed0054..e0b9e1ec1 100644 --- a/airtime_mvc/application/forms/LiveStreamingPreferences.php +++ b/airtime_mvc/application/forms/LiveStreamingPreferences.php @@ -7,7 +7,6 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm { $CC_CONFIG = Config::getConfig(); $isDemo = isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1; - $isStreamConfigable = Application_Model_Preference::GetEnableStreamConf() == "true"; $defaultFade = Application_Model_Preference::GetDefaultTransitionFade(); @@ -103,7 +102,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm $this->addElement($showSourceMount); // demo only code - if (!$isStreamConfigable) { + if ($isDemo) { $elements = $this->getElements(); foreach ($elements as $element) { if ($element->getType() != 'Zend_Form_Element_Hidden') { diff --git a/airtime_mvc/application/forms/StreamSetting.php b/airtime_mvc/application/forms/StreamSetting.php index 262432686..1f149eae4 100644 --- a/airtime_mvc/application/forms/StreamSetting.php +++ b/airtime_mvc/application/forms/StreamSetting.php @@ -16,6 +16,10 @@ class Application_Form_StreamSetting extends Zend_Form public function startFrom() { + $this->setDecorators(array( + array('ViewScript', array('viewScript' => 'preference/stream-setting.phtml')) + )); + $setting = $this->setting; $icecast_vorbis_metadata = new Zend_Form_Element_Checkbox('icecast_vorbis_metadata'); @@ -55,6 +59,13 @@ class Application_Form_StreamSetting extends Zend_Form ->setAttribs(array('style' => "border: 0; color: #f6931f; font-weight: bold;")) ->setDecorators(array('ViewHelper')); $this->addElement($replay_gain); + + $custom = Application_Model_Preference::getUsingCustomStreamSettings(); + $customSettings = new Zend_Form_Element_Radio('customStreamSettings'); + $customSettings->setLabel(_('Stream Settings:')); + $customSettings->setMultiOptions(array(_("Default"), _("Use Custom"))); + $customSettings->setValue(!empty($custom) ? $custom : 0); + $this->addElement($customSettings); } public function isValid($data) diff --git a/airtime_mvc/application/forms/StreamSettingSubForm.php b/airtime_mvc/application/forms/StreamSettingSubForm.php index 8d1f96f43..435d465da 100644 --- a/airtime_mvc/application/forms/StreamSettingSubForm.php +++ b/airtime_mvc/application/forms/StreamSettingSubForm.php @@ -42,7 +42,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm $this->setIsArray(true); $this->setElementsBelongTo($prefix."_data"); - $disable_all = Application_Model_Preference::GetEnableStreamConf() == "false"; + $disable_all = !Application_Model_Preference::getUsingCustomStreamSettings(); $enable = new Zend_Form_Element_Checkbox('enable'); $enable->setLabel(_('Enabled:')) @@ -221,10 +221,10 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm $adminPass->setAttrib('alt', 'regular_text'); $this->addElement($adminPass); - $liquidsopa_error_msg = '

'._('Getting information from the server...').'

'; + $liquidsoap_error_msg = '

'._('Getting information from the server...').'

'; $this->setDecorators(array( - array('ViewScript', array('viewScript' => 'form/stream-setting-form.phtml', "stream_number"=>$stream_number, "enabled"=>$enable->getValue(), "liquidsoap_error_msg"=>$liquidsopa_error_msg)) + array('ViewScript', array('viewScript' => 'form/stream-setting-form.phtml', "stream_number"=>$stream_number, "enabled"=>$enable->getValue(), "liquidsoap_error_msg"=>$liquidsoap_error_msg)) )); } @@ -232,23 +232,25 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm { $f_data = $data['s'.$this->prefix."_data"]; $isValid = parent::isValid($f_data); - if ($f_data['enable'] == 1) { - if ($f_data['host'] == '') { - $element = $this->getElement("host"); - $element->addError(_("Server cannot be empty.")); - $isValid = false; - } - if ($f_data['port'] == '') { - $element = $this->getElement("port"); - $element->addError(_("Port cannot be empty.")); - $isValid = false; - } - if ($f_data['output'] == 'icecast') { - if ($f_data['mount'] == '') { - $element = $this->getElement("mount"); - $element->addError(_("Mount cannot be empty with Icecast server.")); + if ($f_data) { + if ($f_data['enable'] == 1) { + if ($f_data['host'] == '') { + $element = $this->getElement("host"); + $element->addError(_("Server cannot be empty.")); $isValid = false; } + if ($f_data['port'] == '') { + $element = $this->getElement("port"); + $element->addError(_("Port cannot be empty.")); + $isValid = false; + } + if ($f_data['output'] == 'icecast') { + if ($f_data['mount'] == '') { + $element = $this->getElement("mount"); + $element->addError(_("Mount cannot be empty with Icecast server.")); + $isValid = false; + } + } } } diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index e8d116246..e597ecd27 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -1489,4 +1489,14 @@ class Application_Model_Preference self::setValue("task_manager_lock", $value); } + // SAAS-876 - Toggle indicating whether user is using custom stream settings + + public static function getUsingCustomStreamSettings() { + return self::getValue("using_custom_stream_settings"); + } + + public static function setUsingCustomStreamSettings($value) { + self::setValue("using_custom_stream_settings", $value); + } + } diff --git a/airtime_mvc/application/views/scripts/form/stream-setting-form.phtml b/airtime_mvc/application/views/scripts/form/stream-setting-form.phtml index a8d61d247..ca98ed789 100644 --- a/airtime_mvc/application/views/scripts/form/stream-setting-form.phtml +++ b/airtime_mvc/application/views/scripts/form/stream-setting-form.phtml @@ -1,7 +1,7 @@ stream_number; ?> -

">stream_number?>

+

">stream_number?>

enabled == 0?'style="display: none;':''?> id="-config">
diff --git a/airtime_mvc/application/views/scripts/preference/stream-setting.phtml b/airtime_mvc/application/views/scripts/preference/stream-setting.phtml index 29fbc6756..32d1b034d 100644 --- a/airtime_mvc/application/views/scripts/preference/stream-setting.phtml +++ b/airtime_mvc/application/views/scripts/preference/stream-setting.phtml @@ -1,12 +1,10 @@
-

enable_stream_conf == "true"){?>style="float:left">

+

- enable_stream_conf == "true"){?>
- + form->getElement('csrf') ?>
- statusMsg;?>
@@ -39,6 +37,12 @@
form->getElement('icecast_vorbis_metadata') ?>
+ + form->getElement('customStreamSettings')->render(); + ?> +
@@ -105,16 +109,18 @@
- num_stream;$i++){ - echo $this->form->getSubform("s".$i."_subform"); - } - ?> + num_stream;$i++){ + echo $this->form->getSubform("s".$i."_subform"); + } + } else { + // TODO: replace this with something that looks good + } + ?>
- enable_stream_conf == "true"){?>
- - +
diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index 6ad9b941c..5d9bc4a67 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -2252,6 +2252,10 @@ span.errors.sp-errors{ width: 1100px; } +#stream_save_bottom { + bottom: 0; +} + .preferences .padded { margin-top: 5px; /* Firefox needs this */ } diff --git a/airtime_mvc/public/js/airtime/preferences/streamsetting.js b/airtime_mvc/public/js/airtime/preferences/streamsetting.js index 0fd0cd90a..54e397da6 100644 --- a/airtime_mvc/public/js/airtime/preferences/streamsetting.js +++ b/airtime_mvc/public/js/airtime/preferences/streamsetting.js @@ -469,7 +469,7 @@ $(document).ready(function() { setSliderForReplayGain(); getAdminPasswordStatus(); - $('#stream_save').live('click', function(){ + $("[id^='stream_save']").live('click', function(){ var confirm_pypo_restart_text = sprintf($.i18n._("If you change the username or password values for an enabled stream the playout engine will be rebooted and your listeners will hear silence for 5-10 seconds. Changing the following fields will NOT cause a reboot: Stream Label (Global Settings), and Switch Transition Fade(s), Master Username, and Master Password (Input Stream Settings). If %s is recording, and if the change causes a playout engine restart, the recording will be interrupted."), PRODUCT_NAME); if (confirm(confirm_pypo_restart_text)) { var data = $('#stream_form').serialize(); From ac2e1a2d4bc55b29027f280839407d492121077c Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Wed, 8 Jul 2015 16:04:09 -0400 Subject: [PATCH 2/7] SAAS-876 - More work on stream settings page --- .../controllers/PreferenceController.php | 5 +- .../application/forms/StreamSetting.php | 4 +- .../forms/StreamSettingSubForm.php | 76 ++++++------------- .../scripts/preference/stream-setting.phtml | 15 +--- airtime_mvc/public/css/styles.css | 1 + .../js/airtime/preferences/streamsetting.js | 9 ++- 6 files changed, 38 insertions(+), 72 deletions(-) diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 16c2bf2b3..3ee1be528 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -248,9 +248,7 @@ class PreferenceController extends Zend_Controller_Action Application_Model_StreamSetting::setLiquidsoapError($i, "waiting"); } - if (Application_Model_Preference::getUsingCustomStreamSettings()) { - Application_Model_RabbitMq::SendMessageToPypo("update_stream_setting", $data); - } + Application_Model_RabbitMq::SendMessageToPypo("update_stream_setting", $data); $this->view->statusMsg = "
"._("Stream Setting Updated.")."
"; } } @@ -293,6 +291,7 @@ class PreferenceController extends Zend_Controller_Action $subform->setStreamTypes($stream_types); $subform->setStreamBitrates($stream_bitrates); $subform->startForm(); + $subform->toggleState(); $form->addSubForm($subform, "s".$i."_subform"); } diff --git a/airtime_mvc/application/forms/StreamSetting.php b/airtime_mvc/application/forms/StreamSetting.php index 1f149eae4..bbef95ca3 100644 --- a/airtime_mvc/application/forms/StreamSetting.php +++ b/airtime_mvc/application/forms/StreamSetting.php @@ -62,8 +62,8 @@ class Application_Form_StreamSetting extends Zend_Form $custom = Application_Model_Preference::getUsingCustomStreamSettings(); $customSettings = new Zend_Form_Element_Radio('customStreamSettings'); - $customSettings->setLabel(_('Stream Settings:')); - $customSettings->setMultiOptions(array(_("Default"), _("Use Custom"))); + $customSettings->setLabel(_('Streaming Server:')); + $customSettings->setMultiOptions(array(_("Airtime Pro Streaming"), _("Custom / 3rd Party"))); $customSettings->setValue(!empty($custom) ? $custom : 0); $this->addElement($customSettings); } diff --git a/airtime_mvc/application/forms/StreamSettingSubForm.php b/airtime_mvc/application/forms/StreamSettingSubForm.php index 435d465da..fe6c95d89 100644 --- a/airtime_mvc/application/forms/StreamSettingSubForm.php +++ b/airtime_mvc/application/forms/StreamSettingSubForm.php @@ -6,6 +6,8 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm private $stream_types; private $stream_bitrates; + static $customizable; + public function init() { @@ -42,51 +44,41 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm $this->setIsArray(true); $this->setElementsBelongTo($prefix."_data"); - $disable_all = !Application_Model_Preference::getUsingCustomStreamSettings(); - $enable = new Zend_Form_Element_Checkbox('enable'); $enable->setLabel(_('Enabled:')) ->setValue($setting[$prefix.'_enable'] == 'true' ? 1 : 0) ->setDecorators(array('ViewHelper')); - if ($disable_all) { - $enable->setAttrib("disabled", "disabled"); - } $this->addElement($enable); + static::$customizable[] = $enable->getName(); $mobile = new Zend_Form_Element_Checkbox('mobile'); $mobile->setLabel(_('Mobile:')); $mobile->setValue($setting[$prefix.'_mobile']); $mobile->setDecorators(array('ViewHelper')); $this->addElement($mobile); + static::$customizable[] = $mobile->getName(); $type = new Zend_Form_Element_Select('type'); $type->setLabel(_("Stream Type:")) ->setMultiOptions($stream_types) ->setValue(isset($setting[$prefix.'_type'])?$setting[$prefix.'_type']:0) ->setDecorators(array('ViewHelper')); - if ($disable_all) { - $type->setAttrib("disabled", "disabled"); - } $this->addElement($type); + static::$customizable[] = $type->getName(); $bitrate = new Zend_Form_Element_Select('bitrate'); $bitrate->setLabel(_("Bit Rate:")) ->setMultiOptions($stream_bitrates) ->setValue(isset($setting[$prefix.'_bitrate'])?$setting[$prefix.'_bitrate']:0) ->setDecorators(array('ViewHelper')); - if ($disable_all) { - $bitrate->setAttrib("disabled", "disabled"); - } $this->addElement($bitrate); + static::$customizable[] = $bitrate->getName(); $output = new Zend_Form_Element_Select('output'); $output->setLabel(_("Service Type:")) ->setMultiOptions(array("icecast"=>"Icecast", "shoutcast"=>"SHOUTcast")) ->setValue(isset($setting[$prefix.'_output'])?$setting[$prefix.'_output']:"icecast") ->setDecorators(array('ViewHelper')); - if ($disable_all) { - $output->setAttrib("disabled", "disabled"); - } $this->addElement($output); $channels = new Zend_Form_Element_Select('channels'); @@ -94,10 +86,8 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm ->setMultiOptions(array("mono"=>_("1 - Mono"), "stereo"=>_("2 - Stereo"))) ->setValue(isset($setting[$prefix.'_channels']) ? $setting[$prefix.'_channels'] : "stereo") ->setDecorators(array('ViewHelper')); - if ($disable_all) { - $channels->setAttrib("disabled", "disabled"); - } $this->addElement($channels); + static::$customizable[] = $channels->getName(); $host = new Zend_Form_Element_Text('host'); $host->setLabel(_("Server")) @@ -105,9 +95,6 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm ->setValidators(array( array('regex', false, array('/^[0-9a-zA-Z-_.]+$/', 'messages' => _('Invalid character entered'))))) ->setDecorators(array('ViewHelper')); - if ($disable_all) { - $host->setAttrib("disabled", "disabled"); - } $host->setAttrib('alt', 'domain'); $this->addElement($host); @@ -117,9 +104,6 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm ->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999)))) ->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>_('Only numbers are allowed.')))) ->setDecorators(array('ViewHelper')); - if ($disable_all) { - $port->setAttrib("disabled", "disabled"); - } $this->addElement($port); $pass = new Zend_Form_Element_Text('pass'); @@ -128,9 +112,6 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm ->setValidators(array( array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered'))))) ->setDecorators(array('ViewHelper')); - if ($disable_all) { - $pass->setAttrib("disabled", "disabled"); - } $pass->setAttrib('alt', 'regular_text'); $this->addElement($pass); @@ -138,9 +119,6 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm $genre->setLabel(_("Genre")) ->setValue(isset($setting[$prefix.'_genre'])?$setting[$prefix.'_genre']:"") ->setDecorators(array('ViewHelper')); - if ($disable_all) { - $genre->setAttrib("disabled", "disabled"); - } $this->addElement($genre); $url = new Zend_Form_Element_Text('url'); @@ -149,9 +127,6 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm ->setValidators(array( array('regex', false, array('/^[0-9a-zA-Z\-_.:\/]+$/', 'messages' => _('Invalid character entered'))))) ->setDecorators(array('ViewHelper')); - if ($disable_all) { - $url->setAttrib("disabled", "disabled"); - } $url->setAttrib('alt', 'url'); $this->addElement($url); @@ -159,18 +134,12 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm $name->setLabel(_("Name")) ->setValue(isset($setting[$prefix.'_name'])?$setting[$prefix.'_name']:"") ->setDecorators(array('ViewHelper')); - if ($disable_all) { - $name->setAttrib("disabled", "disabled"); - } $this->addElement($name); $description = new Zend_Form_Element_Text('description'); $description->setLabel(_("Description")) ->setValue(isset($setting[$prefix.'_description'])?$setting[$prefix.'_description']:"") ->setDecorators(array('ViewHelper')); - if ($disable_all) { - $description->setAttrib("disabled", "disabled"); - } $this->addElement($description); $mount = new Zend_Form_Element_Text('mount'); @@ -179,9 +148,6 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm ->setValidators(array( array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered'))))) ->setDecorators(array('ViewHelper')); - if ($disable_all) { - $mount->setAttrib("disabled", "disabled"); - } $mount->setAttrib('alt', 'regular_text'); $this->addElement($mount); @@ -191,9 +157,6 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm ->setValidators(array( array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered'))))) ->setDecorators(array('ViewHelper')); - if ($disable_all) { - $user->setAttrib("disabled", "disabled"); - } $user->setAttrib('alt', 'regular_text'); $this->addElement($user); @@ -203,9 +166,6 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm ->setValidators(array( array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered'))))) ->setDecorators(array('ViewHelper')); - if ($disable_all) { - $adminUser->setAttrib("disabled", "disabled"); - } $adminUser->setAttrib('alt', 'regular_text'); $this->addElement($adminUser); @@ -215,16 +175,16 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm ->setValidators(array( array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered'))))) ->setDecorators(array('ViewHelper')); - if ($disable_all) { - $adminPass->setAttrib("disabled", "disabled"); - } $adminPass->setAttrib('alt', 'regular_text'); $this->addElement($adminPass); $liquidsoap_error_msg = '

'._('Getting information from the server...').'

'; $this->setDecorators(array( - array('ViewScript', array('viewScript' => 'form/stream-setting-form.phtml', "stream_number"=>$stream_number, "enabled"=>$enable->getValue(), "liquidsoap_error_msg"=>$liquidsoap_error_msg)) + array('ViewScript', array('viewScript' => 'form/stream-setting-form.phtml', + "stream_number"=>$stream_number, + "enabled"=>$enable->getValue(), + "liquidsoap_error_msg"=>$liquidsoap_error_msg)) )); } @@ -232,7 +192,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm { $f_data = $data['s'.$this->prefix."_data"]; $isValid = parent::isValid($f_data); - if ($f_data) { + if (Application_Model_Preference::getUsingCustomStreamSettings() && $f_data) { if ($f_data['enable'] == 1) { if ($f_data['host'] == '') { $element = $this->getElement("host"); @@ -256,4 +216,16 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm return $isValid; } + + public function toggleState() { + $elements = $this->getElements(); + foreach ($elements as $element) { + if (Application_Model_Preference::getUsingCustomStreamSettings()) { + $element->setAttrib('disabled', null); + } else if (!(in_array($element->getName(), static::$customizable) + || $element->getType() == 'Zend_Form_Element_Hidden')) { + $element->setAttrib('disabled', 'disabled'); + } + } + } } diff --git a/airtime_mvc/application/views/scripts/preference/stream-setting.phtml b/airtime_mvc/application/views/scripts/preference/stream-setting.phtml index 32d1b034d..a2abe8835 100644 --- a/airtime_mvc/application/views/scripts/preference/stream-setting.phtml +++ b/airtime_mvc/application/views/scripts/preference/stream-setting.phtml @@ -38,11 +38,6 @@ form->getElement('icecast_vorbis_metadata') ?> - form->getElement('customStreamSettings')->render(); - ?> -
@@ -110,12 +105,10 @@
num_stream;$i++){ - echo $this->form->getSubform("s".$i."_subform"); - } - } else { - // TODO: replace this with something that looks good + // TODO: replace this with something that looks good + echo $this->form->getElement('customStreamSettings')->render(); + for($i=1;$i<=$this->num_stream;$i++){ + echo $this->form->getSubform("s".$i."_subform"); } ?>
diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index 5d9bc4a67..e6b1e1082 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -1867,6 +1867,7 @@ span.errors.sp-errors{ margin:8px 0 0 0; cursor:pointer; position:relative; + clear: both; } .collapsible-content { margin-top:-1px; diff --git a/airtime_mvc/public/js/airtime/preferences/streamsetting.js b/airtime_mvc/public/js/airtime/preferences/streamsetting.js index 54e397da6..8c4cc9c14 100644 --- a/airtime_mvc/public/js/airtime/preferences/streamsetting.js +++ b/airtime_mvc/public/js/airtime/preferences/streamsetting.js @@ -476,10 +476,11 @@ $(document).ready(function() { var url = baseUrl+'Preference/stream-setting'; $.post(url, {format:"json", data: data}, function(json){ - $('#content').empty().append(json.html); - setupEventListeners(); - setSliderForReplayGain(); - setPseudoAdminPassword(json.s1_set_admin_pass, json.s2_set_admin_pass, json.s3_set_admin_pass, json.s4_set_admin_pass); + window.location.reload(); + //$('#content').empty().append(json.html); + //setupEventListeners(); + //setSliderForReplayGain(); + //setPseudoAdminPassword(json.s1_set_admin_pass, json.s2_set_admin_pass, json.s3_set_admin_pass, json.s4_set_admin_pass); }); } }); From c99165a8dd76518b3ad4f64c72b64079cf83b4d0 Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Fri, 10 Jul 2015 13:17:20 -0400 Subject: [PATCH 3/7] SAAS-876 - better implementation of toggle between Airtime Pro/Custom streaming options --- airtime_mvc/application/forms/StreamSetting.php | 2 +- airtime_mvc/application/forms/StreamSettingSubForm.php | 4 +++- airtime_mvc/public/js/airtime/preferences/streamsetting.js | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/airtime_mvc/application/forms/StreamSetting.php b/airtime_mvc/application/forms/StreamSetting.php index bbef95ca3..d7e785d18 100644 --- a/airtime_mvc/application/forms/StreamSetting.php +++ b/airtime_mvc/application/forms/StreamSetting.php @@ -63,7 +63,7 @@ class Application_Form_StreamSetting extends Zend_Form $custom = Application_Model_Preference::getUsingCustomStreamSettings(); $customSettings = new Zend_Form_Element_Radio('customStreamSettings'); $customSettings->setLabel(_('Streaming Server:')); - $customSettings->setMultiOptions(array(_("Airtime Pro Streaming"), _("Custom / 3rd Party"))); + $customSettings->setMultiOptions(array(_("Airtime Pro Streaming"), _("Custom / 3rd Party Streaming"))); $customSettings->setValue(!empty($custom) ? $custom : 0); $this->addElement($customSettings); } diff --git a/airtime_mvc/application/forms/StreamSettingSubForm.php b/airtime_mvc/application/forms/StreamSettingSubForm.php index fe6c95d89..55ed201e8 100644 --- a/airtime_mvc/application/forms/StreamSettingSubForm.php +++ b/airtime_mvc/application/forms/StreamSettingSubForm.php @@ -192,8 +192,10 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm { $f_data = $data['s'.$this->prefix."_data"]; $isValid = parent::isValid($f_data); + // XXX: A couple of ugly workarounds here, but I guess that's what you get when you + // combine an already-complex POST and GET into a single action... if (Application_Model_Preference::getUsingCustomStreamSettings() && $f_data) { - if ($f_data['enable'] == 1) { + if ($f_data['enable'] == 1 && isset($f_data["host"])) { if ($f_data['host'] == '') { $element = $this->getElement("host"); $element->addError(_("Server cannot be empty.")); diff --git a/airtime_mvc/public/js/airtime/preferences/streamsetting.js b/airtime_mvc/public/js/airtime/preferences/streamsetting.js index 8c4cc9c14..2a18a4aaa 100644 --- a/airtime_mvc/public/js/airtime/preferences/streamsetting.js +++ b/airtime_mvc/public/js/airtime/preferences/streamsetting.js @@ -28,7 +28,7 @@ function rebuildStreamURL(ele){ }else{ streamurl = "http://"+host+":"+port+"/" } - div.find("#stream_url").text(streamurl) + div.find("#stream_url").html('' + streamurl + '') } function restrictOggBitrate(ele, on){ var div = ele.closest("div") From 9fdc08f88a6ce2835f84f825e71ed9bc5570f0e0 Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Mon, 13 Jul 2015 12:28:58 -0400 Subject: [PATCH 4/7] SAAS-876 - reset to default settings when using Airtime Pro streaming --- .../application/common/ProvisioningHelper.php | 7 +++++ airtime_mvc/application/configs/constants.php | 1 + .../controllers/PreferenceController.php | 25 ++++++++++++------ .../forms/StreamSettingSubForm.php | 22 +++++++++++----- airtime_mvc/application/models/Preference.php | 12 +++++++++ .../application/models/StreamSetting.php | 26 ++++++++++++++++++- 6 files changed, 78 insertions(+), 15 deletions(-) diff --git a/airtime_mvc/application/common/ProvisioningHelper.php b/airtime_mvc/application/common/ProvisioningHelper.php index cdd9818c0..f5aacd53d 100644 --- a/airtime_mvc/application/common/ProvisioningHelper.php +++ b/airtime_mvc/application/common/ProvisioningHelper.php @@ -11,6 +11,7 @@ class ProvisioningHelper private $dbuser, $dbpass, $dbname, $dbhost, $dbowner, $apikey; private $instanceId; private $stationName, $description; + private $defaultIcecastPassword; public function __construct($apikey) { @@ -118,6 +119,9 @@ class ProvisioningHelper if (isset($_POST['description'])) { $this->description = $_POST['description']; } + if (isset($_POST['icecast_pass'])) { + $this->defaultIcecastPassword = $_POST['icecast_pass']; + } } /** @@ -208,6 +212,9 @@ class ProvisioningHelper if ($this->description) { Application_Model_Preference::SetStationDescription($this->description); } + if (isset($this->defaultIcecastPassword)) { + Application_Model_Preference::setDefaultIcecastPassword($this->defaultIcecastPassword); + } } } diff --git a/airtime_mvc/application/configs/constants.php b/airtime_mvc/application/configs/constants.php index aaed5d901..62349ec0b 100644 --- a/airtime_mvc/application/configs/constants.php +++ b/airtime_mvc/application/configs/constants.php @@ -32,6 +32,7 @@ define('DEFAULT_LOGO_PLACEHOLDER', 1); define('DEFAULT_LOGO_FILE', 'images/airtime_logo.png'); define('DEFAULT_TIMESTAMP_FORMAT', 'Y-m-d H:i:s'); define('DEFAULT_MICROTIME_FORMAT', 'Y-m-d H:i:s.u'); +define('DEFAULT_ICECAST_PASS', 'hackme'); // Metadata Keys for files define('MDATA_KEY_FILEPATH' , 'filepath'); diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 22324f2ab..7eee7afbe 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -218,14 +218,8 @@ class PreferenceController extends Zend_Controller_Action $s4_set_admin_pass = !empty($values["s4_data"]["admin_pass"]); // this goes into cc_pref table - Application_Model_Preference::setUsingCustomStreamSettings($values['customStreamSettings']); - Application_Model_Preference::SetStreamLabelFormat($values['streamFormat']); - Application_Model_Preference::SetLiveStreamMasterUsername($values["master_username"]); - Application_Model_Preference::SetLiveStreamMasterPassword($values["master_password"]); - Application_Model_Preference::SetDefaultTransitionFade($values["transition_fade"]); - Application_Model_Preference::SetAutoTransition($values["auto_transition"]); - Application_Model_Preference::SetAutoSwitch($values["auto_switch"]); - + $this->setStreamPreferences($values); + // compare new values with current value $changeRGenabled = Application_Model_Preference::GetEnableReplayGain() != $values["enableReplayGain"]; $changeRGmodifier = Application_Model_Preference::getReplayGainModifier() != $values["replayGainModifier"]; @@ -317,6 +311,21 @@ class PreferenceController extends Zend_Controller_Action } } + /** + * Set stream settings preferences + * + * @param array $values stream setting preference values + */ + private function setStreamPreferences($values) { + Application_Model_Preference::setUsingCustomStreamSettings($values['customStreamSettings']); + Application_Model_Preference::SetStreamLabelFormat($values['streamFormat']); + Application_Model_Preference::SetLiveStreamMasterUsername($values["master_username"]); + Application_Model_Preference::SetLiveStreamMasterPassword($values["master_password"]); + Application_Model_Preference::SetDefaultTransitionFade($values["transition_fade"]); + Application_Model_Preference::SetAutoTransition($values["auto_transition"]); + Application_Model_Preference::SetAutoSwitch($values["auto_switch"]); + } + public function serverBrowseAction() { $request = $this->getRequest(); diff --git a/airtime_mvc/application/forms/StreamSettingSubForm.php b/airtime_mvc/application/forms/StreamSettingSubForm.php index 55ed201e8..b3deb477a 100644 --- a/airtime_mvc/application/forms/StreamSettingSubForm.php +++ b/airtime_mvc/application/forms/StreamSettingSubForm.php @@ -41,6 +41,10 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm $stream_types = $this->stream_types; $stream_bitrates = $this->stream_bitrates; + $streamDefaults = Application_Model_StreamSetting::getDefaults($prefix); + // If we're not using custom stream settings, use the defaults + $useDefaults = !Application_Model_Preference::getUsingCustomStreamSettings(); + $this->setIsArray(true); $this->setElementsBelongTo($prefix."_data"); @@ -77,7 +81,8 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm $output = new Zend_Form_Element_Select('output'); $output->setLabel(_("Service Type:")) ->setMultiOptions(array("icecast"=>"Icecast", "shoutcast"=>"SHOUTcast")) - ->setValue(isset($setting[$prefix.'_output'])?$setting[$prefix.'_output']:"icecast") + ->setValue($useDefaults ? $streamDefaults['output'] : + (isset($setting[$prefix.'_output'])?$setting[$prefix.'_output']:"icecast")) ->setDecorators(array('ViewHelper')); $this->addElement($output); @@ -91,7 +96,8 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm $host = new Zend_Form_Element_Text('host'); $host->setLabel(_("Server")) - ->setValue(isset($setting[$prefix.'_host'])?$setting[$prefix.'_host']:"") + ->setValue($useDefaults ? $streamDefaults['host'] : + (isset($setting[$prefix.'_host'])?$setting[$prefix.'_host']:"")) ->setValidators(array( array('regex', false, array('/^[0-9a-zA-Z-_.]+$/', 'messages' => _('Invalid character entered'))))) ->setDecorators(array('ViewHelper')); @@ -100,7 +106,8 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm $port = new Zend_Form_Element_Text('port'); $port->setLabel(_("Port")) - ->setValue(isset($setting[$prefix.'_port'])?$setting[$prefix.'_port']:"") + ->setValue($useDefaults ? $streamDefaults['port'] : + (isset($setting[$prefix.'_port'])?$setting[$prefix.'_port']:"")) ->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999)))) ->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>_('Only numbers are allowed.')))) ->setDecorators(array('ViewHelper')); @@ -108,7 +115,8 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm $pass = new Zend_Form_Element_Text('pass'); $pass->setLabel(_("Password")) - ->setValue(isset($setting[$prefix.'_pass'])?$setting[$prefix.'_pass']:"") + ->setValue($useDefaults ? $streamDefaults['pass'] : + (isset($setting[$prefix.'_pass'])?$setting[$prefix.'_pass']:"")) ->setValidators(array( array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered'))))) ->setDecorators(array('ViewHelper')); @@ -144,7 +152,8 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm $mount = new Zend_Form_Element_Text('mount'); $mount->setLabel(_("Mount Point")) - ->setValue(isset($setting[$prefix.'_mount'])?$setting[$prefix.'_mount']:"") + ->setValue($useDefaults ? $streamDefaults['mount'] : + (isset($setting[$prefix.'_mount'])?$setting[$prefix.'_mount']:"")) ->setValidators(array( array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered'))))) ->setDecorators(array('ViewHelper')); @@ -153,7 +162,8 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm $user = new Zend_Form_Element_Text('user'); $user->setLabel(_("Username")) - ->setValue(isset($setting[$prefix.'_user'])?$setting[$prefix.'_user']:"") + ->setValue($useDefaults ? $streamDefaults['user'] : + (isset($setting[$prefix.'_user'])?$setting[$prefix.'_user']:"")) ->setValidators(array( array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered'))))) ->setDecorators(array('ViewHelper')); diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index ddf676696..ac0925fde 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -1522,6 +1522,18 @@ class Application_Model_Preference self::setValue("using_custom_stream_settings", $value); } + // SAAS-876 - Store the default Icecast password to restore when switching + // back to Airtime Pro streaming settings + + public static function getDefaultIcecastPassword() { + $val = self::getValue("default_icecast_password"); + return empty($val) ? DEFAULT_ICECAST_PASS : $val; + } + + public static function setDefaultIcecastPassword($value) { + self::setValue("default_icecast_password", $value); + } + public static function getRadioPageDisplayLoginButton() { return self::getValue("radio_page_display_login_button"); diff --git a/airtime_mvc/application/models/StreamSetting.php b/airtime_mvc/application/models/StreamSetting.php index be2d63065..3844e9363 100644 --- a/airtime_mvc/application/models/StreamSetting.php +++ b/airtime_mvc/application/models/StreamSetting.php @@ -246,6 +246,10 @@ class Application_Model_StreamSetting } elseif (is_array($d)) { $temp = explode('_', $key); $prefix = $temp[0]; + // SAAS-876 - If we're using Airtime Pro streaming, set the stream to use the default settings + if (!Application_Model_Preference::getUsingCustomStreamSettings()) { + $d = array_merge($d, static::getDefaults($prefix)); + } foreach ($d as $k => $v) { $keyname = $prefix . "_" . $k; if ($k == 'enable') { @@ -265,8 +269,28 @@ class Application_Model_StreamSetting } } + /** + * SAAS-876 - Get the default stream settings values for Airtime Pro streaming + * + * @param int $prefix + * + * @return array array of default stream setting values + */ + public static function getDefaults($prefix) { + $config = Config::getConfig(); + return array( + 'host' => $config['stationId'] . '.out.airtime.pro', + 'port' => 8000, + 'output' => 'icecast', + 'user' => $config['stationId'], + 'pass' => Application_Model_Preference::getDefaultIcecastPassword(), + // Kind of ugly... convert prefix int to ascii char + 'mount' => $config['stationId'] . '_' . chr($prefix[1] + 96), + ); + } + /* - * Sets indivisual stream setting. + * Sets individual stream setting. * * $data - data array. $data is []. * TODO: Make this SQL a prepared statement! From 56585fb01c0f6d508e2ca1fe4194199cc5daa2ef Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Mon, 13 Jul 2015 13:28:27 -0400 Subject: [PATCH 5/7] Add default icecast pass to settable params in ProvisioningController --- airtime_mvc/application/controllers/ProvisioningController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/airtime_mvc/application/controllers/ProvisioningController.php b/airtime_mvc/application/controllers/ProvisioningController.php index 06ee7a2ab..3532a9408 100644 --- a/airtime_mvc/application/controllers/ProvisioningController.php +++ b/airtime_mvc/application/controllers/ProvisioningController.php @@ -41,6 +41,9 @@ class ProvisioningController extends Zend_Controller_Action if (isset($_POST['provisioning_status'])) { Application_Model_Preference::setProvisioningStatus($_POST['provisioning_status']); } + if (isset($_POST['icecast_pass'])) { + Application_Model_Preference::setDefaultIcecastPassword($_POST['icecast_pass']); + } } catch (Exception $e) { $this->getResponse() ->setHttpResponseCode(400) From 755ec79e7deb3f2e2d2165f9bfcb329339e72f63 Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Mon, 13 Jul 2015 15:17:47 -0400 Subject: [PATCH 6/7] SAAS-876 - frontend tweaks --- .../application/controllers/LocaleController.php | 3 +-- .../js/airtime/preferences/streamsetting.js | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/airtime_mvc/application/controllers/LocaleController.php b/airtime_mvc/application/controllers/LocaleController.php index 7d83a165e..31d899d48 100644 --- a/airtime_mvc/application/controllers/LocaleController.php +++ b/airtime_mvc/application/controllers/LocaleController.php @@ -171,8 +171,7 @@ class LocaleController extends Zend_Controller_Action "Check this box to automatically switch on Master/Show source upon source connection." => _("Check this box to automatically switch on Master/Show source upon source connection."), "If your Icecast server expects a username of 'source', this field can be left blank." => _("If your Icecast server expects a username of 'source', this field can be left blank."), "If your live streaming client does not ask for a username, this field should be 'source'." => _("If your live streaming client does not ask for a username, this field should be 'source'."), - "If you change the username or password values for an enabled stream the playout engine will be rebooted and your listeners will hear silence for 5-10 seconds. Changing the following fields will NOT cause a reboot: Stream Label (Global Settings), and Switch Transition Fade(s), Master Username, and Master Password (Input Stream Settings). If Airtime is recording, and if the change causes a playout engine restart, the recording will be interrupted." - => _("If you change the username or password values for an enabled stream the playout engine will be rebooted and your listeners will hear silence for 5-10 seconds. Changing the following fields will NOT cause a reboot: Stream Label (Global Settings), and Switch Transition Fade(s), Master Username, and Master Password (Input Stream Settings). If Airtime is recording, and if the change causes a playout engine restart, the recording will be interrupted."), + "WARNING: This will restart your stream and may cause a short dropout for your listeners!" => _("WARNING: This will restart your stream and may cause a short dropout for your listeners!"), "This is the admin username and password for Icecast/SHOUTcast to get listener statistics." => _("This is the admin username and password for Icecast/SHOUTcast to get listener statistics."), //preferences/support-setting.js "Image must be one of jpg, jpeg, png, or gif" => _("Image must be one of jpg, jpeg, png, or gif"), diff --git a/airtime_mvc/public/js/airtime/preferences/streamsetting.js b/airtime_mvc/public/js/airtime/preferences/streamsetting.js index 2a18a4aaa..7cc65f40a 100644 --- a/airtime_mvc/public/js/airtime/preferences/streamsetting.js +++ b/airtime_mvc/public/js/airtime/preferences/streamsetting.js @@ -468,9 +468,12 @@ $(document).ready(function() { setupEventListeners(); setSliderForReplayGain(); getAdminPasswordStatus(); - - $("[id^='stream_save']").live('click', function(){ - var confirm_pypo_restart_text = sprintf($.i18n._("If you change the username or password values for an enabled stream the playout engine will be rebooted and your listeners will hear silence for 5-10 seconds. Changing the following fields will NOT cause a reboot: Stream Label (Global Settings), and Switch Transition Fade(s), Master Username, and Master Password (Input Stream Settings). If %s is recording, and if the change causes a playout engine restart, the recording will be interrupted."), PRODUCT_NAME); + var s = $("[name^='customStreamSettings']:checked"); + + $("[id^='stream_save'], [name^='customStreamSettings']").live('click', function() { + var e = $(this); + if (e[0] == s[0]) { return; } + var confirm_pypo_restart_text = $.i18n._("WARNING: This will restart your stream and may cause a short dropout for your listeners!"); if (confirm(confirm_pypo_restart_text)) { var data = $('#stream_form').serialize(); var url = baseUrl+'Preference/stream-setting'; @@ -482,6 +485,13 @@ $(document).ready(function() { //setSliderForReplayGain(); //setPseudoAdminPassword(json.s1_set_admin_pass, json.s2_set_admin_pass, json.s3_set_admin_pass, json.s4_set_admin_pass); }); + } else { + if (e.prop('checked')) { + if (e[0] != s[0]) { + e.prop('checked', false); + s.prop('checked', true); + } + } } }); }); From 683c1a4641fde8d5e213ee5ce75bb31cd43cab5c Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Mon, 13 Jul 2015 15:52:04 -0400 Subject: [PATCH 7/7] SAAS-876 - use baseurl for default host value --- airtime_mvc/application/configs/constants.php | 1 + airtime_mvc/application/models/StreamSetting.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/configs/constants.php b/airtime_mvc/application/configs/constants.php index 62349ec0b..768643903 100644 --- a/airtime_mvc/application/configs/constants.php +++ b/airtime_mvc/application/configs/constants.php @@ -32,6 +32,7 @@ define('DEFAULT_LOGO_PLACEHOLDER', 1); define('DEFAULT_LOGO_FILE', 'images/airtime_logo.png'); define('DEFAULT_TIMESTAMP_FORMAT', 'Y-m-d H:i:s'); define('DEFAULT_MICROTIME_FORMAT', 'Y-m-d H:i:s.u'); +define('DEFAULT_ICECAST_PORT', 8000); define('DEFAULT_ICECAST_PASS', 'hackme'); // Metadata Keys for files diff --git a/airtime_mvc/application/models/StreamSetting.php b/airtime_mvc/application/models/StreamSetting.php index 3844e9363..34e037cd5 100644 --- a/airtime_mvc/application/models/StreamSetting.php +++ b/airtime_mvc/application/models/StreamSetting.php @@ -279,8 +279,8 @@ class Application_Model_StreamSetting public static function getDefaults($prefix) { $config = Config::getConfig(); return array( - 'host' => $config['stationId'] . '.out.airtime.pro', - 'port' => 8000, + 'host' => $config['baseUrl'], + 'port' => DEFAULT_ICECAST_PORT, 'output' => 'icecast', 'user' => $config['stationId'], 'pass' => Application_Model_Preference::getDefaultIcecastPassword(),