Merge branch 'saas' into cc-5709-airtime-analyzer-buy-now-saas

This commit is contained in:
drigato 2014-06-23 10:59:07 -04:00
commit f40cdbc8cd
70 changed files with 49423 additions and 46970 deletions

View file

@ -118,7 +118,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
$nowDateTime = new DateTime("now", $showTimezone);
$showStartDateTime = new DateTime($start_time, $showTimezone);
$showEndDateTime = new DateTime($end_time, $showTimezone);
if ($validateStartDate) {
if ($showStartDateTime < $nowDateTime) {
$this->getElement('add_show_start_time')->setErrors(array(_('Cannot create show in the past')));
@ -135,16 +135,16 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
}
}
}
// if end time is in the past, return error
if ($showEndDateTime < $nowDateTime) {
$this->getElement('add_show_end_time')->setErrors(array(_('End date/time cannot be in the past')));
$valid = false;
}
//validate duration.
$duration = $showStartDateTime->diff($showEndDateTime);
if ($showStartDateTime > $showEndDateTime) {
$this->getElement('add_show_duration')->setErrors(array(_('Cannot have duration < 0m')));
$valid = false;
@ -153,14 +153,14 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
$this->getElement('add_show_duration')->setErrors(array(_('Cannot have duration 00h 00m')));
$valid = false;
}
else if (intval($duration->format('%d')) > 0 &&
else if (intval($duration->format('%d')) > 0 &&
(intval($duration->format('%h')) > 0
|| intval($duration->format('%i')) > 0
|| intval($duration->format('%s')) > 0)) {
$this->getElement('add_show_duration')->setErrors(array(_('Cannot have duration greater than 24h')));
$valid = false;
}
/* We need to know the show duration broken down into hours and minutes
* They are used for checking overlapping shows and for validating
@ -176,7 +176,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
if ($valid) {
//we need to know the start day of the week in show's local timezome
$startDow = $showStartDateTime->format("w");
$utc = new DateTimeZone('UTC');
$showStartDateTime->setTimezone($utc);
$showEndDateTime->setTimezone($utc);
@ -264,24 +264,11 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
//this is a new show
$overlapping = Application_Model_Schedule::checkOverlappingShows(
$repeatShowStart, $repeatShowEnd);
/* If the repeating show is rebroadcasted we need to check
* the rebroadcast dates relative to the repeating show
*/
if (!$overlapping && $formData['add_show_rebroadcast']) {
$overlapping = self::checkRebroadcastDates(
$repeatShowStart, $formData, $hours, $minutes);
}
} else {
$overlapping = Application_Model_Schedule::checkOverlappingShows(
$repeatShowStart, $repeatShowEnd, $update, null, $formData["add_show_id"]);
if (!$overlapping && $formData['add_show_rebroadcast']) {
$overlapping = self::checkRebroadcastDates(
$repeatShowStart, $formData, $hours, $minutes, true);
}
}
if ($overlapping) {
$valid = false;
$this->getElement('add_show_duration')->setErrors(array(_('Cannot schedule overlapping shows')));
@ -300,36 +287,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
$valid = false;
$this->getElement('add_show_duration')->setErrors(array(_('Cannot schedule overlapping shows')));
}
} elseif ($formData["add_show_rebroadcast"]) {
/* Check first show
* Continue if the first show does not overlap
*/
$overlapping = Application_Model_Schedule::checkOverlappingShows($showStartDateTime, $showEndDateTime, $update, $instanceId);
if (!$overlapping) {
$durationToAdd = "PT".$hours."H".$minutes."M";
for ($i = 1; $i <= 10; $i++) {
if (empty($formData["add_show_rebroadcast_date_absolute_".$i])) break;
$abs_rebroadcast_start = $formData["add_show_rebroadcast_date_absolute_".$i]." ".
$formData["add_show_rebroadcast_time_absolute_".$i];
$rebroadcastShowStart = new DateTime($abs_rebroadcast_start);
$rebroadcastShowStart->setTimezone(new DateTimeZone('UTC'));
$rebroadcastShowEnd = clone $rebroadcastShowStart;
$rebroadcastShowEnd->add(new DateInterval($durationToAdd));
$overlapping = Application_Model_Schedule::checkOverlappingShows($rebroadcastShowStart,
$rebroadcastShowEnd, $update, null, $formData["add_show_id"]);
if ($overlapping) {
$valid = false;
$this->getElement('add_show_duration')->setErrors(array(_('Cannot schedule overlapping shows')));
break;
}
}
} else {
$valid = false;
$this->getElement('add_show_duration')->setErrors(array(_('Cannot schedule overlapping shows')));
}
} else {
$overlapping = Application_Model_Schedule::checkOverlappingShows($showStartDateTime, $showEndDateTime, $update, $instanceId);
if ($overlapping) {
@ -357,10 +315,10 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
$rebroadcastShowStart->add(new DateInterval("P".$rebroadcastWhenDays[0]."D"));
$rebroadcastShowStart->setTime($rebroadcastWhenTime[0], $rebroadcastWhenTime[1]);
$rebroadcastShowStart->setTimezone(new DateTimeZone('UTC'));
$rebroadcastShowEnd = clone $rebroadcastShowStart;
$rebroadcastShowEnd->add(new DateInterval("PT".$hours."H".$minutes."M"));
if ($showEdit) {
$overlapping = Application_Model_Schedule::checkOverlappingShows(
$rebroadcastShowStart, $rebroadcastShowEnd, true, null, $formData['add_show_id']);
@ -368,13 +326,13 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
$overlapping = Application_Model_Schedule::checkOverlappingShows(
$rebroadcastShowStart, $rebroadcastShowEnd);
}
if ($overlapping) break;
}
return $overlapping;
}
public function disable()
{
$elements = $this->getElements();

View file

@ -7,7 +7,6 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm
public function init()
{
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/preferences_email_server.phtml'))
));

