Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
Yuchen Wang 2011-11-24 14:05:38 -05:00
commit b84c51212a
168 changed files with 63455 additions and 63 deletions

View file

@ -165,10 +165,10 @@ class PreferenceController extends Zend_Controller_Action
$num_of_stream = intval(Application_Model_Preference::GetNumOfStreams());
$form = new Application_Form_StreamSetting();
if(Application_Model_Preference::GetPlanLevel() == 'disabled'){
$form->setSetting($setting);
$form->startFrom();
}
$form->setSetting($setting);
$form->startFrom();
for($i=1; $i<=$num_of_stream; $i++){
$subform = new Application_Form_StreamSettingSubForm();
$subform->setPrefix($i);
@ -192,9 +192,14 @@ class PreferenceController extends Zend_Controller_Action
}
}
}
if(Application_Model_Preference::GetPlanLevel() == 'disabled' && $form->isValid($post_data['output_sound_device'])){
$values['output_sound_device'] = $form->getValue('output_sound_device');
if($form->isValid($post_data)){
if(Application_Model_Preference::GetPlanLevel() == 'disabled'){// && $form->isValid($post_data['output_sound_device'])){
$values['output_sound_device'] = $form->getValue('output_sound_device');
}
$values['icecast_vorbis_metadata'] = $form->getValue('icecast_vorbis_metadata');
}
var_dump($form->getValue('icecast_vorbis_metadata'));
if(!$error){
Application_Model_StreamSetting::setStreamSetting($values);
$data = array();

View file

@ -435,7 +435,7 @@ class ScheduleController extends Zend_Controller_Action
//convert from UTC to user's timezone for display.
$originalDateTime = new DateTime($originalShowStart, new DateTimeZone("UTC"));
$originalDateTime->setTimezone(new DateTimeZone(date_default_timezone_get));
$originalDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
//$timestamp = Application_Model_DateHelper::ConvertToLocalDateTimeString($originalDateTime->format("Y-m-d H:i:s"));
$this->view->additionalShowInfo =
"Rebroadcast of show \"$originalShowName\" from "
@ -493,7 +493,7 @@ class ScheduleController extends Zend_Controller_Action
$startsDateTime = new DateTime($show->getStartDate()." ".$show->getStartTime(), new DateTimeZone("UTC"));
$endsDateTime = new DateTime($show->getEndDate()." ".$show->getEndTime(), new DateTimeZone("UTC"));
$startsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
$endsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
@ -508,13 +508,16 @@ class ScheduleController extends Zend_Controller_Action
$formWhen->getElement('add_show_start_date')->setOptions(array('disabled' => true));
}
//need to get the days of the week in the php timezone (for the front end).
$days = array();
$showDays = CcShowDaysQuery::create()->filterByDbShowId($showInstance->getShowId())->find();
foreach($showDays as $showDay){
array_push($days, $showDay->getDbDay());
$showStartDay = new DateTime($showDay->getDbFirstShow(), new DateTimeZone($showDay->getDbTimezone()));
$showStartDay->setTimezone(new DateTimeZone(date_default_timezone_get()));
array_push($days, $showStartDay->format('w'));
}
$displayedEndDate = new DateTime($show->getRepeatingEndDate(), new DateTimeZone("UTC"));
$displayedEndDate = new DateTime($show->getRepeatingEndDate(), new DateTimeZone($showDays[0]->getDbTimezone()));
$displayedEndDate->sub(new DateInterval("P1D"));//end dates are stored non-inclusively.
$displayedEndDate->setTimezone(new DateTimeZone(date_default_timezone_get()));
@ -742,7 +745,7 @@ class ScheduleController extends Zend_Controller_Action
$this->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
$this->view->rebroadcast = $formRebroadcast;
$this->view->addNewShow = true;
//the form still needs to be "update" since
//the validity test failed.
if ($data['add_show_id'] != -1){
@ -751,9 +754,9 @@ class ScheduleController extends Zend_Controller_Action
if (!$startDateModified){
$formWhen->getElement('add_show_start_date')->setOptions(array('disabled' => true));
}
$this->view->form = $this->view->render('schedule/add-show-form.phtml');
}
}else{
$userInfo = Zend_Auth::getInstance()->getStorage()->read();

View file

@ -15,19 +15,31 @@ class Application_Form_StreamSetting extends Zend_Form
public function startFrom() {
$setting = $this->setting;
$output_sound_device = new Zend_Form_Element_Checkbox('output_sound_device');
$output_sound_device->setLabel('Enabled')
->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);
if(Application_Model_Preference::GetPlanLevel() == 'disabled'){
$output_sound_device = new Zend_Form_Element_Checkbox('output_sound_device');
$output_sound_device->setLabel('Hardware Audio Ouput')
->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);
}
$this->addElement($output_sound_device);
$icecast_vorbis_metadata = new Zend_Form_Element_Checkbox('icecast_vorbis_metadata');
$icecast_vorbis_metadata->setLabel('Icecast Vorbis Meatadata')
->setRequired(false)
->setValue(($setting['icecast_vorbis_metadata'] == "true")?1:0)
->setDecorators(array('ViewHelper'));
if (Application_Model_Preference::GetEnableStreamConf() == "false"){
$icecast_vorbis_metadata->setAttrib("readonly", true);
}
$this->addElement($icecast_vorbis_metadata);
}
public function isValid($data){
$this->populate(array("output_sound_device"=>$data));
$this->populate(array("output_sound_device"=>$data['output_sound_device'], "icecast_vorbis_metadata"=>$data['icecast_vorbis_metadata']));
return true;
}
}

