2012-02-08 06:04:19 +01:00
|
|
|
<?php
|
|
|
|
require_once 'customvalidators/ConditionalNotEmpty.php';
|
|
|
|
|
|
|
|
class Application_Form_AddShowLiveStream extends Zend_Form_SubForm
|
|
|
|
{
|
|
|
|
|
|
|
|
public function init()
|
|
|
|
{
|
2012-05-17 23:33:50 +02:00
|
|
|
$description1 = "This follows the same security pattern for the shows: only users assigned to the show can connect.";
|
2012-02-21 23:58:05 +01:00
|
|
|
$cb_airtime_auth = new Zend_Form_Element_Checkbox("cb_airtime_auth");
|
2012-05-17 23:33:50 +02:00
|
|
|
$cb_airtime_auth->setLabel("Use Airtime Authentication:")
|
2012-02-08 06:04:19 +01:00
|
|
|
->setDescription($description1)
|
|
|
|
->setRequired(false)
|
|
|
|
->setDecorators(array('ViewHelper'));
|
2012-02-21 23:58:05 +01:00
|
|
|
$this->addElement($cb_airtime_auth);
|
2012-02-08 06:04:19 +01:00
|
|
|
|
2012-05-22 17:51:53 +02:00
|
|
|
$description2 = "Specify custom authentication which will work only for this show.";
|
2012-02-21 23:58:05 +01:00
|
|
|
$cb_custom_auth = new Zend_Form_Element_Checkbox("cb_custom_auth");
|
2012-05-17 23:33:50 +02:00
|
|
|
$cb_custom_auth ->setLabel("Use Custom Authentication:")
|
2012-02-08 06:04:19 +01:00
|
|
|
->setDescription($description2)
|
|
|
|
->setRequired(false)
|
|
|
|
->setDecorators(array('ViewHelper'));
|
2012-02-21 23:58:05 +01:00
|
|
|
$this->addElement($cb_custom_auth);
|
2012-02-08 06:04:19 +01:00
|
|
|
|
|
|
|
//custom username
|
|
|
|
$custom_username = new Zend_Form_Element_Text('custom_username');
|
|
|
|
$custom_username->setAttrib('class', 'input_text')
|
|
|
|
->setAttrib('autocomplete', 'off')
|
|
|
|
->setAllowEmpty(true)
|
|
|
|
->setLabel('Custom Username')
|
|
|
|
->setFilters(array('StringTrim'))
|
|
|
|
->setValidators(array(
|
2012-02-21 23:58:05 +01:00
|
|
|
new ConditionalNotEmpty(array("cb_custom_auth"=>"1"))))
|
2012-02-08 06:04:19 +01:00
|
|
|
->setDecorators(array('ViewHelper'));
|
|
|
|
$this->addElement($custom_username);
|
|
|
|
|
|
|
|
//custom password
|
|
|
|
$custom_password = new Zend_Form_Element_Password('custom_password');
|
|
|
|
$custom_password->setAttrib('class', 'input_text')
|
|
|
|
->setAttrib('autocomplete', 'off')
|
|
|
|
->setAttrib('renderPassword','true')
|
|
|
|
->setAllowEmpty(true)
|
|
|
|
->setLabel('Custom Password')
|
|
|
|
->setFilters(array('StringTrim'))
|
|
|
|
->setValidators(array(
|
2012-02-21 23:58:05 +01:00
|
|
|
new ConditionalNotEmpty(array("cb_custom_auth"=>"1"))))
|
2012-02-08 06:04:19 +01:00
|
|
|
->setDecorators(array('ViewHelper'));
|
|
|
|
$this->addElement($custom_password);
|
2012-02-21 23:58:05 +01:00
|
|
|
|
2012-03-26 21:07:27 +02:00
|
|
|
$connection_url = Application_Model_Preference::GetLiveDJSourceConnectionURL();
|
|
|
|
if(trim($connection_url) == ""){
|
|
|
|
$connection_url = "N/A";
|
|
|
|
}
|
|
|
|
|
2012-02-21 23:58:05 +01:00
|
|
|
$this->setDecorators(array(
|
2012-03-26 21:07:27 +02:00
|
|
|
array('ViewScript', array('viewScript' => 'form/add-show-live-stream.phtml', "connection_url"=>$connection_url))
|
2012-02-21 23:58:05 +01:00
|
|
|
));
|
2012-02-08 06:04:19 +01:00
|
|
|
}
|
2012-03-26 21:07:27 +02:00
|
|
|
|
|
|
|
public function isValid($data){
|
|
|
|
$isValid = parent::isValid($data);
|
|
|
|
|
|
|
|
if($data['cb_custom_auth'] == 1){
|
|
|
|
if(trim($data['custom_username']) == ''){
|
|
|
|
$element = $this->getElement("custom_username");
|
|
|
|
$element->addError("Username field cannot be empty.");
|
|
|
|
$isValid = false;
|
|
|
|
}
|
|
|
|
if(trim($data['custom_password']) == ''){
|
|
|
|
$element = $this->getElement("custom_password");
|
|
|
|
$element->addError("Password field cannot be empty.");
|
|
|
|
$isValid = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $isValid;
|
|
|
|
}
|
2012-02-08 06:04:19 +01:00
|
|
|
}
|