Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
33326ec052
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
class Application_Common_Database
|
||||
{
|
||||
public static function prepareAndExecute($sql, array $paramValueMap,
|
||||
public static function prepareAndExecute($sql, array $paramValueMap,
|
||||
$type='all', $fetchType=PDO::FETCH_ASSOC)
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
|
@ -15,8 +15,13 @@ class Application_Common_Database
|
|||
$rows = $stmt->fetch($fetchType);
|
||||
} else if ($type == 'column'){
|
||||
$rows = $stmt->fetchColumn();
|
||||
} else {
|
||||
} else if ($type == 'all') {
|
||||
$rows = $stmt->fetchAll($fetchType);
|
||||
} else if ($type == 'execute') {
|
||||
$rows = null;
|
||||
} else {
|
||||
$msg = "bad type passed: type($type)";
|
||||
throw new Exception("Error: $msg");
|
||||
}
|
||||
} else {
|
||||
$msg = implode(',', $stmt->errorInfo());
|
||||
|
|
|
@ -175,7 +175,7 @@ class Application_Model_Playlist implements Application_Model_LibraryEditable
|
|||
f.length AS orig_length
|
||||
FROM cc_playlistcontents AS pc
|
||||
JOIN cc_files AS f ON pc.file_id=f.id
|
||||
WHERE pc.playlist_id = {$this->id}
|
||||
WHERE pc.playlist_id = :playlist_id1
|
||||
AND TYPE = 0)
|
||||
UNION ALL
|
||||
(SELECT pc.id AS id,
|
||||
|
@ -194,7 +194,7 @@ class Application_Model_Playlist implements Application_Model_LibraryEditable
|
|||
FROM cc_playlistcontents AS pc
|
||||
JOIN cc_webstream AS ws ON pc.stream_id=ws.id
|
||||
LEFT JOIN cc_subjs AS sub ON sub.id = ws.creator_id
|
||||
WHERE pc.playlist_id = {$this->id}
|
||||
WHERE pc.playlist_id = :playlist_id2
|
||||
AND pc.TYPE = 1)
|
||||
UNION ALL
|
||||
(SELECT pc.id AS id,
|
||||
|
@ -213,13 +213,12 @@ class Application_Model_Playlist implements Application_Model_LibraryEditable
|
|||
FROM cc_playlistcontents AS pc
|
||||
JOIN cc_block AS bl ON pc.block_id=bl.id
|
||||
JOIN cc_subjs AS sbj ON bl.creator_id=sbj.id
|
||||
WHERE pc.playlist_id = {$this->id}
|
||||
WHERE pc.playlist_id = :playlist_id3
|
||||
AND pc.TYPE = 2)) AS temp
|
||||
ORDER BY temp.position;
|
||||
SQL;
|
||||
|
||||
$con = Propel::getConnection();
|
||||
$rows = $con->query($sql)->fetchAll(PDO::FETCH_ASSOC);
|
||||
$rows = Application_Common_Database::prepareAndExecute($sql, array(':playlist_id1'=>$this->id, ':playlist_id2'=>$this->id, ':playlist_id3'=>$this->id));
|
||||
|
||||
$offset = 0;
|
||||
foreach ($rows as &$row) {
|
||||
|
@ -291,9 +290,9 @@ SQL;
|
|||
{
|
||||
$sql = "SELECT bl.id FROM cc_playlistcontents as pc
|
||||
JOIN cc_block as bl ON pc.type=2 AND pc.block_id=bl.id AND bl.type='dynamic'
|
||||
WHERE playlist_id={$this->id} AND pc.type=2";
|
||||
$r = $this->con->query($sql);
|
||||
$result = $r->fetchAll(PDO::FETCH_ASSOC);
|
||||
WHERE playlist_id=:playlist_id AND pc.type=2";
|
||||
|
||||
$result = Application_Common_Database::prepareAndExecute($sql, array(':playlist_id'=>$this->id));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
@ -625,9 +624,8 @@ SQL;
|
|||
|
||||
if (!is_null($fadeIn)) {
|
||||
|
||||
$sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$clipLength}'";
|
||||
$r = $this->con->query($sql);
|
||||
if ($r->fetchColumn(0)) {
|
||||
$sql = "SELECT INTERVAL :fadein > INTERVAL '{$clipLength}'";
|
||||
if (Application_Common_Database::prepareAndExecute($sql, array(':fadein'=>$fadeIn), 'column')) {
|
||||
//"Fade In can't be larger than overall playlength.";
|
||||
$fadeIn = $clipLength;
|
||||
}
|
||||
|
@ -635,9 +633,8 @@ SQL;
|
|||
}
|
||||
if (!is_null($fadeOut)) {
|
||||
|
||||
$sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$clipLength}'";
|
||||
$r = $this->con->query($sql);
|
||||
if ($r->fetchColumn(0)) {
|
||||
$sql = "SELECT INTERVAL :fadeout > INTERVAL '{$clipLength}'";
|
||||
if (Application_Common_Database::prepareAndExecute($sql, array(':fadeout'=>$fadeOut), 'column')) {
|
||||
//Fade Out can't be larger than overall playlength.";
|
||||
$fadeOut = $clipLength;
|
||||
}
|
||||
|
@ -727,25 +724,22 @@ SQL;
|
|||
$cueOut = $origLength;
|
||||
}
|
||||
|
||||
$sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$cueOut}'";
|
||||
$r = $this->con->query($sql);
|
||||
if ($r->fetchColumn(0)) {
|
||||
$sql = "SELECT INTERVAL :cueIn > INTERVAL :cueOut";
|
||||
if (Application_Common_Database::prepareAndExecute($sql, array(':cueIn'=>$cueIn, ':cueOut'=>$cueOut), 'column')) {
|
||||
$errArray["error"] = "Can't set cue in to be larger than cue out.";
|
||||
|
||||
return $errArray;
|
||||
}
|
||||
|
||||
$sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'";
|
||||
$r = $this->con->query($sql);
|
||||
if ($r->fetchColumn(0)) {
|
||||
$sql = "SELECT INTERVAL :cueOut > INTERVAL :origLength";
|
||||
if (Application_Common_Database::prepareAndExecute($sql, array(':cueOut'=>$cueOut, ':origLength'=>$origLength), 'column')) {
|
||||
$errArray["error"] = "Can't set cue out to be greater than file length.";
|
||||
|
||||
return $errArray;
|
||||
}
|
||||
|
||||
$sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$cueIn}'";
|
||||
$r = $this->con->query($sql);
|
||||
$cliplength = $r->fetchColumn(0);
|
||||
$sql = "SELECT INTERVAL :cueOut - INTERVAL :cueIn";
|
||||
$cliplength = Application_Common_Database::prepareAndExecute($sql, array(':cueOut'=>$cueOut, ':cueIn'=>$cueIn), 'column');
|
||||
|
||||
$row->setDbCuein($cueIn);
|
||||
$row->setDbCueout($cueOut);
|
||||
|
@ -753,17 +747,15 @@ SQL;
|
|||
|
||||
} elseif (!is_null($cueIn)) {
|
||||
|
||||
$sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$oldCueOut}'";
|
||||
$r = $this->con->query($sql);
|
||||
if ($r->fetchColumn(0)) {
|
||||
$sql = "SELECT INTERVAL :cueIn > INTERVAL :oldCueOut";
|
||||
if (Application_Common_Database::prepareAndExecute($sql, array(':cueIn'=>$cueIn, ':oldCueOut'=>$oldCueOut), 'column')) {
|
||||
$errArray["error"] = "Can't set cue in to be larger than cue out.";
|
||||
|
||||
return $errArray;
|
||||
}
|
||||
|
||||
$sql = "SELECT INTERVAL '{$oldCueOut}' - INTERVAL '{$cueIn}'";
|
||||
$r = $this->con->query($sql);
|
||||
$cliplength = $r->fetchColumn(0);
|
||||
$sql = "SELECT INTERVAL :oldCueOut - INTERVAL :cueIn";
|
||||
$cliplength = Application_Common_Database::prepareAndExecute($sql, array(':cueIn'=>$cueIn, ':oldCueOut'=>$oldCueOut, 'column'));
|
||||
|
||||
$row->setDbCuein($cueIn);
|
||||
$row->setDBCliplength($cliplength);
|
||||
|
@ -773,25 +765,22 @@ SQL;
|
|||
$cueOut = $origLength;
|
||||
}
|
||||
|
||||
$sql = "SELECT INTERVAL '{$cueOut}' < INTERVAL '{$oldCueIn}'";
|
||||
$r = $this->con->query($sql);
|
||||
if ($r->fetchColumn(0)) {
|
||||
$sql = "SELECT INTERVAL :cueOut < INTERVAL :oldCueIn";
|
||||
if (Application_Common_Database::prepareAndExecute($sql, array(':cueOut'=>$cueOut, ':oldCueIn'=>$oldCueIn, 'column'))) {
|
||||
$errArray["error"] = "Can't set cue out to be smaller than cue in.";
|
||||
|
||||
return $errArray;
|
||||
}
|
||||
|
||||
$sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'";
|
||||
$r = $this->con->query($sql);
|
||||
if ($r->fetchColumn(0)) {
|
||||
$sql = "SELECT INTERVAL :cueOut > INTERVAL :origLength";
|
||||
if (Application_Common_Database::prepareAndExecute($sql, array(':cueOut'=>$cueOut, ':origLength'=>$origLength, 'column'))) {
|
||||
$errArray["error"] = "Can't set cue out to be greater than file length.";
|
||||
|
||||
return $errArray;
|
||||
}
|
||||
|
||||
$sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$oldCueIn}'";
|
||||
$r = $this->con->query($sql);
|
||||
$cliplength = $r->fetchColumn(0);
|
||||
$sql = "SELECT INTERVAL :cueOut - INTERVAL :oldCueIn";
|
||||
$cliplength = Application_Common_Database::prepareAndExecute($sql, array(':cueOut'=>$cueOut, ':oldCueIn'=>$oldCueIn, 'column'));
|
||||
|
||||
$row->setDbCueout($cueOut);
|
||||
$row->setDBCliplength($cliplength);
|
||||
|
@ -799,16 +788,14 @@ SQL;
|
|||
|
||||
$cliplength = $row->getDbCliplength();
|
||||
|
||||
$sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$cliplength}'";
|
||||
$r = $this->con->query($sql);
|
||||
if ($r->fetchColumn(0)) {
|
||||
$sql = "SELECT INTERVAL :fadeIn > INTERVAL :cliplength";
|
||||
if (Application_Common_Database::prepareAndExecute($sql, array(':fadeIn'=>$fadeIn, ':cliplength'=>$cliplength, 'column'))) {
|
||||
$fadeIn = $cliplength;
|
||||
$row->setDbFadein($fadeIn);
|
||||
}
|
||||
|
||||
$sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$cliplength}'";
|
||||
$r = $this->con->query($sql);
|
||||
if ($r->fetchColumn(0)) {
|
||||
$sql = "SELECT INTERVAL :fadeOut > INTERVAL :cliplength";
|
||||
if (Application_Common_Database::prepareAndExecute($sql, array(':fadeOut'=>$fadeOut, ':cliplength'=>$cliplength, 'column'))) {
|
||||
$fadeOut = $cliplength;
|
||||
$row->setDbFadein($fadeOut);
|
||||
}
|
||||
|
|
|
@ -18,48 +18,57 @@ class Application_Model_Preference
|
|||
|
||||
//Check if key already exists
|
||||
$sql = "SELECT COUNT(*) FROM cc_pref"
|
||||
." WHERE keystr = '$key'";
|
||||
|
||||
." WHERE keystr = :key";
|
||||
|
||||
$paramMap = array();
|
||||
$paramMap[':key'] = $key;
|
||||
|
||||
//For user specific preference, check if id matches as well
|
||||
if ($isUserValue) {
|
||||
$sql .= " AND subjid = '$id'";
|
||||
$sql .= " AND subjid = :id";
|
||||
$paramMap[':id'] = $id;
|
||||
}
|
||||
|
||||
$result = $con->query($sql)->fetchColumn(0);
|
||||
$result = Application_Common_Database::prepareAndExecute($sql, $paramMap, 'column');
|
||||
|
||||
if ($value == "") {
|
||||
$value = "NULL";
|
||||
} else {
|
||||
$value = "'$value'";
|
||||
$value = "$value";
|
||||
}
|
||||
|
||||
$paramMap = array();
|
||||
if ($result == 1) {
|
||||
// result found
|
||||
if (is_null($id) || !$isUserValue) {
|
||||
// system pref
|
||||
$sql = "UPDATE cc_pref"
|
||||
." SET subjid = NULL, valstr = $value"
|
||||
." WHERE keystr = '$key'";
|
||||
." SET subjid = NULL, valstr = :value"
|
||||
." WHERE keystr = :key";
|
||||
} else {
|
||||
// user pref
|
||||
$sql = "UPDATE cc_pref"
|
||||
. " SET valstr = $value"
|
||||
. " WHERE keystr = '$key' AND subjid = $id";
|
||||
. " SET valstr = :value"
|
||||
. " WHERE keystr = :key AND subjid = :id";
|
||||
$paramMap[':id'] = $id;
|
||||
}
|
||||
} else {
|
||||
// result not found
|
||||
if (is_null($id) || !$isUserValue) {
|
||||
// system pref
|
||||
$sql = "INSERT INTO cc_pref (keystr, valstr)"
|
||||
." VALUES ('$key', $value)";
|
||||
." VALUES (:key, :value)";
|
||||
} else {
|
||||
// user pref
|
||||
$sql = "INSERT INTO cc_pref (subjid, keystr, valstr)"
|
||||
." VALUES ($id, '$key', $value)";
|
||||
." VALUES (:id, :key, :value)";
|
||||
$paramMap[':id'] = $id;
|
||||
}
|
||||
}
|
||||
$paramMap[':key'] = $key;
|
||||
$paramMap[':value'] = $value;
|
||||
|
||||
$con->exec($sql);
|
||||
Application_Common_Database::prepareAndExecute($sql, $paramMap, 'execute');
|
||||
|
||||
} catch (Exception $e) {
|
||||
header('HTTP/1.0 503 Service Unavailable');
|
||||
|
@ -77,28 +86,39 @@ class Application_Model_Preference
|
|||
//Check if key already exists
|
||||
$sql = "SELECT COUNT(*) FROM cc_pref"
|
||||
." WHERE keystr = '$key'";
|
||||
/*." WHERE keystr = :key";
|
||||
$paramMap = array();
|
||||
$paramMap[':key'] = $key;*/
|
||||
//For user specific preference, check if id matches as well
|
||||
if ($isUserValue) {
|
||||
$auth = Zend_Auth::getInstance();
|
||||
if ($auth->hasIdentity()) {
|
||||
$id = $auth->getIdentity()->id;
|
||||
$sql .= " AND subjid = '$id'";
|
||||
/*$sql .= " AND subjid = :id";
|
||||
$paramMap[':id'] = $id;*/
|
||||
}
|
||||
}
|
||||
$result = $con->query($sql)->fetchColumn(0);
|
||||
//$result = Application_Common_Database::prepareAndExecute($sql, $paramMap, 'column');
|
||||
if ($result == 0)
|
||||
|
||||
return "";
|
||||
else {
|
||||
$sql = "SELECT valstr FROM cc_pref"
|
||||
." WHERE keystr = '$key'";
|
||||
/*." WHERE keystr = :key";
|
||||
$paramMap = array();
|
||||
$paramMap[':key'] = $key;*/
|
||||
|
||||
//For user specific preference, check if id matches as well
|
||||
if ($isUserValue && $auth->hasIdentity()) {
|
||||
$sql .= " AND subjid = '$id'";
|
||||
/*$sql .= " AND subjid = :id";
|
||||
$paramMap[':id'] = $id;*/
|
||||
}
|
||||
|
||||
$result = $con->query($sql)->fetchColumn(0);
|
||||
//$result = Application_Common_Database::prepareAndExecute($sql, $paramMap, 'column');
|
||||
|
||||
return ($result !== false) ? $result : "";
|
||||
}
|
||||
|
|
|
@ -10,10 +10,9 @@ class Application_Model_Schedule
|
|||
public function IsFileScheduledInTheFuture($p_fileId)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$sql = "SELECT COUNT(*) FROM ".$CC_CONFIG["scheduleTable"]
|
||||
." WHERE file_id = {$p_fileId} AND ends > NOW() AT TIME ZONE 'UTC'";
|
||||
$count = $con->query($sql)->fetchColumn(0);
|
||||
." WHERE file_id = :file_id AND ends > NOW() AT TIME ZONE 'UTC'";
|
||||
$count = Application_Common_Database::prepareAndExecute($sql, array(':file_id'=>$p_fileId), 'column');
|
||||
|
||||
return (is_numeric($count) && ($count != '0'));
|
||||
}
|
||||
|
@ -52,7 +51,8 @@ class Application_Model_Schedule
|
|||
"currentShow"=>$shows['currentShow'],
|
||||
"nextShow"=>$shows['nextShow'],
|
||||
"timezone"=> date("T"),
|
||||
"timezoneOffset"=> date("Z"));
|
||||
"timezoneOffset"=> date("Z")
|
||||
);
|
||||
|
||||
return $range;
|
||||
}
|
||||
|
@ -71,7 +71,6 @@ class Application_Model_Schedule
|
|||
return;
|
||||
}
|
||||
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$sql = "SELECT %%columns%% st.starts as starts, st.ends as ends,
|
||||
st.media_item_played as media_item_played, si.ends as show_ends
|
||||
|
@ -88,14 +87,18 @@ class Application_Model_Schedule
|
|||
LEFT JOIN (SELECT * FROM cc_webstream_metadata ORDER BY start_time DESC LIMIT 1) AS wm on st.id = wm.instance_id";
|
||||
|
||||
$predicateArr = array();
|
||||
$paramMap = array();
|
||||
if (isset($p_previousShowID)) {
|
||||
$predicateArr[] = 'st.instance_id = '.$p_previousShowID;
|
||||
$predicateArr[] = 'st.instance_id = :previousShowId';
|
||||
$paramMap[':previousShowId'] = $p_previousShowID;
|
||||
}
|
||||
if (isset($p_currentShowID)) {
|
||||
$predicateArr[] = 'st.instance_id = '.$p_currentShowID;
|
||||
$predicateArr[] = 'st.instance_id = :currentShowId';
|
||||
$paramMap[':currentShowId'] = $p_currentShowID;
|
||||
}
|
||||
if (isset($p_nextShowID)) {
|
||||
$predicateArr[] = 'st.instance_id = '.$p_nextShowID;
|
||||
$predicateArr[] = 'st.instance_id = :nextShowId';
|
||||
$paramMap[':nextShowId'] = $p_nextShowID;
|
||||
}
|
||||
|
||||
$sql .= " (".implode(" OR ", $predicateArr).") ";
|
||||
|
@ -109,7 +112,7 @@ class Application_Model_Schedule
|
|||
|
||||
$sql = "SELECT * FROM (($filesSql) UNION ($streamSql)) AS unioned ORDER BY starts";
|
||||
|
||||
$rows = $con->query($sql)->fetchAll(PDO::FETCH_ASSOC);
|
||||
$rows = Application_Common_Database::prepareAndExecute($sql, $paramMap);
|
||||
$numberOfRows = count($rows);
|
||||
|
||||
$results['previous'] = null;
|
||||
|
@ -169,7 +172,6 @@ class Application_Model_Schedule
|
|||
public static function GetLastScheduleItem($p_timeNow)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$sql = "SELECT"
|
||||
." ft.artist_name, ft.track_title,"
|
||||
." st.starts as starts, st.ends as ends"
|
||||
|
@ -178,13 +180,13 @@ class Application_Model_Schedule
|
|||
." ON st.file_id = ft.id"
|
||||
." LEFT JOIN $CC_CONFIG[showInstances] sit"
|
||||
." ON st.instance_id = sit.id"
|
||||
." WHERE st.ends < TIMESTAMP '$p_timeNow'"
|
||||
." WHERE st.ends < TIMESTAMP :timeNow"
|
||||
." AND st.starts >= sit.starts" //this and the next line are necessary since we can overbook shows.
|
||||
." AND st.starts < sit.ends"
|
||||
." ORDER BY st.ends DESC"
|
||||
." LIMIT 1";
|
||||
|
||||
$row = $con->query($sql)->fetchAll();
|
||||
$row = Application_Common_Database::prepareAndExecute($sql, array(':timeNow'=>$p_timeNow));
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
@ -192,7 +194,6 @@ class Application_Model_Schedule
|
|||
public static function GetCurrentScheduleItem($p_timeNow, $p_instanceId)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
/* 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
|
||||
|
@ -204,13 +205,13 @@ class Application_Model_Schedule
|
|||
." 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'"
|
||||
." WHERE st.starts <= TIMESTAMP :timeNow1"
|
||||
." AND st.instance_id = :instanceId"
|
||||
." AND st.ends > TIMESTAMP :timeNow2"
|
||||
." ORDER BY st.starts DESC"
|
||||
." LIMIT 1";
|
||||
|
||||
$row = $con->query($sql)->fetchAll();
|
||||
$row = Application_Common_Database::prepareAndExecute($sql, array(':timeNow1'=>$p_timeNow, ':instanceId'=>$p_instanceId, ':timeNow2'=>$p_timeNow,));
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
@ -218,7 +219,6 @@ class Application_Model_Schedule
|
|||
public static function GetNextScheduleItem($p_timeNow)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$sql = "SELECT"
|
||||
." ft.artist_name, ft.track_title,"
|
||||
." st.starts as starts, st.ends as ends"
|
||||
|
@ -227,13 +227,13 @@ class Application_Model_Schedule
|
|||
." ON st.file_id = ft.id"
|
||||
." LEFT JOIN $CC_CONFIG[showInstances] sit"
|
||||
." ON st.instance_id = sit.id"
|
||||
." WHERE st.starts > TIMESTAMP '$p_timeNow'"
|
||||
." WHERE st.starts > TIMESTAMP :timeNow"
|
||||
." AND st.starts >= sit.starts" //this and the next line are necessary since we can overbook shows.
|
||||
." AND st.starts < sit.ends"
|
||||
." ORDER BY st.starts"
|
||||
." LIMIT 1";
|
||||
|
||||
$row = $con->query($sql)->fetchAll();
|
||||
$row = Application_Common_Database::prepareAndExecute($sql, array(':timeNow'=>$p_timeNow));
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
@ -514,7 +514,6 @@ SQL;
|
|||
public static function GetItems($p_startTime, $p_endTime)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$baseQuery = "SELECT st.file_id AS file_id,"
|
||||
." st.id AS id,"
|
||||
|
@ -540,15 +539,15 @@ SQL;
|
|||
." LEFT JOIN cc_webstream AS ws"
|
||||
." ON st.stream_id = ws.id";
|
||||
|
||||
$predicates = " WHERE st.ends > '$p_startTime'"
|
||||
." AND st.starts < '$p_endTime'"
|
||||
$predicates = " WHERE st.ends > :startTime1"
|
||||
." AND st.starts < :endTime"
|
||||
." AND st.playout_status > 0"
|
||||
." AND si.ends > '$p_startTime'"
|
||||
." AND si.ends > :startTime2"
|
||||
." ORDER BY st.starts";
|
||||
|
||||
$sql = $baseQuery.$predicates;
|
||||
|
||||
$rows = $con->query($sql)->fetchAll();
|
||||
$rows = Application_Common_Database::prepareAndExecute($sql, array(':startTime1'=>$p_startTime, ':endTime'=>$p_endTime, ':startTime2'=>$p_startTime));
|
||||
|
||||
if (count($rows) < 3) {
|
||||
Logging::debug("Get Schedule: Less than 3 results returned. Doing another query since we need a minimum of 3 results.");
|
||||
|
@ -557,15 +556,15 @@ SQL;
|
|||
$dt->add(new DateInterval("PT24H"));
|
||||
$range_end = $dt->format("Y-m-d H:i:s");
|
||||
|
||||
$predicates = " WHERE st.ends > '$p_startTime'"
|
||||
." AND st.starts < '$range_end'"
|
||||
$predicates = " WHERE st.ends > :startTime1"
|
||||
." AND st.starts < :rangeEnd"
|
||||
." AND st.playout_status > 0"
|
||||
." AND si.ends > '$p_startTime'"
|
||||
." AND si.ends > :startTime2"
|
||||
." ORDER BY st.starts"
|
||||
." LIMIT 3";
|
||||
|
||||
$sql = $baseQuery.$predicates;
|
||||
$rows = $con->query($sql)->fetchAll();
|
||||
$rows = Application_Common_Database::prepareAndExecute($sql, array(':startTime1'=>$p_startTime, ':rangeEnd'=>$range_end, ':startTime2'=>$p_startTime));
|
||||
}
|
||||
|
||||
return $rows;
|
||||
|
@ -748,9 +747,8 @@ SQL;
|
|||
public static function deleteWithFileId($fileId)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"]." WHERE file_id=$fileId";
|
||||
$res = $con->query($sql);
|
||||
$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"]." WHERE file_id=:file_id";
|
||||
$res = Application_Common_Database::prepareAndExecute($sql, array(':file_id'=>$fileId), 'execute');
|
||||
}
|
||||
|
||||
public static function createNewFormSections($p_view)
|
||||
|
@ -1091,7 +1089,7 @@ SQL;
|
|||
and date(starts) >= (date('{$show_end->format('Y-m-d H:i:s')}') - INTERVAL '2 days')
|
||||
and modified_instance = false order by ends";
|
||||
|
||||
$stmt = $con->prepare("SELECT id, starts, ends FROM
|
||||
$stmt = $con->prepare("SELECT id, starts, ends FROM
|
||||
{$CC_CONFIG['showInstances']}
|
||||
where (ends <= :show_end1 or starts <= :show_end2)
|
||||
and date(starts) >= (date(:show_end3) - INTERVAL '2 days')
|
||||
|
|
|
@ -1873,7 +1873,7 @@ SELECT si.starts AS start_timestamp,
|
|||
ends
|
||||
FROM cc_show_instances si
|
||||
LEFT JOIN cc_show s
|
||||
ON si.instance_id = s.id
|
||||
ON si.show_id = s.id
|
||||
WHERE si.show_id = s.id
|
||||
AND si.starts <= :timeNow1::timestamp
|
||||
AND si.ends > :timeNow2::timestamp
|
||||
|
@ -1916,7 +1916,7 @@ SELECT si.starts AS start_timestamp,
|
|||
ends
|
||||
FROM cc_show_instances si
|
||||
LEFT JOIN cc_show s
|
||||
ON si.instance_id = s.id
|
||||
ON si.show_id = s.id
|
||||
WHERE si.show_id = s.id
|
||||
AND si.starts > :timeNow1::timestamp - INTERVAL '2 days'
|
||||
AND si.ends < :timeNow2::timestamp + INTERVAL '2 days'
|
||||
|
@ -1930,7 +1930,7 @@ SQL;
|
|||
$stmt->bindValue(':timeNow2', $p_timeNow);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$rows = $stmt->fetchAll();
|
||||
} else {
|
||||
$msg = implode(',', $stmt->errorInfo());
|
||||
throw new Exception("Error: $msg");
|
||||
|
@ -2055,7 +2055,7 @@ SELECT si.starts AS start_timestamp,
|
|||
ends
|
||||
FROM cc_show_instances si
|
||||
LEFT JOIN cc_show s
|
||||
ON si.instance_id = s.id
|
||||
ON si.show_id = s.id
|
||||
WHERE si.show_id = s.id
|
||||
AND si.starts >= :timeStart::timestamp
|
||||
AND si.starts < :timeEnd::timestamp
|
||||
|
|
|
@ -23,6 +23,7 @@ echo " 1. Install Packages"
|
|||
echo "----------------------------------------------------"
|
||||
|
||||
dist=`lsb_release -is`
|
||||
code=`lsb_release -cs`
|
||||
|
||||
if [ "$dist" = "Debian" ]; then
|
||||
set +e
|
||||
|
@ -51,8 +52,7 @@ php-pear php5-gd postgresql odbc-postgresql python libsoundtouch-ocaml \
|
|||
libtaglib-ocaml libao-ocaml libmad-ocaml ecasound \
|
||||
libesd0 libportaudio2 libsamplerate0 rabbitmq-server patch \
|
||||
php5-curl mpg123 monit python-virtualenv multitail libcamomile-ocaml-data \
|
||||
libpulse0 vorbis-tools lsb-release lsof sudo mp3gain vorbisgain flac vorbis-tools \
|
||||
timeout
|
||||
libpulse0 vorbis-tools lsb-release lsof sudo mp3gain vorbisgain flac vorbis-tools
|
||||
|
||||
#install packages with --force-yes option (this is useful in the case
|
||||
#of Debian, where these packages are unauthorized)
|
||||
|
@ -68,6 +68,13 @@ else
|
|||
apt-get -y install libzend-framework-php
|
||||
fi
|
||||
|
||||
if [ "$code" = "lucid" ]; then
|
||||
apt-get -y install timeout
|
||||
else
|
||||
apt-get -y install coreutils
|
||||
fi
|
||||
|
||||
|
||||
#Install Sourcefabric's custom Liquidsoap debian package
|
||||
apt-get -y --force-yes install sourcefabric-keyring
|
||||
apt-get -y --force-yes install liquidsoap
|
||||
|
|
|
@ -26,11 +26,12 @@ echo " 1. Install Packages"
|
|||
echo "----------------------------------------------------"
|
||||
|
||||
dist=`lsb_release -is`
|
||||
code=`lsb_release -cs`
|
||||
|
||||
if [ "$dist" -eq "Debian" ]; then
|
||||
grep "deb http://www.debian-multimedia.org squeeze main non-free" /etc/apt/sources.list
|
||||
grep "deb http://www.deb-multimedia.org squeeze main non-free" /etc/apt/sources.list
|
||||
if [ "$?" -ne "0" ]; then
|
||||
echo "deb http://www.debian-multimedia.org squeeze main non-free" >> /etc/apt/sources.list
|
||||
echo "deb http://www.deb-multimedia.org squeeze main non-free" >> /etc/apt/sources.list
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -42,8 +43,7 @@ php-pear php5-gd postgresql odbc-postgresql python libsoundtouch-ocaml \
|
|||
libtaglib-ocaml libao-ocaml libmad-ocaml ecasound \
|
||||
libesd0 libportaudio2 libsamplerate0 rabbitmq-server patch \
|
||||
php5-curl mpg123 monit python-virtualenv multitail libcamomile-ocaml-data \
|
||||
libpulse0 vorbis-tools lsb-release lsof sudo mp3gain vorbisgain flac vorbis-tools \
|
||||
timeout
|
||||
libpulse0 vorbis-tools lsb-release lsof sudo mp3gain vorbisgain flac vorbis-tools
|
||||
|
||||
#install packages with --force-yes option (this is useful in the case
|
||||
#of Debian, where these packages are unauthorized)
|
||||
|
@ -58,6 +58,12 @@ else
|
|||
apt-get -y install libzend-framework-php
|
||||
fi
|
||||
|
||||
if [ "$code" = "lucid" ]; then
|
||||
apt-get -y install timeout
|
||||
else
|
||||
apt-get -y install coreutils
|
||||
fi
|
||||
|
||||
# NGINX Config File
|
||||
echo "----------------------------------------------------"
|
||||
echo "2.1 NGINX Config File"
|
||||
|
|
Loading…
Reference in New Issue