diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index d36949953..692a6b387 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -1023,6 +1023,8 @@ SQL; $content_count = Application_Model_ShowInstance::getContentCount( $p_start, $p_end); $isFull = Application_Model_ShowInstance::getIsFull($p_start, $p_end); + $hasAutoPlaylist = Application_Model_ShowInstance::getShowHasAutoplaylist($p_start, $p_end); + $displayTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone()); $utcTimezone = new DateTimeZone("UTC"); @@ -1064,6 +1066,11 @@ SQL; } else { $options["show_partial_filled"] = true; } + if (array_key_exists($show['instance_id'], $hasAutoPlaylist)) { + $options["show_has_auto_playlist"] = !$hasAutoPlaylist[$show['instance_id']]; + } else { + $options["show_has_auto_playlist"] = true; + } $event = array(); diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index bd6f8862e..c219637fa 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -237,8 +237,6 @@ SQL; $ts = intval($this->_showInstance->getDbLastScheduled("U")) ? : 0; $id = $this->_showInstance->getDbId(); $lastid = $this->getLastAudioItemId(); -// Logging::info("The last id is $lastid"); - $scheduler = new Application_Model_Scheduler($checkUserPerm); $scheduler->scheduleAfter( array(array("id" => $lastid, "instance" => $id, "timestamp" => $ts)), @@ -290,6 +288,7 @@ SQL; } private function checkToDeleteShow($showId) + { //UTC DateTime object $showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil(); @@ -556,6 +555,26 @@ SQL; return $isFilled; } + public static function getShowHasAutoplaylist($p_start, $p_end) + { + $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME); + $con->beginTransaction(); + try { + // query the show instances to find whether a show instance has an autoplaylist + $showInstances = CcShowInstancesQuery::create() + ->filterByDbEnds($p_end->format(DEFAULT_TIMESTAMP_FORMAT), Criteria::LESS_THAN) + ->filterByDbStarts($p_start->format(DEFAULT_TIMESTAMP_FORMAT), Criteria::GREATER_THAN) + ->leftJoinCcShow() + ->find($con); + return $showInstances; + } + catch (Exception $e) { + $con->rollback(); + Logging::info("Couldn't query show instances for calendar to find which had autoplaylists"); + Logging::info($e->getMessage()); + } + } + public function showEmpty() { $sql = <<'); - } else { + // in theory a linked show shouldn't have an automatic playlist so adding this here + } else if (event.show_has_auto_playlist === true) { + $(element) + .find(".fc-event-time") + .before(''); + } + else { $(element) .find(".fc-event-time") .before(''); @@ -224,7 +230,11 @@ function eventRender(event, element, view) { $(element) .find(".fc-event-time") .before(''); - } else { + } else if (event.show_has_auto_playlist === true) { + $(element) + .find(".fc-event-time") + .before(''); + } else { $(element) .find(".fc-event-time") .before(''); @@ -234,26 +244,38 @@ function eventRender(event, element, view) { $(element) .find(".fc-event-time") .before(''); + } else if (event.show_has_auto_playlist === true) { + $(element) + .find(".fc-event-time") + .before(''); } } } else if (view.name === 'month') { if (event.show_empty === 1) { if (event.linked) { - $(element) + $(element) .find(".fc-event-title") .after(''); + } else if (event.show_has_auto_playlist === true) { + $(element) + .find(".fc-event-title") + .after(''); } else { - $(element) + $(element) .find(".fc-event-title") .after(''); } } else if (event.show_partial_filled === true) { if (event.linked) { $(element) - .find(".fc-event-title") - .after(''); + .find(".fc-event-title") + .after(''); + } else if (event.show_has_auto_playlist === true) { + $(element) + .find(".fc-event-title") + .after(''); } else { - $(element) + $(element) .find(".fc-event-title") .after(''); } @@ -262,6 +284,10 @@ function eventRender(event, element, view) { $(element) .find(".fc-event-title") .after(''); + } else if (event.show_has_auto_playlist === true) { + $(element) + .find(".fc-event-title") + .after(''); } } }