From 457230ba07613af134b3f5d7bea7b5cb7b7ad9e9 Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Fri, 3 Jul 2015 13:32:41 -0400 Subject: [PATCH 01/14] 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 02/14] 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 03/14] 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 04/14] 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 05/14] 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 06/14] 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 07/14] 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(), From 5c4803ddf21f48916e6561586425eff39eb195cb Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Wed, 22 Jul 2015 13:48:47 -0400 Subject: [PATCH 08/14] SAAS-781 - password reset --- .../controllers/LoginController.php | 24 ++-- .../forms/EmailServerPreferences.php | 106 ------------------ .../application/forms/PasswordRestore.php | 4 +- airtime_mvc/application/models/Auth.php | 4 +- airtime_mvc/application/models/Email.php | 12 +- airtime_mvc/application/models/Preference.php | 81 ------------- .../views/scripts/form/login.phtml | 12 +- .../scripts/login/password-restore.phtml | 5 +- 8 files changed, 28 insertions(+), 220 deletions(-) delete mode 100644 airtime_mvc/application/forms/EmailServerPreferences.php diff --git a/airtime_mvc/application/controllers/LoginController.php b/airtime_mvc/application/controllers/LoginController.php index e810d4246..face87056 100644 --- a/airtime_mvc/application/controllers/LoginController.php +++ b/airtime_mvc/application/controllers/LoginController.php @@ -140,9 +140,6 @@ class LoginController extends Zend_Controller_Action Application_Model_Locale::configureLocalization($request->getcookie('airtime_locale', $stationLocale)); -// if (!Application_Model_Preference::GetEnableSystemEmail()) { -// $this->_redirect('login'); -// } else { //uses separate layout without a navigation. $this->_helper->layout->setLayout('login'); @@ -150,16 +147,16 @@ class LoginController extends Zend_Controller_Action $request = $this->getRequest(); if ($request->isPost() && $form->isValid($request->getPost())) { - if (is_null($form->username->getValue()) || $form->username->getValue() == '') { - $user = CcSubjsQuery::create() - ->filterByDbEmail($form->email->getValue()) - ->findOne(); + $query = CcSubjsQuery::create(); + if (empty($form->username->getValue())) { + $query->filterByDbEmail($form->email->getValue()); + } else if (empty($form->email->getValue())) { + $query->filterByDbLogin($form->username->getValue()); } else { - $user = CcSubjsQuery::create() - ->filterByDbEmail($form->email->getValue()) - ->filterByDbLogin($form->username->getValue()) - ->findOne(); + $query->filterByDbEmail($form->email->getValue()) + ->filterByDbLogin($form->username->getValue()); } + $user = $query->findOne(); if (!empty($user)) { $auth = new Application_Model_Auth(); @@ -168,15 +165,14 @@ class LoginController extends Zend_Controller_Action if ($success) { $this->_helper->redirector('password-restore-after', 'login'); } else { - $form->email->addError($this->view->translate(_("Email could not be sent. Check your mail server settings and ensure it has been configured properly."))); + $form->email->addError($this->view->translate(_("There was a problem sending the recovery email."))); } } else { - $form->email->addError($this->view->translate(_("Given email not found."))); + $form->email->addError($this->view->translate(_("We couldn't find the email you entered - you can also try here."))); } } $this->view->form = $form; -// } } public function passwordRestoreAfterAction() diff --git a/airtime_mvc/application/forms/EmailServerPreferences.php b/airtime_mvc/application/forms/EmailServerPreferences.php deleted file mode 100644 index 1e0feda79..000000000 --- a/airtime_mvc/application/forms/EmailServerPreferences.php +++ /dev/null @@ -1,106 +0,0 @@ -setDecorators(array( - array('ViewScript', array('viewScript' => 'form/preferences_email_server.phtml')) - )); - - // Enable system emails - $this->addElement('checkbox', 'enableSystemEmail', array( - 'label' => _('Enable System Emails (Password Reset)'), - 'required' => false, - 'value' => Application_Model_Preference::GetEnableSystemEmail(), - 'decorators' => array( - 'ViewHelper' - ) - )); - - $this->addElement('text', 'systemEmail', array( - 'class' => 'input_text', - 'label' => _("Reset Password 'From' Email"), - 'value' => Application_Model_Preference::GetSystemEmail(), - 'readonly' => true, - 'decorators' => array('viewHelper') - )); - - $this->addElement('checkbox', 'configureMailServer', array( - 'label' => _('Configure Mail Server'), - 'required' => false, - 'value' => Application_Model_Preference::GetMailServerConfigured(), - 'decorators' => array ( - 'viewHelper' - ) - )); - - $this->addElement('checkbox', 'msRequiresAuth', array( - 'label' => _('Requires Authentication'), - 'required' => false, - 'value' => Application_Model_Preference::GetMailServerRequiresAuth(), - 'decorators' => array( - 'viewHelper' - ) - )); - - $this->addElement('text', 'mailServer', array( - 'class' => 'input_text', - 'label' => _('Mail Server'), - 'value' => Application_Model_Preference::GetMailServer(), - 'readonly' => true, - 'decorators' => array('viewHelper'), - 'allowEmpty' => false, - 'validators' => array( - new ConditionalNotEmpty(array( - 'configureMailServer' => '1' - )) - ) - )); - - $this->addElement('text', 'email', array( - 'class' => 'input_text', - 'label' => _('Email Address'), - 'value' => Application_Model_Preference::GetMailServerEmailAddress(), - 'readonly' => true, - 'decorators' => array('viewHelper'), - 'allowEmpty' => false, - 'validators' => array( - new ConditionalNotEmpty(array( - 'configureMailServer' => '1', - 'msRequiresAuth' => '1' - )) - ) - )); - - $this->addElement('password', 'ms_password', array( - 'class' => 'input_text', - 'label' => _('Password'), - 'value' => Application_Model_Preference::GetMailServerPassword(), - 'readonly' => true, - 'decorators' => array('viewHelper'), - 'allowEmpty' => false, - 'validators' => array( - new ConditionalNotEmpty(array( - 'configureMailServer' => '1', - 'msRequiresAuth' => '1' - )) - ), - 'renderPassword' => true - )); - - $port = new Zend_Form_Element_Text('port'); - $port->class = 'input_text'; - $port->setRequired(false) - ->setValue(Application_Model_Preference::GetMailServerPort()) - ->setLabel(_('Port')) - ->setAttrib('readonly', true) - ->setDecorators(array('viewHelper')); - - $this->addElement($port); - - } - -} diff --git a/airtime_mvc/application/forms/PasswordRestore.php b/airtime_mvc/application/forms/PasswordRestore.php index 0e8f4ad9c..12a957617 100644 --- a/airtime_mvc/application/forms/PasswordRestore.php +++ b/airtime_mvc/application/forms/PasswordRestore.php @@ -11,7 +11,7 @@ class Application_Form_PasswordRestore extends Zend_Form )); $this->addElement('text', 'email', array( - 'label' => _('E-mail'), + 'label' => _('Email'), 'required' => true, 'filters' => array( 'stringTrim', @@ -43,7 +43,7 @@ class Application_Form_PasswordRestore extends Zend_Form $cancel = new Zend_Form_Element_Button("cancel"); $cancel->class = 'ui-button ui-widget ui-state-default ui-button-text-only center'; - $cancel->setLabel(_("Cancel")) + $cancel->setLabel(_("Return to login")) ->setIgnore(True) ->setAttrib('onclick', 'redirectToLogin();') ->setDecorators(array('ViewHelper')); diff --git a/airtime_mvc/application/models/Auth.php b/airtime_mvc/application/models/Auth.php index 6c4c75edd..044972b37 100644 --- a/airtime_mvc/application/models/Auth.php +++ b/airtime_mvc/application/models/Auth.php @@ -34,9 +34,7 @@ class Application_Model_Auth $message .= "{$e_link_protocol}://{$e_link_base}:{$e_link_port}{$e_link_path}"; $str = sprintf(_('%s Password Reset'), PRODUCT_NAME); - $success = Application_Model_Email::send($str, $message, $user->getDbEmail()); - - return $success; + return Application_Model_Email::send($str, $message, $user->getDbEmail()); } public function invalidateTokens($user, $action) diff --git a/airtime_mvc/application/models/Email.php b/airtime_mvc/application/models/Email.php index 774617c1e..e1b399f4c 100644 --- a/airtime_mvc/application/models/Email.php +++ b/airtime_mvc/application/models/Email.php @@ -2,18 +2,20 @@ class Application_Model_Email { + /** * Send email * * @param string $subject * @param string $message - * @param mixed $tos - * @return void + * @param mixed $to + * @return boolean */ - public static function send($subject, $message, $tos, $from = null) - { + public static function send($subject, $message, $to) { - return mail($tos, $subject, $message); + $headers = 'From: Airtime '; + return mail($to, $subject, $message, $headers); } + } diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 6143058ba..6f899f439 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -1161,87 +1161,6 @@ class Application_Model_Preference { return self::getValue("auto_switch"); } - - public static function SetEnableSystemEmail($upload) - { - self::setValue("enable_system_email", $upload); - } - - public static function GetEnableSystemEmail() - { - $v = self::getValue("enable_system_email"); - return ($v === "") ? 0 : $v; - } - - public static function SetSystemEmail($value) - { - self::setValue("system_email", $value, false); - } - - public static function GetSystemEmail() - { - return self::getValue("system_email"); - } - - public static function SetMailServerConfigured($value) - { - self::setValue("mail_server_configured", $value, false); - } - - public static function GetMailServerConfigured() - { - return self::getValue("mail_server_configured"); - } - - public static function SetMailServer($value) - { - self::setValue("mail_server", $value, false); - } - - public static function GetMailServer() - { - return self::getValue("mail_server"); - } - - public static function SetMailServerEmailAddress($value) - { - self::setValue("mail_server_email_address", $value, false); - } - - public static function GetMailServerEmailAddress() - { - return self::getValue("mail_server_email_address"); - } - - public static function SetMailServerPassword($value) - { - self::setValue("mail_server_password", $value, false); - } - - public static function GetMailServerPassword() - { - return self::getValue("mail_server_password"); - } - - public static function SetMailServerPort($value) - { - self::setValue("mail_server_port", $value, false); - } - - public static function GetMailServerPort() - { - return self::getValue("mail_server_port"); - } - - public static function SetMailServerRequiresAuth($value) - { - self::setValue("mail_server_requires_auth", $value, false); - } - - public static function GetMailServerRequiresAuth() - { - return self::getValue("mail_server_requires_auth"); - } /* User specific preferences end */ public static function ShouldShowPopUp() diff --git a/airtime_mvc/application/views/scripts/form/login.phtml b/airtime_mvc/application/views/scripts/form/login.phtml index 09893410d..0c96983ca 100644 --- a/airtime_mvc/application/views/scripts/form/login.phtml +++ b/airtime_mvc/application/views/scripts/form/login.phtml @@ -30,17 +30,15 @@ element->getElement('csrf') ?> - - -
- -
- element->getElement('captcha') ?>
 
element->getElement('submit') ?>
- + + +
+ +
diff --git a/airtime_mvc/application/views/scripts/login/password-restore.phtml b/airtime_mvc/application/views/scripts/login/password-restore.phtml index e814ca6be..945ae73e4 100644 --- a/airtime_mvc/application/views/scripts/login/password-restore.phtml +++ b/airtime_mvc/application/views/scripts/login/password-restore.phtml @@ -1,10 +1,11 @@ -dialog ?> +dialog ?> + +lang_tz_popup_form; ?> diff --git a/airtime_mvc/public/js/airtime/nowplaying/lang-timezone-setup.js b/airtime_mvc/public/js/airtime/nowplaying/lang-timezone-setup.js new file mode 100644 index 000000000..6d6242159 --- /dev/null +++ b/airtime_mvc/public/js/airtime/nowplaying/lang-timezone-setup.js @@ -0,0 +1,40 @@ +$(document).ready(function() { + + var dialog = $("#lang-timezone-popup"); + + dialog.dialog({ + autoOpen: false, + width: 500, + resizable: false, + modal: true, + position:['center',50], + buttons: [ + { + id: "setup-later", + text: $.i18n._("Set Later"), + "class": "btn", + click: function() { + $(this).dialog("close"); + } + }, + { + id: "help_airtime", + text: $.i18n._("OK"), + "class": "btn", + click: function() { + var formValues = $("#lang-timezone-form").serializeArray(); + $.post(baseUrl+"setup/setup-language-timezone", + { + format: "json", + data: formValues + }, function(json) { + console.log(json); + $("#lang-timezone-popup").dialog("close"); + }); + } + } + ] + }); + + dialog.dialog('open'); +}); From 989b4994aabe39d65b5fe461b7cc4c2a4f5e53e0 Mon Sep 17 00:00:00 2001 From: drigato Date: Mon, 27 Jul 2015 14:38:42 -0400 Subject: [PATCH 10/14] SAAS-945: Language + Timezone Setup Popup forgot to auto detect user's timezone --- .../controllers/SetupController.php | 23 +++++++----------- .../controllers/ShowbuilderController.php | 2 +- .../scripts/form/setup-lang-timezone.phtml | 5 +++- .../airtime/nowplaying/lang-timezone-setup.js | 24 ++++++++++++------- .../js/js-timezone-detect/jstz-1.0.4.min.js | 2 ++ 5 files changed, 30 insertions(+), 26 deletions(-) create mode 100644 airtime_mvc/public/js/js-timezone-detect/jstz-1.0.4.min.js diff --git a/airtime_mvc/application/controllers/SetupController.php b/airtime_mvc/application/controllers/SetupController.php index 59bc09e45..9b211eeb6 100644 --- a/airtime_mvc/application/controllers/SetupController.php +++ b/airtime_mvc/application/controllers/SetupController.php @@ -18,31 +18,24 @@ class SetupController extends Zend_Controller_Action if ($request->isPost()) { - $postData = $request->getPost(); - $formData = array(); - foreach ($postData["data"] as $key => $value) { - if ($value["name"] == "csrf") continue; - $formData[$value["name"]] = $value["value"]; - } + $formData = $request->getPost(); if ($form->isValid($formData)) { $userService = new Application_Service_UserService(); $currentUser = $userService->getCurrentUser(); $currentUserId = $currentUser->getDbId(); - Application_Model_Preference::SetUserTimezone($formData["timezone"], $currentUserId); - Application_Model_Preference::SetDefaultTimezone($formData["timezone"]); + Application_Model_Preference::SetUserTimezone($formData["setup_timezone"], $currentUserId); + Application_Model_Preference::SetDefaultTimezone($formData["setup_timezone"]); - Application_Model_Preference::SetUserLocale($formData["language"], $currentUserId); - Application_Model_Preference::SetDefaultLocale($formData["language"]); + Application_Model_Preference::SetUserLocale($formData["setup_language"], $currentUserId); + Application_Model_Preference::SetDefaultLocale($formData["setup_language"]); Application_Model_Preference::setLangTimezoneSetupComplete(true); - $this->_helper->json->sendJson(null); - } else { - $this->_helper->json->sendJson($form->get); + $this->_redirect('/Showbuilder'); } - } else { - $this->_helper->json->sendJson($form); } + $this->_redirect('/Showbuilder'); } + } \ No newline at end of file diff --git a/airtime_mvc/application/controllers/ShowbuilderController.php b/airtime_mvc/application/controllers/ShowbuilderController.php index 0ba6fbedb..65521749c 100644 --- a/airtime_mvc/application/controllers/ShowbuilderController.php +++ b/airtime_mvc/application/controllers/ShowbuilderController.php @@ -45,6 +45,7 @@ class ShowbuilderController extends Zend_Controller_Action //$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.ColReorder.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.columnFilter.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'js/js-timezone-detect/jstz-1.0.4.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/blockui/jquery.blockUI.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); @@ -64,7 +65,6 @@ class ShowbuilderController extends Zend_Controller_Action // and they have not seen the setup popup before if ($currentUser->getDbType() == "S" && strpos(strtolower($previousPage), 'login') !== false && empty($setupComplete)) { - Logging::info("hello"); $lang_tz_popup_form = new Application_Form_SetupLanguageTimezone(); $this->view->lang_tz_popup_form = $lang_tz_popup_form; $this->view->headScript()->appendFile($baseUrl.'js/airtime/nowplaying/lang-timezone-setup.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); diff --git a/airtime_mvc/application/views/scripts/form/setup-lang-timezone.phtml b/airtime_mvc/application/views/scripts/form/setup-lang-timezone.phtml index 9a08f679b..117d92a82 100644 --- a/airtime_mvc/application/views/scripts/form/setup-lang-timezone.phtml +++ b/airtime_mvc/application/views/scripts/form/setup-lang-timezone.phtml @@ -1,5 +1,5 @@
" style="display: none;"> -
+
element->getElement('csrf') ?> @@ -7,6 +7,9 @@ element->getElement('setup_language')->render(); ?> element->getElement('setup_timezone')->render(); ?> + +
+ You can set these settings later under Preferences and your user settings.
diff --git a/airtime_mvc/public/js/airtime/nowplaying/lang-timezone-setup.js b/airtime_mvc/public/js/airtime/nowplaying/lang-timezone-setup.js index 6d6242159..4e200dbb9 100644 --- a/airtime_mvc/public/js/airtime/nowplaying/lang-timezone-setup.js +++ b/airtime_mvc/public/js/airtime/nowplaying/lang-timezone-setup.js @@ -22,19 +22,25 @@ $(document).ready(function() { text: $.i18n._("OK"), "class": "btn", click: function() { - var formValues = $("#lang-timezone-form").serializeArray(); - $.post(baseUrl+"setup/setup-language-timezone", - { - format: "json", - data: formValues - }, function(json) { - console.log(json); - $("#lang-timezone-popup").dialog("close"); - }); + $("#lang-timezone-form").submit(); } } ] }); + var language = window.navigator.userLanguage || window.navigator.language; + if (language === undefined) { + language = "en_CA"; + } + language = language.replace("-", "_"); + $("#setup_language").val(language); + + var timezone = jstz.determine(); + var timezone_name = timezone.name(); + if (timezone_name === undefined) { + timezone_name = "America/Toronto"; + } + $("#setup_timezone").val(timezone_name); + dialog.dialog('open'); }); diff --git a/airtime_mvc/public/js/js-timezone-detect/jstz-1.0.4.min.js b/airtime_mvc/public/js/js-timezone-detect/jstz-1.0.4.min.js new file mode 100644 index 000000000..96e3dd8ae --- /dev/null +++ b/airtime_mvc/public/js/js-timezone-detect/jstz-1.0.4.min.js @@ -0,0 +1,2 @@ +/*! jstz - v1.0.4 - 2012-12-12 */ +(function(e){var t=function(){"use strict";var e="s",n=function(e){var t=-e.getTimezoneOffset();return t!==null?t:0},r=function(e,t,n){var r=new Date;return e!==undefined&&r.setFullYear(e),r.setDate(n),r.setMonth(t),r},i=function(e){return n(r(e,0,2))},s=function(e){return n(r(e,5,2))},o=function(e){var t=e.getMonth()>7?s(e.getFullYear()):i(e.getFullYear()),r=n(e);return t-r!==0},u=function(){var t=i(),n=s(),r=i()-s();return r<0?t+",1":r>0?n+",1,"+e:t+",0"},a=function(){var e=u();return new t.TimeZone(t.olson.timezones[e])};return{determine:a,date_is_dst:o}}();t.TimeZone=function(e){"use strict";var n=null,r=function(){return n},i=function(){var e=t.olson.ambiguity_list[n],r=e.length,i=0,s=e[0];for(;i Date: Wed, 5 Aug 2015 09:48:31 -0400 Subject: [PATCH 11/14] SAAS-838: Undefined variable previousMediaName --- airtime_mvc/application/models/Schedule.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 811b90bd7..bec73fc7d 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -215,6 +215,7 @@ SQL; $currentMedia["ends"] = $currentMedia["show_ends"]; } + $currentMediaName = ""; $currentMediaFileId = $currentMedia["file_id"]; $currentMediaStreamId = $currentMedia["stream_id"]; if (isset($currentMediaFileId)) { @@ -256,6 +257,7 @@ SQL; ->orderByDbStarts(Criteria::DESC) ->findOne(); if (isset($previousMedia)) { + $previousMediaName = ""; $previousMediaFileId = $previousMedia->getDbFileId(); $previousMediaStreamId = $previousMedia->getDbStreamId(); if (isset($previousMediaFileId)) { From eef61a65fc020bfcccd8f7a00853f51ece085286 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Wed, 5 Aug 2015 14:49:43 -0400 Subject: [PATCH 12/14] Cleanup and comments for the timezone/language popup --- .../controllers/SetupController.php | 2 + .../controllers/ShowbuilderController.php | 97 +++++-------------- .../application/models/airtime/CcSubjs.php | 5 + .../scripts/form/setup-lang-timezone.phtml | 7 +- .../views/scripts/showbuilder/index.phtml | 5 - .../airtime/nowplaying/lang-timezone-setup.js | 4 +- 6 files changed, 34 insertions(+), 86 deletions(-) diff --git a/airtime_mvc/application/controllers/SetupController.php b/airtime_mvc/application/controllers/SetupController.php index 9b211eeb6..590696862 100644 --- a/airtime_mvc/application/controllers/SetupController.php +++ b/airtime_mvc/application/controllers/SetupController.php @@ -1,5 +1,7 @@ view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']); - $setupComplete = Application_Model_Preference::getLangTimezoneSetupComplete(); - $previousPage = $request->getHeader('Referer'); - $userService = new Application_Service_UserService(); - $currentUser = $userService->getCurrentUser(); - - // If current user is Super Admin, and they came from the login page, - // and they have not seen the setup popup before - if ($currentUser->getDbType() == "S" && strpos(strtolower($previousPage), 'login') !== false - && empty($setupComplete)) { - $lang_tz_popup_form = new Application_Form_SetupLanguageTimezone(); - $this->view->lang_tz_popup_form = $lang_tz_popup_form; - $this->view->headScript()->appendFile($baseUrl.'js/airtime/nowplaying/lang-timezone-setup.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - } - - //TODO: is it safe to remove this?? - /* - if ($request->isPost()) { - $form = new Application_Form_RegisterAirtime(); - - $values = $request->getPost(); - if ($values["Publicise"] != 1 && $form->isValid($values)) { - Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]); - - if (isset($values["Privacy"])) { - Application_Model_Preference::SetPrivacyPolicyCheck($values["Privacy"]); - } - session_start(); //open session for writing again - // unset referrer - Zend_Session::namespaceUnset('referrer'); - } elseif ($values["Publicise"] == '1' && $form->isValid($values)) { - Application_Model_Preference::SetHeadTitle($values["stnName"], $this->view); - Application_Model_Preference::SetPhone($values["Phone"]); - Application_Model_Preference::SetEmail($values["Email"]); - Application_Model_Preference::SetStationWebSite($values["StationWebSite"]); - Application_Model_Preference::SetPublicise($values["Publicise"]); - - $form->Logo->receive(); - $imagePath = $form->Logo->getFileName(); - - Application_Model_Preference::SetStationCountry($values["Country"]); - Application_Model_Preference::SetStationCity($values["City"]); - Application_Model_Preference::SetStationDescription($values["Description"]); - Application_Model_Preference::SetStationLogo($imagePath); - Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]); - - if (isset($values["Privacy"])) { - Application_Model_Preference::SetPrivacyPolicyCheck($values["Privacy"]); - } - session_start(); //open session for writing again - // unset referrer - Zend_Session::namespaceUnset('referrer'); - } else { - $logo = Application_Model_Preference::GetStationLogo(); - if ($logo) { - $this->view->logoImg = $logo; - } - $this->view->dialog = $form; - $this->view->headScript()->appendFile($baseUrl.'js/airtime/nowplaying/register.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - } - } - - //popup if previous page was login - if ($refer_sses->referrer == 'login' && Application_Model_Preference::ShouldShowPopUp() - && !Application_Model_Preference::GetSupportFeedback() && $user->isAdmin()){ - - $form = new Application_Form_RegisterAirtime(); - - $logo = Application_Model_Preference::GetStationLogo(); - if ($logo) { - $this->view->logoImg = $logo; - } - $this->view->dialog = $form; - $this->view->headScript()->appendFile($baseUrl.'js/airtime/nowplaying/register.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - } - */ + //Show the timezone and language setup popup, if needed. + $this->checkAndShowSetupPopup($request); //determine whether to remove/hide/display the library. $showLib = false; @@ -202,6 +129,26 @@ class ShowbuilderController extends Zend_Controller_Action $this->view->headLink()->appendStylesheet($baseUrl.'css/showbuilder.css?'.$CC_CONFIG['airtime_version']); } + /** Check if we need to show the timezone/language setup popup and display it. (eg. on first run) */ + public function checkAndShowSetupPopup($request) + { + $CC_CONFIG = Config::getConfig(); + $baseUrl = Application_Common_OsPath::getBaseDir(); + $setupComplete = Application_Model_Preference::getLangTimezoneSetupComplete(); + $previousPage = $request->getHeader('Referer'); + $userService = new Application_Service_UserService(); + $currentUser = $userService->getCurrentUser(); + $previousPageWasLoginScreen = strpos(strtolower($previousPage), 'login') !== false; + + // If current user is Super Admin, and they came from the login page, + // and they have not seen the setup popup before + if ($currentUser->isSuperAdmin() && $previousPageWasLoginScreen /*&& empty($setupComplete)*/) { + $lang_tz_popup_form = new Application_Form_SetupLanguageTimezone(); + $this->view->lang_tz_popup_form = $lang_tz_popup_form; + $this->view->headScript()->appendFile($baseUrl.'js/airtime/nowplaying/lang-timezone-setup.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + } + } + public function contextMenuAction() { $baseUrl = Application_Common_OsPath::getBaseDir(); diff --git a/airtime_mvc/application/models/airtime/CcSubjs.php b/airtime_mvc/application/models/airtime/CcSubjs.php index 7fe6289f1..54531025b 100644 --- a/airtime_mvc/application/models/airtime/CcSubjs.php +++ b/airtime_mvc/application/models/airtime/CcSubjs.php @@ -18,6 +18,11 @@ class CcSubjs extends BaseCcSubjs { return $this->type === UTYPE_SUPERADMIN || $this->type === UTYPE_ADMIN || $this->type === UTYPE_PROGRAM_MANAGER; } + public function isSuperAdmin() + { + return $this->type === UTYPE_SUPERADMIN; + } + public function isHostOfShow($showId) { return CcShowHostsQuery::create() diff --git a/airtime_mvc/application/views/scripts/form/setup-lang-timezone.phtml b/airtime_mvc/application/views/scripts/form/setup-lang-timezone.phtml index 117d92a82..1c9e31ed5 100644 --- a/airtime_mvc/application/views/scripts/form/setup-lang-timezone.phtml +++ b/airtime_mvc/application/views/scripts/form/setup-lang-timezone.phtml @@ -1,4 +1,4 @@ -
" style="display: none;"> +
" style="display: none;">
@@ -7,10 +7,9 @@ element->getElement('setup_language')->render(); ?> element->getElement('setup_timezone')->render(); ?> - -
- You can set these settings later under Preferences and your user settings.
+

You can change these later in your preferences and user settings.

+
diff --git a/airtime_mvc/application/views/scripts/showbuilder/index.phtml b/airtime_mvc/application/views/scripts/showbuilder/index.phtml index 1d1751bec..0473ec1bf 100644 --- a/airtime_mvc/application/views/scripts/showbuilder/index.phtml +++ b/airtime_mvc/application/views/scripts/showbuilder/index.phtml @@ -20,9 +20,4 @@
- -dialog ?> - lang_tz_popup_form; ?> diff --git a/airtime_mvc/public/js/airtime/nowplaying/lang-timezone-setup.js b/airtime_mvc/public/js/airtime/nowplaying/lang-timezone-setup.js index 4e200dbb9..af1529f46 100644 --- a/airtime_mvc/public/js/airtime/nowplaying/lang-timezone-setup.js +++ b/airtime_mvc/public/js/airtime/nowplaying/lang-timezone-setup.js @@ -7,11 +7,11 @@ $(document).ready(function() { width: 500, resizable: false, modal: true, - position:['center',50], + position:['center','center'], buttons: [ { id: "setup-later", - text: $.i18n._("Set Later"), + text: $.i18n._("Not Now"), "class": "btn", click: function() { $(this).dialog("close"); From 1093e7085a9ed5b0f128ea5bda443c1e484e4c7a Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Wed, 5 Aug 2015 15:00:28 -0400 Subject: [PATCH 13/14] Re-enable hiding the first run popup after first run --- airtime_mvc/application/controllers/ShowbuilderController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/controllers/ShowbuilderController.php b/airtime_mvc/application/controllers/ShowbuilderController.php index 33a3118f2..c96ca658e 100644 --- a/airtime_mvc/application/controllers/ShowbuilderController.php +++ b/airtime_mvc/application/controllers/ShowbuilderController.php @@ -142,7 +142,7 @@ class ShowbuilderController extends Zend_Controller_Action // If current user is Super Admin, and they came from the login page, // and they have not seen the setup popup before - if ($currentUser->isSuperAdmin() && $previousPageWasLoginScreen /*&& empty($setupComplete)*/) { + if ($currentUser->isSuperAdmin() && $previousPageWasLoginScreen && empty($setupComplete)) { $lang_tz_popup_form = new Application_Form_SetupLanguageTimezone(); $this->view->lang_tz_popup_form = $lang_tz_popup_form; $this->view->headScript()->appendFile($baseUrl.'js/airtime/nowplaying/lang-timezone-setup.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); From 9c5a6347544de9cea57e5585bdfe0d9816a89408 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Wed, 5 Aug 2015 15:30:14 -0400 Subject: [PATCH 14/14] Fix default Icecast hostname --- airtime_mvc/application/models/StreamSetting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/StreamSetting.php b/airtime_mvc/application/models/StreamSetting.php index 34e037cd5..80e085f89 100644 --- a/airtime_mvc/application/models/StreamSetting.php +++ b/airtime_mvc/application/models/StreamSetting.php @@ -279,7 +279,7 @@ class Application_Model_StreamSetting public static function getDefaults($prefix) { $config = Config::getConfig(); return array( - 'host' => $config['baseUrl'], + 'host' => $config['stationId'] . ".out.airtime.pro", 'port' => DEFAULT_ICECAST_PORT, 'output' => 'icecast', 'user' => $config['stationId'],