View file

@ -5,7 +5,6 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
public function init()
{
$notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
$rangeValidator = Application_Form_Helper_ValidationTypes::overrideBetweenValidator(0, 59.9);
$this->setDecorators(array(
@ -92,6 +91,20 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
$third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi());
$third_party_api->setDecorators(array('ViewHelper'));
$this->addElement($third_party_api);
//
// Add the description element
$this->addElement('textarea', 'widgetCode', array(
'label' => 'Javascript Code:',
'required' => false,
'readonly' => true,
'style' => 'font-family: Consolas, "Liberation Mono", Courier,
monospace;',
'class' => 'input_text_area',
'value' => self::getWidgetCode(), //$_SERVER["SERVER_NAME"],
'decorators' => array(
'ViewHelper'
)
));
$locale = new Zend_Form_Element_Select("locale");
$locale->setLabel(_("Default Interface Language"));
@ -117,6 +130,42 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
$this->addElement($week_start_day);
}
private static function getWidgetCode() {
$host = $_SERVER['SERVER_NAME'];
$code = <<<CODE
<script src="http://$host/widgets/js/jquery-1.6.1.min.js" type="text/javascript"></script>
<script src="http://$host/widgets/js/jquery-ui-1.8.10.custom.min.js" type="text/javascript"></script>
<script src="http://$host/widgets/js/jquery.showinfo.js" type="text/javascript"></script>
<div id="headerLiveHolder" style="border: 1px solid #999999; padding: 10px;"></div>
<div id="onAirToday"></div>
<div id="scheduleTabs"></div>
<script type="text/javascript">
$(document).ready(function() {
$("#headerLiveHolder").airtimeLiveInfo({
sourceDomain: "http://$host",
updatePeriod: 20 //seconds
});
$("#onAirToday").airtimeShowSchedule({
sourceDomain: "http://$host",
updatePeriod: 5, //seconds
showLimit: 10
});
$("#scheduleTabs").airtimeWeekSchedule({
sourceDomain:"http://$host",
updatePeriod: 600 //seconds
});
});
</script>
CODE;
return $code;
}
private function getWeekStartDays()
{
$days = array(

View file

@ -80,44 +80,6 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
->setDecorators(array('ViewHelper'));
$this->addElement($live_dj_connection_url);
//liquidsoap harbor.input port
$betweenValidator = Application_Form_Helper_ValidationTypes::overrideBetweenValidator(1024, 49151);
$m_port = Application_Model_StreamSetting::getMasterLiveStreamPort();
$master_dj_port = new Zend_Form_Element_Text('master_harbor_input_port');
$master_dj_port->setLabel(_("Master Source Port"))
->setValue($m_port)
->setValidators(array($betweenValidator))
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>_('Only numbers are allowed.'))))
->setDecorators(array('ViewHelper'));
$this->addElement($master_dj_port);
$m_mount = Application_Model_StreamSetting::getMasterLiveStreamMountPoint();
$master_dj_mount = new Zend_Form_Element_Text('master_harbor_input_mount_point');
$master_dj_mount->setLabel(_("Master Source Mount Point"))
->setValue($m_mount)
->setValidators(array(
array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered')))))
->setDecorators(array('ViewHelper'));
$this->addElement($master_dj_mount);
//liquidsoap harbor.input port
$l_port = Application_Model_StreamSetting::getDjLiveStreamPort();
$live_dj_port = new Zend_Form_Element_Text('dj_harbor_input_port');
$live_dj_port->setLabel(_("Show Source Port"))
->setValue($l_port)
->setValidators(array($betweenValidator))
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>_('Only numbers are allowed.'))))
->setDecorators(array('ViewHelper'));
$this->addElement($live_dj_port);
$l_mount = Application_Model_StreamSetting::getDjLiveStreamMountPoint();
$live_dj_mount = new Zend_Form_Element_Text('dj_harbor_input_mount_point');
$live_dj_mount->setLabel(_("Show Source Mount Point"))
->setValue($l_mount)
->setValidators(array(
array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered')))))
->setDecorators(array('ViewHelper'));
$this->addElement($live_dj_mount);
// demo only code
if (!$isStreamConfigable) {
$elements = $this->getElements();
@ -145,49 +107,6 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
public function isValid($data)
{
$isValid = parent::isValid($data);
$master_harbor_input_port = $data['master_harbor_input_port'];
$dj_harbor_input_port = $data['dj_harbor_input_port'];
if ($master_harbor_input_port == $dj_harbor_input_port && $master_harbor_input_port != "") {
$element = $this->getElement("dj_harbor_input_port");
$element->addError(_("You cannot use same port as Master DJ port."));
$isValid = false;
}
if ($master_harbor_input_port != "") {
if (is_numeric($master_harbor_input_port)) {
if ($master_harbor_input_port != Application_Model_StreamSetting::getMasterLiveStreamPort()) {
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
try {
socket_bind($sock, 0, $master_harbor_input_port);
} catch (Exception $e) {
$element = $this->getElement("master_harbor_input_port");
$element->addError(sprintf(_("Port %s is not available"), $master_harbor_input_port));
$isValid = false;
}
socket_close($sock);
}
} else {
$isValid = false;
}
}
if ($dj_harbor_input_port != "") {
if (is_numeric($dj_harbor_input_port)) {
if ($dj_harbor_input_port != Application_Model_StreamSetting::getDjLiveStreamPort()) {
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
try {
socket_bind($sock, 0, $dj_harbor_input_port);
} catch (Exception $e) {
$element = $this->getElement("dj_harbor_input_port");
$element->addError(sprintf(_("Port %s is not available"), $dj_harbor_input_port));
$isValid = false;
}
socket_close($sock);
}
} else {
$isValid = false;
}
}
return $isValid;
}

View file

@ -2,14 +2,12 @@
class Application_Form_Preferences extends Zend_Form
{
public function init()
{
$baseUrl = Application_Common_OsPath::getBaseDir();
$this->setMethod('post');
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/preferences.phtml'))
));
@ -17,9 +15,6 @@ class Application_Form_Preferences extends Zend_Form
$general_pref = new Application_Form_GeneralPreferences();
$this->addSubForm($general_pref, 'preferences_general');
$email_pref = new Application_Form_EmailServerPreferences();
$this->addSubForm($email_pref, 'preferences_email_server');
$soundcloud_pref = new Application_Form_SoundcloudPreferences();
$this->addSubForm($soundcloud_pref, 'preferences_soundcloud');

View file

@ -11,16 +11,6 @@ class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm
array('ViewScript', array('viewScript' => 'form/preferences_soundcloud.phtml'))
));
//enable soundcloud uploads
$this->addElement('checkbox', 'UseSoundCloud', array(
'label' => _('Automatically Upload Recorded Shows'),
'required' => false,
'value' => Application_Model_Preference::GetAutoUploadRecordedShowToSoundcloud(),
'decorators' => array(
'ViewHelper'
)
));
//enable soundcloud uploads option
$this->addElement('checkbox', 'UploadToSoundcloudOption', array(
'label' => _('Enable SoundCloud Upload'),

View file

@ -17,28 +17,6 @@ class Application_Form_StreamSetting extends Zend_Form
public function startFrom()
{
$setting = $this->setting;
if (Application_Model_Preference::GetPlanLevel() == 'disabled') {
$output_sound_device = new Zend_Form_Element_Checkbox('output_sound_device');
$output_sound_device->setLabel(_('Hardware Audio Output'))
->setRequired(false)
->setValue(($setting['output_sound_device'] == "true")?1:0)
->setDecorators(array('ViewHelper'));
if (Application_Model_Preference::GetEnableStreamConf() == "false") {
$output_sound_device->setAttrib("readonly", true);
}
$this->addElement($output_sound_device);
$output_types = array("ALSA"=>"ALSA", "AO"=>"AO", "OSS"=>"OSS", "Portaudio"=>"Portaudio", "Pulseaudio"=>"Pulseaudio");
$output_type = new Zend_Form_Element_Select('output_sound_device_type');
$output_type->setLabel(_("Output Type"))
->setMultiOptions($output_types)
->setValue($setting['output_sound_device_type'])
->setDecorators(array('ViewHelper'));
if ($setting['output_sound_device'] != "true") {
$output_type->setAttrib("disabled", "disabled");
}
$this->addElement($output_type);
}
$icecast_vorbis_metadata = new Zend_Form_Element_Checkbox('icecast_vorbis_metadata');
$icecast_vorbis_metadata->setLabel(_('Icecast Vorbis Metadata'))

View file

@ -4,7 +4,6 @@ require_once 'customfilters/ImageSize.php';
class Application_Form_SupportSettings extends Zend_Form
{
public function init()
{
$country_list = Application_Model_Preference::GetCountryList();
@ -128,20 +127,6 @@ class Application_Form_SupportSettings extends Zend_Form
}
$this->addElement($checkboxPublicise);
// text area for sending detail
$this->addElement('textarea', 'SendInfo', array(
'class' => 'sending_textarea',
'required' => false,
'filters' => array('StringTrim'),
'readonly' => true,
'cols' => 61,
'rows' => 5,
'value' => Application_Model_Preference::GetSystemInfo(false, true),
'decorators' => array(
'ViewHelper'
)
));
// checkbox for privacy policy
$checkboxPrivacy = new Zend_Form_Element_Checkbox("Privacy");
$checkboxPrivacy->setLabel(
@ -164,7 +149,6 @@ class Application_Form_SupportSettings extends Zend_Form
public function isValid ($data)
{
$isValid = parent::isValid($data);
if (isset($data["Privacy"])) {
$checkPrivacy = $this->getElement('Privacy');
if ($data["SupportFeedback"] == "1" && $data["Privacy"] != "1") {