Merge branch '2.4.x' into 2.4.x-saas
Conflicts: python_apps/pypo/liquidsoap_scripts/ls_script.liq utils/phone_home_stat.php
This commit is contained in:
commit
f2d5fa96da
114 changed files with 9850 additions and 9170 deletions
|
@ -330,7 +330,7 @@ SQL;
|
|||
{
|
||||
list($value, $modifier) = $this->getLimitValueAndModifier();
|
||||
if ($modifier == "items") {
|
||||
$length = $value." ".$modifier;
|
||||
$length = $value." "._("items");
|
||||
} else {
|
||||
$hour = "00";
|
||||
$mins = "00";
|
||||
|
@ -686,6 +686,10 @@ SQL;
|
|||
public function createCrossfade($id1, $fadeOut, $id2, $fadeIn, $offset)
|
||||
{
|
||||
$this->con->beginTransaction();
|
||||
|
||||
if (!isset($offset)) {
|
||||
$offset = Application_Model_Preference::GetDefaultCrossfadeDuration();
|
||||
}
|
||||
|
||||
try {
|
||||
if (isset($id1)) {
|
||||
|
@ -1350,6 +1354,21 @@ SQL;
|
|||
"year" => _("Year")
|
||||
);
|
||||
|
||||
$modifierOptions = array(
|
||||
"0" => _("Select modifier"),
|
||||
"contains" => _("contains"),
|
||||
"does not contain" => _("does not contain"),
|
||||
"is" => _("is"),
|
||||
"is not" => _("is not"),
|
||||
"starts with" => _("starts with"),
|
||||
"ends with" => _("ends with"),
|
||||
"is" => _("is"),
|
||||
"is not" => _("is not"),
|
||||
"is greater than" => _("is greater than"),
|
||||
"is less than" => _("is less than"),
|
||||
"is in the range" => _("is in the range")
|
||||
);
|
||||
|
||||
// Load criteria from db
|
||||
$out = CcBlockcriteriaQuery::create()->orderByDbCriteria()->findByDbBlockId($this->id);
|
||||
$storedCrit = array();
|
||||
|
@ -1361,11 +1380,20 @@ SQL;
|
|||
$extra = $crit->getDbExtra();
|
||||
|
||||
if ($criteria == "limit") {
|
||||
$storedCrit["limit"] = array("value"=>$value, "modifier"=>$modifier);
|
||||
$storedCrit["limit"] = array(
|
||||
"value"=>$value,
|
||||
"modifier"=>$modifier,
|
||||
"display_modifier"=>_($modifier));
|
||||
} else if($criteria == "repeat_tracks") {
|
||||
$storedCrit["repeat_tracks"] = array("value"=>$value);
|
||||
} else {
|
||||
$storedCrit["crit"][$criteria][] = array("criteria"=>$criteria, "value"=>$value, "modifier"=>$modifier, "extra"=>$extra, "display_name"=>$criteriaOptions[$criteria]);
|
||||
$storedCrit["crit"][$criteria][] = array(
|
||||
"criteria"=>$criteria,
|
||||
"value"=>$value,
|
||||
"modifier"=>$modifier,
|
||||
"extra"=>$extra,
|
||||
"display_name"=>$criteriaOptions[$criteria],
|
||||
"display_modifier"=>$modifierOptions[$modifier]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ class Application_Model_Datatables
|
|||
{
|
||||
private static function buildWhereClauseForAdvancedSearch($dbname2searchTerm)
|
||||
{
|
||||
$where = array();
|
||||
$where['clause'] = array();
|
||||
$where['params'] = array();
|
||||
foreach ($dbname2searchTerm as $dbname=>$term) {
|
||||
|
|
|
@ -4,7 +4,7 @@ class Application_Model_ListenerStat
|
|||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public static function getDataPointsWithinRange($p_start, $p_end) {
|
||||
$sql = <<<SQL
|
||||
SELECT mount_name, count(*)
|
||||
|
@ -16,13 +16,13 @@ group by mount_name
|
|||
SQL;
|
||||
$data = Application_Common_Database::prepareAndExecute($sql,
|
||||
array('p1'=>$p_start, 'p2'=>$p_end));
|
||||
|
||||
|
||||
$out = array();
|
||||
foreach ($data as $d) {
|
||||
$jump = intval($d['count']/1000);
|
||||
$jump = max(1, $jump);
|
||||
$remainder = $jump == 1?0:1;
|
||||
|
||||
|
||||
$sql = <<<SQL
|
||||
SELECT *
|
||||
FROM
|
||||
|
@ -41,29 +41,36 @@ SQL;
|
|||
$t->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
// tricking javascript so it thinks the server timezone is in UTC
|
||||
$dt = new DateTime($t->format("Y-m-d H:i:s"), new DateTimeZone("UTC"));
|
||||
|
||||
|
||||
$r['timestamp'] = $dt->format("U");
|
||||
$out[$r['mount_name']][] = $r;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$enabledStreamIds = Application_Model_StreamSetting::getEnabledStreamIds();
|
||||
$enabledOut = array();
|
||||
|
||||
|
||||
foreach ($enabledStreamIds as $sId) {
|
||||
|
||||
|
||||
$sql = "SELECT value FROM cc_stream_setting"
|
||||
." WHERE keyname = :key";
|
||||
|
||||
|
||||
$result = Application_Common_Database::prepareAndExecute($sql, array('key' => $sId."_mount"), "single");
|
||||
|
||||
|
||||
$enabledMountPoint = $result["value"];
|
||||
|
||||
|
||||
if (isset($out[$enabledMountPoint])) {
|
||||
$enabledOut[$enabledMountPoint] = $out[$enabledMountPoint];
|
||||
}
|
||||
else {
|
||||
//TODO fix this hack (here for CC-5254)
|
||||
//all shoutcast streams are automatically put under "shoutcast" mount point.
|
||||
if (isset($out["shoutcast"])) {
|
||||
$enabledOut["shoutcast"] = $out["shoutcast"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $enabledOut;
|
||||
}
|
||||
|
||||
|
|
|
@ -154,8 +154,6 @@ class Application_Model_Playlist implements Application_Model_LibraryEditable
|
|||
*/
|
||||
public function getContents($filterFiles=false)
|
||||
{
|
||||
Logging::info("Getting contents for playlist {$this->id}");
|
||||
|
||||
$sql = <<<SQL
|
||||
SELECT *
|
||||
FROM (
|
||||
|
@ -411,26 +409,44 @@ SQL;
|
|||
|| $obj instanceof CcWebstream ||
|
||||
$obj instanceof CcBlock) {
|
||||
|
||||
$entry = $this->plItem;
|
||||
$entry["id"] = $obj->getDbId();
|
||||
$entry["pos"] = $pos;
|
||||
$entry = $this->plItem;
|
||||
$entry["id"] = $obj->getDbId();
|
||||
$entry["pos"] = $pos;
|
||||
$entry["cliplength"] = $obj->getDbLength();
|
||||
|
||||
if ($obj instanceof CcFiles && $obj) {
|
||||
$entry["cuein"] = $obj->getDbCuein();
|
||||
$entry["cueout"] = $obj->getDbCueout();
|
||||
|
||||
$entry["cuein"] = isset($p_item['cuein']) ?
|
||||
$p_item['cuein'] : $obj->getDbCuein();
|
||||
|
||||
$entry["cueout"] = isset($p_item['cueout']) ?
|
||||
$p_item['cueout'] : $obj->getDbCueout();
|
||||
|
||||
$cue_out = Application_Common_DateHelper::calculateLengthInSeconds($entry['cueout']);
|
||||
$cue_in = Application_Common_DateHelper::calculateLengthInSeconds($entry['cuein']);
|
||||
$entry["cliplength"] = Application_Common_DateHelper::secondsToPlaylistTime($cue_out-$cue_in);
|
||||
} elseif ($obj instanceof CcWebstream && $obj) {
|
||||
$cue_in = isset($p_item['cueInSec']) ?
|
||||
$p_item['cueInSec'] : Application_Common_DateHelper::calculateLengthInSeconds($entry['cuein']);
|
||||
|
||||
$cue_out = isset($p_item['cueOutSec']) ?
|
||||
$p_item['cueOutSec'] : Application_Common_DateHelper::calculateLengthInSeconds($entry['cueout']);
|
||||
|
||||
$entry["cliplength"] = isset($p_item['length']) ?
|
||||
$p_item['length'] : Application_Common_DateHelper::secondsToPlaylistTime($cue_out-$cue_in);
|
||||
}
|
||||
elseif ($obj instanceof CcWebstream && $obj) {
|
||||
$entry["cuein"] = "00:00:00";
|
||||
$entry["cueout"] = $entry["cliplength"];
|
||||
}
|
||||
$entry["ftype"] = $objType;
|
||||
$entry["ftype"] = $objType;
|
||||
|
||||
$entry["fadein"] = isset($p_item['fadein']) ?
|
||||
$p_item['fadein'] : $entry["fadein"];
|
||||
|
||||
$entry["fadeout"] = isset($p_item['fadeout']) ?
|
||||
$p_item['fadeout'] : $entry["fadeout"];
|
||||
}
|
||||
|
||||
return $entry;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
throw new Exception("trying to add a object that does not exist.");
|
||||
}
|
||||
}
|
||||
|
@ -451,11 +467,10 @@ SQL;
|
|||
try {
|
||||
|
||||
if (is_numeric($p_afterItem)) {
|
||||
Logging::info("Finding playlist content item {$p_afterItem}");
|
||||
|
||||
|
||||
$afterItem = CcPlaylistcontentsQuery::create()->findPK($p_afterItem);
|
||||
$index = $afterItem->getDbPosition();
|
||||
Logging::info("index is {$index}");
|
||||
|
||||
$pos = ($addType == 'after') ? $index + 1 : $index;
|
||||
|
||||
$contentsToUpdate = CcPlaylistcontentsQuery::create()
|
||||
|
@ -488,9 +503,6 @@ SQL;
|
|||
|
||||
}
|
||||
|
||||
Logging::info("Adding to playlist");
|
||||
Logging::info("at position {$pos}");
|
||||
|
||||
foreach ($p_items as $ac) {
|
||||
$res = $this->insertPlaylistElement($this->buildEntry($ac, $pos));
|
||||
|
||||
|
@ -500,8 +512,6 @@ SQL;
|
|||
$db_file->setDbIsPlaylist(true)->save($this->con);
|
||||
|
||||
$pos = $pos + 1;
|
||||
Logging::info("Adding $ac[1] $ac[0]");
|
||||
|
||||
}
|
||||
|
||||
//reset the positions of the remaining items.
|
||||
|
@ -673,6 +683,10 @@ SQL;
|
|||
{
|
||||
$this->con->beginTransaction();
|
||||
|
||||
if (!isset($offset)) {
|
||||
$offset = Application_Model_Preference::GetDefaultCrossfadeDuration();
|
||||
}
|
||||
|
||||
try {
|
||||
if (isset($id1)) {
|
||||
$this->changeFadeInfo($id1, null, $fadeOut);
|
||||
|
@ -729,7 +743,6 @@ SQL;
|
|||
|
||||
if (!is_null($offset)) {
|
||||
$row->setDbTrackOffset($offset);
|
||||
Logging::info("Setting offset {$offset} on item {$id}");
|
||||
$row->save($this->con);
|
||||
}
|
||||
}
|
||||
|
@ -1071,8 +1084,7 @@ SQL;
|
|||
$sql .= "END WHERE position IN ($currentPos) and playlist_id=:p1";
|
||||
|
||||
Application_Common_Database::prepareAndExecute($sql, array("p1"=>$this->id));
|
||||
$result['result'] = 0;
|
||||
return $result;
|
||||
return array('result' => 0);
|
||||
}
|
||||
|
||||
public static function getAllPlaylistFiles()
|
||||
|
|
|
@ -38,9 +38,11 @@ class Application_Model_Preference
|
|||
$paramMap[':id'] = $userId;
|
||||
}
|
||||
|
||||
Application_Common_Database::prepareAndExecute("LOCK TABLE cc_pref");
|
||||
|
||||
$result = Application_Common_Database::prepareAndExecute($sql,
|
||||
$paramMap,
|
||||
'column',
|
||||
Application_Common_Database::COLUMN,
|
||||
PDO::FETCH_ASSOC,
|
||||
$con);
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ AND file_id is not null
|
|||
SQL;
|
||||
|
||||
$files = Application_Common_Database::prepareAndExecute( $sql, array());
|
||||
|
||||
|
||||
$real_files = array();
|
||||
foreach ($files as $f) {
|
||||
$real_files[] = $f['file_id'];
|
||||
|
@ -48,7 +48,7 @@ WHERE ends > now() AT TIME ZONE 'UTC'
|
|||
AND stream_id is not null
|
||||
SQL;
|
||||
$streams = Application_Common_Database::prepareAndExecute( $sql, array());
|
||||
|
||||
|
||||
$real_streams = array();
|
||||
foreach ($streams as $s) {
|
||||
$real_streams[] = $s['stream_id'];
|
||||
|
@ -322,7 +322,8 @@ SQL;
|
|||
ft.album_title AS file_album_title,
|
||||
ft.length AS file_length,
|
||||
ft.file_exists AS file_exists,
|
||||
ft.mime AS file_mime
|
||||
ft.mime AS file_mime,
|
||||
ft.soundcloud_id AS soundcloud_id
|
||||
SQL;
|
||||
$filesJoin = <<<SQL
|
||||
cc_schedule AS sched
|
||||
|
@ -357,7 +358,8 @@ SQL;
|
|||
ws.description AS file_album_title,
|
||||
ws.length AS file_length,
|
||||
't'::BOOL AS file_exists,
|
||||
ws.mime as file_mime
|
||||
ws.mime AS file_mime,
|
||||
(SELECT NULL::integer AS soundcloud_id)
|
||||
SQL;
|
||||
$streamJoin = <<<SQL
|
||||
cc_schedule AS sched
|
||||
|
@ -391,17 +393,17 @@ SQL;
|
|||
|
||||
$showPredicate = "";
|
||||
if (count($p_shows) > 0) {
|
||||
|
||||
|
||||
$params = array();
|
||||
$map = array();
|
||||
|
||||
|
||||
for ($i = 0, $len = count($p_shows); $i < $len; $i++) {
|
||||
$holder = "show_".$i;
|
||||
|
||||
$holder = ":show_".$i;
|
||||
|
||||
$params[] = $holder;
|
||||
$map[$holder] = $p_shows[$i];
|
||||
}
|
||||
|
||||
|
||||
$showPredicate = " AND show_id IN (".implode(",", $params).")";
|
||||
$paramMap = $paramMap + $map;
|
||||
} else if (count($p_show_instances) > 0) {
|
||||
|
@ -448,13 +450,13 @@ SQL;
|
|||
":ts_6" => $p_end_str,
|
||||
);
|
||||
$paramMap = $paramMap + $map;
|
||||
|
||||
|
||||
$rows = Application_Common_Database::prepareAndExecute(
|
||||
$sql,
|
||||
$paramMap,
|
||||
Application_Common_Database::ALL
|
||||
);
|
||||
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
|
@ -475,7 +477,7 @@ SQL;
|
|||
$sql .= " WHERE id=:pid";
|
||||
$map = array(":pid" => $p_id);
|
||||
|
||||
Application_Common_Database::prepareAndExecute($sql, $map,
|
||||
Application_Common_Database::prepareAndExecute($sql, $map,
|
||||
Application_Common_Database::EXECUTE);
|
||||
}
|
||||
|
||||
|
@ -501,9 +503,9 @@ SQL;
|
|||
{
|
||||
$sql = "SELECT count(*) as cnt FROM cc_schedule";
|
||||
|
||||
$res = Application_Common_Database::prepareAndExecute($sql, array(),
|
||||
$res = Application_Common_Database::prepareAndExecute($sql, array(),
|
||||
Application_Common_Database::COLUMN);
|
||||
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
@ -706,7 +708,7 @@ SQL;
|
|||
$key = "{$time}_{$i}";
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
$data["media"][$key] = $item;
|
||||
}
|
||||
|
||||
|
@ -755,7 +757,7 @@ SQL;
|
|||
|
||||
$replay_gain = is_null($item["replay_gain"]) ? "0": $item["replay_gain"];
|
||||
$replay_gain += Application_Model_Preference::getReplayGainModifier();
|
||||
|
||||
|
||||
if ( !Application_Model_Preference::GetEnableReplayGain() ) {
|
||||
$replay_gain = 0;
|
||||
}
|
||||
|
@ -775,7 +777,7 @@ SQL;
|
|||
'replay_gain' => $replay_gain,
|
||||
'independent_event' => $independent_event,
|
||||
);
|
||||
|
||||
|
||||
if ($schedule_item['cue_in'] > $schedule_item['cue_out']) {
|
||||
$schedule_item['cue_in'] = $schedule_item['cue_out'];
|
||||
}
|
||||
|
@ -915,10 +917,10 @@ SQL;
|
|||
} else {
|
||||
throw new Exception("Unknown schedule type: ".print_r($item, true));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Check if two events are less than or equal to 1 second apart
|
||||
*/
|
||||
public static function areEventsLinked($event1, $event2) {
|
||||
|
@ -996,7 +998,7 @@ SQL;
|
|||
public static function deleteAll()
|
||||
{
|
||||
$sql = "TRUNCATE TABLE cc_schedule";
|
||||
Application_Common_Database::prepareAndExecute($sql, array(),
|
||||
Application_Common_Database::prepareAndExecute($sql, array(),
|
||||
Application_Common_Database::EXECUTE);
|
||||
}
|
||||
|
||||
|
@ -1199,14 +1201,14 @@ SQL;
|
|||
$update=false, $instanceId=null, $showId=null)
|
||||
{
|
||||
$overlapping = false;
|
||||
|
||||
|
||||
$params = array(
|
||||
':show_end1' => $show_end->format('Y-m-d H:i:s'),
|
||||
':show_end2' => $show_end->format('Y-m-d H:i:s'),
|
||||
':show_end3' => $show_end->format('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/* If a show is being edited, exclude it from the query
|
||||
* In both cases (new and edit) we only grab shows that
|
||||
* are scheduled 2 days prior
|
||||
|
@ -1277,18 +1279,18 @@ SQL;
|
|||
return 'file';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function GetFileId($p_scheduleId)
|
||||
{
|
||||
$scheduledItem = CcScheduleQuery::create()->findPK($p_scheduleId);
|
||||
|
||||
return $scheduledItem->getDbFileId();
|
||||
}
|
||||
|
||||
|
||||
public static function GetStreamId($p_scheduleId)
|
||||
{
|
||||
$scheduledItem = CcScheduleQuery::create()->findPK($p_scheduleId);
|
||||
|
||||
|
||||
return $scheduledItem->getDbStreamId();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ class Application_Model_Scheduler
|
|||
private $epochNow;
|
||||
private $nowDT;
|
||||
private $user;
|
||||
|
||||
|
||||
private $crossfadeDuration;
|
||||
|
||||
private $checkUserPermissions = true;
|
||||
|
@ -40,7 +40,7 @@ class Application_Model_Scheduler
|
|||
}
|
||||
|
||||
$this->user = Application_Model_User::getCurrentUser();
|
||||
|
||||
|
||||
$this->crossfadeDuration = Application_Model_Preference::GetDefaultCrossfadeDuration();
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,9 @@ class Application_Model_Scheduler
|
|||
|
||||
$nowEpoch = floatval($this->nowDT->format("U.u"));
|
||||
|
||||
$schedInfo = array();
|
||||
$instanceInfo = array();
|
||||
|
||||
for ($i = 0; $i < count($items); $i++) {
|
||||
$id = $items[$i]["id"];
|
||||
|
||||
|
@ -103,7 +106,7 @@ class Application_Model_Scheduler
|
|||
}
|
||||
|
||||
$schedIds = array();
|
||||
if (isset($schedInfo)) {
|
||||
if (count($schedInfo) > 0) {
|
||||
$schedIds = array_keys($schedInfo);
|
||||
}
|
||||
$schedItems = CcScheduleQuery::create()->findPKs($schedIds, $this->con);
|
||||
|
@ -191,16 +194,18 @@ class Application_Model_Scheduler
|
|||
|
||||
if ($type === "audioclip") {
|
||||
$file = CcFilesQuery::create()->findPK($id, $this->con);
|
||||
$storedFile = new Application_Model_StoredFile($file, $this->con);
|
||||
|
||||
if (is_null($file) || !$file->visible()) {
|
||||
throw new Exception(_("A selected File does not exist!"));
|
||||
} else {
|
||||
$data = $this->fileInfo;
|
||||
$data["id"] = $id;
|
||||
$data["cliplength"] = $storedFile->getRealClipLength(
|
||||
$file->getDbCuein(),
|
||||
$file->getDbCueout());
|
||||
|
||||
$cuein = Application_Common_DateHelper::playlistTimeToSeconds($file->getDbCuein());
|
||||
$cueout = Application_Common_DateHelper::playlistTimeToSeconds($file->getDbCueout());
|
||||
$row_length = Application_Common_DateHelper::secondsToPlaylistTime($cueout - $cuein);
|
||||
|
||||
$data["cliplength"] = $row_length;
|
||||
|
||||
$data["cuein"] = $file->getDbCuein();
|
||||
$data["cueout"] = $file->getDbCueout();
|
||||
|
@ -263,11 +268,11 @@ class Application_Model_Scheduler
|
|||
$cuein = Application_Common_DateHelper::calculateLengthInSeconds($data["cuein"]);
|
||||
$cueout = Application_Common_DateHelper::calculateLengthInSeconds($data["cueout"]);
|
||||
$data["cliplength"] = Application_Common_DateHelper::secondsToPlaylistTime($cueout - $cuein);
|
||||
|
||||
|
||||
//fade is in format SS.uuuuuu
|
||||
$data["fadein"] = $defaultFadeIn;
|
||||
$data["fadeout"] = $defaultFadeOut;
|
||||
|
||||
|
||||
$data["type"] = 0;
|
||||
$files[] = $data;
|
||||
}
|
||||
|
@ -322,11 +327,11 @@ class Application_Model_Scheduler
|
|||
$cuein = Application_Common_DateHelper::calculateLengthInSeconds($data["cuein"]);
|
||||
$cueout = Application_Common_DateHelper::calculateLengthInSeconds($data["cueout"]);
|
||||
$data["cliplength"] = Application_Common_DateHelper::secondsToPlaylistTime($cueout - $cuein);
|
||||
|
||||
|
||||
//fade is in format SS.uuuuuu
|
||||
$data["fadein"] = $defaultFadeIn;
|
||||
$data["fadeout"] = $defaultFadeOut;
|
||||
|
||||
|
||||
$data["type"] = 0;
|
||||
$files[] = $data;
|
||||
}
|
||||
|
@ -336,7 +341,7 @@ class Application_Model_Scheduler
|
|||
|
||||
return $files;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @param DateTime startDT in UTC
|
||||
* @param string duration
|
||||
|
@ -347,18 +352,18 @@ class Application_Model_Scheduler
|
|||
private function findTimeDifference($p_startDT, $p_seconds)
|
||||
{
|
||||
$startEpoch = $p_startDT->format("U.u");
|
||||
|
||||
|
||||
//add two float numbers to 6 subsecond precision
|
||||
//DateTime::createFromFormat("U.u") will have a problem if there is no decimal in the resulting number.
|
||||
$newEpoch = bcsub($startEpoch , (string) $p_seconds, 6);
|
||||
|
||||
|
||||
$dt = DateTime::createFromFormat("U.u", $newEpoch, new DateTimeZone("UTC"));
|
||||
|
||||
|
||||
if ($dt === false) {
|
||||
//PHP 5.3.2 problem
|
||||
$dt = DateTime::createFromFormat("U", intval($newEpoch), new DateTimeZone("UTC"));
|
||||
}
|
||||
|
||||
|
||||
return $dt;
|
||||
}
|
||||
|
||||
|
@ -388,7 +393,7 @@ class Application_Model_Scheduler
|
|||
return $dt;
|
||||
}
|
||||
|
||||
private function findNextStartTime($DT, $instance)
|
||||
private function findNextStartTime($DT, $instanceId)
|
||||
{
|
||||
$sEpoch = $DT->format("U.u");
|
||||
$nEpoch = $this->epochNow;
|
||||
|
@ -410,7 +415,7 @@ class Application_Model_Scheduler
|
|||
->setDbCueIn('00:00:00')
|
||||
->setDbCueOut('00:00:00')
|
||||
->setDbPlayoutStatus(-1)
|
||||
->setDbInstanceId($instance->getDbId())
|
||||
->setDbInstanceId($instanceId)
|
||||
->save($this->con);
|
||||
} else {
|
||||
$nextDT = $DT;
|
||||
|
@ -418,39 +423,45 @@ class Application_Model_Scheduler
|
|||
|
||||
return $nextDT;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @param int $showInstance
|
||||
* This function recalculates the start/end times of items in a gapless show to
|
||||
* account for crossfade durations.
|
||||
*/
|
||||
private function calculateCrossfades($showInstance)
|
||||
private function calculateCrossfades($instanceId)
|
||||
{
|
||||
Logging::info("adjusting start, end times of scheduled items to account for crossfades show instance #".$showInstance);
|
||||
|
||||
$instance = CcShowInstancesQuery::create()->findPK($showInstance, $this->con);
|
||||
if (is_null($instance)) {
|
||||
throw new OutDatedScheduleException(_("The schedule you're viewing is out of date!"));
|
||||
}
|
||||
|
||||
$itemStartDT = $instance->getDbStarts(null);
|
||||
$itemEndDT = null;
|
||||
|
||||
$schedule = CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($showInstance)
|
||||
->orderByDbStarts()
|
||||
->find($this->con);
|
||||
|
||||
foreach ($schedule as $item) {
|
||||
$itemEndDT = $this->findEndTime($itemStartDT, $item->getDbClipLength());
|
||||
Logging::info("adjusting start, end times of scheduled items to account for crossfades show instance #".$instanceId);
|
||||
|
||||
$item->setDbStarts($itemStartDT)
|
||||
->setDbEnds($itemEndDT);
|
||||
$sql = "SELECT * FROM cc_show_instances ".
|
||||
"WHERE id = {$instanceId}";
|
||||
$instance = Application_Common_Database::prepareAndExecute(
|
||||
$sql, array(), Application_Common_Database::SINGLE);
|
||||
|
||||
$itemStartDT = $this->findTimeDifference($itemEndDT, $this->crossfadeDuration);
|
||||
}
|
||||
|
||||
$schedule->save($this->con);
|
||||
if (is_null($instance)) {
|
||||
throw new OutDatedScheduleException(_("The schedule you're viewing is out of date!"));
|
||||
}
|
||||
|
||||
$itemStartDT = new DateTime($instance["starts"], new DateTimeZone("UTC"));
|
||||
$itemEndDT = null;
|
||||
|
||||
$schedule_sql = "SELECT * FROM cc_schedule ".
|
||||
"WHERE instance_id = {$instanceId} ".
|
||||
"ORDER BY starts";
|
||||
$schedule = Application_Common_Database::prepareAndExecute($schedule_sql);
|
||||
|
||||
foreach ($schedule as $item) {
|
||||
$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")}' ".
|
||||
"WHERE id = {$item["id"]}";
|
||||
Application_Common_Database::prepareAndExecute(
|
||||
$update_sql, array(), Application_Common_Database::EXECUTE);
|
||||
|
||||
$itemStartDT = $this->findTimeDifference($itemEndDT, $this->crossfadeDuration);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -491,7 +502,7 @@ class Application_Model_Scheduler
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Enter description here ...
|
||||
* @param $scheduleItems
|
||||
* cc_schedule items, where the items get inserted after
|
||||
|
@ -531,12 +542,18 @@ class Application_Model_Scheduler
|
|||
* of inserted items
|
||||
*/
|
||||
if ($id != 0) {
|
||||
$ccSchedule = CcScheduleQuery::create()->findPk($id);
|
||||
$ccShowInstance = CcShowInstancesQuery::create()->findPk($ccSchedule->getDbInstanceId());
|
||||
$ccShow = $ccShowInstance->getCcShow();
|
||||
$linked = $ccShow->isLinked();
|
||||
$schedule_sql = "SELECT * FROM cc_schedule WHERE id = ".$id;
|
||||
$ccSchedule = Application_Common_Database::prepareAndExecute(
|
||||
$schedule_sql, array(), Application_Common_Database::SINGLE);
|
||||
|
||||
$show_sql = "SELECT * FROM cc_show WHERE id IN (".
|
||||
"SELECT show_id FROM cc_show_instances WHERE id = ".$ccSchedule["instance_id"].")";
|
||||
$ccShow = Application_Common_Database::prepareAndExecute(
|
||||
$show_sql, array(), Application_Common_Database::SINGLE);
|
||||
|
||||
$linked = $ccShow["linked"];
|
||||
if ($linked) {
|
||||
$unique = $ccShow->getDbId() . $ccSchedule->getDbPosition();
|
||||
$unique = $ccShow["id"] . $ccSchedule["position"];
|
||||
if (!in_array($unique, $temp)) {
|
||||
$temp[] = $unique;
|
||||
} else {
|
||||
|
@ -544,11 +561,14 @@ class Application_Model_Scheduler
|
|||
}
|
||||
}
|
||||
} else {
|
||||
$ccShowInstance = CcShowInstancesQuery::create()->findPk($schedule["instance"]);
|
||||
$ccShow = $ccShowInstance->getccShow();
|
||||
$linked = $ccShow->isLinked();
|
||||
$show_sql = "SELECT * FROM cc_show WHERE id IN (".
|
||||
"SELECT show_id FROM cc_show_instances WHERE id = ".$schedule["instance"].")";
|
||||
$ccShow = Application_Common_Database::prepareAndExecute(
|
||||
$show_sql, array(), Application_Common_Database::SINGLE);
|
||||
|
||||
$linked = $ccShow["linked"];
|
||||
if ($linked) {
|
||||
$unique = $ccShow->getDbId() . "a";
|
||||
$unique = $ccShow["id"] . "a";
|
||||
if (!in_array($unique, $temp)) {
|
||||
$temp[] = $unique;
|
||||
} else {
|
||||
|
@ -562,38 +582,59 @@ class Application_Model_Scheduler
|
|||
* to that show
|
||||
*/
|
||||
if ($linked) {
|
||||
$instances = $ccShow->getCcShowInstancess();
|
||||
$instance_sql = "SELECT * FROM cc_show_instances ".
|
||||
"WHERE show_id = ".$ccShow["id"];
|
||||
$instances = Application_Common_Database::prepareAndExecute(
|
||||
$instance_sql);
|
||||
} else {
|
||||
$instances = array($ccShowInstance);
|
||||
$instance_sql = "SELECT * FROM cc_show_instances ".
|
||||
"WHERE id = ".$schedule["instance"];
|
||||
$instances = Application_Common_Database::prepareAndExecute(
|
||||
$instance_sql);
|
||||
}
|
||||
|
||||
$excludePositions = array();
|
||||
foreach($instances as &$instance) {
|
||||
$instanceId = $instance->getDbId();
|
||||
$instanceId = $instance["id"];
|
||||
if ($id !== 0) {
|
||||
/* We use the selected cursor's position to find the same
|
||||
* positions in every other linked instance
|
||||
*/
|
||||
$pos = $ccSchedule->getDbPosition();
|
||||
$pos = $ccSchedule["position"];
|
||||
|
||||
$linkCcSchedule = CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($instanceId)
|
||||
->filterByDbPosition($pos)
|
||||
->findOne();
|
||||
$linkedItem_sql = "SELECT ends FROM cc_schedule ".
|
||||
"WHERE instance_id = {$instanceId} ".
|
||||
"AND position = {$pos} ".
|
||||
"AND playout_status != -1";
|
||||
$linkedItemEnds = Application_Common_Database::prepareAndExecute(
|
||||
$linkedItem_sql, array(), Application_Common_Database::COLUMN);
|
||||
|
||||
$schedItemEndDT = $linkCcSchedule->getDbEnds(null);
|
||||
$nextStartDT = $this->findNextStartTime($schedItemEndDT, $instance);
|
||||
$nextStartDT = $this->findNextStartTime(
|
||||
new DateTime($linkedItemEnds, new DateTimeZone("UTC")),
|
||||
$instanceId);
|
||||
|
||||
$pos++;
|
||||
|
||||
/* Show is not empty so we need to apply crossfades
|
||||
* for the first inserted item
|
||||
*/
|
||||
$applyCrossfades = true;
|
||||
}
|
||||
//selected empty row to add after
|
||||
else {
|
||||
$showStartDT = $instance->getDbStarts(null);
|
||||
$nextStartDT = $this->findNextStartTime($showStartDT, $instance);
|
||||
$showStartDT = new DateTime($instance["starts"], new DateTimeZone("UTC"));
|
||||
$nextStartDT = $this->findNextStartTime($showStartDT, $instanceId);
|
||||
|
||||
//show is empty so start position counter at 0
|
||||
//first item in show so start position counter at 0
|
||||
$pos = 0;
|
||||
|
||||
/* Show is empty so we don't need to calculate crossfades
|
||||
* for the first inserted item
|
||||
*/
|
||||
$applyCrossfades = false;
|
||||
}
|
||||
|
||||
if (!in_array($instance->getDbId(), $affectedShowInstances)) {
|
||||
if (!in_array($instanceId, $affectedShowInstances)) {
|
||||
$affectedShowInstances[] = $instanceId;
|
||||
}
|
||||
|
||||
|
@ -605,7 +646,12 @@ class Application_Model_Scheduler
|
|||
|
||||
$pstart = microtime(true);
|
||||
|
||||
$initalStartDT = clone $nextStartDT;
|
||||
if ($applyCrossfades) {
|
||||
$initalStartDT = clone $this->findTimeDifference(
|
||||
$nextStartDT, $this->crossfadeDuration);
|
||||
} else {
|
||||
$initalStartDT = clone $nextStartDT;
|
||||
}
|
||||
|
||||
$pend = microtime(true);
|
||||
Logging::debug("finding all following items.");
|
||||
|
@ -620,83 +666,129 @@ class Application_Model_Scheduler
|
|||
}
|
||||
}
|
||||
|
||||
$doInsert = false;
|
||||
$doUpdate = false;
|
||||
$values = array();
|
||||
|
||||
foreach ($filesToInsert as &$file) {
|
||||
//item existed previously and is being moved.
|
||||
//need to keep same id for resources if we want REST.
|
||||
if (isset($file['sched_id'])) {
|
||||
$sched = CcScheduleQuery::create()->findPk($file["sched_id"]);
|
||||
$adjustFromDT = clone $nextStartDT;
|
||||
$doUpdate = true;
|
||||
|
||||
$movedItem_sql = "SELECT * FROM cc_schedule ".
|
||||
"WHERE id = ".$file["sched_id"];
|
||||
$sched = Application_Common_Database::prepareAndExecute(
|
||||
$movedItem_sql, array(), Application_Common_Database::SINGLE);
|
||||
|
||||
/* We need to keep a record of the original positon a track
|
||||
* is being moved from so we can use it to retrieve the correct
|
||||
* items in linked instances
|
||||
*/
|
||||
if (!isset($originalPosition)) {
|
||||
$originalPosition = $sched->getDbPosition();
|
||||
$originalPosition = $sched["position"];
|
||||
}
|
||||
|
||||
/* If we are moving an item in a linked show we need to get
|
||||
* the relative item to move in each instance. We know what the
|
||||
* relative item is by its position
|
||||
*/
|
||||
if ($linked && $moveAction) {
|
||||
$sched = CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($instanceId)
|
||||
->filterByDbPosition($originalPosition)
|
||||
->findOne();
|
||||
}
|
||||
$excludeIds[] = intval($sched->getDbId());
|
||||
if ($linked) {
|
||||
$movedItem_sql = "SELECT * FROM cc_schedule ".
|
||||
"WHERE position = {$originalPosition} ".
|
||||
"AND instance_id = {$instanceId}";
|
||||
|
||||
$file["cliplength"] = $sched->getDbClipLength();
|
||||
$file["cuein"] = $sched->getDbCueIn();
|
||||
$file["cueout"] = $sched->getDbCueOut();
|
||||
$file["fadein"] = $sched->getDbFadeIn();
|
||||
$file["fadeout"] = $sched->getDbFadeOut();
|
||||
$sched = Application_Common_Database::prepareAndExecute(
|
||||
$movedItem_sql, array(), Application_Common_Database::SINGLE);
|
||||
}
|
||||
$excludeIds[] = intval($sched["id"]);
|
||||
|
||||
$file["cliplength"] = $sched["clip_length"];
|
||||
$file["cuein"] = $sched["cue_in"];
|
||||
$file["cueout"] = $sched["cue_out"];
|
||||
$file["fadein"] = $sched["fade_in"];
|
||||
$file["fadeout"] = $sched["fade_out"];
|
||||
} else {
|
||||
$sched = new CcSchedule();
|
||||
$doInsert = true;
|
||||
}
|
||||
|
||||
$endTimeDT = $this->findEndTime($nextStartDT, $file['cliplength']);
|
||||
// default fades are in seconds
|
||||
// we need to convert to '00:00:00' format
|
||||
$file['fadein'] = Application_Common_DateHelper::secondsToPlaylistTime($file['fadein']);
|
||||
$file['fadeout'] = Application_Common_DateHelper::secondsToPlaylistTime($file['fadeout']);
|
||||
|
||||
$sched->setDbStarts($nextStartDT)
|
||||
->setDbEnds($endTimeDT)
|
||||
->setDbCueIn($file['cuein'])
|
||||
->setDbCueOut($file['cueout'])
|
||||
->setDbFadeIn($file['fadein'])
|
||||
->setDbFadeOut($file['fadeout'])
|
||||
->setDbClipLength($file['cliplength'])
|
||||
->setDbPosition($pos);
|
||||
|
||||
if (!$moveAction) {
|
||||
$sched->setDbInstanceId($instanceId);
|
||||
}
|
||||
|
||||
switch ($file["type"]) {
|
||||
case 0:
|
||||
$sched->setDbFileId($file['id']);
|
||||
$fileId = $file["id"];
|
||||
$streamId = "null";
|
||||
break;
|
||||
case 1:
|
||||
$sched->setDbStreamId($file['id']);
|
||||
$streamId = $file["id"];
|
||||
$fileId = "null";
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
$sched->save($this->con);
|
||||
if ($applyCrossfades) {
|
||||
$nextStartDT = $this->findTimeDifference($nextStartDT,
|
||||
$this->crossfadeDuration);
|
||||
$endTimeDT = $this->findEndTime($nextStartDT, $file['cliplength']);
|
||||
$endTimeDT = $this->findTimeDifference($endTimeDT, $this->crossfadeDuration);
|
||||
/* Set it to false because the rest of the crossfades
|
||||
* will be applied after we insert each item
|
||||
*/
|
||||
$applyCrossfades = false;
|
||||
}
|
||||
|
||||
$nextStartDT = $endTimeDT;
|
||||
$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")}', ".
|
||||
"'{$file["cuein"]}', ".
|
||||
"'{$file["cueout"]}', ".
|
||||
"'{$file["fadein"]}', ".
|
||||
"'{$file["fadeout"]}', ".
|
||||
"'{$file["cliplength"]}', ".
|
||||
"{$pos}, ".
|
||||
"{$instanceId}, ".
|
||||
"{$fileId}, ".
|
||||
"{$streamId})";
|
||||
|
||||
} 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")}', ".
|
||||
"cue_in = '{$file["cuein"]}', ".
|
||||
"cue_out = '{$file["cueout"]}', ".
|
||||
"fade_in = '{$file["fadein"]}', ".
|
||||
"fade_out = '{$file["fadeout"]}', ".
|
||||
"clip_length = '{$file["cliplength"]}', ".
|
||||
"position = {$pos} ".
|
||||
"WHERE id = {$sched["id"]}";
|
||||
|
||||
Application_Common_Database::prepareAndExecute(
|
||||
$update_sql, array(), Application_Common_Database::EXECUTE);
|
||||
}
|
||||
|
||||
$nextStartDT = $this->findTimeDifference($endTimeDT, $this->crossfadeDuration);
|
||||
$pos++;
|
||||
|
||||
/* If we are adjusting start and end times for items
|
||||
* after the insert location, we need to exclude the
|
||||
* schedule item we just inserted because it has correct
|
||||
* start and end times*/
|
||||
$excludeIds[] = $sched->getDbId();
|
||||
|
||||
}//all files have been inserted/moved
|
||||
if ($doInsert) {
|
||||
$insert_sql = "INSERT INTO cc_schedule ".
|
||||
"(starts, ends, cue_in, cue_out, fade_in, fade_out, ".
|
||||
"clip_length, position, instance_id, file_id, stream_id) VALUES ".
|
||||
implode($values, ",")." RETURNING id";
|
||||
|
||||
$stmt = $this->con->prepare($insert_sql);
|
||||
if ($stmt->execute()) {
|
||||
foreach ($stmt->fetchAll() as $row) {
|
||||
$excludeIds[] = $row["id"];
|
||||
}
|
||||
};
|
||||
}
|
||||
// update is_scheduled flag for each cc_file
|
||||
$fileIds = array();
|
||||
foreach ($filesToInsert as &$file) {
|
||||
|
@ -717,34 +809,43 @@ class Application_Model_Scheduler
|
|||
}
|
||||
|
||||
if ($adjustSched === true) {
|
||||
$followingSchedItems = CcScheduleQuery::create()
|
||||
->filterByDBStarts($initalStartDT->format("Y-m-d H:i:s.u"), Criteria::GREATER_EQUAL)
|
||||
->filterByDbInstanceId($instance->getDbId())
|
||||
->filterByDbId($excludeIds, Criteria::NOT_IN)
|
||||
->orderByDbStarts()
|
||||
->find($this->con);
|
||||
|
||||
$followingItems_sql = "SELECT * FROM cc_schedule ".
|
||||
"WHERE starts >= '{$initalStartDT->format("Y-m-d H:i:s.u")}' ".
|
||||
"AND instance_id = {$instanceId} ";
|
||||
if (count($excludeIds) > 0) {
|
||||
$followingItems_sql .= "AND id NOT IN (". implode($excludeIds, ",").") ";
|
||||
}
|
||||
$followingItems_sql .= "ORDER BY starts";
|
||||
$followingSchedItems = Application_Common_Database::prepareAndExecute(
|
||||
$followingItems_sql);
|
||||
|
||||
$pstart = microtime(true);
|
||||
|
||||
//recalculate the start/end times after the inserted items.
|
||||
foreach ($followingSchedItems as $item) {
|
||||
$endTimeDT = $this->findEndTime($nextStartDT, $item->getDbClipLength());
|
||||
$item->setDbStarts($nextStartDT);
|
||||
$item->setDbEnds($endTimeDT);
|
||||
$item->setDbPosition($pos);
|
||||
$item->save($this->con);
|
||||
$nextStartDT = $endTimeDT;
|
||||
$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")}', ".
|
||||
"position = {$pos} ".
|
||||
"WHERE id = {$item["id"]}";
|
||||
Application_Common_Database::prepareAndExecute(
|
||||
$update_sql, array(), Application_Common_Database::EXECUTE);
|
||||
|
||||
$nextStartDT = $this->findTimeDifference($endTimeDT, $this->crossfadeDuration);
|
||||
$pos++;
|
||||
}
|
||||
|
||||
$pend = microtime(true);
|
||||
Logging::debug("adjusting all following items.");
|
||||
Logging::debug(floatval($pend) - floatval($pstart));
|
||||
|
||||
$this->calculateCrossfades($instance->getDbId());
|
||||
}
|
||||
if ($moveAction) {
|
||||
$this->calculateCrossfades($instanceId);
|
||||
}
|
||||
}//for each instance
|
||||
|
||||
}//for each schedule location
|
||||
|
||||
$endProfile = microtime(true);
|
||||
|
@ -782,6 +883,11 @@ class Application_Model_Scheduler
|
|||
}
|
||||
}
|
||||
|
||||
private function updateMovedItem()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private function getInstances($instanceId)
|
||||
{
|
||||
$ccShowInstance = CcShowInstancesQuery::create()->findPk($instanceId);
|
||||
|
@ -999,7 +1105,7 @@ class Application_Model_Scheduler
|
|||
} else {
|
||||
$removedItem->delete($this->con);
|
||||
}
|
||||
|
||||
|
||||
// update is_scheduled in cc_files but only if
|
||||
// the file is not scheduled somewhere else
|
||||
$fileId = $removedItem->getDbFileId();
|
||||
|
|
|
@ -388,6 +388,7 @@ class Application_Model_ShowBuilder
|
|||
$outdated = false;
|
||||
$shows = Application_Model_Show::getShows($this->startDT, $this->endDT);
|
||||
|
||||
$include = array();
|
||||
if ($this->opts["showFilter"] !== 0) {
|
||||
$include[] = $this->opts["showFilter"];
|
||||
} elseif ($this->opts["myShows"] === 1) {
|
||||
|
|
|
@ -352,10 +352,10 @@ SQL;
|
|||
);
|
||||
|
||||
//only need to check overlap if show increased in size.
|
||||
if (strtotime($new_ends) > strtotime($ends)) {
|
||||
if (strtotime($now_ends) > strtotime($ends)) {
|
||||
|
||||
$utcStartDateTime = new DateTime($ends, new DateTimeZone("UTC"));
|
||||
$utcEndDateTime = new DateTime($new_ends, new DateTimeZone("UTC"));
|
||||
$utcEndDateTime = new DateTime($now_ends, new DateTimeZone("UTC"));
|
||||
|
||||
$overlap = Application_Model_Show::getShows($utcStartDateTime, $utcEndDateTime);
|
||||
|
||||
|
@ -381,7 +381,7 @@ SQL;
|
|||
|
||||
}
|
||||
|
||||
$this->setShowEnd($new_ends);
|
||||
$this->setShowEnd($now_ends);
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
}
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ class Application_Model_StoredFile
|
|||
}
|
||||
}
|
||||
$dbMd[constant($mdConst)] = $mdValue;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
$this->setDbColMetadata($dbMd);
|
||||
|
@ -214,7 +214,7 @@ class Application_Model_StoredFile
|
|||
if (isset($this->_dbMD[$dbColumn])) {
|
||||
$propelColumn = $this->_dbMD[$dbColumn];
|
||||
$method = "set$propelColumn";
|
||||
|
||||
|
||||
/* We need to set track_number to null if it is an empty string
|
||||
* because propel defaults empty strings to zeros */
|
||||
if ($dbColumn == "track_number" && empty($mdValue)) $mdValue = null;
|
||||
|
@ -330,7 +330,7 @@ SQL;
|
|||
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindParam(':file_id', $this->id, PDO::PARAM_INT);
|
||||
|
||||
|
||||
if ($stmt->execute()) {
|
||||
$ids = $stmt->fetchAll();
|
||||
} else {
|
||||
|
@ -386,7 +386,7 @@ SQL;
|
|||
// set hidden flag to true
|
||||
$this->_file->setDbHidden(true);
|
||||
$this->_file->save();
|
||||
|
||||
|
||||
// need to explicitly update any playlist's and block's length
|
||||
// that contains the file getting deleted
|
||||
$fileId = $this->_file->getDbId();
|
||||
|
@ -396,7 +396,7 @@ SQL;
|
|||
$pl->setDbLength($pl->computeDbLength(Propel::getConnection(CcPlaylistPeer::DATABASE_NAME)));
|
||||
$pl->save();
|
||||
}
|
||||
|
||||
|
||||
$blRows = CcBlockcontentsQuery::create()->filterByDbFileId($fileId)->find();
|
||||
foreach ($blRows as $row) {
|
||||
$bl = CcBlockQuery::create()->filterByDbId($row->getDbBlockId())->findOne();
|
||||
|
@ -506,19 +506,19 @@ SQL;
|
|||
public function getFileUrl()
|
||||
{
|
||||
$CC_CONFIG = Config::getConfig();
|
||||
|
||||
|
||||
$protocol = empty($_SERVER['HTTPS']) ? "http" : "https";
|
||||
|
||||
|
||||
$serverName = $_SERVER['SERVER_NAME'];
|
||||
$serverPort = $_SERVER['SERVER_PORT'];
|
||||
$subDir = $CC_CONFIG['baseDir'];
|
||||
|
||||
|
||||
if ($subDir[0] === "/") {
|
||||
$subDir = substr($subDir, 1, strlen($subDir) - 1);
|
||||
}
|
||||
|
||||
|
||||
$baseUrl = "{$protocol}://{$serverName}:{$serverPort}/{$subDir}";
|
||||
|
||||
|
||||
return $this->getRelativeFileUrl($baseUrl);
|
||||
}
|
||||
|
||||
|
@ -528,8 +528,6 @@ SQL;
|
|||
*/
|
||||
public function getRelativeFileUrl($baseUrl)
|
||||
{
|
||||
Logging::debug("Zend base url: $baseUrl");
|
||||
|
||||
return $baseUrl."api/get-media/file/".$this->getId().".".$this->getFileExtension();
|
||||
}
|
||||
|
||||
|
@ -643,7 +641,7 @@ SQL;
|
|||
public static function searchLibraryFiles($datatables)
|
||||
{
|
||||
$baseUrl = Application_Common_OsPath::getBaseDir();
|
||||
|
||||
|
||||
$con = Propel::getConnection(CcFilesPeer::DATABASE_NAME);
|
||||
|
||||
$displayColumns = self::getLibraryColumns();
|
||||
|
@ -780,16 +778,18 @@ SQL;
|
|||
foreach ($results['aaData'] as &$row) {
|
||||
$row['id'] = intval($row['id']);
|
||||
|
||||
$len_formatter = new LengthFormatter($row['length']);
|
||||
$row['length'] = $len_formatter->format();
|
||||
|
||||
$cuein_formatter = new LengthFormatter($row["cuein"]);
|
||||
$row["cuein"] = $cuein_formatter->format();
|
||||
|
||||
$cueout_formatter = new LengthFormatter($row["cueout"]);
|
||||
$row["cueout"] = $cueout_formatter->format();
|
||||
|
||||
if ($row['ftype'] === "audioclip") {
|
||||
|
||||
$cuein_formatter = new LengthFormatter($row["cuein"]);
|
||||
$row["cuein"] = $cuein_formatter->format();
|
||||
|
||||
$cueout_formatter = new LengthFormatter($row["cueout"]);
|
||||
$row["cueout"] = $cueout_formatter->format();
|
||||
|
||||
$cuein = Application_Common_DateHelper::playlistTimeToSeconds($row["cuein"]);
|
||||
$cueout = Application_Common_DateHelper::playlistTimeToSeconds($row["cueout"]);
|
||||
$row_length = Application_Common_DateHelper::secondsToPlaylistTime($cueout - $cuein);
|
||||
|
||||
$formatter = new SamplerateFormatter($row['sample_rate']);
|
||||
$row['sample_rate'] = $formatter->format();
|
||||
|
||||
|
@ -798,13 +798,20 @@ SQL;
|
|||
|
||||
//soundcloud status
|
||||
$file = Application_Model_StoredFile::RecallById($row['id']);
|
||||
$row['soundcloud_status'] = $file->getSoundCloudId();
|
||||
$row['soundcloud_id'] = $file->getSoundCloudId();
|
||||
|
||||
// for audio preview
|
||||
$row['audioFile'] = $row['id'].".".pathinfo($row['filepath'], PATHINFO_EXTENSION);
|
||||
} else {
|
||||
$row['audioFile'] = $row['id'];
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
$row['audioFile'] = $row['id'];
|
||||
$row_length = $row['length'];
|
||||
}
|
||||
|
||||
$len_formatter = new LengthFormatter($row_length);
|
||||
$row['length'] = $len_formatter->format();
|
||||
|
||||
//convert mtime and utime to localtime
|
||||
$row['mtime'] = new DateTime($row['mtime'], new DateTimeZone('UTC'));
|
||||
|
@ -895,7 +902,7 @@ SQL;
|
|||
$in = fopen($_FILES['file']['tmp_name'], "rb");
|
||||
|
||||
if ($in) {
|
||||
while ($buff = fread($in, 4096))
|
||||
while (($buff = fread($in, 4096)))
|
||||
fwrite($out, $buff);
|
||||
} else
|
||||
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": _("Failed to open input stream.")}, "id" : "id"}');
|
||||
|
@ -914,7 +921,7 @@ SQL;
|
|||
$in = fopen("php://input", "rb");
|
||||
|
||||
if ($in) {
|
||||
while ($buff = fread($in, 4096))
|
||||
while (($buff = fread($in, 4096)))
|
||||
fwrite($out, $buff);
|
||||
} else
|
||||
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": _("Failed to open input stream.")}, "id" : "id"}');
|
||||
|
@ -963,6 +970,7 @@ SQL;
|
|||
// Check if we have enough space before copying
|
||||
if (!self::isEnoughDiskSpaceToCopy($stor, $audio_file)) {
|
||||
$freeSpace = disk_free_space($stor);
|
||||
$fileSize = filesize($audio_file);
|
||||
|
||||
return array("code" => 107,
|
||||
"message" => sprintf(_("The file was not uploaded, there is "
|
||||
|
@ -1030,7 +1038,7 @@ SQL;
|
|||
$LIQUIDSOAP_ERRORS = array('TagLib: MPEG::Properties::read() -- Could not find a valid last MPEG frame in the stream.');
|
||||
|
||||
// Ask Liquidsoap if file is playable
|
||||
$ls_command = sprintf('/usr/bin/airtime-liquidsoap -v -c "output.dummy(audio_to_stereo(single(%s)))" 2>&1',
|
||||
$ls_command = sprintf('/usr/bin/airtime-liquidsoap -v -c "output.dummy(audio_to_stereo(single(%s)))" 2>&1',
|
||||
escapeshellarg($audio_file));
|
||||
|
||||
$command = "export PATH=/usr/local/bin:/usr/bin:/bin/usr/bin/ && $ls_command";
|
||||
|
@ -1070,14 +1078,14 @@ SQL;
|
|||
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindParam(':dir_id', $dir_id);
|
||||
|
||||
|
||||
if ($stmt->execute()) {
|
||||
$rows = $stmt->fetchAll();
|
||||
} else {
|
||||
$msg = implode(',', $stmt->errorInfo());
|
||||
throw new Exception("Error: $msg");
|
||||
}
|
||||
|
||||
|
||||
$results = array();
|
||||
foreach ($rows as $row) {
|
||||
$results[] = $row["fp"];
|
||||
|
@ -1113,10 +1121,10 @@ SQL;
|
|||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
|
||||
public static function getAllFilesWithoutSilan() {
|
||||
$con = Propel::getConnection();
|
||||
|
||||
|
||||
$sql = <<<SQL
|
||||
SELECT f.id,
|
||||
m.directory || f.filepath AS fp
|
||||
|
@ -1126,14 +1134,14 @@ WHERE file_exists = 'TRUE'
|
|||
AND silan_check IS FALSE Limit 100
|
||||
SQL;
|
||||
$stmt = $con->prepare($sql);
|
||||
|
||||
|
||||
if ($stmt->execute()) {
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
} else {
|
||||
$msg = implode(',', $stmt->errorInfo());
|
||||
throw new Exception("Error: $msg");
|
||||
}
|
||||
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
|
@ -1229,7 +1237,7 @@ SQL;
|
|||
->save();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// This method seems to be unsued everywhere so I've commented it out
|
||||
// If it's absence does not have any effect then it will be completely
|
||||
// removed soon
|
||||
|
@ -1257,7 +1265,7 @@ SQL;
|
|||
$description = $file->getDbTrackTitle();
|
||||
$tag = array();
|
||||
$genre = $file->getDbGenre();
|
||||
$release = $file->getDbYear();
|
||||
$release = $file->getDbUtime();
|
||||
try {
|
||||
$soundcloud = new Application_Model_Soundcloud();
|
||||
$soundcloud_res = $soundcloud->uploadTrack(
|
||||
|
@ -1286,7 +1294,7 @@ SQL;
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function setIsPlaylist($p_playlistItems, $p_type, $p_status) {
|
||||
foreach ($p_playlistItems as $item) {
|
||||
$file = self::RecallById($item->getDbFileId());
|
||||
|
@ -1304,7 +1312,7 @@ SQL;
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function setIsScheduled($p_scheduleItem, $p_status,
|
||||
$p_fileId=null) {
|
||||
|
||||
|
@ -1347,14 +1355,6 @@ SQL;
|
|||
Application_Common_Database::prepareAndExecute($sql, array(),
|
||||
Application_Common_Database::EXECUTE);
|
||||
}
|
||||
|
||||
public function getRealClipLength($p_cuein, $p_cueout) {
|
||||
$sql = "SELECT :cueout::INTERVAL - :cuein::INTERVAL";
|
||||
|
||||
return Application_Common_Database::prepareAndExecute($sql, array(
|
||||
':cueout' => $p_cueout,
|
||||
':cuein' => $p_cuein), 'column');
|
||||
}
|
||||
}
|
||||
|
||||
class DeleteScheduledFileException extends Exception {}
|
||||
|
|
|
@ -125,6 +125,7 @@ class Application_Model_Systemstatus
|
|||
public static function GetPlatformInfo()
|
||||
{
|
||||
$keys = array("release", "machine", "memory", "swap");
|
||||
$data = array();
|
||||
foreach ($keys as $key) {
|
||||
$data[$key] = "UNKNOWN";
|
||||
}
|
||||
|
@ -212,7 +213,7 @@ class Application_Model_Systemstatus
|
|||
|
||||
public static function GetDiskInfo()
|
||||
{
|
||||
$partions = array();
|
||||
$partitions = array();
|
||||
|
||||
//connect to DB and find how much total space user has allocated.
|
||||
$totalSpace = Application_Model_Preference::GetDiskQuota();
|
||||
|
|
|
@ -226,7 +226,7 @@ class Application_Model_User
|
|||
public function deleteAllFiles()
|
||||
{
|
||||
$my_files = $this->getOwnedFiles();
|
||||
foreach ($files as $file) {
|
||||
foreach ($my_files as $file) {
|
||||
$file->delete();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,14 @@ class CcFiles extends BaseCcFiles {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function setDbTrackNumber($v)
|
||||
{
|
||||
$max = pow(2, 31)-1;
|
||||
$v = ($v > $max) ? $max : $v;
|
||||
|
||||
return parent::setDbTrackNumber($v);
|
||||
}
|
||||
|
||||
// returns true if the file exists and is not hidden
|
||||
public function visible() {
|
||||
return $this->getDbFileExists() && !$this->getDbHidden();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue