diff --git a/CREDITS b/CREDITS index 518f7366c..d09b5198c 100644 --- a/CREDITS +++ b/CREDITS @@ -5,6 +5,9 @@ CREDITS Version 2.5.0 ------------- +Albert Santoni (albert.santoni@sourcefabric.org) + Rold: Developer Team Lead + Denise Rigato (denise.rigato@sourcefabric.org) Role: Software Developer diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 79ed4eeba..9bf324151 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -62,7 +62,8 @@ class ScheduleController extends Zend_Controller_Action //full-calendar-functions.js requires this variable, so that datePicker widget can be offset to server time instead of client time $this->view->headScript()->appendScript("var timezoneOffset = ".date("Z")."; //in seconds"); - $this->view->headScript()->appendFile($baseUrl.'js/airtime/schedule/full-calendar-functions.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + //set offset to ensure it loads last + $this->view->headScript()->offsetSetFile(100, $baseUrl.'js/airtime/schedule/full-calendar-functions.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/fullcalendar/fullcalendar.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/timepicker/jquery.ui.timepicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); diff --git a/airtime_mvc/application/forms/AddShowWhen.php b/airtime_mvc/application/forms/AddShowWhen.php index 62b8004c5..518b07405 100644 --- a/airtime_mvc/application/forms/AddShowWhen.php +++ b/airtime_mvc/application/forms/AddShowWhen.php @@ -168,9 +168,9 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm if ($valid) { $utc = new DateTimeZone('UTC'); $showTimezone = new DateTimeZone($formData["add_show_timezone"]); - $show_start = new DateTime($start_time); + $show_start = new DateTime($start_time, $showTimezone); $show_start->setTimezone($utc); - $show_end = new DateTime($end_time); + $show_end = new DateTime($end_time, $showTimezone); $show_end->setTimezone($utc); if ($formData["add_show_repeats"]) { @@ -188,7 +188,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm } elseif (!$formData["add_show_no_end"]) { $popUntil = $formData["add_show_end_date"]." ".$formData["add_show_end_time"]; - $populateUntilDateTime = new DateTime($popUntil); + $populateUntilDateTime = new DateTime($popUntil, $showTimezone); $populateUntilDateTime->setTimezone($utc); } @@ -216,7 +216,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm * Do this for each show day */ if (!$overlapping) { - $startDow = date("w", $show_start->getTimestamp()); + $startDow = $show_start->format("w"); if (!isset($formData['add_show_day_check'])) { return false; diff --git a/airtime_mvc/application/forms/EditUser.php b/airtime_mvc/application/forms/EditUser.php index 2711bb334..8b8565fce 100644 --- a/airtime_mvc/application/forms/EditUser.php +++ b/airtime_mvc/application/forms/EditUser.php @@ -118,7 +118,7 @@ class Application_Form_EditUser extends Zend_Form $this->addElement($locale); $timezone = new Zend_Form_Element_Select("cu_timezone"); - $timezone->setLabel(_("Timezone:")); + $timezone->setLabel(_("Interface Timezone:")); $timezone->setMultiOptions(Application_Common_Timezone::getTimezones()); $timezone->setValue(Application_Model_Preference::GetUserTimezone($currentUserId)); $timezone->setDecorators(array('ViewHelper')); diff --git a/airtime_mvc/application/forms/GeneralPreferences.php b/airtime_mvc/application/forms/GeneralPreferences.php index 19e3fc064..34b60e704 100644 --- a/airtime_mvc/application/forms/GeneralPreferences.php +++ b/airtime_mvc/application/forms/GeneralPreferences.php @@ -102,7 +102,7 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm /* Form Element for setting the Timezone */ $timezone = new Zend_Form_Element_Select("timezone"); - $timezone->setLabel(_("Default Interface Timezone")); + $timezone->setLabel(_("Station Timezone")); $timezone->setMultiOptions(Application_Common_Timezone::getTimezones()); $timezone->setValue(Application_Model_Preference::GetDefaultTimezone()); $timezone->setDecorators(array('ViewHelper')); diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php index 661df065b..7a0cca0a4 100644 --- a/airtime_mvc/application/models/Scheduler.php +++ b/airtime_mvc/application/models/Scheduler.php @@ -454,8 +454,8 @@ class Application_Model_Scheduler $itemEndDT = $this->findEndTime($itemStartDT, $item["clip_length"]); $update_sql = "UPDATE cc_schedule SET ". - "starts = '{$itemStartDT->format("Y-m-d H:i:s")}', ". - "ends = '{$itemEndDT->format("Y-m-d H:i:s")}' ". + "starts = '{$itemStartDT->format("Y-m-d H:i:s.u")}', ". + "ends = '{$itemEndDT->format("Y-m-d H:i:s.u")}' ". "WHERE id = {$item["id"]}"; Application_Common_Database::prepareAndExecute( $update_sql, array(), Application_Common_Database::EXECUTE); @@ -744,8 +744,8 @@ class Application_Model_Scheduler $endTimeDT = $this->findEndTime($nextStartDT, $file['cliplength']); if ($doInsert) { $values[] = "(". - "'{$nextStartDT->format("Y-m-d H:i:s")}', ". - "'{$endTimeDT->format("Y-m-d H:i:s")}', ". + "'{$nextStartDT->format("Y-m-d H:i:s.u")}', ". + "'{$endTimeDT->format("Y-m-d H:i:s.u")}', ". "'{$file["cuein"]}', ". "'{$file["cueout"]}', ". "'{$file["fadein"]}', ". @@ -758,8 +758,8 @@ class Application_Model_Scheduler } elseif ($doUpdate) { $update_sql = "UPDATE cc_schedule SET ". - "starts = '{$nextStartDT->format("Y-m-d H:i:s")}', ". - "ends = '{$endTimeDT->format("Y-m-d H:i:s")}', ". + "starts = '{$nextStartDT->format("Y-m-d H:i:s.u")}', ". + "ends = '{$endTimeDT->format("Y-m-d H:i:s.u")}', ". "cue_in = '{$file["cuein"]}', ". "cue_out = '{$file["cueout"]}', ". "fade_in = '{$file["fadein"]}', ". @@ -827,8 +827,8 @@ class Application_Model_Scheduler $endTimeDT = $this->findEndTime($nextStartDT, $item["clip_length"]); $endTimeDT = $this->findTimeDifference($endTimeDT, $this->crossfadeDuration); $update_sql = "UPDATE cc_schedule SET ". - "starts = '{$nextStartDT->format("Y-m-d H:i:s")}', ". - "ends = '{$endTimeDT->format("Y-m-d H:i:s")}', ". + "starts = '{$nextStartDT->format("Y-m-d H:i:s.u")}', ". + "ends = '{$endTimeDT->format("Y-m-d H:i:s.u")}', ". "position = {$pos} ". "WHERE id = {$item["id"]}"; Application_Common_Database::prepareAndExecute( diff --git a/airtime_mvc/application/services/ShowService.php b/airtime_mvc/application/services/ShowService.php index c3f4af401..76eea0290 100644 --- a/airtime_mvc/application/services/ShowService.php +++ b/airtime_mvc/application/services/ShowService.php @@ -14,6 +14,10 @@ class Application_Service_ShowService private $repeatType; private $isUpdate; private $linkedShowContent; + private $oldShowTimezone; + private $localShowStartHour; + private $localShowStartMin; + private $origCcShowDay; public function __construct($showId=null, $showData=null, $isUpdate=false) { @@ -29,6 +33,7 @@ class Application_Service_ShowService } else { $this->repeatType = -1; } + $this->isRecorded = (isset($showData['add_show_record']) && $showData['add_show_record']) ? 1 : 0; $this->isRebroadcast = (isset($showData['add_show_rebroadcast']) && $showData['add_show_rebroadcast']) ? 1 : 0; $this->isUpdate = $isUpdate; @@ -114,6 +119,23 @@ class Application_Service_ShowService } } + /** + * + * If a user is editing a show we need to store the original timezone and + * start time in case the show's timezone is changed and we are crossing + * over DST + */ + private function storeOrigLocalShowInfo() + { + $this->origCcShowDay = $this->ccShow->getFirstCcShowDay(); + + $this->oldShowTimezone = $this->origCcShowDay->getDbTimezone(); + + $origStartTime = explode(":", $this->origCcShowDay->getDbStartTime()); + $this->localShowStartHour = $origStartTime[0]; + $this->localShowStartMin = $origStartTime[1]; + } + public function addUpdateShow($showData) { $service_user = new Application_Service_UserService(); @@ -134,10 +156,16 @@ class Application_Service_ShowService $daysAdded = array(); if ($this->isUpdate) { $daysAdded = $this->delegateInstanceCleanup($showData); + + $this->storeOrigLocalShowInfo(); + // updates cc_show_instances start/end times, and updates // schedule start/end times - $this->applyShowStartEndDifference($showData); + // **Not sure why this function is here. It seems unnecesssary + //$this->applyShowStartEndDifference($showData); + $this->deleteRebroadcastInstances(); + $this->deleteCcShowDays(); $this->deleteCcShowHosts(); if ($this->isRebroadcast) { @@ -158,6 +186,10 @@ class Application_Service_ShowService //create new ccShowInstances $this->delegateInstanceCreation($daysAdded); + if ($this->isUpdate) { + $this->adjustSchedule($showData); + } + $con->commit(); Application_Model_RabbitMq::PushSchedule(); } catch (Exception $e) { @@ -168,6 +200,20 @@ class Application_Service_ShowService } } + private function adjustSchedule($showData) + { + $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME); + $ccShowInstances = CcShowInstancesQuery::create() + ->filterByDbShowId($this->ccShow->getDbId()) + ->find(); + + $this->updateScheduleStartEndTimes($showData); + + foreach ($ccShowInstances as $instance) { + $instance->updateScheduleStatus($con); + } + } + /** * * Receives a cc_show id and determines whether to create a @@ -734,11 +780,9 @@ SQL; return $endDate; } - private function applyShowStartEndDifference($showData) + private function updateScheduleStartEndTimes($showData) { $showId = $this->ccShow->getDbId(); - //CcShowDay object - $currentShowDay = $this->ccShow->getFirstCcShowDay(); //DateTime in show's local time $newStartDateTime = new DateTime($showData["add_show_start_date"]." ". @@ -746,9 +790,8 @@ SQL; new DateTimeZone($showData["add_show_timezone"])); $diff = $this->calculateShowStartDiff($newStartDateTime, - $currentShowDay->getLocalStartDateAndTime()); + $this->origCcShowDay->getLocalStartDateAndTime()); - $this->updateInstanceStartEndTime($diff); $ccShowInstances = $this->ccShow->getFutureCcShowInstancess(); $instanceIds = array(); foreach ($ccShowInstances as $ccShowInstance) { @@ -855,11 +898,6 @@ SQL; $ccShowInstance->setDbRecord($showDay->getDbRecord()); $ccShowInstance->save(); - if ($this->isUpdate) { - $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME); - $ccShowInstance->updateScheduleStatus($con); - } - if ($this->isRebroadcast) { $this->createRebroadcastInstances($showDay, $start, $ccShowInstance->getDbId()); } @@ -908,13 +946,9 @@ SQL; /* * Make sure start date is less than populate until date AND * last show date is null OR start date is less than last show date - * - * (NOTE: We cannot call getTimestamp() to compare the dates because of - * a PHP 5.3.3 bug with DatePeriod objects - See CC-5159 for more details) */ - if ($utcStartDateTime->format("Y-m-d H:i:s") <= $populateUntil->format("Y-m-d H:i:s") && - ( is_null($utcLastShowDateTime) || - $utcStartDateTime->format("Y-m-d H:i:s") < $utcLastShowDateTime->format("Y-m-d H:i:s")) ) { + if ($utcStartDateTime <= $populateUntil && + ( is_null($utcLastShowDateTime) || $utcStartDateTime < $utcLastShowDateTime) ) { $lastCreatedShow = clone $utcStartDateTime; /* There may not always be an instance when editing a show @@ -946,11 +980,6 @@ SQL; $ccShowInstance->setDbEnds($utcEndDateTime); $ccShowInstance->setDbRecord($record); $ccShowInstance->save(); - - if ($updateScheduleStatus) { - $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME); - $ccShowInstance->updateScheduleStatus($con); - } } if ($this->isRebroadcast) { @@ -1039,11 +1068,6 @@ SQL; $ccShowInstance->setDbEnds($utcEndDateTime); $ccShowInstance->setDbRecord($record); $ccShowInstance->save(); - - if ($updateScheduleStatus) { - $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME); - $ccShowInstance->updateScheduleStatus($con); - } } if ($this->isRebroadcast) { @@ -1219,8 +1243,13 @@ SQL; */ private function getInstance($starts) { + $temp = clone($starts); + $temp->setTimezone(new DateTimeZone($this->oldShowTimezone)); + $temp->setTime($this->localShowStartHour, $this->localShowStartMin); + $temp->setTimezone(new DateTimeZone("UTC")); + $ccShowInstance = CcShowInstancesQuery::create() - ->filterByDbStarts($starts->format("Y-m-d H:i:s"), Criteria::EQUAL) + ->filterByDbStarts($temp->format("Y-m-d H:i:s"), Criteria::EQUAL) ->filterByDbShowId($this->ccShow->getDbId(), Criteria::EQUAL) ->filterByDbModifiedInstance(false, Criteria::EQUAL) ->filterByDbRebroadcast(0, Criteria::EQUAL) diff --git a/airtime_mvc/application/views/scripts/audiopreview/audio-preview.phtml b/airtime_mvc/application/views/scripts/audiopreview/audio-preview.phtml index fcade27d9..27aac26eb 100644 --- a/airtime_mvc/application/views/scripts/audiopreview/audio-preview.phtml +++ b/airtime_mvc/application/views/scripts/audiopreview/audio-preview.phtml @@ -20,26 +20,26 @@
@@ -57,16 +57,16 @@
- +
- +
- +
@@ -76,8 +76,8 @@
- - + ", "") ?>
diff --git a/airtime_mvc/application/views/scripts/dashboard/about.phtml b/airtime_mvc/application/views/scripts/dashboard/about.phtml index 3f50f42f8..05f65cd80 100644 --- a/airtime_mvc/application/views/scripts/dashboard/about.phtml +++ b/airtime_mvc/application/views/scripts/dashboard/about.phtml @@ -1,5 +1,5 @@
-

+

-

+