diff --git a/airtime_mvc/application/controllers/DashboardController.php b/airtime_mvc/application/controllers/DashboardController.php index 31d820f11..6a8c2995b 100644 --- a/airtime_mvc/application/controllers/DashboardController.php +++ b/airtime_mvc/application/controllers/DashboardController.php @@ -53,7 +53,7 @@ class DashboardController extends Zend_Controller_Action $show_id = isset($show[0]['id'])?$show[0]['id']:0; $source_connected = Application_Model_Preference::GetSourceStatus($sourcename); - if($user->canSchedule($show_id) && ($source_connected || $sourcename == 'scheduled_play')){ + if($user->canSchedule($show_id) && ($source_connected || $sourcename == 'scheduled_play' || $current_status == "on")){ $change_status_to = "on"; diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 338923877..c8edc4453 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -12,7 +12,7 @@ class Application_Model_Schedule { global $CC_CONFIG; $con = Propel::getConnection(); $sql = "SELECT COUNT(*) FROM ".$CC_CONFIG["scheduleTable"] - ." WHERE file_id = {$p_fileId} AND starts > NOW()"; + ." WHERE file_id = {$p_fileId} AND ends > NOW() AT TIME ZONE 'UTC'"; $count = $con->query($sql)->fetchColumn(0); if (is_numeric($count) && ($count != '0')) { return TRUE; diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 5486e6aa2..6cfe7a335 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -1061,7 +1061,7 @@ class Application_Model_Show { //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']){ + if (($data['add_show_id'] != -1) && isset($data['add_show_rebroadcast']) && $data['add_show_rebroadcast']){ CcShowRebroadcastQuery::create() ->filterByDbShowId($data['add_show_id']) ->delete(); @@ -1309,8 +1309,9 @@ class Application_Model_Show { $ccShowInstance = $show->getInstanceOnDate($utcStartDateTime); if ($ccShowInstance->getDbModifiedInstance()){ - //show instance on this date has been deleted. - continue; + //show instance on this date has been deleted. + $utcStartDateTime = self::advanceRepeatingDate($p_interval, $start, $timezone); + continue; } $newInstance = false; @@ -1342,44 +1343,48 @@ class Application_Model_Show { $showInstance->deleteRebroadcasts(); self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone); - - if ($p_interval == 'P1M'){ - /* When adding months, there is a problem if we are on January 31st and add one month with PHP. - * What ends up happening is that since February 31st doesn't exist, the date returned is - * March 3rd. For now let's ignore the day and assume we are always working with the - * first of each month, and use PHP to add 1 month to this (this will take care of rolling - * over the years 2011->2012, etc.). Then let's append the actual day, and use the php - * checkdate() function, to see if it is valid. If not, then we'll just skip this month. */ - - $startDt = new DateTime($start, new DateTimeZone($timezone)); - - /* pass in only the year and month (not the day) */ - $dt = new DateTime($startDt->format("Y-m"), new DateTimeZone($timezone)); - - /* Keep adding 1 month, until we find the next month that contains the day - * we are looking for (31st day for example) */ - do { - $dt->add(new DateInterval($p_interval)); - } while(!checkdate($dt->format("m"), $startDt->format("d"), $dt->format("Y"))); - $dt->setDate($dt->format("Y"), $dt->format("m"), $startDt->format("d")); - - $start = $dt->format("Y-m-d H:i:s"); - - $dt->setTimezone(new DateTimeZone('UTC')); - $utcStartDateTime = $dt; - } else { - $dt = new DateTime($start, new DateTimeZone($timezone)); - $dt->add(new DateInterval($p_interval)); - $start = $dt->format("Y-m-d H:i:s"); - - $dt->setTimezone(new DateTimeZone('UTC')); - $utcStartDateTime = $dt; - } + $utcStartDateTime = self::advanceRepeatingDate($p_interval, $start, $timezone); } Application_Model_Show::setNextPop($start, $show_id, $day); } + + private static function advanceRepeatingDate($p_interval, $start, $timezone){ + if ($p_interval == 'P1M'){ + /* When adding months, there is a problem if we are on January 31st and add one month with PHP. + * What ends up happening is that since February 31st doesn't exist, the date returned is + * March 3rd. For now let's ignore the day and assume we are always working with the + * first of each month, and use PHP to add 1 month to this (this will take care of rolling + * over the years 2011->2012, etc.). Then let's append the actual day, and use the php + * checkdate() function, to see if it is valid. If not, then we'll just skip this month. */ + + /* pass in only the year and month (not the day) */ + $dt = new DateTime($startDt->format("Y-m"), new DateTimeZone($timezone)); + + $dt = new DateTime($startDt->format("Y-m"), new DateTimeZone($timezone)); + + /* Keep adding 1 month, until we find the next month that contains the day + * we are looking for (31st day for example) */ + do { + $dt->add(new DateInterval($p_interval)); + } while(!checkdate($dt->format("m"), $startDt->format("d"), $dt->format("Y"))); + $dt->setDate($dt->format("Y"), $dt->format("m"), $startDt->format("d")); + + $start = $dt->format("Y-m-d H:i:s"); + + $dt->setTimezone(new DateTimeZone('UTC')); + $utcStartDateTime = $dt; + } else { + $dt = new DateTime($start, new DateTimeZone($timezone)); + $dt->add(new DateInterval($p_interval)); + $start = $dt->format("Y-m-d H:i:s"); + + $dt->setTimezone(new DateTimeZone('UTC')); + $utcStartDateTime = $dt; + } + return $utcStartDateTime; + } /* * @param $p_start @@ -1477,7 +1482,6 @@ class Application_Model_Show { //UTC DateTime object $showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil(); - //if application is requesting shows past our previous populated until date, generate shows up until this point. if (is_null($showsPopUntil) || $showsPopUntil->getTimestamp() < $end_timestamp->getTimestamp()) { Application_Model_Show::populateAllShowsInRange($showsPopUntil, $end_timestamp); @@ -1492,7 +1496,6 @@ class Application_Model_Show { LEFT JOIN cc_show_instances AS si2 ON si1.instance_id = si2.id LEFT JOIN cc_show AS show ON show.id = si1.show_id WHERE si1.modified_instance = FALSE"; - //only want shows that are starting at the time or later. $start_string = $start_timestamp->format("Y-m-d H:i:s"); $end_string = $end_timestamp->format("Y-m-d H:i:s"); @@ -1563,7 +1566,6 @@ class Application_Model_Show { //Logging::log($sql); $res = $con->query($sql)->fetchAll(); - foreach ($res as $row) { Application_Model_Show::populateShow($row, $p_endTimestamp); } @@ -1584,7 +1586,7 @@ class Application_Model_Show { $days = $interval->format('%a'); $shows = Application_Model_Show::getShows($p_start, $p_end); $nowEpoch = time(); - + foreach ($shows as $show) { $options = array(); diff --git a/airtime_mvc/application/models/airtime/CcShowInstances.php b/airtime_mvc/application/models/airtime/CcShowInstances.php index 6b2812ee1..e2366cc4f 100644 --- a/airtime_mvc/application/models/airtime/CcShowInstances.php +++ b/airtime_mvc/application/models/airtime/CcShowInstances.php @@ -160,8 +160,12 @@ class CcShowInstances extends BaseCcShowInstances { * @param PropelPDO $con A connection object */ public function updateDbTimeFilled(PropelPDO $con) - { - $this->setDbTimeFilled($this->computeDbTimeFilled($con)); + { + $timefilled = $this->computeDbTimeFilled($con); + if($timefilled == null){ + $timefilled = "00:00:00"; + } + $this->setDbTimeFilled($timefilled); $this->save($con); } diff --git a/airtime_mvc/application/views/scripts/form/add-show-live-stream.phtml b/airtime_mvc/application/views/scripts/form/add-show-live-stream.phtml index 86272f3ce..1ce5b8459 100644 --- a/airtime_mvc/application/views/scripts/form/add-show-live-stream.phtml +++ b/airtime_mvc/application/views/scripts/form/add-show-live-stream.phtml @@ -21,6 +21,7 @@