2010-12-07 20:19:27 +01:00
|
|
|
<?php
|
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
class Application_Model_Schedule
|
|
|
|
{
|
2010-12-07 23:29:28 +01:00
|
|
|
/**
|
|
|
|
* Return TRUE if file is going to be played in the future.
|
|
|
|
*
|
|
|
|
* @param string $p_fileId
|
|
|
|
*/
|
|
|
|
public function IsFileScheduledInTheFuture($p_fileId)
|
|
|
|
{
|
2012-04-01 21:51:03 +02:00
|
|
|
global $CC_CONFIG;
|
|
|
|
$con = Propel::getConnection();
|
2010-12-07 23:29:28 +01:00
|
|
|
$sql = "SELECT COUNT(*) FROM ".$CC_CONFIG["scheduleTable"]
|
2012-06-08 21:24:37 +02:00
|
|
|
." WHERE file_id = {$p_fileId} AND ends > NOW() AT TIME ZONE 'UTC'";
|
2012-04-01 21:51:03 +02:00
|
|
|
$count = $con->query($sql)->fetchColumn(0);
|
2010-12-07 23:29:28 +01:00
|
|
|
if (is_numeric($count) && ($count != '0')) {
|
|
|
|
return TRUE;
|
|
|
|
} else {
|
|
|
|
return FALSE;
|
|
|
|
}
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
2010-12-07 23:29:28 +01:00
|
|
|
|
2010-12-22 00:28:17 +01:00
|
|
|
/**
|
2011-02-03 00:25:42 +01:00
|
|
|
* Returns data related to the scheduled items.
|
2010-12-22 00:28:17 +01:00
|
|
|
*
|
2012-07-16 03:17:13 +02:00
|
|
|
* @param int $p_prev
|
|
|
|
* @param int $p_next
|
2010-12-22 00:28:17 +01:00
|
|
|
* @return date
|
|
|
|
*/
|
2012-03-13 22:46:13 +01:00
|
|
|
public static function GetPlayOrderRange($p_prev = 1, $p_next = 1)
|
2011-03-22 14:55:33 +01:00
|
|
|
{
|
2012-07-16 03:17:13 +02:00
|
|
|
if (!is_int($p_prev) || !is_int($p_next)) {
|
2010-12-22 00:28:17 +01:00
|
|
|
//must enter integers to specify ranges
|
2012-07-12 01:31:24 +02:00
|
|
|
Logging::log("Invalid range parameters: $p_prev or $p_next");
|
2011-02-07 06:26:16 +01:00
|
|
|
return array();
|
2010-12-22 00:28:17 +01:00
|
|
|
}
|
2010-12-07 23:29:28 +01:00
|
|
|
|
2012-04-13 23:45:28 +02:00
|
|
|
$date = new Application_Common_DateHelper;
|
2011-11-12 06:04:37 +01:00
|
|
|
$timeNow = $date->getTimestamp();
|
2011-11-15 21:45:08 +01:00
|
|
|
$utcTimeNow = $date->getUtcTimestamp();
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-03-13 15:21:01 +01:00
|
|
|
$shows = Application_Model_Show::getPrevCurrentNext($utcTimeNow);
|
2012-04-13 00:49:24 +02:00
|
|
|
$previousShowID = count($shows['previousShow'])>0?$shows['previousShow'][0]['instance_id']:null;
|
|
|
|
$currentShowID = count($shows['currentShow'])>0?$shows['currentShow'][0]['instance_id']:null;
|
|
|
|
$nextShowID = count($shows['nextShow'])>0?$shows['nextShow'][0]['instance_id']:null;
|
2012-03-16 19:02:53 +01:00
|
|
|
$results = Application_Model_Schedule::GetPrevCurrentNext($previousShowID, $currentShowID, $nextShowID, $utcTimeNow);
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2011-11-15 21:45:08 +01:00
|
|
|
$range = array("env"=>APPLICATION_ENV,
|
2011-08-15 22:40:24 +02:00
|
|
|
"schedulerTime"=>$timeNow,
|
2012-03-16 19:02:53 +01:00
|
|
|
"previous"=>$results['previous'] !=null?$results['previous']:(count($shows['previousShow'])>0?$shows['previousShow'][0]:null),
|
2012-05-22 22:33:18 +02:00
|
|
|
"current"=>$results['current'] !=null?$results['current']:((count($shows['currentShow'])>0 && $shows['currentShow'][0]['record'] == 1)?$shows['currentShow'][0]:null),
|
2012-03-16 19:02:53 +01:00
|
|
|
"next"=> $results['next'] !=null?$results['next']:(count($shows['nextShow'])>0?$shows['nextShow'][0]:null),
|
2012-03-13 15:21:01 +01:00
|
|
|
"currentShow"=>$shows['currentShow'],
|
|
|
|
"nextShow"=>$shows['nextShow'],
|
2011-01-31 22:34:08 +01:00
|
|
|
"timezone"=> date("T"),
|
2011-07-12 20:09:40 +02:00
|
|
|
"timezoneOffset"=> date("Z"));
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2011-11-15 21:45:08 +01:00
|
|
|
return $range;
|
2010-12-07 23:29:28 +01:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-03-13 15:21:01 +01:00
|
|
|
/**
|
|
|
|
* Queries the database for the set of schedules one hour before and after the given time.
|
|
|
|
* If a show starts and ends within that time that is considered the current show. Then the
|
|
|
|
* scheduled item before it is the previous show, and the scheduled item after it is the next
|
|
|
|
* show. This way the dashboard getCurrentPlaylist is very fast. But if any one of the three
|
|
|
|
* show types are not found through this mechanism a call is made to the old way of querying
|
|
|
|
* the database to find the track info.
|
|
|
|
**/
|
2012-03-16 19:02:53 +01:00
|
|
|
public static function GetPrevCurrentNext($p_previousShowID, $p_currentShowID, $p_nextShowID, $p_timeNow)
|
2012-03-13 15:21:01 +01:00
|
|
|
{
|
2012-03-16 22:13:32 +01:00
|
|
|
if ($p_previousShowID == null && $p_currentShowID == null && $p_nextShowID == null)
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
return;
|
2012-04-01 21:51:03 +02:00
|
|
|
|
|
|
|
global $CC_CONFIG;
|
|
|
|
$con = Propel::getConnection();
|
|
|
|
$sql = 'Select ft.artist_name, ft.track_title, st.starts as starts, st.ends as ends, st.media_item_played as media_item_played, si.ends as show_ends
|
|
|
|
FROM cc_schedule st LEFT JOIN cc_files ft ON st.file_id = ft.id LEFT JOIN cc_show_instances si on st.instance_id = si.id
|
|
|
|
WHERE ';
|
|
|
|
|
|
|
|
/* Alternate SQL...merge conflict and I'm not sure which on is right.... -MK
|
|
|
|
$sql = 'Select ft.artist_name, ft.track_title, st.starts as starts, st.ends as ends, st.media_item_played as media_item_played, si.ends as show_ends
|
2012-07-11 00:51:32 +02:00
|
|
|
FROM cc_schedule st LEFT JOIN cc_files ft ON st.file_id = ft.id
|
2012-03-16 19:02:53 +01:00
|
|
|
WHERE ';
|
2012-04-01 21:51:03 +02:00
|
|
|
*/
|
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
if (isset($p_previousShowID)) {
|
2012-03-16 19:02:53 +01:00
|
|
|
if (isset($p_nextShowID) || isset($p_currentShowID))
|
|
|
|
$sql .= '(';
|
|
|
|
$sql .= 'st.instance_id = '.$p_previousShowID;
|
|
|
|
}
|
2012-07-16 03:17:13 +02:00
|
|
|
if ($p_currentShowID != null) {
|
2012-03-16 19:02:53 +01:00
|
|
|
if ($p_previousShowID != null)
|
|
|
|
$sql .= ' OR ';
|
|
|
|
else if($p_nextShowID != null)
|
|
|
|
$sql .= '(';
|
|
|
|
$sql .= 'st.instance_id = '.$p_currentShowID;
|
|
|
|
}
|
|
|
|
if ($p_nextShowID != null) {
|
|
|
|
if ($p_previousShowID != null || $p_currentShowID != null)
|
|
|
|
$sql .= ' OR ';
|
|
|
|
$sql .= 'st.instance_id = '.$p_nextShowID;
|
|
|
|
if($p_previousShowID != null || $p_currentShowID != null)
|
|
|
|
$sql .= ')';
|
|
|
|
} else if($p_previousShowID != null && $p_currentShowID != null)
|
|
|
|
$sql .= ')';
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-03-16 19:02:53 +01:00
|
|
|
$sql .= ' AND st.playout_status > 0 ORDER BY st.starts';
|
2012-04-01 21:51:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
$rows = $con->query($sql)->fetchAll();
|
2012-03-13 15:21:01 +01:00
|
|
|
$numberOfRows = count($rows);
|
2012-03-13 22:46:13 +01:00
|
|
|
|
2012-03-13 15:21:01 +01:00
|
|
|
$results['previous'] = null;
|
|
|
|
$results['current'] = null;
|
|
|
|
$results['next'] = null;
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-03-13 15:21:01 +01:00
|
|
|
$timeNowAsMillis = strtotime($p_timeNow);
|
2012-07-16 03:17:13 +02:00
|
|
|
for ($i = 0; $i < $numberOfRows; ++$i) {
|
2012-04-11 22:06:10 +02:00
|
|
|
// if the show is overbooked, then update the track end time to the end of the show time.
|
2012-07-16 03:17:13 +02:00
|
|
|
if ($rows[$i]['ends'] > $rows[$i]["show_ends"]) {
|
2012-04-11 21:54:03 +02:00
|
|
|
$rows[$i]['ends'] = $rows[$i]["show_ends"];
|
|
|
|
}
|
2012-07-16 03:17:13 +02:00
|
|
|
if ((strtotime($rows[$i]['starts']) <= $timeNowAsMillis) && (strtotime($rows[$i]['ends']) >= $timeNowAsMillis)) {
|
|
|
|
if ($i - 1 >= 0) {
|
2012-03-13 15:21:01 +01:00
|
|
|
$results['previous'] = array("name"=>$rows[$i-1]["artist_name"]." - ".$rows[$i-1]["track_title"],
|
|
|
|
"starts"=>$rows[$i-1]["starts"],
|
2012-05-18 00:21:58 +02:00
|
|
|
"ends"=>$rows[$i-1]["ends"],
|
|
|
|
"type"=>'track');
|
2012-03-13 15:21:01 +01:00
|
|
|
}
|
|
|
|
$results['current'] = array("name"=>$rows[$i]["artist_name"]." - ".$rows[$i]["track_title"],
|
|
|
|
"starts"=>$rows[$i]["starts"],
|
2012-04-04 00:29:36 +02:00
|
|
|
"ends"=> (($rows[$i]["ends"] > $rows[$i]["show_ends"]) ? $rows[$i]["show_ends"]: $rows[$i]["ends"]),
|
2012-03-13 15:21:01 +01:00
|
|
|
"media_item_played"=>$rows[$i]["media_item_played"],
|
2012-05-18 00:21:58 +02:00
|
|
|
"record"=>0,
|
|
|
|
"type"=>'track');
|
2012-07-16 03:17:13 +02:00
|
|
|
if ( isset($rows[$i+1])) {
|
2012-03-13 15:21:01 +01:00
|
|
|
$results['next'] = array("name"=>$rows[$i+1]["artist_name"]." - ".$rows[$i+1]["track_title"],
|
|
|
|
"starts"=>$rows[$i+1]["starts"],
|
2012-05-18 00:21:58 +02:00
|
|
|
"ends"=>$rows[$i+1]["ends"],
|
|
|
|
"type"=>'track');
|
2012-03-13 15:21:01 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (strtotime($rows[$i]['ends']) < $timeNowAsMillis ) {
|
2012-03-13 22:46:13 +01:00
|
|
|
$previousIndex = $i;
|
2012-03-13 15:21:01 +01:00
|
|
|
}
|
|
|
|
if (strtotime($rows[$i]['starts']) > $timeNowAsMillis) {
|
|
|
|
$results['next'] = array("name"=>$rows[$i]["artist_name"]." - ".$rows[$i]["track_title"],
|
|
|
|
"starts"=>$rows[$i]["starts"],
|
2012-05-18 00:21:58 +02:00
|
|
|
"ends"=>$rows[$i]["ends"],
|
|
|
|
"type"=>'track');
|
2012-03-13 15:21:01 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-03-13 22:46:13 +01:00
|
|
|
//If we didn't find a a current show because the time didn't fit we may still have
|
|
|
|
//found a previous show so use it.
|
|
|
|
if ($results['previous'] === null && isset($previousIndex)) {
|
|
|
|
$results['previous'] = array("name"=>$rows[$previousIndex]["artist_name"]." - ".$rows[$previousIndex]["track_title"],
|
|
|
|
"starts"=>$rows[$previousIndex]["starts"],
|
|
|
|
"ends"=>$rows[$previousIndex]["ends"]);;
|
|
|
|
}
|
2012-07-16 03:17:13 +02:00
|
|
|
|
2012-03-13 15:21:01 +01:00
|
|
|
return $results;
|
|
|
|
}
|
2011-05-11 01:06:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetLastScheduleItem($p_timeNow)
|
|
|
|
{
|
2012-04-01 21:51:03 +02:00
|
|
|
global $CC_CONFIG;
|
|
|
|
$con = Propel::getConnection();
|
2011-06-29 20:40:56 +02:00
|
|
|
$sql = "SELECT"
|
|
|
|
." ft.artist_name, ft.track_title,"
|
|
|
|
." st.starts as starts, st.ends as ends"
|
2011-05-11 01:06:35 +02:00
|
|
|
." FROM $CC_CONFIG[scheduleTable] st"
|
|
|
|
." LEFT JOIN $CC_CONFIG[filesTable] ft"
|
|
|
|
." ON st.file_id = ft.id"
|
2011-06-29 20:40:56 +02:00
|
|
|
." LEFT JOIN $CC_CONFIG[showInstances] sit"
|
|
|
|
." ON st.instance_id = sit.id"
|
2011-05-11 01:06:35 +02:00
|
|
|
." WHERE st.ends < TIMESTAMP '$p_timeNow'"
|
2011-06-29 20:40:56 +02:00
|
|
|
." AND st.starts >= sit.starts" //this and the next line are necessary since we can overbook shows.
|
|
|
|
." AND st.starts < sit.ends"
|
2011-05-11 01:06:35 +02:00
|
|
|
." ORDER BY st.ends DESC"
|
|
|
|
." LIMIT 1";
|
|
|
|
|
2012-04-01 21:51:03 +02:00
|
|
|
$row = $con->query($sql)->fetchAll();
|
2012-07-16 03:17:13 +02:00
|
|
|
|
2011-05-11 01:06:35 +02:00
|
|
|
return $row;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetCurrentScheduleItem($p_timeNow, $p_instanceId)
|
|
|
|
{
|
2012-04-01 21:51:03 +02:00
|
|
|
global $CC_CONFIG;
|
|
|
|
$con = Propel::getConnection();
|
2011-06-02 18:45:57 +02:00
|
|
|
/* 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. */
|
2011-05-11 01:06:35 +02:00
|
|
|
$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'"
|
2011-06-03 22:36:13 +02:00
|
|
|
." AND st.instance_id = $p_instanceId"
|
2011-05-11 01:06:35 +02:00
|
|
|
." AND st.ends > TIMESTAMP '$p_timeNow'"
|
2011-06-02 18:45:57 +02:00
|
|
|
." ORDER BY st.starts DESC"
|
2011-05-11 01:06:35 +02:00
|
|
|
." LIMIT 1";
|
|
|
|
|
2012-04-01 21:51:03 +02:00
|
|
|
$row = $con->query($sql)->fetchAll();
|
2012-07-16 03:17:13 +02:00
|
|
|
|
2011-05-11 01:06:35 +02:00
|
|
|
return $row;
|
|
|
|
}
|
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetNextScheduleItem($p_timeNow)
|
|
|
|
{
|
2012-04-01 21:51:03 +02:00
|
|
|
global $CC_CONFIG;
|
|
|
|
$con = Propel::getConnection();
|
2011-06-29 20:40:56 +02:00
|
|
|
$sql = "SELECT"
|
|
|
|
." ft.artist_name, ft.track_title,"
|
|
|
|
." st.starts as starts, st.ends as ends"
|
2011-05-11 01:06:35 +02:00
|
|
|
." FROM $CC_CONFIG[scheduleTable] st"
|
|
|
|
." LEFT JOIN $CC_CONFIG[filesTable] ft"
|
|
|
|
." ON st.file_id = ft.id"
|
2011-06-29 20:40:56 +02:00
|
|
|
." LEFT JOIN $CC_CONFIG[showInstances] sit"
|
|
|
|
." ON st.instance_id = sit.id"
|
2011-05-11 01:06:35 +02:00
|
|
|
." WHERE st.starts > TIMESTAMP '$p_timeNow'"
|
2011-06-29 20:40:56 +02:00
|
|
|
." AND st.starts >= sit.starts" //this and the next line are necessary since we can overbook shows.
|
|
|
|
." AND st.starts < sit.ends"
|
2011-05-11 01:06:35 +02:00
|
|
|
." ORDER BY st.starts"
|
|
|
|
." LIMIT 1";
|
|
|
|
|
2012-04-01 21:51:03 +02:00
|
|
|
$row = $con->query($sql)->fetchAll();
|
2012-07-16 03:17:13 +02:00
|
|
|
|
2011-05-11 01:06:35 +02:00
|
|
|
return $row;
|
|
|
|
}
|
|
|
|
|
2012-07-11 00:51:32 +02:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* @param DateTime $p_startDateTime
|
|
|
|
*
|
|
|
|
* @param DateTime $p_endDateTime
|
|
|
|
*
|
|
|
|
* @return array $scheduledItems
|
|
|
|
*
|
|
|
|
*/
|
2012-03-02 14:01:02 +01:00
|
|
|
public static function GetScheduleDetailItems($p_start, $p_end, $p_shows)
|
2012-01-23 19:07:07 +01:00
|
|
|
{
|
2012-04-01 21:51:03 +02:00
|
|
|
global $CC_CONFIG;
|
|
|
|
$con = Propel::getConnection();
|
2012-01-23 19:07:07 +01:00
|
|
|
$sql = "SELECT DISTINCT
|
|
|
|
|
2012-01-31 18:59:27 +01:00
|
|
|
showt.name AS show_name, showt.color AS show_color,
|
2012-03-22 18:04:22 +01:00
|
|
|
showt.background_color AS show_background_color, showt.id AS show_id,
|
2012-01-26 15:21:04 +01:00
|
|
|
|
|
|
|
si.starts AS si_starts, si.ends AS si_ends, si.time_filled AS si_time_filled,
|
2012-04-20 13:03:50 +02:00
|
|
|
si.record AS si_record, si.rebroadcast AS si_rebroadcast, si.instance_id AS parent_show,
|
2012-05-14 15:06:56 +02:00
|
|
|
si.id AS si_id, si.last_scheduled AS si_last_scheduled, si.file_id AS si_file_id,
|
2012-01-26 15:21:04 +01:00
|
|
|
|
2012-01-26 19:10:37 +01:00
|
|
|
sched.starts AS sched_starts, sched.ends AS sched_ends, sched.id AS sched_id,
|
2012-02-27 21:29:02 +01:00
|
|
|
sched.cue_in AS cue_in, sched.cue_out AS cue_out,
|
|
|
|
sched.fade_in AS fade_in, sched.fade_out AS fade_out,
|
2012-03-02 12:22:08 +01:00
|
|
|
sched.playout_status AS playout_status,
|
2012-01-26 15:21:04 +01:00
|
|
|
|
2012-07-25 04:24:08 +02:00
|
|
|
--ft.track_title AS file_track_title, ft.artist_name AS file_artist_name,
|
|
|
|
--ft.album_title AS file_album_title, ft.length AS file_length, ft.file_exists AS file_exists
|
|
|
|
|
|
|
|
%%file_columns%%
|
2012-01-23 19:07:07 +01:00
|
|
|
|
|
|
|
FROM
|
2012-07-25 04:24:08 +02:00
|
|
|
((
|
|
|
|
--cc_schedule AS sched JOIN cc_files AS ft ON (sched.file_id = ft.id)
|
|
|
|
%%file_join%%
|
|
|
|
|
|
|
|
--JOIN cc_webstream AS ws ON (sched.stream_id = ws.id)
|
|
|
|
RIGHT JOIN cc_show_instances AS si ON (si.id = sched.instance_id))
|
2012-01-23 19:07:07 +01:00
|
|
|
JOIN cc_show AS showt ON (showt.id = si.show_id)
|
|
|
|
)
|
|
|
|
|
2012-02-09 21:19:21 +01:00
|
|
|
WHERE si.modified_instance = false AND
|
|
|
|
|
2012-03-02 14:01:02 +01:00
|
|
|
((si.starts >= '{$p_start}' AND si.starts < '{$p_end}')
|
|
|
|
OR (si.ends > '{$p_start}' AND si.ends <= '{$p_end}')
|
|
|
|
OR (si.starts <= '{$p_start}' AND si.ends >= '{$p_end}'))";
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-02-15 00:39:27 +01:00
|
|
|
if (count($p_shows) > 0) {
|
|
|
|
$sql .= " AND show_id IN (".implode(",", $p_shows).")";
|
|
|
|
}
|
|
|
|
|
2012-07-25 04:24:08 +02:00
|
|
|
$sql .= " ORDER BY si.starts, sched.starts";
|
|
|
|
$sql2 = $sql;
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-07-25 04:24:08 +02:00
|
|
|
$sql = str_replace("%%file_columns%%", "ft.track_title AS file_track_title, ft.artist_name AS file_artist_name,
|
|
|
|
ft.album_title AS file_album_title, ft.length AS file_length, ft.file_exists AS file_exists", $sql);
|
|
|
|
$sql = str_replace("%%file_join%%", "cc_schedule AS sched JOIN cc_files AS ft ON (sched.file_id = ft.id)", $sql);
|
2012-01-26 15:21:04 +01:00
|
|
|
|
2012-07-25 04:24:08 +02:00
|
|
|
$sql2 = str_replace("%%file_columns%%", "ws.name AS file_track_title, ws.login AS file_artist_name,
|
|
|
|
ws.description AS file_album_title, ws.length AS file_length, 't'::BOOL AS file_exists", $sql2);
|
|
|
|
$sql2 = str_replace("%%file_join%%", "cc_schedule AS sched JOIN cc_webstream AS ws ON (sched.stream_id = ws.id)", $sql2);
|
|
|
|
|
|
|
|
$sql = "($sql) UNION ($sql2)";
|
|
|
|
|
|
|
|
Logging::debug($sql);
|
|
|
|
$rows = $con->query($sql)->fetchAll(PDO::FETCH_ASSOC);
|
2012-07-16 03:17:13 +02:00
|
|
|
|
2011-03-05 05:53:29 +01:00
|
|
|
return $rows;
|
|
|
|
}
|
|
|
|
|
2011-03-22 14:55:33 +01:00
|
|
|
public static function UpdateMediaPlayedStatus($p_id)
|
|
|
|
{
|
2012-04-01 21:51:03 +02:00
|
|
|
global $CC_CONFIG;
|
|
|
|
$con = Propel::getConnection();
|
2011-02-23 23:03:27 +01:00
|
|
|
$sql = "UPDATE ".$CC_CONFIG['scheduleTable']
|
2012-05-22 23:39:27 +02:00
|
|
|
." SET media_item_played=TRUE";
|
|
|
|
// we need to update 'broadcasted' column as well
|
|
|
|
// check the current switch status
|
|
|
|
$live_dj = Application_Model_Preference::GetSourceSwitchStatus('live_dj') == 'on'?true:false;
|
|
|
|
$master_dj = Application_Model_Preference::GetSourceSwitchStatus('master_dj') == 'on'?true:false;
|
|
|
|
$scheduled_play = Application_Model_Preference::GetSourceSwitchStatus('scheduled_play') == 'on'?true:false;
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
if (!$live_dj && !$master_dj && $scheduled_play) {
|
2012-05-22 23:39:27 +02:00
|
|
|
$sql .= ", broadcasted=1";
|
|
|
|
}
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-05-22 23:39:27 +02:00
|
|
|
$sql .= " WHERE id=$p_id";
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-05-22 23:39:27 +02:00
|
|
|
$retVal = $con->exec($sql);
|
2012-07-16 03:17:13 +02:00
|
|
|
|
2012-05-22 23:39:27 +02:00
|
|
|
return $retVal;
|
|
|
|
}
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function UpdateBrodcastedStatus($dateTime, $value)
|
|
|
|
{
|
2012-05-22 23:39:27 +02:00
|
|
|
global $CC_CONFIG;
|
|
|
|
$con = Propel::getConnection();
|
|
|
|
$now = $dateTime->format("Y-m-d H:i:s");
|
|
|
|
$sql = "UPDATE ".$CC_CONFIG['scheduleTable']
|
|
|
|
." SET broadcasted=$value"
|
|
|
|
." WHERE starts <= '$now' AND ends >= '$now'";
|
2012-04-01 21:51:03 +02:00
|
|
|
$retVal = $con->exec($sql);
|
2012-07-16 03:17:13 +02:00
|
|
|
|
2011-03-22 14:55:33 +01:00
|
|
|
return $retVal;
|
2011-02-23 23:03:27 +01:00
|
|
|
}
|
2011-07-19 12:37:06 +02:00
|
|
|
|
2012-04-01 21:51:03 +02:00
|
|
|
public static function getSchduledPlaylistCount()
|
|
|
|
{
|
|
|
|
global $CC_CONFIG;
|
|
|
|
$con = Propel::getConnection();
|
2011-06-15 18:06:50 +02:00
|
|
|
$sql = "SELECT count(*) as cnt FROM ".$CC_CONFIG['scheduleTable'];
|
2012-07-16 03:17:13 +02:00
|
|
|
|
2012-04-01 21:51:03 +02:00
|
|
|
return $con->query($sql)->fetchColumn(0);
|
2011-06-15 18:06:50 +02:00
|
|
|
}
|
2011-02-23 23:03:27 +01:00
|
|
|
|
2010-12-07 23:29:28 +01:00
|
|
|
/**
|
|
|
|
* Convert a time string in the format "YYYY-MM-DD HH:mm:SS"
|
|
|
|
* to "YYYY-MM-DD-HH-mm-SS".
|
|
|
|
*
|
2012-07-16 03:17:13 +02:00
|
|
|
* @param string $p_time
|
2010-12-07 23:29:28 +01:00
|
|
|
* @return string
|
|
|
|
*/
|
2011-03-22 14:55:33 +01:00
|
|
|
private static function AirtimeTimeToPypoTime($p_time)
|
2010-12-07 23:29:28 +01:00
|
|
|
{
|
|
|
|
$p_time = substr($p_time, 0, 19);
|
|
|
|
$p_time = str_replace(" ", "-", $p_time);
|
|
|
|
$p_time = str_replace(":", "-", $p_time);
|
2012-07-16 03:17:13 +02:00
|
|
|
|
2010-12-07 23:29:28 +01:00
|
|
|
return $p_time;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert a time string in the format "YYYY-MM-DD-HH-mm-SS" to
|
|
|
|
* "YYYY-MM-DD HH:mm:SS".
|
|
|
|
*
|
2012-07-16 03:17:13 +02:00
|
|
|
* @param string $p_time
|
2010-12-07 23:29:28 +01:00
|
|
|
* @return string
|
|
|
|
*/
|
2011-03-22 14:55:33 +01:00
|
|
|
private static function PypoTimeToAirtimeTime($p_time)
|
2010-12-07 23:29:28 +01:00
|
|
|
{
|
|
|
|
$t = explode("-", $p_time);
|
2012-07-16 03:17:13 +02:00
|
|
|
|
2010-12-07 23:29:28 +01:00
|
|
|
return $t[0]."-".$t[1]."-".$t[2]." ".$t[3].":".$t[4].":00";
|
|
|
|
}
|
|
|
|
|
2010-12-10 00:44:47 +01:00
|
|
|
/**
|
|
|
|
* Return true if the input string is in the format YYYY-MM-DD-HH-mm
|
|
|
|
*
|
2012-07-16 03:17:13 +02:00
|
|
|
* @param string $p_time
|
2010-12-10 00:44:47 +01:00
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public static function ValidPypoTimeFormat($p_time)
|
|
|
|
{
|
|
|
|
$t = explode("-", $p_time);
|
|
|
|
if (count($t) != 5) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
foreach ($t as $part) {
|
|
|
|
if (!is_numeric($part)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2012-07-16 03:17:13 +02:00
|
|
|
|
2010-12-10 00:44:47 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-12-07 23:29:28 +01:00
|
|
|
/**
|
|
|
|
* Converts a time value as a string (with format HH:MM:SS.mmmmmm) to
|
|
|
|
* millisecs.
|
|
|
|
*
|
2012-07-16 03:17:13 +02:00
|
|
|
* @param string $p_time
|
2010-12-07 23:29:28 +01:00
|
|
|
* @return int
|
|
|
|
*/
|
2011-04-06 23:53:09 +02:00
|
|
|
public static function WallTimeToMillisecs($p_time)
|
2010-12-07 23:29:28 +01:00
|
|
|
{
|
|
|
|
$t = explode(":", $p_time);
|
|
|
|
$millisecs = 0;
|
|
|
|
if (strpos($t[2], ".")) {
|
|
|
|
$secParts = explode(".", $t[2]);
|
|
|
|
$millisecs = $secParts[1];
|
2012-04-11 17:03:13 +02:00
|
|
|
$millisecs = str_pad(substr($millisecs, 0, 3),3, '0');
|
2010-12-07 23:29:28 +01:00
|
|
|
$millisecs = intval($millisecs);
|
|
|
|
$seconds = intval($secParts[0]);
|
|
|
|
} else {
|
|
|
|
$seconds = intval($t[2]);
|
|
|
|
}
|
|
|
|
$ret = $millisecs + ($seconds * 1000) + ($t[1] * 60 * 1000) + ($t[0] * 60 * 60 * 1000);
|
2012-07-16 03:17:13 +02:00
|
|
|
|
2010-12-07 23:29:28 +01:00
|
|
|
return $ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compute the difference between two times in the format "HH:MM:SS.mmmmmm".
|
|
|
|
* Note: currently only supports calculating millisec differences.
|
|
|
|
*
|
2012-07-16 03:17:13 +02:00
|
|
|
* @param string $p_time1
|
|
|
|
* @param string $p_time2
|
2010-12-07 23:29:28 +01:00
|
|
|
* @return double
|
|
|
|
*/
|
|
|
|
private static function TimeDiff($p_time1, $p_time2)
|
|
|
|
{
|
|
|
|
$parts1 = explode(".", $p_time1);
|
|
|
|
$parts2 = explode(".", $p_time2);
|
|
|
|
$diff = 0;
|
|
|
|
if ( (count($parts1) > 1) && (count($parts2) > 1) ) {
|
|
|
|
$millisec1 = substr($parts1[1], 0, 3);
|
|
|
|
$millisec1 = str_pad($millisec1, 3, "0");
|
|
|
|
$millisec1 = intval($millisec1);
|
|
|
|
$millisec2 = substr($parts2[1], 0, 3);
|
|
|
|
$millisec2 = str_pad($millisec2, 3, "0");
|
|
|
|
$millisec2 = intval($millisec2);
|
2011-01-17 08:32:51 +01:00
|
|
|
$diff = abs($millisec1 - $millisec2)/1000;
|
2010-12-07 23:29:28 +01:00
|
|
|
}
|
2012-07-16 03:17:13 +02:00
|
|
|
|
2010-12-07 23:29:28 +01:00
|
|
|
return $diff;
|
|
|
|
}
|
2012-03-01 15:09:13 +01:00
|
|
|
|
2012-02-22 23:29:49 +01:00
|
|
|
/**
|
2012-03-06 01:02:46 +01:00
|
|
|
* Returns an array of schedule items from cc_schedule table. Tries
|
|
|
|
* to return at least 3 items (if they are available). The parameters
|
|
|
|
* $p_startTime and $p_endTime specify the range. Schedule items returned
|
|
|
|
* do not have to be entirely within this range. It is enough that the end
|
|
|
|
* or beginning of the scheduled item is in the range.
|
2012-04-01 21:51:03 +02:00
|
|
|
*
|
2012-02-22 23:29:49 +01:00
|
|
|
*
|
2012-03-06 01:02:46 +01:00
|
|
|
* @param string $p_startTime
|
2012-02-22 23:29:49 +01:00
|
|
|
* In the format YYYY-MM-DD HH:MM:SS.nnnnnn
|
2012-03-06 01:02:46 +01:00
|
|
|
* @param string $p_endTime
|
2012-02-22 23:29:49 +01:00
|
|
|
* In the format YYYY-MM-DD HH:MM:SS.nnnnnn
|
|
|
|
* @return array
|
2012-03-06 01:02:46 +01:00
|
|
|
* Returns null if nothing found, else an array of associative
|
|
|
|
* arrays representing each row.
|
2012-02-22 23:29:49 +01:00
|
|
|
*/
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetItems($p_startTime, $p_endTime)
|
|
|
|
{
|
2012-04-01 21:51:03 +02:00
|
|
|
global $CC_CONFIG;
|
|
|
|
$con = Propel::getConnection();
|
|
|
|
|
2012-03-01 23:58:44 +01:00
|
|
|
$baseQuery = "SELECT st.file_id AS file_id,"
|
2012-07-06 05:23:44 +02:00
|
|
|
." st.id AS id,"
|
|
|
|
." st.instance_id AS instance_id,"
|
2012-03-01 23:58:44 +01:00
|
|
|
." st.starts AS start,"
|
|
|
|
." st.ends AS end,"
|
|
|
|
." st.cue_in AS cue_in,"
|
|
|
|
." st.cue_out AS cue_out,"
|
|
|
|
." st.fade_in AS fade_in,"
|
|
|
|
." st.fade_out AS fade_out,"
|
2012-07-25 04:24:08 +02:00
|
|
|
." st.type AS type,"
|
2012-07-06 05:23:44 +02:00
|
|
|
." si.starts AS show_start,"
|
|
|
|
." si.ends AS show_end,"
|
2012-07-25 04:24:08 +02:00
|
|
|
." f.id AS file_id"
|
2012-07-06 05:23:44 +02:00
|
|
|
." f.replay_gain AS replay_gain"
|
2012-07-25 04:24:08 +02:00
|
|
|
." f.file_path AS file_path"
|
|
|
|
." ws.id as stream_id"
|
|
|
|
." ws.url as url"
|
2012-07-06 05:23:44 +02:00
|
|
|
." FROM $CC_CONFIG[scheduleTable] AS st"
|
|
|
|
." LEFT JOIN $CC_CONFIG[showInstances] AS si"
|
|
|
|
." ON st.instance_id = si.id"
|
|
|
|
." LEFT JOIN $CC_CONFIG[filesTable] AS f"
|
2012-07-25 04:24:08 +02:00
|
|
|
." ON st.file_id = f.id"
|
|
|
|
." LEFT JOIN cc_webstream AS ws"
|
|
|
|
." ON st.stream_id = ws.id";
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-03-06 01:02:46 +01:00
|
|
|
$predicates = " WHERE st.ends > '$p_startTime'"
|
|
|
|
." AND st.starts < '$p_endTime'"
|
2012-03-30 12:24:55 +02:00
|
|
|
." AND st.playout_status > 0"
|
2012-03-30 23:18:14 +02:00
|
|
|
." AND si.ends > '$p_startTime'"
|
2012-03-01 23:58:44 +01:00
|
|
|
." ORDER BY st.starts";
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-03-01 23:58:44 +01:00
|
|
|
$sql = $baseQuery.$predicates;
|
2012-03-01 15:09:13 +01:00
|
|
|
|
2012-04-01 21:51:03 +02:00
|
|
|
$rows = $con->query($sql)->fetchAll();
|
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
if (count($rows) < 3) {
|
2012-04-01 21:51:03 +02:00
|
|
|
Logging::debug("Get Schedule: Less than 3 results returned. Doing another query since we need a minimum of 3 results.");
|
|
|
|
|
2012-03-01 23:58:44 +01:00
|
|
|
$dt = new DateTime("@".time());
|
2012-04-17 00:38:48 +02:00
|
|
|
$dt->add(new DateInterval("PT24H"));
|
2012-03-01 23:58:44 +01:00
|
|
|
$range_end = $dt->format("Y-m-d H:i:s");
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-03-06 01:02:46 +01:00
|
|
|
$predicates = " WHERE st.ends > '$p_startTime'"
|
2012-03-01 23:58:44 +01:00
|
|
|
." AND st.starts < '$range_end'"
|
2012-03-30 12:24:55 +02:00
|
|
|
." AND st.playout_status > 0"
|
2012-03-30 23:18:14 +02:00
|
|
|
." AND si.ends > '$p_startTime'"
|
2012-03-01 23:58:44 +01:00
|
|
|
." ORDER BY st.starts"
|
|
|
|
." LIMIT 3";
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-03-01 23:58:44 +01:00
|
|
|
$sql = $baseQuery.$predicates;
|
2012-04-01 21:51:03 +02:00
|
|
|
$rows = $con->query($sql)->fetchAll();
|
2012-03-01 23:58:44 +01:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-02-22 23:29:49 +01:00
|
|
|
return $rows;
|
|
|
|
}
|
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetScheduledPlaylists($p_fromDateTime = null, $p_toDateTime = null)
|
|
|
|
{
|
2012-04-01 21:51:03 +02:00
|
|
|
global $CC_CONFIG;
|
2010-12-07 23:29:28 +01:00
|
|
|
|
2012-02-22 23:29:49 +01:00
|
|
|
/* if $p_fromDateTime and $p_toDateTime function parameters are null, then set range
|
|
|
|
* from "now" to "now + 24 hours". */
|
|
|
|
if (is_null($p_fromDateTime)) {
|
|
|
|
$t1 = new DateTime("@".time());
|
|
|
|
$range_start = $t1->format("Y-m-d H:i:s");
|
|
|
|
} else {
|
|
|
|
$range_start = Application_Model_Schedule::PypoTimeToAirtimeTime($p_fromDateTime);
|
|
|
|
}
|
|
|
|
if (is_null($p_fromDateTime)) {
|
|
|
|
$t2 = new DateTime("@".time());
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-03-17 19:53:15 +01:00
|
|
|
$cache_ahead_hours = $CC_CONFIG["cache_ahead_hours"];
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
if (is_numeric($cache_ahead_hours)) {
|
2012-03-17 19:53:15 +01:00
|
|
|
//make sure we are not dealing with a float
|
|
|
|
$cache_ahead_hours = intval($cache_ahead_hours);
|
|
|
|
} else {
|
|
|
|
$cache_ahead_hours = 1;
|
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-03-17 19:53:15 +01:00
|
|
|
$t2->add(new DateInterval("PT".$cache_ahead_hours."H"));
|
2012-02-22 23:29:49 +01:00
|
|
|
$range_end = $t2->format("Y-m-d H:i:s");
|
|
|
|
} else {
|
|
|
|
$range_end = Application_Model_Schedule::PypoTimeToAirtimeTime($p_toDateTime);
|
|
|
|
}
|
2012-03-01 15:09:13 +01:00
|
|
|
|
2012-02-22 23:29:49 +01:00
|
|
|
// Scheduler wants everything in a playlist
|
2012-02-23 02:41:24 +01:00
|
|
|
$items = Application_Model_Schedule::GetItems($range_start, $range_end);
|
2012-03-01 15:09:13 +01:00
|
|
|
|
2012-02-23 02:41:24 +01:00
|
|
|
$data = array();
|
|
|
|
$utcTimeZone = new DateTimeZone("UTC");
|
2012-03-01 15:09:13 +01:00
|
|
|
|
2012-02-27 19:52:35 +01:00
|
|
|
$data["status"] = array();
|
|
|
|
$data["media"] = array();
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-03-29 22:57:28 +02:00
|
|
|
$kick_times = Application_Model_ShowInstance::GetEndTimeOfNextShowWithLiveDJ($range_start, $range_end);
|
2012-07-16 03:17:13 +02:00
|
|
|
foreach ($kick_times as $kick_time_info) {
|
2012-03-29 22:57:28 +02:00
|
|
|
$kick_time = $kick_time_info['ends'];
|
|
|
|
$temp = explode('.', Application_Model_Preference::GetDefaultTransitionFade());
|
|
|
|
// we round down transition time since PHP cannot handle millisecond. We need to
|
|
|
|
// handle this better in the future
|
|
|
|
$transition_time = intval($temp[0]);
|
|
|
|
$switchOffDataTime = new DateTime($kick_time, $utcTimeZone);
|
|
|
|
$switch_off_time = $switchOffDataTime->sub(new DateInterval('PT'.$transition_time.'S'));
|
|
|
|
$switch_off_time = $switch_off_time->format("Y-m-d H:i:s");
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-03-29 22:57:28 +02:00
|
|
|
$kick_start = Application_Model_Schedule::AirtimeTimeToPypoTime($kick_time);
|
|
|
|
$data["media"][$kick_start]['start'] = $kick_start;
|
|
|
|
$data["media"][$kick_start]['end'] = $kick_start;
|
|
|
|
$data["media"][$kick_start]['event_type'] = "kick_out";
|
|
|
|
$data["media"][$kick_start]['type'] = "event";
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
if ($kick_time !== $switch_off_time) {
|
2012-06-28 04:50:46 +02:00
|
|
|
$switch_start = Application_Model_Schedule::AirtimeTimeToPypoTime($switch_off_time);
|
|
|
|
$data["media"][$switch_start]['start'] = $switch_start;
|
|
|
|
$data["media"][$switch_start]['end'] = $switch_start;
|
2012-03-29 22:57:28 +02:00
|
|
|
$data["media"][$switch_start]['event_type'] = "switch_off";
|
|
|
|
$data["media"][$switch_start]['type'] = "event";
|
|
|
|
}
|
2012-03-28 21:12:01 +02:00
|
|
|
}
|
2012-03-01 15:09:13 +01:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
foreach ($items as $item) {
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-04-12 01:22:47 +02:00
|
|
|
$showInstance = CcShowInstancesQuery::create()->findPK($item["instance_id"]);
|
|
|
|
$showId = $showInstance->getDbShowId();
|
|
|
|
$show = CcShowQuery::create()->findPK($showId);
|
|
|
|
$showName = $show->getDbName();
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-02-23 02:41:24 +01:00
|
|
|
$showEndDateTime = new DateTime($item["show_end"], $utcTimeZone);
|
2012-03-23 17:49:50 +01:00
|
|
|
$trackStartDateTime = new DateTime($item["start"], $utcTimeZone);
|
2012-02-27 19:52:35 +01:00
|
|
|
$trackEndDateTime = new DateTime($item["end"], $utcTimeZone);
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
if ($trackStartDateTime->getTimestamp() > $showEndDateTime->getTimestamp()) {
|
2012-04-11 05:13:52 +02:00
|
|
|
continue;
|
|
|
|
}
|
2012-03-01 15:09:13 +01:00
|
|
|
|
2012-02-23 17:21:16 +01:00
|
|
|
/* Note: cue_out and end are always the same. */
|
|
|
|
/* TODO: Not all tracks will have "show_end" */
|
2012-07-16 03:17:13 +02:00
|
|
|
if ($trackEndDateTime->getTimestamp() > $showEndDateTime->getTimestamp()) {
|
2012-03-23 17:49:50 +01:00
|
|
|
$di = $trackStartDateTime->diff($showEndDateTime);
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-03-23 17:49:50 +01:00
|
|
|
$item["cue_out"] = $di->format("%H:%i:%s").".000";
|
2012-04-11 05:13:52 +02:00
|
|
|
$item["end"] = $showEndDateTime->format("Y-m-d H:i:s");
|
2012-02-23 02:41:24 +01:00
|
|
|
}
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-07-25 04:24:08 +02:00
|
|
|
Logging::log($item);
|
|
|
|
//TODO: need to know item type
|
|
|
|
//
|
|
|
|
//
|
|
|
|
if ($item['type'] == 0) {
|
|
|
|
//row is from cc_files
|
|
|
|
$media_id = $item['file_id'];
|
|
|
|
$uri = $item['file_path'];
|
|
|
|
$type = "file";
|
|
|
|
} else if ($item['type'] == 1) {
|
|
|
|
$media_id = $item['stream_id'];
|
|
|
|
$uri = $item['url'];
|
|
|
|
$type = "stream";
|
|
|
|
}
|
|
|
|
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-03-01 15:09:13 +01:00
|
|
|
$start = Application_Model_Schedule::AirtimeTimeToPypoTime($item["start"]);
|
2012-07-25 04:24:08 +02:00
|
|
|
|
2012-02-27 19:52:35 +01:00
|
|
|
$data["media"][$start] = array(
|
2012-07-25 04:24:08 +02:00
|
|
|
'id' => $media_id,
|
|
|
|
'type' => $type,
|
2012-02-29 04:33:19 +01:00
|
|
|
'row_id' => $item["id"],
|
2012-02-23 02:41:24 +01:00
|
|
|
'uri' => $uri,
|
|
|
|
'fade_in' => Application_Model_Schedule::WallTimeToMillisecs($item["fade_in"]),
|
|
|
|
'fade_out' => Application_Model_Schedule::WallTimeToMillisecs($item["fade_out"]),
|
2012-04-13 23:45:28 +02:00
|
|
|
'cue_in' => Application_Common_DateHelper::CalculateLengthInSeconds($item["cue_in"]),
|
|
|
|
'cue_out' => Application_Common_DateHelper::CalculateLengthInSeconds($item["cue_out"]),
|
2012-02-27 19:52:35 +01:00
|
|
|
'start' => $start,
|
2012-04-12 01:22:47 +02:00
|
|
|
'end' => Application_Model_Schedule::AirtimeTimeToPypoTime($item["end"]),
|
2012-07-06 05:23:44 +02:00
|
|
|
'show_name' => $showName,
|
2012-07-16 04:13:04 +02:00
|
|
|
'replay_gain' => is_null($item["replay_gain"]) ? "0": $item["replay_gain"]
|
2012-02-23 02:41:24 +01:00
|
|
|
);
|
|
|
|
}
|
2012-03-01 15:09:13 +01:00
|
|
|
|
2012-02-22 23:29:49 +01:00
|
|
|
return $data;
|
|
|
|
}
|
2010-12-07 23:29:28 +01:00
|
|
|
|
2011-04-25 22:48:34 +02:00
|
|
|
public static function deleteAll()
|
|
|
|
{
|
2012-04-01 21:51:03 +02:00
|
|
|
global $CC_CONFIG;
|
|
|
|
$con = Propel::getConnection();
|
|
|
|
$con->exec("TRUNCATE TABLE ".$CC_CONFIG["scheduleTable"]);
|
2011-04-25 22:48:34 +02:00
|
|
|
}
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function deleteWithFileId($fileId)
|
|
|
|
{
|
2012-04-13 21:03:27 +02:00
|
|
|
global $CC_CONFIG;
|
|
|
|
$con = Propel::getConnection();
|
|
|
|
$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"]." WHERE file_id=$fileId";
|
|
|
|
$res = $con->query($sql);
|
2012-04-12 22:17:19 +02:00
|
|
|
}
|
2011-07-19 12:37:06 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function createNewFormSections($p_view)
|
|
|
|
{
|
2011-09-02 21:24:35 +02:00
|
|
|
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
2012-01-23 19:07:07 +01:00
|
|
|
|
2011-06-03 20:01:58 +02:00
|
|
|
$formWhat = new Application_Form_AddShowWhat();
|
2012-07-11 00:51:32 +02:00
|
|
|
$formWho = new Application_Form_AddShowWho();
|
|
|
|
$formWhen = new Application_Form_AddShowWhen();
|
|
|
|
$formRepeats = new Application_Form_AddShowRepeats();
|
|
|
|
$formStyle = new Application_Form_AddShowStyle();
|
|
|
|
$formLive = new Application_Form_AddShowLiveStream();
|
|
|
|
|
|
|
|
$formWhat->removeDecorator('DtDdWrapper');
|
|
|
|
$formWho->removeDecorator('DtDdWrapper');
|
|
|
|
$formWhen->removeDecorator('DtDdWrapper');
|
|
|
|
$formRepeats->removeDecorator('DtDdWrapper');
|
|
|
|
$formStyle->removeDecorator('DtDdWrapper');
|
|
|
|
$formLive->removeDecorator('DtDdWrapper');
|
2011-07-19 12:37:06 +02:00
|
|
|
|
2011-06-03 20:01:58 +02:00
|
|
|
$p_view->what = $formWhat;
|
|
|
|
$p_view->when = $formWhen;
|
|
|
|
$p_view->repeats = $formRepeats;
|
|
|
|
$p_view->who = $formWho;
|
|
|
|
$p_view->style = $formStyle;
|
2012-02-08 06:04:19 +01:00
|
|
|
$p_view->live = $formLive;
|
2011-07-19 12:37:06 +02:00
|
|
|
|
2012-07-11 00:51:32 +02:00
|
|
|
$formWhat->populate(array('add_show_id' => '-1',
|
2012-04-12 17:54:51 +02:00
|
|
|
'add_show_instance_id' => '-1'));
|
2011-06-13 20:20:57 +02:00
|
|
|
$formWhen->populate(array('add_show_start_date' => date("Y-m-d"),
|
|
|
|
'add_show_start_time' => '00:00',
|
2012-02-17 22:47:12 +01:00
|
|
|
'add_show_end_date_no_repeate' => date("Y-m-d"),
|
|
|
|
'add_show_end_time' => '01:00',
|
2012-04-27 20:07:14 +02:00
|
|
|
'add_show_duration' => '01h 00m'));
|
2011-06-13 20:20:57 +02:00
|
|
|
|
2012-02-17 22:47:12 +01:00
|
|
|
$formRepeats->populate(array('add_show_end_date' => date("Y-m-d")));
|
2012-01-23 19:07:07 +01:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
if (!$isSaas) {
|
2011-09-02 21:24:35 +02:00
|
|
|
$formRecord = new Application_Form_AddShowRR();
|
|
|
|
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
|
|
|
|
$formRebroadcast = new Application_Form_AddShowRebroadcastDates();
|
2012-01-23 19:07:07 +01:00
|
|
|
|
2011-09-02 21:24:35 +02:00
|
|
|
$formRecord->removeDecorator('DtDdWrapper');
|
|
|
|
$formAbsoluteRebroadcast->removeDecorator('DtDdWrapper');
|
|
|
|
$formRebroadcast->removeDecorator('DtDdWrapper');
|
2012-01-23 19:07:07 +01:00
|
|
|
|
2011-09-02 21:24:35 +02:00
|
|
|
$p_view->rr = $formRecord;
|
|
|
|
$p_view->absoluteRebroadcast = $formAbsoluteRebroadcast;
|
|
|
|
$p_view->rebroadcast = $formRebroadcast;
|
|
|
|
}
|
|
|
|
$p_view->addNewShow = true;
|
2011-06-03 20:01:58 +02:00
|
|
|
}
|
2012-07-11 00:51:32 +02:00
|
|
|
|
|
|
|
/* This function is responsible for handling the case where an individual
|
2012-04-12 19:29:49 +02:00
|
|
|
* show instance in a repeating show was edited (via the context menu in the Calendar).
|
|
|
|
* There is still lots of clean-up to do. For example we shouldn't be passing $controller into
|
|
|
|
* this method to manipulate the view (this should be done inside the controller function). With
|
|
|
|
* 2.1 deadline looming, this is OK for now. -Martin */
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function updateShowInstance($data, $controller)
|
|
|
|
{
|
2012-04-12 21:10:40 +02:00
|
|
|
$isSaas = (Application_Model_Preference::GetPlanLevel() != 'disabled');
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-04-12 19:29:49 +02:00
|
|
|
$formWhat = new Application_Form_AddShowWhat();
|
2012-07-11 00:51:32 +02:00
|
|
|
$formWhen = new Application_Form_AddShowWhen();
|
|
|
|
$formRepeats = new Application_Form_AddShowRepeats();
|
|
|
|
$formWho = new Application_Form_AddShowWho();
|
|
|
|
$formStyle = new Application_Form_AddShowStyle();
|
|
|
|
$formLive = new Application_Form_AddShowLiveStream();
|
|
|
|
|
|
|
|
$formWhat->removeDecorator('DtDdWrapper');
|
|
|
|
$formWhen->removeDecorator('DtDdWrapper');
|
|
|
|
$formRepeats->removeDecorator('DtDdWrapper');
|
|
|
|
$formWho->removeDecorator('DtDdWrapper');
|
|
|
|
$formStyle->removeDecorator('DtDdWrapper');
|
|
|
|
$formLive->removeDecorator('DtDdWrapper');
|
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
if (!$isSaas) {
|
2012-04-12 19:29:49 +02:00
|
|
|
$formRecord = new Application_Form_AddShowRR();
|
|
|
|
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
|
|
|
|
$formRebroadcast = new Application_Form_AddShowRebroadcastDates();
|
|
|
|
|
|
|
|
$formRecord->removeDecorator('DtDdWrapper');
|
|
|
|
$formAbsoluteRebroadcast->removeDecorator('DtDdWrapper');
|
|
|
|
$formRebroadcast->removeDecorator('DtDdWrapper');
|
|
|
|
}
|
|
|
|
$when = $formWhen->isValid($data);
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
if ($when && $formWhen->checkReliantFields($data, true, null, true)) {
|
2012-04-12 19:29:49 +02:00
|
|
|
$start_dt = new DateTime($data['add_show_start_date']." ".$data['add_show_start_time'], new DateTimeZone(date_default_timezone_get()));
|
|
|
|
$start_dt->setTimezone(new DateTimeZone('UTC'));
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-04-12 19:29:49 +02:00
|
|
|
$end_dt = new DateTime($data['add_show_end_date_no_repeat']." ".$data['add_show_end_time'], new DateTimeZone(date_default_timezone_get()));
|
|
|
|
$end_dt->setTimezone(new DateTimeZone('UTC'));
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-04-12 19:29:49 +02:00
|
|
|
$ccShowInstance = CcShowInstancesQuery::create()->findPK($data["add_show_instance_id"]);
|
|
|
|
$ccShowInstance->setDbStarts($start_dt);
|
|
|
|
$ccShowInstance->setDbEnds($end_dt);
|
2012-07-11 00:51:32 +02:00
|
|
|
$ccShowInstance->save();
|
|
|
|
|
2012-04-12 19:29:49 +02:00
|
|
|
Application_Model_Schedule::createNewFormSections($controller->view);
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-04-12 19:29:49 +02:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
$formWhat->disable();
|
|
|
|
$formWhen->disableRepeatCheckbox();
|
|
|
|
$formRepeats->disable();
|
|
|
|
$formWho->disable();
|
|
|
|
$formStyle->disable();
|
|
|
|
//$formLive->disable();
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-04-12 19:29:49 +02:00
|
|
|
$controller->view->what = $formWhat;
|
|
|
|
$controller->view->when = $formWhen;
|
|
|
|
$controller->view->repeats = $formRepeats;
|
|
|
|
$controller->view->who = $formWho;
|
|
|
|
$controller->view->style = $formStyle;
|
2012-07-11 00:51:32 +02:00
|
|
|
$controller->view->live = $formLive;
|
2012-07-16 03:17:13 +02:00
|
|
|
if (!$isSaas) {
|
2012-04-12 19:29:49 +02:00
|
|
|
$controller->view->rr = $formRecord;
|
|
|
|
$controller->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
|
|
|
|
$controller->view->rebroadcast = $formRebroadcast;
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-04-12 19:29:49 +02:00
|
|
|
//$formRecord->disable();
|
|
|
|
//$formAbsoluteRebroadcast->disable();
|
|
|
|
//$formRebroadcast->disable();
|
|
|
|
}
|
2012-07-16 03:17:13 +02:00
|
|
|
|
2012-04-12 19:29:49 +02:00
|
|
|
return false;
|
2012-07-11 00:51:32 +02:00
|
|
|
}
|
2012-04-12 19:29:49 +02:00
|
|
|
}
|
2012-07-11 00:51:32 +02:00
|
|
|
|
|
|
|
/* This function is responsible for handling the case where the entire show (not a single show instance)
|
2012-04-12 19:29:49 +02:00
|
|
|
* was edited (via the context menu in the Calendar).
|
|
|
|
* There is still lots of clean-up to do. For example we shouldn't be passing $controller into
|
|
|
|
* this method to manipulate the view (this should be done inside the controller function). With
|
|
|
|
* 2.1 deadline looming, this is OK for now.
|
|
|
|
* Another clean-up is to move all the form manipulation to the proper form class.....
|
2012-07-11 00:51:32 +02:00
|
|
|
* -Martin
|
2012-04-12 19:29:49 +02:00
|
|
|
*/
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function addUpdateShow($data, $controller, $validateStartDate, $originalStartDate=null, $update=false, $instanceId=null)
|
|
|
|
{
|
2012-04-11 22:45:03 +02:00
|
|
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
|
|
|
$user = new Application_Model_User($userInfo->id);
|
|
|
|
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
|
|
|
|
2012-04-12 21:10:40 +02:00
|
|
|
$isSaas = (Application_Model_Preference::GetPlanLevel() != 'disabled');
|
2012-04-11 22:45:03 +02:00
|
|
|
$record = false;
|
|
|
|
|
|
|
|
$formWhat = new Application_Form_AddShowWhat();
|
2012-07-11 00:51:32 +02:00
|
|
|
$formWho = new Application_Form_AddShowWho();
|
|
|
|
$formWhen = new Application_Form_AddShowWhen();
|
|
|
|
$formRepeats = new Application_Form_AddShowRepeats();
|
|
|
|
$formStyle = new Application_Form_AddShowStyle();
|
|
|
|
$formLive = new Application_Form_AddShowLiveStream();
|
|
|
|
|
|
|
|
$formWhat->removeDecorator('DtDdWrapper');
|
|
|
|
$formWho->removeDecorator('DtDdWrapper');
|
|
|
|
$formWhen->removeDecorator('DtDdWrapper');
|
|
|
|
$formRepeats->removeDecorator('DtDdWrapper');
|
|
|
|
$formStyle->removeDecorator('DtDdWrapper');
|
|
|
|
$formLive->removeDecorator('DtDdWrapper');
|
|
|
|
|
|
|
|
$what = $formWhat->isValid($data);
|
|
|
|
$when = $formWhen->isValid($data);
|
|
|
|
$live = $formLive->isValid($data);
|
2012-07-16 03:17:13 +02:00
|
|
|
if ($when) {
|
2012-07-05 00:58:22 +02:00
|
|
|
$when = $formWhen->checkReliantFields($data, $validateStartDate, $originalStartDate, $update, $instanceId);
|
2012-04-11 22:45:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//The way the following code works is that is parses the hour and
|
|
|
|
//minute from a string with the format "1h 20m" or "2h" or "36m".
|
|
|
|
//So we are detecting whether an hour or minute value exists via strpos
|
|
|
|
//and then parse appropriately. A better way to do this in the future is
|
|
|
|
//actually pass the format from javascript in the format hh:mm so we don't
|
|
|
|
//have to do this extra String parsing.
|
|
|
|
$hPos = strpos($data["add_show_duration"], 'h');
|
|
|
|
$mPos = strpos($data["add_show_duration"], 'm');
|
|
|
|
|
|
|
|
$hValue = 0;
|
|
|
|
$mValue = 0;
|
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
if ($hPos !== false) {
|
2012-07-11 00:51:32 +02:00
|
|
|
$hValue = trim(substr($data["add_show_duration"], 0, $hPos));
|
2012-04-11 22:45:03 +02:00
|
|
|
}
|
2012-07-16 03:17:13 +02:00
|
|
|
if ($mPos !== false) {
|
2012-04-11 22:45:03 +02:00
|
|
|
$hPos = $hPos === FALSE ? 0 : $hPos+1;
|
2012-07-11 00:51:32 +02:00
|
|
|
$mValue = trim(substr($data["add_show_duration"], $hPos, -1 ));
|
2012-04-11 22:45:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$data["add_show_duration"] = $hValue.":".$mValue;
|
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
if (!$isSaas) {
|
2012-04-11 22:45:03 +02:00
|
|
|
$formRecord = new Application_Form_AddShowRR();
|
|
|
|
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
|
|
|
|
$formRebroadcast = new Application_Form_AddShowRebroadcastDates();
|
|
|
|
|
|
|
|
$formRecord->removeDecorator('DtDdWrapper');
|
|
|
|
$formAbsoluteRebroadcast->removeDecorator('DtDdWrapper');
|
|
|
|
$formRebroadcast->removeDecorator('DtDdWrapper');
|
|
|
|
|
|
|
|
|
|
|
|
$record = $formRecord->isValid($data);
|
|
|
|
}
|
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
if ($data["add_show_repeats"]) {
|
2012-07-11 00:51:32 +02:00
|
|
|
$repeats = $formRepeats->isValid($data);
|
2012-07-16 03:17:13 +02:00
|
|
|
if ($repeats) {
|
2012-04-11 22:45:03 +02:00
|
|
|
$repeats = $formRepeats->checkReliantFields($data);
|
|
|
|
}
|
2012-07-16 03:17:13 +02:00
|
|
|
if (!$isSaas) {
|
2012-04-11 22:45:03 +02:00
|
|
|
$formAbsoluteRebroadcast->reset();
|
|
|
|
//make it valid, results don't matter anyways.
|
|
|
|
$rebroadAb = 1;
|
|
|
|
|
|
|
|
if ($data["add_show_rebroadcast"]) {
|
|
|
|
$rebroad = $formRebroadcast->isValid($data);
|
2012-07-16 03:17:13 +02:00
|
|
|
if ($rebroad) {
|
2012-04-11 22:45:03 +02:00
|
|
|
$rebroad = $formRebroadcast->checkReliantFields($data);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$rebroad = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$repeats = 1;
|
2012-07-16 03:17:13 +02:00
|
|
|
if (!$isSaas) {
|
2012-04-11 22:45:03 +02:00
|
|
|
$formRebroadcast->reset();
|
|
|
|
//make it valid, results don't matter anyways.
|
|
|
|
$rebroad = 1;
|
|
|
|
|
|
|
|
if ($data["add_show_rebroadcast"]) {
|
|
|
|
$rebroadAb = $formAbsoluteRebroadcast->isValid($data);
|
2012-07-16 03:17:13 +02:00
|
|
|
if ($rebroadAb) {
|
2012-04-11 22:45:03 +02:00
|
|
|
$rebroadAb = $formAbsoluteRebroadcast->checkReliantFields($data);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$rebroadAb = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-11 00:51:32 +02:00
|
|
|
$who = $formWho->isValid($data);
|
|
|
|
$style = $formStyle->isValid($data);
|
2012-04-11 22:45:03 +02:00
|
|
|
if ($what && $when && $repeats && $who && $style && $live) {
|
2012-07-16 03:17:13 +02:00
|
|
|
if (!$isSaas) {
|
|
|
|
if ($record && $rebroadAb && $rebroad) {
|
2012-04-11 22:45:03 +02:00
|
|
|
if ($isAdminOrPM) {
|
|
|
|
Application_Model_Show::create($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
//send back a new form for the user.
|
|
|
|
Application_Model_Schedule::createNewFormSections($controller->view);
|
|
|
|
|
|
|
|
//$controller->view->newForm = $controller->view->render('schedule/add-show-form.phtml');
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
$controller->view->what = $formWhat;
|
|
|
|
$controller->view->when = $formWhen;
|
|
|
|
$controller->view->repeats = $formRepeats;
|
|
|
|
$controller->view->who = $formWho;
|
|
|
|
$controller->view->style = $formStyle;
|
|
|
|
$controller->view->rr = $formRecord;
|
|
|
|
$controller->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
|
|
|
|
$controller->view->rebroadcast = $formRebroadcast;
|
|
|
|
$controller->view->live = $formLive;
|
|
|
|
//$controller->view->addNewShow = !$editShow;
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-04-11 22:45:03 +02:00
|
|
|
//$controller->view->form = $controller->view->render('schedule/add-show-form.phtml');
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ($isAdminOrPM) {
|
|
|
|
Application_Model_Show::create($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
//send back a new form for the user.
|
|
|
|
Application_Model_Schedule::createNewFormSections($controller->view);
|
|
|
|
|
|
|
|
//$controller->view->newForm = $controller->view->render('schedule/add-show-form.phtml');
|
|
|
|
return true;
|
|
|
|
}
|
2012-07-11 00:51:32 +02:00
|
|
|
} else {
|
2012-04-11 22:45:03 +02:00
|
|
|
$controller->view->what = $formWhat;
|
|
|
|
$controller->view->when = $formWhen;
|
|
|
|
$controller->view->repeats = $formRepeats;
|
|
|
|
$controller->view->who = $formWho;
|
|
|
|
$controller->view->style = $formStyle;
|
|
|
|
$controller->view->live = $formLive;
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
if (!$isSaas) {
|
2012-04-11 22:45:03 +02:00
|
|
|
$controller->view->rr = $formRecord;
|
|
|
|
$controller->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
|
|
|
|
$controller->view->rebroadcast = $formRebroadcast;
|
|
|
|
}
|
|
|
|
//$controller->view->addNewShow = !$editShow;
|
|
|
|
//$controller->view->form = $controller->view->render('schedule/add-show-form.phtml');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function checkOverlappingShows($show_start, $show_end, $update=false, $instanceId=null)
|
|
|
|
{
|
2012-07-04 17:34:18 +02:00
|
|
|
global $CC_CONFIG;
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-07-04 17:34:18 +02:00
|
|
|
$overlapping = false;
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-07-04 17:34:18 +02:00
|
|
|
$con = Propel::getConnection();
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-07-05 00:58:22 +02:00
|
|
|
if ($update) {
|
|
|
|
$sql = "SELECT id, starts, ends FROM ".$CC_CONFIG["showInstances"]."
|
2012-07-05 17:24:49 +02:00
|
|
|
where ends <= '{$show_end->format('Y-m-d H:i:s')}'
|
2012-07-05 00:58:22 +02:00
|
|
|
and id != ".$instanceId. " order by ends";
|
|
|
|
} else {
|
|
|
|
$sql = "SELECT id, starts, ends FROM ".$CC_CONFIG["showInstances"]."
|
2012-07-05 17:24:49 +02:00
|
|
|
where ends <= '{$show_end->format('Y-m-d H:i:s')}' order by ends";
|
2012-07-05 00:58:22 +02:00
|
|
|
}
|
|
|
|
$rows = $con->query($sql);
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
foreach ($rows as $row) {
|
2012-07-05 00:58:22 +02:00
|
|
|
$start = new DateTime($row["starts"], new DateTimeZone('UTC'));
|
|
|
|
$end = new DateTime($row["ends"], new DateTimeZone('UTC'));
|
2012-07-04 17:34:18 +02:00
|
|
|
|
2012-07-11 00:51:32 +02:00
|
|
|
if ($show_start->getTimestamp() < $end->getTimestamp() &&
|
2012-07-05 17:24:49 +02:00
|
|
|
$show_end->getTimestamp() > $start->getTimestamp()) {
|
2012-07-04 17:34:18 +02:00
|
|
|
$overlapping = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-07-16 03:17:13 +02:00
|
|
|
|
2012-07-04 17:34:18 +02:00
|
|
|
return $overlapping;
|
|
|
|
}
|
2012-07-20 00:07:39 +02:00
|
|
|
|
|
|
|
public static function GetFileId($p_scheduleId)
|
|
|
|
{
|
|
|
|
$scheduledItem = CcScheduleQuery::create()->findPK($p_scheduleId);
|
|
|
|
return $scheduledItem->getDbFileId();
|
|
|
|
}
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|