From fa929d45a61394637fd0974da010a0c2bacb3456 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 2 Sep 2011 16:13:30 -0400 Subject: [PATCH] CC-2753: Ability to disable stream 1 but still show it in the interface - interface change - all elements becomes 'disabled' depending on 'disable_stream_conf' flag --- .../controllers/PreferenceController.php | 1 + .../application/forms/StreamSetting.php | 3 ++ .../forms/StreamSettingSubForm.php | 42 +++++++++++++++++++ airtime_mvc/application/models/Preference.php | 8 ++++ .../scripts/preference/stream-setting.phtml | 2 + 5 files changed, 56 insertions(+) diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 291a715dd..6bccbf697 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -188,6 +188,7 @@ class PreferenceController extends Zend_Controller_Action } } $this->view->num_stream = $num_of_stream; + $this->view->disable_stream_conf = Application_Model_Preference::GetDisableStreamConf(); $this->view->form = $form; } diff --git a/airtime_mvc/application/forms/StreamSetting.php b/airtime_mvc/application/forms/StreamSetting.php index 4291b594f..746215b11 100644 --- a/airtime_mvc/application/forms/StreamSetting.php +++ b/airtime_mvc/application/forms/StreamSetting.php @@ -20,6 +20,9 @@ class Application_Form_StreamSetting extends Zend_Form ->setRequired(false) ->setValue(($setting['output_sound_device'] == "true")?1:0) ->setDecorators(array('ViewHelper')); + if(Application_Model_Preference::GetDisableStreamConf() == "true"){ + $output_sound_device->setAttrib("readonly", true); + } $this->addElement($output_sound_device); } diff --git a/airtime_mvc/application/forms/StreamSettingSubForm.php b/airtime_mvc/application/forms/StreamSettingSubForm.php index 2c765a68c..2a77480d9 100644 --- a/airtime_mvc/application/forms/StreamSettingSubForm.php +++ b/airtime_mvc/application/forms/StreamSettingSubForm.php @@ -36,10 +36,18 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{ $this->setIsArray(true); $this->setElementsBelongTo($prefix."_data"); + $disable_all = false; + if(Application_Model_Preference::GetDisableStreamConf() == "true"){ + $disable_all = true; + } + $enable = new Zend_Form_Element_Checkbox('enable'); $enable->setLabel('Enabled:') ->setValue($setting[$prefix.'_output'] != 'disabled'?1:0) ->setDecorators(array('ViewHelper')); + if($disable_all){ + $enable->setAttrib("disabled", "disabled"); + } $this->addElement($enable); $type = new Zend_Form_Element_Select('type'); @@ -47,6 +55,9 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{ ->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); $bitrate = new Zend_Form_Element_Select('bitrate'); @@ -54,6 +65,10 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{ ->setMultiOptions($stream_bitrates) ->setValue(isset($setting[$prefix.'_bitrate'])?$setting[$prefix.'_bitrate']:0) ->setDecorators(array('ViewHelper')); + if($disable_all){ + $bitrate->setAttrib("disabled", "disabled"); + } + $this->addElement($type); $this->addElement($bitrate); $output = new Zend_Form_Element_Select('output'); @@ -61,54 +76,81 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{ ->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); $host = new Zend_Form_Element_Text('host'); $host->setLabel("Server") ->setValue(isset($setting[$prefix.'_host'])?$setting[$prefix.'_host']:"") ->setDecorators(array('ViewHelper')); + if($disable_all){ + $host->setAttrib("disabled", "disabled"); + } $this->addElement($host); $port = new Zend_Form_Element_Text('port'); $port->setLabel("Port") ->setValue(isset($setting[$prefix.'_port'])?$setting[$prefix.'_port']:"") ->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']:"") ->setDecorators(array('ViewHelper')); + if($disable_all){ + $pass->setAttrib("disabled", "disabled"); + } $this->addElement($pass); $genre = new Zend_Form_Element_Text('genre'); $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'); $url->setLabel("URL") ->setValue(isset($setting[$prefix.'_url'])?$setting[$prefix.'_url']:"") ->setDecorators(array('ViewHelper')); + if($disable_all){ + $url->setAttrib("disabled", "disabled"); + } $this->addElement($url); $description = new Zend_Form_Element_Text('description'); $description->setLabel("Name/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']:"") ->setDecorators(array('ViewHelper')); + if($disable_all){ + $mount->setAttrib("disabled", "disabled"); + } $this->addElement($mount); $user = new Zend_Form_Element_Text('user'); $user->setLabel("Username") ->setValue(isset($setting[$prefix.'_user'])?$setting[$prefix.'_user']:"") ->setDecorators(array('ViewHelper')); + if($disable_all){ + $user->setAttrib("disabled", "disabled"); + } $this->addElement($user); $this->setDecorators(array( diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 5abec2ce2..0412c6fe6 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -426,5 +426,13 @@ class Application_Model_Preference public static function GetTrialEndingDate(){ return Application_Model_Preference::GetValue("trial_end_date"); } + + public static function SetDisableStreamConf($bool){ + Application_Model_Preference::SetValue("disable_stream_conf", $bool); + } + + public static function GetDisableStreamConf(){ + return Application_Model_Preference::GetValue("disable_stream_conf"); + } } diff --git a/airtime_mvc/application/views/scripts/preference/stream-setting.phtml b/airtime_mvc/application/views/scripts/preference/stream-setting.phtml index e34d6b1f4..3545a6854 100644 --- a/airtime_mvc/application/views/scripts/preference/stream-setting.phtml +++ b/airtime_mvc/application/views/scripts/preference/stream-setting.phtml @@ -18,8 +18,10 @@ echo $this->form->getSubform("s".$i."_subform"); } ?> + disable_stream_conf != "true"){?>
+ \ No newline at end of file