Merge branch 'saas-dev' into saas-showbuilder

This commit is contained in:
Duncan Sommerville 2015-08-05 15:32:04 -04:00
commit 36f2e1844f
32 changed files with 489 additions and 493 deletions

View file

@ -1,106 +0,0 @@
<?php
require_once 'customvalidators/ConditionalNotEmpty.php';
class Application_Form_EmailServerPreferences extends Zend_Form_SubForm
{
public function init()
{
$this->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);
}
}

View file

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

View file

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

View file

@ -0,0 +1,28 @@
<?php
class Application_Form_SetupLanguageTimezone extends Zend_Form_SubForm
{
public function init()
{
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/setup-lang-timezone.phtml'))));
$csrf_namespace = new Zend_Session_Namespace('csrf_namespace');
$csrf_element = new Zend_Form_Element_Hidden('csrf');
$csrf_element->setValue($csrf_namespace->authtoken)->setRequired('true')->removeDecorator('HtmlTag')->removeDecorator('Label');
$this->addElement($csrf_element);
$language = new Zend_Form_Element_Select('setup_language');
$language->setLabel(_("Station Language"));
$language->setMultiOptions(Application_Model_Locale::getLocales());
$this->addElement($language);
$timezone = new Zend_Form_Element_Select('setup_timezone');
$timezone->setLabel(_("Station Timezone"));
$timezone->setMultiOptions(Application_Common_Timezone::getTimezones());
$this->addElement($timezone);
}
}

View file

@ -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(_('Streaming Server:'));
$customSettings->setMultiOptions(array(_("Airtime Pro Streaming"), _("Custom / 3rd Party Streaming")));
$customSettings->setValue(!empty($custom) ? $custom : 0);
$this->addElement($customSettings);
}
public function isValid($data)

View file

@ -6,6 +6,8 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm
private $stream_types;
private $stream_bitrates;
static $customizable;
public function init()
{
@ -39,54 +41,49 @@ 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");
$disable_all = Application_Model_Preference::GetEnableStreamConf() == "false";
$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")
->setValue($useDefaults ? $streamDefaults['output'] :
(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,43 +91,35 @@ 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"))
->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'));
if ($disable_all) {
$host->setAttrib("disabled", "disabled");
}
$host->setAttrib('alt', 'domain');
$this->addElement($host);
$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'));
if ($disable_all) {
$port->setAttrib("disabled", "disabled");
}
$this->addElement($port);
$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'));
if ($disable_all) {
$pass->setAttrib("disabled", "disabled");
}
$pass->setAttrib('alt', 'regular_text');
$this->addElement($pass);
@ -138,9 +127,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 +135,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,41 +142,31 @@ 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');
$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'));
if ($disable_all) {
$mount->setAttrib("disabled", "disabled");
}
$mount->setAttrib('alt', 'regular_text');
$this->addElement($mount);
$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'));
if ($disable_all) {
$user->setAttrib("disabled", "disabled");
}
$user->setAttrib('alt', 'regular_text');
$this->addElement($user);
@ -203,9 +176,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 +185,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);
$liquidsopa_error_msg = '<div class="stream-status status-info"><h3>'._('Getting information from the server...').'</h3></div>';
$liquidsoap_error_msg = '<div class="stream-status status-info"><h3>'._('Getting information from the server...').'</h3></div>';
$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,26 +202,42 @@ 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."));
// 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 && isset($f_data["host"])) {
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;
}
}
}
}
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');
}
}
}
}