From 4eb8a7f394bd4e449c6689e7789d98ff490df060 Mon Sep 17 00:00:00 2001 From: martin Date: Fri, 27 May 2011 15:51:09 -0400 Subject: [PATCH 01/15] CC-2325: no audio after running airtime-pypo-stop/start -seems to work after re-enabling multilog. --- python_apps/media-monitor/airtime-media-monitor-start | 1 + python_apps/pypo/airtime-pypo-start | 4 +++- python_apps/show-recorder/airtime-show-recorder-start | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/python_apps/media-monitor/airtime-media-monitor-start b/python_apps/media-monitor/airtime-media-monitor-start index 084b2b1ad..2b50bb0f4 100755 --- a/python_apps/media-monitor/airtime-media-monitor-start +++ b/python_apps/media-monitor/airtime-media-monitor-start @@ -11,6 +11,7 @@ if os.geteuid() != 0: try: print "Starting daemontool script recorder" os.system("svc -u /etc/service/recorder") + os.system("svc -u /etc/service/recorder/log") except Exception, e: print "exception:" + str(e) diff --git a/python_apps/pypo/airtime-pypo-start b/python_apps/pypo/airtime-pypo-start index 9d5811638..68e323c6c 100755 --- a/python_apps/pypo/airtime-pypo-start +++ b/python_apps/pypo/airtime-pypo-start @@ -11,9 +11,11 @@ if os.geteuid() != 0: try: print "Starting daemontool script pypo" os.system("svc -u /etc/service/pypo") + os.system("svc -u /etc/service/pypo/log") print "Starting daemontool script pypo-liquidsoap" os.system("svc -u /etc/service/pypo-liquidsoap") - + os.system("svc -u /etc/service/pypo-liquidsoap/log") + except Exception, e: print "exception:" + str(e) diff --git a/python_apps/show-recorder/airtime-show-recorder-start b/python_apps/show-recorder/airtime-show-recorder-start index 084b2b1ad..2b50bb0f4 100755 --- a/python_apps/show-recorder/airtime-show-recorder-start +++ b/python_apps/show-recorder/airtime-show-recorder-start @@ -11,6 +11,7 @@ if os.geteuid() != 0: try: print "Starting daemontool script recorder" os.system("svc -u /etc/service/recorder") + os.system("svc -u /etc/service/recorder/log") except Exception, e: print "exception:" + str(e) From 45848e99f157acc418d6ece2cbb333a5967a41c9 Mon Sep 17 00:00:00 2001 From: "paul.baranowski" Date: Mon, 30 May 2011 09:23:48 -0400 Subject: [PATCH 02/15] CC-2337: Include RAM and CPU and whether the OS is 32 or 64 bit in airtime-check-system. Did exactly that. --- utils/airtime-check-system.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/utils/airtime-check-system.php b/utils/airtime-check-system.php index fbd705514..1f7823214 100644 --- a/utils/airtime-check-system.php +++ b/utils/airtime-check-system.php @@ -9,6 +9,8 @@ require_once "$airtime_base_dir/library/php-amqplib/amqp.inc"; set_error_handler("myErrorHandler"); +AirtimeCheck::GetCpuInfo(); +AirtimeCheck::GetRamInfo(); AirtimeCheck::CheckOsTypeVersion(); AirtimeCheck::CheckConfigFilesExist(); @@ -170,6 +172,32 @@ class AirtimeCheck { output_status("ICECAST_PROCESS_ID", $status); } + public static function GetCpuInfo() + { + $command = "cat /proc/cpuinfo |grep -m 1 'model name' "; + exec($command, $output, $result); + + $choppedStr = split(":", $output[0]); + $status = trim($choppedStr[1]); + output_status("CPU", $status); + } + + public static function GetRamInfo() + { + $command = "cat /proc/meminfo |grep 'MemTotal' "; + exec($command, $output, $result); + $choppedStr = split(":", $output[0]); + $status = trim($choppedStr[1]); + output_status("Total RAM", $status); + + $output = null; + $command = "cat /proc/meminfo |grep 'MemFree' "; + exec($command, $output, $result); + $choppedStr = split(":", $output[0]); + $status = trim($choppedStr[1]); + output_status("Free RAM", $status); + } + public static function CheckConfigFilesExist() { //echo PHP_EOL."Verifying Config Files in /etc/airtime".PHP_EOL; @@ -394,6 +422,12 @@ class AirtimeCheck { $os_string = "Unknown"; } + // Figure out if 32 or 64 bit + $command = "file -b /sbin/init"; + exec($command, $output, $result); + $splitStr = split(",", $output[0]); + $os_string .= $splitStr[1]; + output_status("OS", $os_string); } } From 2d6105353e595a27136c9485fac285daaa41861d Mon Sep 17 00:00:00 2001 From: martin Date: Mon, 30 May 2011 11:31:17 -0400 Subject: [PATCH 03/15] -removed unnecessary line from apache vhost file. --- install/apache/airtime-vhost | 1 - 1 file changed, 1 deletion(-) diff --git a/install/apache/airtime-vhost b/install/apache/airtime-vhost index 1af67e56b..4caf438db 100644 --- a/install/apache/airtime-vhost +++ b/install/apache/airtime-vhost @@ -1,6 +1,5 @@ ServerAdmin foo@bar.org - ServerName inferno.web.id DocumentRoot /var/www/airtime/public From f7de484461a86fa9987fb478d28ae83ddf9c6e13 Mon Sep 17 00:00:00 2001 From: Naomi Aro Date: Mon, 30 May 2011 12:24:39 -0400 Subject: [PATCH 04/15] CC-2336 Some Show Editing Features Seem to have been lost recovered everything that original worked I think will keep looking, still problems with editing a show which has already started. --- .../controllers/ScheduleController.php | 27 +++- .../forms/AddShowAbsoluteRebroadcastDates.php | 8 +- .../forms/AddShowRebroadcastDates.php | 8 +- airtime_mvc/application/forms/AddShowWhen.php | 14 ++- airtime_mvc/application/models/DateHelper.php | 35 ++++++ airtime_mvc/application/models/Shows.php | 115 ++++++++---------- 6 files changed, 125 insertions(+), 82 deletions(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 706d3082a..447640f10 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -446,10 +446,14 @@ class ScheduleController extends Zend_Controller_Action 'add_show_description' => $show->getDescription())); $formWhen->populate(array('add_show_start_date' => $show->getStartDate(), - 'add_show_start_time' => Show::removeSecondsFromTime($show->getStartTime()), + 'add_show_start_time' => DateHelper::removeSecondsFromTime($show->getStartTime()), 'add_show_duration' => $show->getDuration(), 'add_show_repeats' => $show->isRepeating() ? 1 : 0)); + if ($show->isStartDateTimeInPast()){ + $formWhen->getElement('add_show_start_date')->setOptions(array('disabled' => true)); + } + $days = array(); $showDays = CcShowDaysQuery::create()->filterByDbShowId($showInstance->getShowId())->find(); foreach($showDays as $showDay){ @@ -476,7 +480,7 @@ class ScheduleController extends Zend_Controller_Action $i = 1; foreach ($rebroadcastsRelative as $rebroadcast){ $rebroadcastFormValues["add_show_rebroadcast_date_$i"] = $rebroadcast['day_offset']; - $rebroadcastFormValues["add_show_rebroadcast_time_$i"] = Show::removeSecondsFromTime($rebroadcast['start_time']); + $rebroadcastFormValues["add_show_rebroadcast_time_$i"] = DateHelper::removeSecondsFromTime($rebroadcast['start_time']); $i++; } $formRebroadcast->populate($rebroadcastFormValues); @@ -486,7 +490,7 @@ class ScheduleController extends Zend_Controller_Action $i = 1; foreach ($rebroadcastsAbsolute as $rebroadcast){ $rebroadcastAbsoluteFormValues["add_show_rebroadcast_date_absolute_$i"] = $rebroadcast['start_date']; - $rebroadcastAbsoluteFormValues["add_show_rebroadcast_time_absolute_$i"] = Show::removeSecondsFromTime($rebroadcast['start_time']); + $rebroadcastAbsoluteFormValues["add_show_rebroadcast_time_absolute_$i"] = DateHelper::removeSecondsFromTime($rebroadcast['start_time']); $i++; } $formAbsoluteRebroadcast->populate($rebroadcastAbsoluteFormValues); @@ -548,6 +552,16 @@ class ScheduleController extends Zend_Controller_Action $data[$j["name"]] = $j["value"]; } + $show = new Show($data['add_show_id']); + + $startDateModified = true; + if ($data['add_show_id'] != -1 && !array_key_exists('add_show_start_date', $data)){ + //show is being updated and changing the start date was disabled, since the + //array key does not exist. We need to repopulate this entry from the db. + $data['add_show_start_date'] = $show->getStartDate(); + $startDateModified = false; + } + $data['add_show_hosts'] = $this->_getParam('hosts'); $data['add_show_day_check'] = $this->_getParam('days'); @@ -586,11 +600,10 @@ class ScheduleController extends Zend_Controller_Action $what = $formWhat->isValid($data); $when = $formWhen->isValid($data); if($when) { - $when = $formWhen->checkReliantFields($data); + $when = $formWhen->checkReliantFields($data, $startDateModified); } if($data["add_show_repeats"]) { - $repeats = $formRepeats->isValid($data); if($repeats) { $repeats = $formRepeats->checkReliantFields($data); @@ -636,7 +649,6 @@ class ScheduleController extends Zend_Controller_Action //update this option. $record = false; if ($data['add_show_id'] != -1){ - $show = new Show($data['add_show_id']); $data['add_show_record'] = $show->isRecorded(); $record = $formRecord->isValid($data); $formRecord->getElement('add_show_record')->setOptions(array('disabled' => true)); @@ -676,6 +688,9 @@ class ScheduleController extends Zend_Controller_Action if ($data['add_show_id'] != -1){ $this->view->addNewShow = false; } + if (!$startDateModified){ + $formWhen->getElement('add_show_start_date')->setOptions(array('disabled' => true)); + } $this->view->form = $this->view->render('schedule/add-show-form.phtml'); } diff --git a/airtime_mvc/application/forms/AddShowAbsoluteRebroadcastDates.php b/airtime_mvc/application/forms/AddShowAbsoluteRebroadcastDates.php index 062b959d2..68d4d80ad 100644 --- a/airtime_mvc/application/forms/AddShowAbsoluteRebroadcastDates.php +++ b/airtime_mvc/application/forms/AddShowAbsoluteRebroadcastDates.php @@ -48,8 +48,8 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm $this->getElement('add_show_rebroadcast_date_absolute_'.$i)->setErrors(array("Day must be specified")); $valid = false; } - - + + if (trim($time) == ""){ $this->getElement('add_show_rebroadcast_time_absolute_'.$i)->setErrors(array("Time must be specified")); $valid = false; @@ -60,7 +60,7 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm continue; } - $show_start_time = $formData['add_show_start_date']."".$formData['add_show_start_time']; + $show_start_time = $formData['add_show_start_date']." ".$formData['add_show_start_time']; $show_end = new DateTime($show_start_time); $duration = $formData['add_show_duration']; @@ -70,7 +70,7 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm $show_end->add(new DateInterval("PT$duration[1]M")); $show_end->add(new DateInterval("PT1H"));//min time to wait until a rebroadcast - $rebroad_start = $day."".$formData['add_show_rebroadcast_time_absolute_'.$i]; + $rebroad_start = $day." ".$formData['add_show_rebroadcast_time_absolute_'.$i]; $rebroad_start = new DateTime($rebroad_start); if($rebroad_start < $show_end) { diff --git a/airtime_mvc/application/forms/AddShowRebroadcastDates.php b/airtime_mvc/application/forms/AddShowRebroadcastDates.php index 015662463..6104d7836 100644 --- a/airtime_mvc/application/forms/AddShowRebroadcastDates.php +++ b/airtime_mvc/application/forms/AddShowRebroadcastDates.php @@ -53,8 +53,8 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm $this->getElement('add_show_rebroadcast_date_'.$i)->setErrors(array("Day must be specified")); $valid = false; } - - + + if (trim($time) == ""){ $this->getElement('add_show_rebroadcast_time_'.$i)->setErrors(array("Time must be specified")); $valid = false; @@ -68,7 +68,7 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm $days = explode(" ", $days); $day = $days[0]; - $show_start_time = $formData['add_show_start_date']."".$formData['add_show_start_time']; + $show_start_time = $formData['add_show_start_date']." ".$formData['add_show_start_time']; $show_end = new DateTime($show_start_time); $duration = $formData['add_show_duration']; @@ -78,7 +78,7 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm $show_end->add(new DateInterval("PT$duration[1]M")); $show_end->add(new DateInterval("PT1H"));//min time to wait until a rebroadcast - $rebroad_start = $formData['add_show_start_date']."".$formData['add_show_rebroadcast_time_'.$i]; + $rebroad_start = $formData['add_show_start_date']." ".$formData['add_show_rebroadcast_time_'.$i]; $rebroad_start = new DateTime($rebroad_start); $rebroad_start->add(new DateInterval("P".$day."D")); diff --git a/airtime_mvc/application/forms/AddShowWhen.php b/airtime_mvc/application/forms/AddShowWhen.php index 389b12989..847f26005 100644 --- a/airtime_mvc/application/forms/AddShowWhen.php +++ b/airtime_mvc/application/forms/AddShowWhen.php @@ -59,20 +59,22 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm } - public function checkReliantFields($formData) { + public function checkReliantFields($formData, $startDateModified) { $valid = true; $now_timestamp = date("Y-m-d H:i:s"); - $start_timestamp = $formData['add_show_start_date']."".$formData['add_show_start_time']; + $start_timestamp = $formData['add_show_start_date']." ".$formData['add_show_start_time']; $now_epoch = strtotime($now_timestamp); $start_epoch = strtotime($start_timestamp); - if($start_epoch < $now_epoch) { - $this->getElement('add_show_start_time')->setErrors(array('Cannot create show in the past')); - $valid = false; - } + if ((($formData['add_show_id'] != -1) && $startDateModified) || ($formData['add_show_id'] == -1)){ + if($start_epoch < $now_epoch) { + $this->getElement('add_show_start_time')->setErrors(array('Cannot create show in the past')); + $valid = false; + } + } if(strtotime("00:00") == strtotime($formData["add_show_duration"])) { $this->getElement('add_show_duration')->setErrors(array('Cannot have duration 00:00')); diff --git a/airtime_mvc/application/models/DateHelper.php b/airtime_mvc/application/models/DateHelper.php index 97b7d9ae9..4d82d3ddc 100644 --- a/airtime_mvc/application/models/DateHelper.php +++ b/airtime_mvc/application/models/DateHelper.php @@ -83,5 +83,40 @@ class DateHelper return $hours.":".$minutes.":".$seconds.".".$ms; } + + /** + * This function formats a time by removing seconds + * + * When we receive a time from the database we get the + * format "hh:mm:ss". But when dealing with show times, we + * do not care about the seconds. + * + * @param int $p_timestamp + * The value which to format. + * @return int + * The timestamp with the new format "hh:mm", or + * the original input parameter, if it does not have + * the correct format. + */ + public static function removeSecondsFromTime($p_timestamp) + { + //Format is in hh:mm:ss. We want hh:mm + $timeExplode = explode(":", $p_timestamp); + + if (count($timeExplode) == 3) + return $timeExplode[0].":".$timeExplode[1]; + else + return $p_timestamp; + } + + public static function getDateFromTimestamp($p_timestamp){ + $explode = explode(" ", $p_timestamp); + return $explode[0]; + } + + public static function getTimeFromTimestamp($p_timestamp){ + $explode = explode(" ", $p_timestamp); + return $explode[1]; + } } diff --git a/airtime_mvc/application/models/Shows.php b/airtime_mvc/application/models/Shows.php index 07a48f3f5..c932cf2fa 100644 --- a/airtime_mvc/application/models/Shows.php +++ b/airtime_mvc/application/models/Shows.php @@ -402,6 +402,19 @@ class Show { } } + /** + * Indicate whether the starting point of the show is in the + * past. + * + * @return boolean + * true if the StartDate is in the past, false otherwise + */ + public function isStartDateTimeInPast(){ + $date = new DateHelper; + $current_timestamp = $date->getTimestamp(); + return ($current_timestamp > $this->getStartDate()." ".$this->getStartTime()); + } + /** * Get the ID's of future instance of the current show. * @@ -533,8 +546,7 @@ class Show { public static function deletePossiblyInvalidInstances($p_data, $p_show, $p_endDate, $isRecorded, $repeatType) { - if ($p_data['add_show_repeats'] != $p_show->isRepeating() - || $isRecorded){ + if (($p_data['add_show_repeats'] != $p_show->isRepeating()) || $isRecorded){ //repeat option was toggled or show is recorded. $p_show->deleteAllInstances(); } @@ -561,7 +573,8 @@ class Show { if ($repeatType != $p_show->getRepeatType()){ //repeat type changed. $p_show->deleteAllInstances(); - } else { + } + else { //repeat type is the same, check if the days of the week are the same $repeatingDaysChanged = false; $showDaysArray = $p_show->getShowDays(); @@ -571,7 +584,8 @@ class Show { if (count($intersect) != count($p_data['add_show_day_check'])){ $repeatingDaysChanged = true; } - } else { + } + else { $repeatingDaysChanged = true; } @@ -589,7 +603,8 @@ class Show { if ((strlen($p_show->getRepeatingEndDate()) == 0) == $p_data['add_show_no_end']){ //show "Never Ends" option was toggled. if ($p_data['add_show_no_end']){ - } else { + } + else { $p_show->removeAllInstancesFromDate($p_endDate); } } @@ -608,7 +623,7 @@ class Show { /** * Create a show. * - * Note: end dates are inclusive. + * Note: end dates are non inclusive. * * @param array $data * @return int @@ -718,15 +733,16 @@ class Show { } //check if we are adding or updating a show, and if updating - //erase all the show's show_rebroadcast information first. - if ($data['add_show_id'] != -1){ - CcShowRebroadcastQuery::create()->filterByDbShowId($data['add_show_id'])->delete(); + //erase all the show's future show_rebroadcast information first. + if (($data['add_show_id'] != -1) && $data['add_show_rebroadcast']){ + CcShowRebroadcastQuery::create() + ->filterByDbShowId($data['add_show_id']) + ->filterByDbStartTime($currentTimestamp, Criteria::GREATER_EQUAL) + ->delete(); } //adding rows to cc_show_rebroadcast if ($isRecorded && $data['add_show_rebroadcast'] && $repeatType != -1) { - for ($i=1; $i<=10; $i++) { - if ($data['add_show_rebroadcast_date_'.$i]) { $showRebroad = new CcShowRebroadcast(); $showRebroad->setDbDayOffset($data['add_show_rebroadcast_date_'.$i]); @@ -735,10 +751,9 @@ class Show { $showRebroad->save(); } } - } else if ($isRecorded && $data['add_show_rebroadcast'] && $repeatType == -1){ - + } + else if ($isRecorded && $data['add_show_rebroadcast'] && $repeatType == -1){ for ($i=1; $i<=10; $i++) { - if ($data['add_show_rebroadcast_date_absolute_'.$i]) { $sql = "SELECT date '{$data['add_show_rebroadcast_date_absolute_'.$i]}' - date '{$data['add_show_start_date']}' "; $r = $con->query($sql); @@ -877,6 +892,9 @@ class Show { $showInstance->correctScheduleStartTimes(); } + $date = new DateHelper(); + $currentTimestamp = $date->getTimestamp(); + $sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}"; $rebroadcasts = $CC_DBC->GetAll($sql); @@ -890,14 +908,16 @@ class Show { $sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'"; $rebroadcast_end_time = $CC_DBC->GetOne($sql); - $newRebroadcastInstance = new CcShowInstances(); - $newRebroadcastInstance->setDbShowId($show_id); - $newRebroadcastInstance->setDbStarts($rebroadcast_start_time); - $newRebroadcastInstance->setDbEnds($rebroadcast_end_time); - $newRebroadcastInstance->setDbRecord(0); - $newRebroadcastInstance->setDbRebroadcast(1); - $newRebroadcastInstance->setDbOriginalShow($show_instance_id); - $newRebroadcastInstance->save(); + if ($rebroadcast_start_time > $currentTimestamp){ + $newRebroadcastInstance = new CcShowInstances(); + $newRebroadcastInstance->setDbShowId($show_id); + $newRebroadcastInstance->setDbStarts($rebroadcast_start_time); + $newRebroadcastInstance->setDbEnds($rebroadcast_end_time); + $newRebroadcastInstance->setDbRecord(0); + $newRebroadcastInstance->setDbRebroadcast(1); + $newRebroadcastInstance->setDbOriginalShow($show_instance_id); + $newRebroadcastInstance->save(); + } } } RabbitMq::PushSchedule(); @@ -927,6 +947,9 @@ class Show { $sql = "SELECT timestamp '{$start}' + interval '{$duration}'"; $end = $CC_DBC->GetOne($sql); + $date = new DateHelper(); + $currentTimestamp = $date->getTimestamp(); + if ($show->hasInstanceOnDate($start)){ $ccShowInstance = $show->getInstanceOnDate($start); $newInstance = false; @@ -934,11 +957,14 @@ class Show { $ccShowInstance = new CcShowInstances(); $newInstance = true; } - $ccShowInstance->setDbShowId($show_id); - $ccShowInstance->setDbStarts($start); - $ccShowInstance->setDbEnds($end); - $ccShowInstance->setDbRecord($record); - $ccShowInstance->save(); + + if ($start > $currentTimestamp){ + $ccShowInstance->setDbShowId($show_id); + $ccShowInstance->setDbStarts($start); + $ccShowInstance->setDbEnds($end); + $ccShowInstance->setDbRecord($record); + $ccShowInstance->save(); + } $show_instance_id = $ccShowInstance->getDbId(); $showInstance = new ShowInstance($show_instance_id); @@ -1132,41 +1158,6 @@ class Show { return $event; } - - public static function getDateFromTimestamp($p_timestamp){ - $explode = explode(" ", $p_timestamp); - return $explode[0]; - } - - public static function getTimeFromTimestamp($p_timestamp){ - $explode = explode(" ", $p_timestamp); - return $explode[1]; - } - - /** - * This function formats a time by removing seconds - * - * When we receive a time from the database we get the - * format "hh:mm:ss". But when dealing with show times, we - * do not care about the seconds. - * - * @param int $p_timestamp - * The value which to format. - * @return int - * The timestamp with the new format "hh:mm", or - * the original input parameter, if it does not have - * the correct format. - */ - public static function removeSecondsFromTime($p_timestamp) - { - //Format is in hh:mm:ss. We want hh:mm - $timeExplode = explode(":", $p_timestamp); - - if (count($timeExplode) == 3) - return $timeExplode[0].":".$timeExplode[1]; - else - return $p_timestamp; - } } class ShowInstance { From 1bca5208e79cd2b7b6b9605c04f640e35ba23e80 Mon Sep 17 00:00:00 2001 From: Naomi Aro Date: Mon, 30 May 2011 15:07:44 -0400 Subject: [PATCH 05/15] CC-2336 Some Show Editing Features Seem to have been lost --- airtime_mvc/application/models/Shows.php | 40 ++++++++++++++---------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/airtime_mvc/application/models/Shows.php b/airtime_mvc/application/models/Shows.php index c932cf2fa..88bc49948 100644 --- a/airtime_mvc/application/models/Shows.php +++ b/airtime_mvc/application/models/Shows.php @@ -700,7 +700,8 @@ class Show { $showDay->setDbShowId($showId); $showDay->setDbRecord($isRecorded); $showDay->save(); - } else { + } + else { foreach ($data['add_show_day_check'] as $day) { if ($startDow !== $day){ @@ -732,6 +733,9 @@ class Show { } } + $date = new DateHelper(); + $currentTimestamp = $date->getTimestamp(); + //check if we are adding or updating a show, and if updating //erase all the show's future show_rebroadcast information first. if (($data['add_show_id'] != -1) && $data['add_show_rebroadcast']){ @@ -741,7 +745,7 @@ class Show { ->delete(); } //adding rows to cc_show_rebroadcast - if ($isRecorded && $data['add_show_rebroadcast'] && $repeatType != -1) { + if (($isRecorded && $data['add_show_rebroadcast']) && $repeatType != -1) { for ($i=1; $i<=10; $i++) { if ($data['add_show_rebroadcast_date_'.$i]) { $showRebroad = new CcShowRebroadcast(); @@ -752,7 +756,7 @@ class Show { } } } - else if ($isRecorded && $data['add_show_rebroadcast'] && $repeatType == -1){ + else if ($isRecorded && $data['add_show_rebroadcast'] && ($repeatType == -1)){ for ($i=1; $i<=10; $i++) { if ($data['add_show_rebroadcast_date_absolute_'.$i]) { $sql = "SELECT date '{$data['add_show_rebroadcast_date_absolute_'.$i]}' - date '{$data['add_show_start_date']}' "; @@ -879,11 +883,13 @@ class Show { $newInstance = true; } - $ccShowInstance->setDbShowId($show_id); - $ccShowInstance->setDbStarts($start); - $ccShowInstance->setDbEnds($end); - $ccShowInstance->setDbRecord($record); - $ccShowInstance->save(); + if ($start > $currentTimestamp){ + $ccShowInstance->setDbShowId($show_id); + $ccShowInstance->setDbStarts($start); + $ccShowInstance->setDbEnds($end); + $ccShowInstance->setDbRecord($record); + $ccShowInstance->save(); + } $show_instance_id = $ccShowInstance->getDbId(); $showInstance = new ShowInstance($show_instance_id); @@ -983,14 +989,16 @@ class Show { $sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'"; $rebroadcast_end_time = $CC_DBC->GetOne($sql); - $newRebroadcastInstance = new CcShowInstances(); - $newRebroadcastInstance->setDbShowId($show_id); - $newRebroadcastInstance->setDbStarts($rebroadcast_start_time); - $newRebroadcastInstance->setDbEnds($rebroadcast_end_time); - $newRebroadcastInstance->setDbRecord(0); - $newRebroadcastInstance->setDbRebroadcast(1); - $newRebroadcastInstance->setDbOriginalShow($show_instance_id); - $newRebroadcastInstance->save(); + if ($rebroadcast_start_time > $currentTimestamp){ + $newRebroadcastInstance = new CcShowInstances(); + $newRebroadcastInstance->setDbShowId($show_id); + $newRebroadcastInstance->setDbStarts($rebroadcast_start_time); + $newRebroadcastInstance->setDbEnds($rebroadcast_end_time); + $newRebroadcastInstance->setDbRecord(0); + $newRebroadcastInstance->setDbRebroadcast(1); + $newRebroadcastInstance->setDbOriginalShow($show_instance_id); + $newRebroadcastInstance->save(); + } } $sql = "SELECT timestamp '{$start}' + interval '{$interval}'"; From f5e6082ee75883dcc829bf041844e9080c99cc30 Mon Sep 17 00:00:00 2001 From: Naomi Aro Date: Mon, 30 May 2011 18:12:57 -0400 Subject: [PATCH 06/15] CC-2336 Some Show Editing Features Seem to have been lost --- airtime_mvc/application/models/DateHelper.php | 9 ++++++ airtime_mvc/application/models/Shows.php | 32 +++++++++++++------ 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/airtime_mvc/application/models/DateHelper.php b/airtime_mvc/application/models/DateHelper.php index 4d82d3ddc..d8f44a3c5 100644 --- a/airtime_mvc/application/models/DateHelper.php +++ b/airtime_mvc/application/models/DateHelper.php @@ -18,6 +18,15 @@ class DateHelper return date("Y-m-d H:i:s", $this->_timestamp); } + /** + * Get date of object construction in the format + * YY:mm:dd + */ + function getDate() + { + return date("Y-m-d", $this->_timestamp); + } + /** * Get time of object construction in the format * HH:mm:ss diff --git a/airtime_mvc/application/models/Shows.php b/airtime_mvc/application/models/Shows.php index 88bc49948..672e72105 100644 --- a/airtime_mvc/application/models/Shows.php +++ b/airtime_mvc/application/models/Shows.php @@ -318,14 +318,19 @@ class Show { * certain date. * * @param string $p_date - * The date which to delete after + * The date which to delete after, if null deletes from the current timestamp. */ - public function removeAllInstancesFromDate($p_date){ + public function removeAllInstancesFromDate($p_date=null){ global $CC_DBC; $date = new DateHelper; $timestamp = $date->getTimestamp(); + if(is_null($p_date)) { + $date = new DateHelper; + $p_date = $date->getDate(); + } + $showId = $this->getId(); $sql = "DELETE FROM cc_show_instances " ." WHERE date(starts) >= DATE '$p_date'" @@ -333,6 +338,13 @@ class Show { ." AND show_id = $showId"; $CC_DBC->query($sql); + + /* + CcShowInstancesQuery::create() + ->filterByDbShowId($showId) + ->filterByDbStartTime($p_date, Criteria::GREATER_EQUAL) + ->delete(); + */ } /** @@ -546,10 +558,13 @@ class Show { public static function deletePossiblyInvalidInstances($p_data, $p_show, $p_endDate, $isRecorded, $repeatType) { - if (($p_data['add_show_repeats'] != $p_show->isRepeating()) || $isRecorded){ - //repeat option was toggled or show is recorded. + if (($p_data['add_show_repeats'] != $p_show->isRepeating()) || ($isRecorded && !$p_data['add_show_repeats'])){ + //repeat option was toggled. $p_show->deleteAllInstances(); } + if($isRecorded && $p_data['add_show_repeats']) { + $p_show->removeAllInstancesFromDate(); + } if ($p_data['add_show_duration'] != $p_show->getDuration()){ //duration has changed @@ -741,11 +756,11 @@ class Show { if (($data['add_show_id'] != -1) && $data['add_show_rebroadcast']){ CcShowRebroadcastQuery::create() ->filterByDbShowId($data['add_show_id']) - ->filterByDbStartTime($currentTimestamp, Criteria::GREATER_EQUAL) + //->filterByDbStartTime($currentTimestamp, Criteria::GREATER_EQUAL) ->delete(); } //adding rows to cc_show_rebroadcast - if (($isRecorded && $data['add_show_rebroadcast']) && $repeatType != -1) { + if (($isRecorded && $data['add_show_rebroadcast']) && ($repeatType != -1)) { for ($i=1; $i<=10; $i++) { if ($data['add_show_rebroadcast_date_'.$i]) { $showRebroad = new CcShowRebroadcast(); @@ -864,13 +879,11 @@ class Show { private static function populateNonRepeatingShow($show_id, $first_show, $start_time, $duration, $day, $record, $end_timestamp) { global $CC_DBC; - $next_date = $first_show." ".$start_time; if (strtotime($next_date) < strtotime($end_timestamp)) { $start = $next_date; - $sql = "SELECT timestamp '{$start}' + interval '{$duration}'"; $end = $CC_DBC->GetOne($sql); @@ -878,7 +891,8 @@ class Show { if ($show->hasInstance()){ $ccShowInstance = $show->getInstance(); $newInstance = false; - } else { + } + else { $ccShowInstance = new CcShowInstances(); $newInstance = true; } From cc6c7475f5e7bd668295f2ce4e08f49bd91b574a Mon Sep 17 00:00:00 2001 From: martin Date: Tue, 31 May 2011 16:42:19 -0400 Subject: [PATCH 07/15] -updated change log for 1.8.2-RC2 release --- Changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog b/Changelog index b979e0399..d0d585597 100644 --- a/Changelog +++ b/Changelog @@ -17,6 +17,8 @@ Highlights: - When canceling a playing show, the currently playing audio file still showed as playing. This has been fixed. - Audio files greater than 100MB were not being played. - Fixed uploading audio on Chrome 11 and higher + - Fixed various editing show problems + - Fixed airtime-pypo-stop/start causing playback problems 1.8.1 - May 2, 2011 From 95f73cd16c37b2804db5158e57f1057ab29aeb78 Mon Sep 17 00:00:00 2001 From: martin Date: Tue, 31 May 2011 16:48:42 -0400 Subject: [PATCH 08/15] -fix version string --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index b185f70e7..1ec57110d 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ PRODUCT_ID=Airtime -PRODUCT_RELEASE=1.9.0-devel +PRODUCT_RELEASE=1.8.2 From 413c752b22531a7e3f621ad1f24f0f14eb19bf6e Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 2 Jun 2011 12:58:33 -0400 Subject: [PATCH 09/15] -update changelog for 1.8.2-RC3 release --- Changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog b/Changelog index d0d585597..0ff1c3f4b 100644 --- a/Changelog +++ b/Changelog @@ -19,6 +19,7 @@ Highlights: - Fixed uploading audio on Chrome 11 and higher - Fixed various editing show problems - Fixed airtime-pypo-stop/start causing playback problems + - Fixed incorrect information being occasionally shown in the top panel 1.8.1 - May 2, 2011 From 308efaeadcb83b58fdce3d2944bbb0387f4b9b14 Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 2 Jun 2011 15:56:54 -0400 Subject: [PATCH 10/15] CC-2336: Some Show Editing Features Seem to have been lost -fixed shows in the past being edited! --- airtime_mvc/application/models/Shows.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/airtime_mvc/application/models/Shows.php b/airtime_mvc/application/models/Shows.php index 672e72105..ca1f0847e 100644 --- a/airtime_mvc/application/models/Shows.php +++ b/airtime_mvc/application/models/Shows.php @@ -887,6 +887,9 @@ class Show { $sql = "SELECT timestamp '{$start}' + interval '{$duration}'"; $end = $CC_DBC->GetOne($sql); + $date = new DateHelper(); + $currentTimestamp = $date->getTimestamp(); + $show = new Show($show_id); if ($show->hasInstance()){ $ccShowInstance = $show->getInstance(); @@ -896,8 +899,8 @@ class Show { $ccShowInstance = new CcShowInstances(); $newInstance = true; } - - if ($start > $currentTimestamp){ + + if ($newInstance || $ccShowInstance->getDbStarts() > $currentTimestamp){ $ccShowInstance->setDbShowId($show_id); $ccShowInstance->setDbStarts($start); $ccShowInstance->setDbEnds($end); @@ -912,9 +915,6 @@ class Show { $showInstance->correctScheduleStartTimes(); } - $date = new DateHelper(); - $currentTimestamp = $date->getTimestamp(); - $sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}"; $rebroadcasts = $CC_DBC->GetAll($sql); @@ -960,6 +960,9 @@ class Show { $rebroadcasts = $CC_DBC->GetAll($sql); $show = new Show($show_id); + $date = new DateHelper(); + $currentTimestamp = $date->getTimestamp(); + while(strtotime($next_date) <= strtotime($end_timestamp) && (strtotime($last_show) > strtotime($next_date) || is_null($last_show))) { $start = $next_date; @@ -967,9 +970,6 @@ class Show { $sql = "SELECT timestamp '{$start}' + interval '{$duration}'"; $end = $CC_DBC->GetOne($sql); - $date = new DateHelper(); - $currentTimestamp = $date->getTimestamp(); - if ($show->hasInstanceOnDate($start)){ $ccShowInstance = $show->getInstanceOnDate($start); $newInstance = false; @@ -977,8 +977,11 @@ class Show { $ccShowInstance = new CcShowInstances(); $newInstance = true; } - - if ($start > $currentTimestamp){ + + /* When editing the start/end time of a repeating show, we don't want to + * change shows that started in the past. So check the start time. + */ + if ($newInstance || $ccShowInstance->getDbStarts() > $currentTimestamp){ $ccShowInstance->setDbShowId($show_id); $ccShowInstance->setDbStarts($start); $ccShowInstance->setDbEnds($end); From e969baee1c295d866f83f91933c29a8df9eb210f Mon Sep 17 00:00:00 2001 From: martin Date: Fri, 3 Jun 2011 14:01:58 -0400 Subject: [PATCH 11/15] cc-2359: record check box is disabled after update show -fixed --- .../controllers/ScheduleController.php | 101 +++--------------- airtime_mvc/application/models/Schedule.php | 32 ++++++ 2 files changed, 49 insertions(+), 84 deletions(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 447640f10..3ef84548e 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -53,34 +53,8 @@ class ScheduleController extends Zend_Controller_Action $this->view->headLink()->appendStylesheet($baseUrl.'/css/colorpicker/css/colorpicker.css'); $this->view->headLink()->appendStylesheet($baseUrl.'/css/add-show.css'); $this->view->headLink()->appendStylesheet($baseUrl.'/css/contextmenu.css'); - - $formWhat = new Application_Form_AddShowWhat(); - $formWho = new Application_Form_AddShowWho(); - $formWhen = new Application_Form_AddShowWhen(); - $formRepeats = new Application_Form_AddShowRepeats(); - $formStyle = new Application_Form_AddShowStyle(); - $formRecord = new Application_Form_AddShowRR(); - $formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates(); - $formRebroadcast = new Application_Form_AddShowRebroadcastDates(); - - $formWhat->removeDecorator('DtDdWrapper'); - $formWho->removeDecorator('DtDdWrapper'); - $formWhen->removeDecorator('DtDdWrapper'); - $formRepeats->removeDecorator('DtDdWrapper'); - $formStyle->removeDecorator('DtDdWrapper'); - $formRecord->removeDecorator('DtDdWrapper'); - - $this->view->what = $formWhat; - $this->view->when = $formWhen; - $this->view->repeats = $formRepeats; - $this->view->who = $formWho; - $this->view->style = $formStyle; - $this->view->rr = $formRecord; - $this->view->absoluteRebroadcast = $formAbsoluteRebroadcast; - $this->view->rebroadcast = $formRebroadcast; - $this->view->addNewShow = true; - - $formWhat->populate(array('add_show_id' => '-1')); + + Schedule::createNewFormSections($this->view); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new User($userInfo->id); @@ -510,35 +484,8 @@ class ScheduleController extends Zend_Controller_Action $this->view->entries = 5; } - public function getFormAction(){ - $formWhat = new Application_Form_AddShowWhat(); - $formWho = new Application_Form_AddShowWho(); - $formWhen = new Application_Form_AddShowWhen(); - $formRepeats = new Application_Form_AddShowRepeats(); - $formStyle = new Application_Form_AddShowStyle(); - $formRecord = new Application_Form_AddShowRR(); - $formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates(); - $formRebroadcast = new Application_Form_AddShowRebroadcastDates(); - - $formWhat->removeDecorator('DtDdWrapper'); - $formWho->removeDecorator('DtDdWrapper'); - $formWhen->removeDecorator('DtDdWrapper'); - $formRepeats->removeDecorator('DtDdWrapper'); - $formStyle->removeDecorator('DtDdWrapper'); - $formRecord->removeDecorator('DtDdWrapper'); - - $this->view->what = $formWhat; - $this->view->when = $formWhen; - $this->view->repeats = $formRepeats; - $this->view->who = $formWho; - $this->view->style = $formStyle; - $this->view->rr = $formRecord; - $this->view->absoluteRebroadcast = $formAbsoluteRebroadcast; - $this->view->rebroadcast = $formRebroadcast; - $this->view->addNewShow = true; - - $formWhat->populate(array('add_show_id' => '-1')); - + public function getFormAction(){ + Schedule::createNewFormSections($this->view); $this->view->form = $this->view->render('schedule/add-show-form.phtml'); } @@ -587,16 +534,6 @@ class ScheduleController extends Zend_Controller_Action $formAbsoluteRebroadcast->removeDecorator('DtDdWrapper'); $formRebroadcast->removeDecorator('DtDdWrapper'); - $this->view->what = $formWhat; - $this->view->when = $formWhen; - $this->view->repeats = $formRepeats; - $this->view->who = $formWho; - $this->view->style = $formStyle; - $this->view->rr = $formRecord; - $this->view->absoluteRebroadcast = $formAbsoluteRebroadcast; - $this->view->rebroadcast = $formRebroadcast; - $this->view->addNewShow = true; - $what = $formWhat->isValid($data); $when = $formWhen->isValid($data); if($when) { @@ -662,27 +599,23 @@ class ScheduleController extends Zend_Controller_Action if ($user->isAdmin()) { Show::create($data); } - + //send back a new form for the user. - $formWhat->reset(); - $formWhat->populate(array('add_show_id' => '-1')); - - $formWho->reset(); - $formWhen->reset(); - $formWhen->populate(array('add_show_start_date' => date("Y-m-d"), - 'add_show_start_time' => '0:00', - 'add_show_duration' => '1:00')); - $formRepeats->reset(); - $formRepeats->populate(array('add_show_end_date' => date("Y-m-d"))); - - $formStyle->reset(); - $formRecord->reset(); - $formAbsoluteRebroadcast->reset(); - $formRebroadcast->reset(); + Schedule::createNewFormSections($this->view); $this->view->newForm = $this->view->render('schedule/add-show-form.phtml'); } - else { + else { + $this->view->what = $formWhat; + $this->view->when = $formWhen; + $this->view->repeats = $formRepeats; + $this->view->who = $formWho; + $this->view->style = $formStyle; + $this->view->rr = $formRecord; + $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){ diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index d6a647d8e..812845062 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -725,5 +725,37 @@ class Schedule { global $CC_CONFIG, $CC_DBC; $CC_DBC->query("TRUNCATE TABLE ".$CC_CONFIG["scheduleTable"]); } + + public static function createNewFormSections($p_view){ + $formWhat = new Application_Form_AddShowWhat(); + $formWho = new Application_Form_AddShowWho(); + $formWhen = new Application_Form_AddShowWhen(); + $formRepeats = new Application_Form_AddShowRepeats(); + $formStyle = new Application_Form_AddShowStyle(); + $formRecord = new Application_Form_AddShowRR(); + $formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates(); + $formRebroadcast = new Application_Form_AddShowRebroadcastDates(); + + $formWhat->removeDecorator('DtDdWrapper'); + $formWho->removeDecorator('DtDdWrapper'); + $formWhen->removeDecorator('DtDdWrapper'); + $formRepeats->removeDecorator('DtDdWrapper'); + $formStyle->removeDecorator('DtDdWrapper'); + $formRecord->removeDecorator('DtDdWrapper'); + $formAbsoluteRebroadcast->removeDecorator('DtDdWrapper'); + $formRebroadcast->removeDecorator('DtDdWrapper'); + + $p_view->what = $formWhat; + $p_view->when = $formWhen; + $p_view->repeats = $formRepeats; + $p_view->who = $formWho; + $p_view->style = $formStyle; + $p_view->rr = $formRecord; + $p_view->absoluteRebroadcast = $formAbsoluteRebroadcast; + $p_view->rebroadcast = $formRebroadcast; + $p_view->addNewShow = true; + + $formWhat->populate(array('add_show_id' => '-1')); + } } From 19e52e81b547f2ec1c2423cd53ab52c688ec0cf3 Mon Sep 17 00:00:00 2001 From: martin Date: Fri, 3 Jun 2011 14:51:17 -0400 Subject: [PATCH 12/15] cc-2351: updating a bi-weekly repeating show is incorrect -fixed --- airtime_mvc/application/models/Shows.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/airtime_mvc/application/models/Shows.php b/airtime_mvc/application/models/Shows.php index ca1f0847e..2340a6a1d 100644 --- a/airtime_mvc/application/models/Shows.php +++ b/airtime_mvc/application/models/Shows.php @@ -572,6 +572,16 @@ class Show { } if ($p_data['add_show_repeats']){ + if (($repeatType == 1 || $repeatType == 2) && + $p_data['add_show_start_date'] != $p_show->getStartDate()){ + + //start date has changed when repeat type is bi-weekly or monthly. + //This screws up the repeating positions of show instances, so lets + //just delete them for now. + + $p_show->deleteAllInstances(); + } + if ($p_data['add_show_start_date'] != $p_show->getStartDate() || $p_data['add_show_start_time'] != $p_show->getStartTime()){ //start date/time has changed @@ -584,12 +594,11 @@ class Show { $p_show->updateStartDateTime($p_data, $p_endDate); } - + if ($repeatType != $p_show->getRepeatType()){ //repeat type changed. $p_show->deleteAllInstances(); - } - else { + } else { //repeat type is the same, check if the days of the week are the same $repeatingDaysChanged = false; $showDaysArray = $p_show->getShowDays(); From c9c9ecf2cd96c278825427d1115a524281dd7873 Mon Sep 17 00:00:00 2001 From: martin Date: Fri, 3 Jun 2011 16:36:13 -0400 Subject: [PATCH 13/15] cc-2344: wrong song displayed -fixed --- airtime_mvc/application/models/Dashboard.php | 18 +++++++++++------- airtime_mvc/application/models/Schedule.php | 17 ++++++++++++++--- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/airtime_mvc/application/models/Dashboard.php b/airtime_mvc/application/models/Dashboard.php index f7d5113b2..d599b5c2b 100644 --- a/airtime_mvc/application/models/Dashboard.php +++ b/airtime_mvc/application/models/Dashboard.php @@ -10,14 +10,16 @@ class Application_Model_Dashboard //name. Else return the last item from the schedule. $showInstance = ShowInstance::GetLastShowInstance($p_timeNow); - $row = Schedule::GetLastScheduleItem($p_timeNow); + $instanceId = $showInstance->getShowId(); + $row = Schedule::GetLastScheduleItem($p_timeNow, $instanceId); if (is_null($showInstance)){ if (count($row) == 0){ return null; } else { - //should never reach here. Doesnt make sense to have - //a schedule item not within a show_instance. + return array("name"=>$row[0]["artist_name"]." - ".$row[0]["track_title"], + "starts"=>$row[0]["starts"], + "ends"=>$row[0]["ends"]); } } else { if (count($row) == 0){ @@ -47,7 +49,8 @@ class Application_Model_Dashboard //name. Else return the last item from the schedule. $showInstance = ShowInstance::GetCurrentShowInstance($p_timeNow); - $row = Schedule::GetCurrentScheduleItem($p_timeNow); + $instanceId = $showInstance->getShowId(); + $row = Schedule::GetCurrentScheduleItem($p_timeNow, $instanceId); if (is_null($showInstance)){ if (count($row) == 0){ @@ -62,8 +65,8 @@ class Application_Model_Dashboard return array("name"=>$showInstance->getName(), "starts"=>$showInstance->getShowStart(), "ends"=>$showInstance->getShowEnd(), - "media_item_played"=>false, //TODO - "record"=>$showInstance->isRecorded()); //TODO + "media_item_played"=>false, + "record"=>$showInstance->isRecorded()); } else { return array("name"=>$row[0]["artist_name"]." - ".$row[0]["track_title"], "starts"=>$row[0]["starts"], @@ -81,7 +84,8 @@ class Application_Model_Dashboard //name. Else return the last item from the schedule. $showInstance = ShowInstance::GetNextShowInstance($p_timeNow); - $row = Schedule::GetNextScheduleItem($p_timeNow); + $instanceId = $showInstance->getShowId(); + $row = Schedule::GetNextScheduleItem($p_timeNow, $instanceId); if (is_null($showInstance)){ if (count($row) == 0){ diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 812845062..71a6d9674 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -378,7 +378,7 @@ class Schedule { "apiKey"=>$CC_CONFIG['apiKey'][0]); } - public static function GetLastScheduleItem($p_timeNow){ + public static function GetLastScheduleItem($p_timeNow, $p_instanceId){ global $CC_CONFIG, $CC_DBC; $sql = "SELECT *" @@ -386,6 +386,7 @@ class Schedule { ." LEFT JOIN $CC_CONFIG[filesTable] ft" ." ON st.file_id = ft.id" ." WHERE st.ends < TIMESTAMP '$p_timeNow'" + ." AND st.instance_id = $p_instanceId" ." ORDER BY st.ends DESC" ." LIMIT 1"; @@ -394,22 +395,31 @@ class Schedule { } - public static function GetCurrentScheduleItem($p_timeNow){ + public static function GetCurrentScheduleItem($p_timeNow, $p_instanceId){ global $CC_CONFIG, $CC_DBC; + /* Note that usually there will be one result returned. In some + * rare cases two songs are returned. This happens when a track + * that was overbooked from a previous show appears as if it + * hasnt ended yet (track end time hasn't been reached yet). For + * this reason, we need to get the track that starts later, as + * this is the *real* track that is currently playing. So this + * is why we are ordering by track start time. */ $sql = "SELECT *" ." FROM $CC_CONFIG[scheduleTable] st" ." LEFT JOIN $CC_CONFIG[filesTable] ft" ." ON st.file_id = ft.id" ." WHERE st.starts <= TIMESTAMP '$p_timeNow'" + ." AND st.instance_id = $p_instanceId" ." AND st.ends > TIMESTAMP '$p_timeNow'" + ." ORDER BY st.starts DESC" ." LIMIT 1"; $row = $CC_DBC->GetAll($sql); return $row; } - public static function GetNextScheduleItem($p_timeNow){ + public static function GetNextScheduleItem($p_timeNow, $p_instanceId){ global $CC_CONFIG, $CC_DBC; $sql = "SELECT *" @@ -417,6 +427,7 @@ class Schedule { ." LEFT JOIN $CC_CONFIG[filesTable] ft" ." ON st.file_id = ft.id" ." WHERE st.starts > TIMESTAMP '$p_timeNow'" + ." AND st.instance_id = $p_instanceId" ." ORDER BY st.starts" ." LIMIT 1"; From e69f9497edadf072c04b0a44008616308c296c1a Mon Sep 17 00:00:00 2001 From: martin Date: Fri, 3 Jun 2011 17:03:11 -0400 Subject: [PATCH 14/15] cc-2344: wrong song displayed -fixed #2 --- airtime_mvc/application/models/Dashboard.php | 14 +++++++------- airtime_mvc/application/models/Schedule.php | 6 ++---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/airtime_mvc/application/models/Dashboard.php b/airtime_mvc/application/models/Dashboard.php index d599b5c2b..18c239b92 100644 --- a/airtime_mvc/application/models/Dashboard.php +++ b/airtime_mvc/application/models/Dashboard.php @@ -10,8 +10,7 @@ class Application_Model_Dashboard //name. Else return the last item from the schedule. $showInstance = ShowInstance::GetLastShowInstance($p_timeNow); - $instanceId = $showInstance->getShowId(); - $row = Schedule::GetLastScheduleItem($p_timeNow, $instanceId); + $row = Schedule::GetLastScheduleItem($p_timeNow); if (is_null($showInstance)){ if (count($row) == 0){ @@ -48,10 +47,12 @@ class Application_Model_Dashboard //after the last item in the schedule table, then return the show's //name. Else return the last item from the schedule. + $row = array(); $showInstance = ShowInstance::GetCurrentShowInstance($p_timeNow); - $instanceId = $showInstance->getShowId(); - $row = Schedule::GetCurrentScheduleItem($p_timeNow, $instanceId); - + if (!is_null($showInstance)){ + $instanceId = $showInstance->getShowInstanceId(); + $row = Schedule::GetCurrentScheduleItem($p_timeNow, $instanceId); + } if (is_null($showInstance)){ if (count($row) == 0){ return null; @@ -84,8 +85,7 @@ class Application_Model_Dashboard //name. Else return the last item from the schedule. $showInstance = ShowInstance::GetNextShowInstance($p_timeNow); - $instanceId = $showInstance->getShowId(); - $row = Schedule::GetNextScheduleItem($p_timeNow, $instanceId); + $row = Schedule::GetNextScheduleItem($p_timeNow); if (is_null($showInstance)){ if (count($row) == 0){ diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 71a6d9674..67c4d352e 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -378,7 +378,7 @@ class Schedule { "apiKey"=>$CC_CONFIG['apiKey'][0]); } - public static function GetLastScheduleItem($p_timeNow, $p_instanceId){ + public static function GetLastScheduleItem($p_timeNow){ global $CC_CONFIG, $CC_DBC; $sql = "SELECT *" @@ -386,7 +386,6 @@ class Schedule { ." LEFT JOIN $CC_CONFIG[filesTable] ft" ." ON st.file_id = ft.id" ." WHERE st.ends < TIMESTAMP '$p_timeNow'" - ." AND st.instance_id = $p_instanceId" ." ORDER BY st.ends DESC" ." LIMIT 1"; @@ -419,7 +418,7 @@ class Schedule { return $row; } - public static function GetNextScheduleItem($p_timeNow, $p_instanceId){ + public static function GetNextScheduleItem($p_timeNow){ global $CC_CONFIG, $CC_DBC; $sql = "SELECT *" @@ -427,7 +426,6 @@ class Schedule { ." LEFT JOIN $CC_CONFIG[filesTable] ft" ." ON st.file_id = ft.id" ." WHERE st.starts > TIMESTAMP '$p_timeNow'" - ." AND st.instance_id = $p_instanceId" ." ORDER BY st.starts" ." LIMIT 1"; From eee885f7463f689d05c4fe5ba879fedf9b6e63cc Mon Sep 17 00:00:00 2001 From: martin Date: Fri, 3 Jun 2011 17:06:47 -0400 Subject: [PATCH 15/15] cc-2344: wrong song displayed -removed unnecessary code. --- airtime_mvc/application/models/Schedule.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 67c4d352e..4bc2fbbd2 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -397,13 +397,6 @@ class Schedule { public static function GetCurrentScheduleItem($p_timeNow, $p_instanceId){ global $CC_CONFIG, $CC_DBC; - /* Note that usually there will be one result returned. In some - * rare cases two songs are returned. This happens when a track - * that was overbooked from a previous show appears as if it - * hasnt ended yet (track end time hasn't been reached yet). For - * this reason, we need to get the track that starts later, as - * this is the *real* track that is currently playing. So this - * is why we are ordering by track start time. */ $sql = "SELECT *" ." FROM $CC_CONFIG[scheduleTable] st" ." LEFT JOIN $CC_CONFIG[filesTable] ft" @@ -411,7 +404,6 @@ class Schedule { ." WHERE st.starts <= TIMESTAMP '$p_timeNow'" ." AND st.instance_id = $p_instanceId" ." AND st.ends > TIMESTAMP '$p_timeNow'" - ." ORDER BY st.starts DESC" ." LIMIT 1"; $row = $CC_DBC->GetAll($sql);