View file

@ -187,14 +187,16 @@ class Application_Model_Show {
$uncheckedDaysImploded = implode(",", $p_uncheckedDays);
$showId = $this->getId();
$date = new Application_Model_DateHelper;
$timestamp = $date->getTimestamp();
$timestamp = gmdate("Y-m-d H:i:s");
$sql = "DELETE FROM cc_show_instances"
." WHERE EXTRACT(DOW FROM starts) IN ($uncheckedDaysImploded)"
." AND starts > TIMESTAMP '$timestamp'"
." AND show_id = $showId";
Logging::log("sql for removing unchecked days");
Logging::log($sql);
$CC_DBC->query($sql);
}
@ -856,7 +858,8 @@ class Application_Model_Show {
//What we are doing here is checking if the show repeats or if
//any repeating days have been checked. If not, then by default
//the "selected" DOW is the initial day.
$startDow = gmdate("w", $utcStartDateTime->getTimestamp());
//DOW in local time.
$startDow = date("w", $startDateTime->getTimestamp());
if (!$data['add_show_repeats']) {
$data['add_show_day_check'] = array($startDow);
} else if ($data['add_show_repeats'] && $data['add_show_day_check'] == "") {
@ -907,7 +910,10 @@ class Application_Model_Show {
$showDay->setDbRecord($isRecorded);
$showDay->save();
} else {
Logging::log("startDow is: {$startDow}");
foreach ($data['add_show_day_check'] as $day) {
Logging::log("day is: {$day}");
$daysAdd=0;
$startDateTimeClone = clone $startDateTime;
if ($startDow !== $day){
@ -916,7 +922,10 @@ class Application_Model_Show {
else
$daysAdd = $day - $startDow;
Logging::log("days to add: {$daysAdd}");
$startDateTimeClone->add(new DateInterval("P".$daysAdd."D"));
Logging::log("start date: {$startDateTimeClone->format("Y-m-d")}");
}
if (is_null($endDate) || $startDateTimeClone->getTimestamp() <= $endDateTime->getTimestamp()) {
$showDay = new CcShowDays();

View file

@ -60,12 +60,13 @@ class Application_Model_StreamSetting {
public static function setStreamSetting($data){
global $CC_DBC;
foreach($data as $key=>$d){
if($key == "output_sound_device"){
if($key == "output_sound_device" || $key == "icecast_vorbis_metadata"){
$v = $d == 1?"true":"false";
$sql = "UPDATE cc_stream_setting SET value='$v' WHERE keyname='$key'";
$CC_DBC->query($sql);
}
else{
var_dump($key);
$temp = explode('_', $key);
$prefix = $temp[0];
foreach($d as $k=>$v){

View file

@ -8,21 +8,29 @@
<div style="clear:both"></div>
<?php }?>
<?php echo $this->statusMsg;?>
<?php if($this->form->getElement('output_sound_device') != null){?>
<fieldset class="padded">
<legend>Hardware Audio Out</legend>
<fieldset class="padded stream-setting-global">
<legend>Global Settings</legend>
<dl class="zend_form">
<?php if($this->form->getElement('output_sound_device') != null){?>
<dt id="hardwareOut-label">
<label class="required" for="EnableHardwareOut">
<label class="required">
<?php echo $this->form->getElement('output_sound_device')->getLabel() ?> :
</label>
</dt>
<dd id="hardwareOut-element">
<?php echo $this->form->getElement('output_sound_device') ?>
</dd>
<?php } ?>
<dt id="vorbisMetadata-label">
<label class="required">
<?php echo $this->form->getElement('icecast_vorbis_metadata')->getLabel() ?> :
</label>
</dt>
<dd id="vorbisMetadata-element">
<?php echo $this->form->getElement('icecast_vorbis_metadata') ?>
</dd>
</dl>
</fieldset>
<?php } ?>
<?php
for($i=1;$i<=$this->num_stream;$i++){
echo $this->form->getSubform("s".$i."_subform");