CC-4090: Make code style PSR compliant - part 4
-models dir
This commit is contained in:
parent
699a49a103
commit
4848717d4d
17 changed files with 439 additions and 404 deletions
File diff suppressed because it is too large
Load diff
|
@ -15,7 +15,7 @@ class Application_Model_Datatables
|
||||||
} else {
|
} else {
|
||||||
$input1 = $term;
|
$input1 = $term;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($isRange) {
|
if ($isRange) {
|
||||||
$sub = array();
|
$sub = array();
|
||||||
if ($input1 != null) {
|
if ($input1 != null) {
|
||||||
|
@ -33,6 +33,7 @@ class Application_Model_Datatables
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return implode(" AND ", $where);
|
return implode(" AND ", $where);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -41,7 +42,7 @@ class Application_Model_Datatables
|
||||||
public static function findEntries($con, $displayColumns, $fromTable, $data, $dataProp = "aaData")
|
public static function findEntries($con, $displayColumns, $fromTable, $data, $dataProp = "aaData")
|
||||||
{
|
{
|
||||||
$librarySetting = Application_Model_Preference::getCurrentLibraryTableSetting();
|
$librarySetting = Application_Model_Preference::getCurrentLibraryTableSetting();
|
||||||
|
|
||||||
// map that maps original column position to db name
|
// map that maps original column position to db name
|
||||||
$current2dbname = array();
|
$current2dbname = array();
|
||||||
// array of search terms
|
// array of search terms
|
||||||
|
@ -50,22 +51,22 @@ class Application_Model_Datatables
|
||||||
if (strstr($key, "mDataProp_")) {
|
if (strstr($key, "mDataProp_")) {
|
||||||
list($dump, $index) = explode("_", $key);
|
list($dump, $index) = explode("_", $key);
|
||||||
$current2dbname[$index] = $d;
|
$current2dbname[$index] = $d;
|
||||||
} else if (strstr($key, "sSearch_")) {
|
} elseif (strstr($key, "sSearch_")) {
|
||||||
list($dump, $index) = explode("_", $key);
|
list($dump, $index) = explode("_", $key);
|
||||||
$orig2searchTerm[$index] = $d;
|
$orig2searchTerm[$index] = $d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// map that maps current column position to original position
|
// map that maps current column position to original position
|
||||||
$current2orig = $librarySetting['ColReorder'];
|
$current2orig = $librarySetting['ColReorder'];
|
||||||
|
|
||||||
// map that maps dbname to searchTerm
|
// map that maps dbname to searchTerm
|
||||||
$dbname2searchTerm = array();
|
$dbname2searchTerm = array();
|
||||||
foreach ($current2dbname as $currentPos=>$dbname) {
|
foreach ($current2dbname as $currentPos=>$dbname) {
|
||||||
$dbname2searchTerm[$dbname] = $orig2searchTerm[$current2orig[$currentPos]];
|
$dbname2searchTerm[$dbname] = $orig2searchTerm[$current2orig[$currentPos]];
|
||||||
}
|
}
|
||||||
|
|
||||||
$where = array();
|
$where = array();
|
||||||
|
|
||||||
$advancedWhere = self::buildWhereClauseForAdvancedSearch($dbname2searchTerm);
|
$advancedWhere = self::buildWhereClauseForAdvancedSearch($dbname2searchTerm);
|
||||||
if ($advancedWhere != "") {
|
if ($advancedWhere != "") {
|
||||||
$where[] = $advancedWhere;
|
$where[] = $advancedWhere;
|
||||||
|
@ -158,7 +159,7 @@ class Application_Model_Datatables
|
||||||
if ($r['ftype'] == 'playlist') {
|
if ($r['ftype'] == 'playlist') {
|
||||||
$pl = new Application_Model_Playlist($r['id']);
|
$pl = new Application_Model_Playlist($r['id']);
|
||||||
$r['length'] = $pl->getLength();
|
$r['length'] = $pl->getLength();
|
||||||
} else if ($r['ftype'] == "block") {
|
} elseif ($r['ftype'] == "block") {
|
||||||
$bl = new Application_Model_Block($r['id']);
|
$bl = new Application_Model_Block($r['id']);
|
||||||
if ($bl->isStatic()) {
|
if ($bl->isStatic()) {
|
||||||
$r['bl_type'] = 'static';
|
$r['bl_type'] = 'static';
|
||||||
|
|
|
@ -26,7 +26,7 @@ class Application_Model_Email
|
||||||
if ($mailServerRequiresAuth) {
|
if ($mailServerRequiresAuth) {
|
||||||
$username = Application_Model_Preference::GetMailServerEmailAddress();
|
$username = Application_Model_Preference::GetMailServerEmailAddress();
|
||||||
$password = Application_Model_Preference::GetMailServerPassword();
|
$password = Application_Model_Preference::GetMailServerPassword();
|
||||||
|
|
||||||
$config = array(
|
$config = array(
|
||||||
'auth' => 'login',
|
'auth' => 'login',
|
||||||
'ssl' => 'ssl',
|
'ssl' => 'ssl',
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Application_Model_Library
|
class Application_Model_Library
|
||||||
{
|
{
|
||||||
|
|
||||||
public static function getObjInfo($p_type)
|
public static function getObjInfo($p_type)
|
||||||
{
|
{
|
||||||
$info = array();
|
$info = array();
|
||||||
|
|
||||||
if (strcmp($p_type, 'playlist')==0) {
|
if (strcmp($p_type, 'playlist')==0) {
|
||||||
$info['className'] = 'Application_Model_Playlist';
|
$info['className'] = 'Application_Model_Playlist';
|
||||||
} else if (strcmp($p_type, 'block')==0) {
|
} elseif (strcmp($p_type, 'block')==0) {
|
||||||
$info['className'] = 'Application_Model_Block';
|
$info['className'] = 'Application_Model_Block';
|
||||||
} else if (strcmp($p_type, 'stream')==0) {
|
} elseif (strcmp($p_type, 'stream')==0) {
|
||||||
$info['className'] = 'Application_Model_Webstream';
|
$info['className'] = 'Application_Model_Webstream';
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Unknown object type: '$p_type'");
|
throw new Exception("Unknown object type: '$p_type'");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -226,7 +226,7 @@ SQL;
|
||||||
$clipSec = Application_Common_DateHelper::playlistTimeToSeconds($row['length']);
|
$clipSec = Application_Common_DateHelper::playlistTimeToSeconds($row['length']);
|
||||||
$offset += $clipSec;
|
$offset += $clipSec;
|
||||||
$offset_cliplength = Application_Common_DateHelper::secondsToPlaylistTime($offset);
|
$offset_cliplength = Application_Common_DateHelper::secondsToPlaylistTime($offset);
|
||||||
|
|
||||||
//format the length for UI.
|
//format the length for UI.
|
||||||
if ($row['type'] == 2) {
|
if ($row['type'] == 2) {
|
||||||
$bl = new Application_Model_Block($row['item_id']);
|
$bl = new Application_Model_Block($row['item_id']);
|
||||||
|
@ -235,15 +235,15 @@ SQL;
|
||||||
$formatter = new LengthFormatter($row['length']);
|
$formatter = new LengthFormatter($row['length']);
|
||||||
}
|
}
|
||||||
$row['length'] = $formatter->format();
|
$row['length'] = $formatter->format();
|
||||||
|
|
||||||
$formatter = new LengthFormatter($offset_cliplength);
|
$formatter = new LengthFormatter($offset_cliplength);
|
||||||
$row['offset'] = $formatter->format();
|
$row['offset'] = $formatter->format();
|
||||||
|
|
||||||
//format the fades in format 00(.000000)
|
//format the fades in format 00(.000000)
|
||||||
$fades = $this->getFadeInfo($row['position']);
|
$fades = $this->getFadeInfo($row['position']);
|
||||||
$row['fadein'] = $fades[0];
|
$row['fadein'] = $fades[0];
|
||||||
$row['fadeout'] = $fades[1];
|
$row['fadeout'] = $fades[1];
|
||||||
|
|
||||||
//format original length
|
//format original length
|
||||||
$formatter = new LengthFormatter($row['orig_length']);
|
$formatter = new LengthFormatter($row['orig_length']);
|
||||||
$row['orig_length'] = $formatter->format();
|
$row['orig_length'] = $formatter->format();
|
||||||
|
@ -261,7 +261,7 @@ SQL;
|
||||||
{
|
{
|
||||||
//First get rid of the first six characters 00:00: which will be added back later for db update
|
//First get rid of the first six characters 00:00: which will be added back later for db update
|
||||||
$fade = substr($fade, 6);
|
$fade = substr($fade, 6);
|
||||||
|
|
||||||
//Second add .000000 if the fade does't have milliseconds format already
|
//Second add .000000 if the fade does't have milliseconds format already
|
||||||
$dbFadeStrPos = strpos( $fade, '.' );
|
$dbFadeStrPos = strpos( $fade, '.' );
|
||||||
if ($dbFadeStrPos === false) {
|
if ($dbFadeStrPos === false) {
|
||||||
|
@ -275,9 +275,10 @@ SQL;
|
||||||
//done, just need to set back the formated values
|
//done, just need to set back the formated values
|
||||||
return $fade;
|
return $fade;
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns true/false and ids of dynamic blocks
|
// returns true/false and ids of dynamic blocks
|
||||||
public function hasDynamicBlock(){
|
public function hasDynamicBlock()
|
||||||
|
{
|
||||||
$ids = $this->getIdsOfDynamicBlocks();
|
$ids = $this->getIdsOfDynamicBlocks();
|
||||||
if (count($ids) > 0) {
|
if (count($ids) > 0) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -285,29 +286,32 @@ SQL;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIdsOfDynamicBlocks() {
|
public function getIdsOfDynamicBlocks()
|
||||||
|
{
|
||||||
$sql = "SELECT bl.id FROM cc_playlistcontents as pc
|
$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'
|
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";
|
WHERE playlist_id={$this->id} AND pc.type=2";
|
||||||
$r = $this->con->query($sql);
|
$r = $this->con->query($sql);
|
||||||
$result = $r->fetchAll(PDO::FETCH_ASSOC);
|
$result = $r->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//aggregate column on playlistcontents cliplength column.
|
//aggregate column on playlistcontents cliplength column.
|
||||||
public function getLength()
|
public function getLength()
|
||||||
{
|
{
|
||||||
if ($this->hasDynamicBlock()){
|
if ($this->hasDynamicBlock()) {
|
||||||
$ids = $this->getIdsOfDynamicBlocks();
|
$ids = $this->getIdsOfDynamicBlocks();
|
||||||
$length = $this->pl->getDbLength();
|
$length = $this->pl->getDbLength();
|
||||||
foreach ($ids as $id){
|
foreach ($ids as $id) {
|
||||||
$bl = new Application_Model_Block($id['id']);
|
$bl = new Application_Model_Block($id['id']);
|
||||||
if ($bl->hasItemLimit()) {
|
if ($bl->hasItemLimit()) {
|
||||||
return "N/A";
|
return "N/A";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$formatter = new LengthFormatter($length);
|
$formatter = new LengthFormatter($length);
|
||||||
|
|
||||||
return "~".$formatter->format();
|
return "~".$formatter->format();
|
||||||
} else {
|
} else {
|
||||||
return $this->pl->getDbLength();
|
return $this->pl->getDbLength();
|
||||||
|
@ -327,10 +331,10 @@ SQL;
|
||||||
if ($info["ftype"] == "audioclip") {
|
if ($info["ftype"] == "audioclip") {
|
||||||
$row->setDbFileId($info["id"]);
|
$row->setDbFileId($info["id"]);
|
||||||
$type = 0;
|
$type = 0;
|
||||||
} else if ($info["ftype"] == "stream") {
|
} elseif ($info["ftype"] == "stream") {
|
||||||
$row->setDbStreamId($info["id"]);
|
$row->setDbStreamId($info["id"]);
|
||||||
$type = 1;
|
$type = 1;
|
||||||
} else if ($info["ftype"] == "block") {
|
} elseif ($info["ftype"] == "block") {
|
||||||
$row->setDbBlockId($info["id"]);
|
$row->setDbBlockId($info["id"]);
|
||||||
$type = 2;
|
$type = 2;
|
||||||
}
|
}
|
||||||
|
@ -352,9 +356,9 @@ SQL;
|
||||||
$objId = $p_item[0];
|
$objId = $p_item[0];
|
||||||
if ($objType == 'audioclip') {
|
if ($objType == 'audioclip') {
|
||||||
$obj = CcFilesQuery::create()->findPK($objId, $this->con);
|
$obj = CcFilesQuery::create()->findPK($objId, $this->con);
|
||||||
} else if ($objType == "stream") {
|
} elseif ($objType == "stream") {
|
||||||
$obj = CcWebstreamQuery::create()->findPK($objId, $this->con);
|
$obj = CcWebstreamQuery::create()->findPK($objId, $this->con);
|
||||||
} else if ($objType == "block") {
|
} elseif ($objType == "block") {
|
||||||
$obj = CcBlockQuery::create()->findPK($objId, $this->con);
|
$obj = CcBlockQuery::create()->findPK($objId, $this->con);
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Unknown file type");
|
throw new Exception("Unknown file type");
|
||||||
|
@ -369,6 +373,7 @@ SQL;
|
||||||
$entry["cueout"] = $obj->getDbLength();
|
$entry["cueout"] = $obj->getDbLength();
|
||||||
$entry["ftype"] = $objType;
|
$entry["ftype"] = $objType;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $entry;
|
return $entry;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("trying to add a object that does not exist.");
|
throw new Exception("trying to add a object that does not exist.");
|
||||||
|
@ -430,7 +435,7 @@ SQL;
|
||||||
|
|
||||||
Logging::info("Adding to playlist");
|
Logging::info("Adding to playlist");
|
||||||
Logging::info("at position {$pos}");
|
Logging::info("at position {$pos}");
|
||||||
|
|
||||||
foreach ($p_items as $ac) {
|
foreach ($p_items as $ac) {
|
||||||
$res = $this->insertPlaylistElement($this->buildEntry($ac, $pos));
|
$res = $this->insertPlaylistElement($this->buildEntry($ac, $pos));
|
||||||
$pos = $pos + 1;
|
$pos = $pos + 1;
|
||||||
|
@ -575,15 +580,16 @@ SQL;
|
||||||
->filterByDbPlaylistId($this->id)
|
->filterByDbPlaylistId($this->id)
|
||||||
->filterByDbPosition($pos)
|
->filterByDbPosition($pos)
|
||||||
->findOne();
|
->findOne();
|
||||||
|
|
||||||
if (!$row) {
|
if (!$row) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#Propel returns values in form 00.000000 format which is for only seconds.
|
#Propel returns values in form 00.000000 format which is for only seconds.
|
||||||
$fadeIn = $row->getDbFadein();
|
$fadeIn = $row->getDbFadein();
|
||||||
$fadeOut = $row->getDbFadeout();
|
$fadeOut = $row->getDbFadeout();
|
||||||
|
|
||||||
return array($fadeIn, $fadeOut);
|
return array($fadeIn, $fadeOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change fadeIn and fadeOut values for playlist Element
|
* Change fadeIn and fadeOut values for playlist Element
|
||||||
|
@ -877,7 +883,7 @@ SQL;
|
||||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||||
$user = new Application_Model_User($userInfo->id);
|
$user = new Application_Model_User($userInfo->id);
|
||||||
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
||||||
|
|
||||||
if (!$isAdminOrPM) {
|
if (!$isAdminOrPM) {
|
||||||
$leftOver = self::playlistsNotOwnedByUser($p_ids, $p_userId);
|
$leftOver = self::playlistsNotOwnedByUser($p_ids, $p_userId);
|
||||||
if (count($leftOver) == 0) {
|
if (count($leftOver) == 0) {
|
||||||
|
@ -889,9 +895,10 @@ SQL;
|
||||||
CcPlaylistQuery::create()->findPKs($p_ids)->delete();
|
CcPlaylistQuery::create()->findPKs($p_ids)->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function returns that are not owen by $p_user_id among $p_ids
|
// This function returns that are not owen by $p_user_id among $p_ids
|
||||||
private static function playlistsNotOwnedByUser($p_ids, $p_userId){
|
private static function playlistsNotOwnedByUser($p_ids, $p_userId)
|
||||||
|
{
|
||||||
$ownedByUser = CcPlaylistQuery::create()->filterByDbCreatorId($p_userId)->find()->getData();
|
$ownedByUser = CcPlaylistQuery::create()->filterByDbCreatorId($p_userId)->find()->getData();
|
||||||
$selectedPls = $p_ids;
|
$selectedPls = $p_ids;
|
||||||
$ownedPls = array();
|
$ownedPls = array();
|
||||||
|
@ -900,11 +907,12 @@ SQL;
|
||||||
$ownedPls[] = $pl->getDbId();
|
$ownedPls[] = $pl->getDbId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$leftOvers = array_diff($selectedPls, $ownedPls);
|
$leftOvers = array_diff($selectedPls, $ownedPls);
|
||||||
|
|
||||||
return $leftOvers;
|
return $leftOvers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete all files from playlist
|
* Delete all files from playlist
|
||||||
* @param int $p_playlistId
|
* @param int $p_playlistId
|
||||||
|
|
|
@ -1089,12 +1089,12 @@ class Application_Model_Preference
|
||||||
{
|
{
|
||||||
return self::getValue("mail_server_port");
|
return self::getValue("mail_server_port");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SetMailServerRequiresAuth($value)
|
public static function SetMailServerRequiresAuth($value)
|
||||||
{
|
{
|
||||||
self::setValue("mail_server_requires_auth", $value, false);
|
self::setValue("mail_server_requires_auth", $value, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetMailServerRequiresAuth()
|
public static function GetMailServerRequiresAuth()
|
||||||
{
|
{
|
||||||
return self::getValue("mail_server_requires_auth");
|
return self::getValue("mail_server_requires_auth");
|
||||||
|
@ -1109,8 +1109,9 @@ class Application_Model_Preference
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getCurrentLibraryTableSetting(){
|
public static function getCurrentLibraryTableSetting()
|
||||||
|
{
|
||||||
return unserialize(self::getValue("library_datatable"));
|
return unserialize(self::getValue("library_datatable"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ class Application_Model_Schedule
|
||||||
if (!is_int($p_prev) || !is_int($p_next)) {
|
if (!is_int($p_prev) || !is_int($p_next)) {
|
||||||
//must enter integers to specify ranges
|
//must enter integers to specify ranges
|
||||||
Logging::info("Invalid range parameters: $p_prev or $p_next");
|
Logging::info("Invalid range parameters: $p_prev or $p_next");
|
||||||
|
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,40 +76,40 @@ class Application_Model_Schedule
|
||||||
|
|
||||||
global $CC_CONFIG;
|
global $CC_CONFIG;
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
$sql = "SELECT %%columns%% st.starts as starts, st.ends as ends,
|
$sql = "SELECT %%columns%% st.starts as starts, st.ends as ends,
|
||||||
st.media_item_played as media_item_played, si.ends as show_ends
|
st.media_item_played as media_item_played, si.ends as show_ends
|
||||||
%%tables%% WHERE ";
|
%%tables%% WHERE ";
|
||||||
|
|
||||||
$fileColumns = "ft.artist_name, ft.track_title, ";
|
$fileColumns = "ft.artist_name, ft.track_title, ";
|
||||||
$fileJoin = "FROM cc_schedule st JOIN cc_files ft ON st.file_id = ft.id
|
$fileJoin = "FROM cc_schedule st JOIN cc_files ft ON st.file_id = ft.id
|
||||||
LEFT JOIN cc_show_instances si ON st.instance_id = si.id";
|
LEFT JOIN cc_show_instances si ON st.instance_id = si.id";
|
||||||
|
|
||||||
$streamColumns = "ws.name AS artist_name, wm.liquidsoap_data AS track_title, ";
|
$streamColumns = "ws.name AS artist_name, wm.liquidsoap_data AS track_title, ";
|
||||||
$streamJoin = "FROM cc_schedule AS st JOIN cc_webstream ws ON st.stream_id = ws.id
|
$streamJoin = "FROM cc_schedule AS st JOIN cc_webstream ws ON st.stream_id = ws.id
|
||||||
LEFT JOIN cc_show_instances AS si ON st.instance_id = si.id
|
LEFT JOIN cc_show_instances AS si ON st.instance_id = si.id
|
||||||
LEFT JOIN cc_subjs AS sub on sub.id = ws.creator_id
|
LEFT JOIN cc_subjs AS sub on sub.id = ws.creator_id
|
||||||
LEFT JOIN (SELECT * FROM cc_webstream_metadata ORDER BY start_time DESC LIMIT 1) AS wm on st.id = wm.instance_id";
|
LEFT JOIN (SELECT * FROM cc_webstream_metadata ORDER BY start_time DESC LIMIT 1) AS wm on st.id = wm.instance_id";
|
||||||
|
|
||||||
$predicateArr = array();
|
$predicateArr = array();
|
||||||
if (isset($p_previousShowID)) {
|
if (isset($p_previousShowID)) {
|
||||||
$predicateArr[] = 'st.instance_id = '.$p_previousShowID;
|
$predicateArr[] = 'st.instance_id = '.$p_previousShowID;
|
||||||
}
|
}
|
||||||
if (isset($p_currentShowID)) {
|
if (isset($p_currentShowID)) {
|
||||||
$predicateArr[] = 'st.instance_id = '.$p_currentShowID;
|
$predicateArr[] = 'st.instance_id = '.$p_currentShowID;
|
||||||
}
|
}
|
||||||
if (isset($p_nextShowID)) {
|
if (isset($p_nextShowID)) {
|
||||||
$predicateArr[] = 'st.instance_id = '.$p_nextShowID;
|
$predicateArr[] = 'st.instance_id = '.$p_nextShowID;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql .= " (".implode(" OR ", $predicateArr).") ";
|
$sql .= " (".implode(" OR ", $predicateArr).") ";
|
||||||
$sql .= ' AND st.playout_status > 0 ORDER BY st.starts';
|
$sql .= ' AND st.playout_status > 0 ORDER BY st.starts';
|
||||||
|
|
||||||
$filesSql = str_replace("%%columns%%", $fileColumns, $sql);
|
$filesSql = str_replace("%%columns%%", $fileColumns, $sql);
|
||||||
$filesSql = str_replace("%%tables%%", $fileJoin, $filesSql);
|
$filesSql = str_replace("%%tables%%", $fileJoin, $filesSql);
|
||||||
|
|
||||||
$streamSql = str_replace("%%columns%%", $streamColumns, $sql);
|
$streamSql = str_replace("%%columns%%", $streamColumns, $sql);
|
||||||
$streamSql = str_replace("%%tables%%", $streamJoin, $streamSql);
|
$streamSql = str_replace("%%tables%%", $streamJoin, $streamSql);
|
||||||
|
|
||||||
$sql = "SELECT * FROM (($filesSql) UNION ($streamSql)) AS unioned ORDER BY starts";
|
$sql = "SELECT * FROM (($filesSql) UNION ($streamSql)) AS unioned ORDER BY starts";
|
||||||
|
|
||||||
$rows = $con->query($sql)->fetchAll(PDO::FETCH_ASSOC);
|
$rows = $con->query($sql)->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
@ -119,13 +120,12 @@ class Application_Model_Schedule
|
||||||
$results['next'] = null;
|
$results['next'] = null;
|
||||||
|
|
||||||
$timeNowAsMillis = strtotime($p_timeNow);
|
$timeNowAsMillis = strtotime($p_timeNow);
|
||||||
for ($i = 0; $i < $numberOfRows; ++$i) {
|
for ($i = 0; $i < $numberOfRows; ++$i) {
|
||||||
// if the show is overbooked, then update the track end time to the end of the show time.
|
// if the show is overbooked, then update the track end time to the end of the show time.
|
||||||
if ($rows[$i]['ends'] > $rows[$i]["show_ends"]) {
|
if ($rows[$i]['ends'] > $rows[$i]["show_ends"]) {
|
||||||
$rows[$i]['ends'] = $rows[$i]["show_ends"];
|
$rows[$i]['ends'] = $rows[$i]["show_ends"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ((strtotime($rows[$i]['starts']) <= $timeNowAsMillis) && (strtotime($rows[$i]['ends']) >= $timeNowAsMillis)) {
|
if ((strtotime($rows[$i]['starts']) <= $timeNowAsMillis) && (strtotime($rows[$i]['ends']) >= $timeNowAsMillis)) {
|
||||||
if ($i - 1 >= 0) {
|
if ($i - 1 >= 0) {
|
||||||
$results['previous'] = array("name"=>$rows[$i-1]["artist_name"]." - ".$rows[$i-1]["track_title"],
|
$results['previous'] = array("name"=>$rows[$i-1]["artist_name"]." - ".$rows[$i-1]["track_title"],
|
||||||
|
@ -140,7 +140,7 @@ class Application_Model_Schedule
|
||||||
"record"=>0,
|
"record"=>0,
|
||||||
"type"=>'track');
|
"type"=>'track');
|
||||||
if (isset($rows[$i+1])) {
|
if (isset($rows[$i+1])) {
|
||||||
$results['next'] = array("name"=>$rows[$i+1]["artist_name"]." - ".$rows[$i+1]["track_title"],
|
$results['next'] = array("name"=>$rows[$i+1]["artist_name"]." - ".$rows[$i+1]["track_title"],
|
||||||
"starts"=>$rows[$i+1]["starts"],
|
"starts"=>$rows[$i+1]["starts"],
|
||||||
"ends"=>$rows[$i+1]["ends"],
|
"ends"=>$rows[$i+1]["ends"],
|
||||||
"type"=>'track');
|
"type"=>'track');
|
||||||
|
@ -192,7 +192,6 @@ class Application_Model_Schedule
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function GetCurrentScheduleItem($p_timeNow, $p_instanceId)
|
public static function GetCurrentScheduleItem($p_timeNow, $p_instanceId)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
global $CC_CONFIG;
|
||||||
|
@ -266,7 +265,7 @@ SELECT DISTINCT sched.starts AS sched_starts,
|
||||||
sched.fade_out AS fade_out,
|
sched.fade_out AS fade_out,
|
||||||
sched.playout_status AS playout_status,
|
sched.playout_status AS playout_status,
|
||||||
sched.instance_id AS sched_instance_id,
|
sched.instance_id AS sched_instance_id,
|
||||||
|
|
||||||
%%columns%%
|
%%columns%%
|
||||||
FROM (%%join%%)
|
FROM (%%join%%)
|
||||||
SQL;
|
SQL;
|
||||||
|
@ -284,11 +283,11 @@ SQL;
|
||||||
SQL;
|
SQL;
|
||||||
|
|
||||||
|
|
||||||
$filesSql = str_replace("%%columns%%",
|
$filesSql = str_replace("%%columns%%",
|
||||||
$filesColumns,
|
$filesColumns,
|
||||||
$templateSql);
|
$templateSql);
|
||||||
$filesSql= str_replace("%%join%%",
|
$filesSql= str_replace("%%join%%",
|
||||||
$filesJoin,
|
$filesJoin,
|
||||||
$filesSql);
|
$filesSql);
|
||||||
|
|
||||||
$streamColumns = <<<SQL
|
$streamColumns = <<<SQL
|
||||||
|
@ -304,11 +303,11 @@ SQL;
|
||||||
LEFT JOIN cc_subjs AS sub ON (ws.creator_id = sub.id)
|
LEFT JOIN cc_subjs AS sub ON (ws.creator_id = sub.id)
|
||||||
SQL;
|
SQL;
|
||||||
|
|
||||||
$streamSql = str_replace("%%columns%%",
|
$streamSql = str_replace("%%columns%%",
|
||||||
$streamColumns,
|
$streamColumns,
|
||||||
$templateSql);
|
$templateSql);
|
||||||
$streamSql = str_replace("%%join%%",
|
$streamSql = str_replace("%%join%%",
|
||||||
$streamJoin,
|
$streamJoin,
|
||||||
$streamSql);
|
$streamSql);
|
||||||
|
|
||||||
|
|
||||||
|
@ -332,7 +331,7 @@ SELECT showt.name AS show_name,
|
||||||
si.last_scheduled AS si_last_scheduled,
|
si.last_scheduled AS si_last_scheduled,
|
||||||
si.file_id AS si_file_id,
|
si.file_id AS si_file_id,
|
||||||
*
|
*
|
||||||
FROM (($filesSql) UNION ($streamSql)) as temp
|
FROM (($filesSql) UNION ($streamSql)) as temp
|
||||||
RIGHT JOIN cc_show_instances AS si ON (si.id = sched_instance_id)
|
RIGHT JOIN cc_show_instances AS si ON (si.id = sched_instance_id)
|
||||||
JOIN cc_show AS showt ON (showt.id = si.show_id)
|
JOIN cc_show AS showt ON (showt.id = si.show_id)
|
||||||
WHERE si.modified_instance = FALSE
|
WHERE si.modified_instance = FALSE
|
||||||
|
@ -348,6 +347,7 @@ ORDER BY si_starts,
|
||||||
SQL;
|
SQL;
|
||||||
|
|
||||||
$rows = $con->query($sql)->fetchAll(PDO::FETCH_ASSOC);
|
$rows = $con->query($sql)->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -671,7 +671,7 @@ SQL;
|
||||||
$uri = $storedFile->getFilePath();
|
$uri = $storedFile->getFilePath();
|
||||||
$type = "file";
|
$type = "file";
|
||||||
$independent_event = false;
|
$independent_event = false;
|
||||||
} else if (!is_null($item['stream_id'])) {
|
} elseif (!is_null($item['stream_id'])) {
|
||||||
//row is type "webstream"
|
//row is type "webstream"
|
||||||
$media_id = $item['stream_id'];
|
$media_id = $item['stream_id'];
|
||||||
$uri = $item['url'];
|
$uri = $item['url'];
|
||||||
|
@ -720,7 +720,7 @@ SQL;
|
||||||
//time of this event is the "end" time of the stream minus 1 second.
|
//time of this event is the "end" time of the stream minus 1 second.
|
||||||
$dt = new DateTime($item["end"], new DateTimeZone('UTC'));
|
$dt = new DateTime($item["end"], new DateTimeZone('UTC'));
|
||||||
$dt->sub(new DateInterval("PT1S"));
|
$dt->sub(new DateInterval("PT1S"));
|
||||||
|
|
||||||
//make sure the webstream doesn't play past the end time of the show
|
//make sure the webstream doesn't play past the end time of the show
|
||||||
if ($dt->getTimestamp() > $showEndDateTime->getTimestamp()) {
|
if ($dt->getTimestamp() > $showEndDateTime->getTimestamp()) {
|
||||||
$dt = $showEndDateTime;
|
$dt = $showEndDateTime;
|
||||||
|
@ -1094,10 +1094,11 @@ SQL;
|
||||||
|
|
||||||
return $overlapping;
|
return $overlapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetFileId($p_scheduleId)
|
public static function GetFileId($p_scheduleId)
|
||||||
{
|
{
|
||||||
$scheduledItem = CcScheduleQuery::create()->findPK($p_scheduleId);
|
$scheduledItem = CcScheduleQuery::create()->findPK($p_scheduleId);
|
||||||
|
|
||||||
return $scheduledItem->getDbFileId();
|
return $scheduledItem->getDbFileId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,12 +146,12 @@ class Application_Model_Scheduler
|
||||||
|
|
||||||
$files[] = $data;
|
$files[] = $data;
|
||||||
}
|
}
|
||||||
} else if ($type === "playlist") {
|
} elseif ($type === "playlist") {
|
||||||
$pl = new Application_Model_Playlist($id);
|
$pl = new Application_Model_Playlist($id);
|
||||||
$contents = $pl->getContents();
|
$contents = $pl->getContents();
|
||||||
|
|
||||||
foreach ($contents as $plItem) {
|
foreach ($contents as $plItem) {
|
||||||
if ($plItem['type'] == 0){
|
if ($plItem['type'] == 0) {
|
||||||
$data["id"] = $plItem['item_id'];
|
$data["id"] = $plItem['item_id'];
|
||||||
$data["cliplength"] = $plItem['length'];
|
$data["cliplength"] = $plItem['length'];
|
||||||
$data["cuein"] = $plItem['cuein'];
|
$data["cuein"] = $plItem['cuein'];
|
||||||
|
@ -159,29 +159,29 @@ class Application_Model_Scheduler
|
||||||
$data["fadein"] = $plItem['fadein'];
|
$data["fadein"] = $plItem['fadein'];
|
||||||
$data["fadeout"] = $plItem['fadeout'];
|
$data["fadeout"] = $plItem['fadeout'];
|
||||||
$data["type"] = 0;
|
$data["type"] = 0;
|
||||||
$files[] = $data;
|
$files[] = $data;
|
||||||
} else if ($plItem['type'] == 2) {
|
} elseif ($plItem['type'] == 2) {
|
||||||
// if it's a block
|
// if it's a block
|
||||||
$bl = new Application_Model_Block($plItem['item_id']);
|
$bl = new Application_Model_Block($plItem['item_id']);
|
||||||
if ($bl->isStatic()) {
|
if ($bl->isStatic()) {
|
||||||
foreach ($bl->getContents() as $track) {
|
foreach ($bl->getContents() as $track) {
|
||||||
$data["id"] = $track['item_id'];
|
$data["id"] = $track['item_id'];
|
||||||
$data["cliplength"] = $track['length'];
|
$data["cliplength"] = $track['length'];
|
||||||
$data["cuein"] = $track['cuein'];
|
$data["cuein"] = $track['cuein'];
|
||||||
$data["cueout"] = $track['cueout'];
|
$data["cueout"] = $track['cueout'];
|
||||||
$data["fadein"] = $track['fadein'];
|
$data["fadein"] = $track['fadein'];
|
||||||
$data["fadeout"] = $track['fadeout'];
|
$data["fadeout"] = $track['fadeout'];
|
||||||
$data["type"] = 0;
|
$data["type"] = 0;
|
||||||
$files[] = $data;
|
$files[] = $data;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$dynamicFiles = $bl->getListOfFilesUnderLimit();
|
$dynamicFiles = $bl->getListOfFilesUnderLimit();
|
||||||
foreach ($dynamicFiles as $fileId=>$f) {
|
foreach ($dynamicFiles as $fileId=>$f) {
|
||||||
$file = CcFilesQuery::create()->findPk($fileId);
|
$file = CcFilesQuery::create()->findPk($fileId);
|
||||||
if (isset($file) && $file->getDbFileExists()) {
|
if (isset($file) && $file->getDbFileExists()) {
|
||||||
$data["id"] = $file->getDbId();
|
$data["id"] = $file->getDbId();
|
||||||
$data["cliplength"] = $file->getDbLength();
|
$data["cliplength"] = $file->getDbLength();
|
||||||
$data["cuein"] = "00:00:00";
|
$data["cuein"] = "00:00:00";
|
||||||
$data["cueout"] = $file->getDbLength();
|
$data["cueout"] = $file->getDbLength();
|
||||||
$defaultFade = Application_Model_Preference::GetDefaultFade();
|
$defaultFade = Application_Model_Preference::GetDefaultFade();
|
||||||
if (isset($defaultFade)) {
|
if (isset($defaultFade)) {
|
||||||
|
@ -190,13 +190,13 @@ class Application_Model_Scheduler
|
||||||
$data["fadeout"] = $defaultFade;
|
$data["fadeout"] = $defaultFade;
|
||||||
}
|
}
|
||||||
$data["type"] = 0;
|
$data["type"] = 0;
|
||||||
$files[] = $data;
|
$files[] = $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ($type == "stream") {
|
} elseif ($type == "stream") {
|
||||||
//need to return
|
//need to return
|
||||||
$stream = CcWebstreamQuery::create()->findPK($id, $this->con);
|
$stream = CcWebstreamQuery::create()->findPK($id, $this->con);
|
||||||
|
|
||||||
|
@ -218,40 +218,41 @@ class Application_Model_Scheduler
|
||||||
|
|
||||||
$files[] = $data;
|
$files[] = $data;
|
||||||
}
|
}
|
||||||
} else if ($type == "block") {
|
} elseif ($type == "block") {
|
||||||
$bl = new Application_Model_Block($id);
|
$bl = new Application_Model_Block($id);
|
||||||
if ($bl->isStatic()) {
|
if ($bl->isStatic()) {
|
||||||
foreach ($bl->getContents() as $track) {
|
foreach ($bl->getContents() as $track) {
|
||||||
$data["id"] = $track['item_id'];
|
$data["id"] = $track['item_id'];
|
||||||
$data["cliplength"] = $track['length'];
|
$data["cliplength"] = $track['length'];
|
||||||
$data["cuein"] = $track['cuein'];
|
$data["cuein"] = $track['cuein'];
|
||||||
$data["cueout"] = $track['cueout'];
|
$data["cueout"] = $track['cueout'];
|
||||||
$data["fadein"] = $track['fadein'];
|
$data["fadein"] = $track['fadein'];
|
||||||
$data["fadeout"] = $track['fadeout'];
|
$data["fadeout"] = $track['fadeout'];
|
||||||
$data["type"] = 0;
|
$data["type"] = 0;
|
||||||
$files[] = $data;
|
$files[] = $data;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$dynamicFiles = $bl->getListOfFilesUnderLimit();
|
$dynamicFiles = $bl->getListOfFilesUnderLimit();
|
||||||
foreach ($dynamicFiles as $fileId=>$f) {
|
foreach ($dynamicFiles as $fileId=>$f) {
|
||||||
$file = CcFilesQuery::create()->findPk($fileId);
|
$file = CcFilesQuery::create()->findPk($fileId);
|
||||||
if (isset($file) && $file->getDbFileExists()) {
|
if (isset($file) && $file->getDbFileExists()) {
|
||||||
$data["id"] = $file->getDbId();
|
$data["id"] = $file->getDbId();
|
||||||
$data["cliplength"] = $file->getDbLength();
|
$data["cliplength"] = $file->getDbLength();
|
||||||
$data["cuein"] = "00:00:00";
|
$data["cuein"] = "00:00:00";
|
||||||
$data["cueout"] = $file->getDbLength();
|
$data["cueout"] = $file->getDbLength();
|
||||||
$defaultFade = Application_Model_Preference::GetDefaultFade();
|
$defaultFade = Application_Model_Preference::GetDefaultFade();
|
||||||
if (isset($defaultFade)) {
|
if (isset($defaultFade)) {
|
||||||
//fade is in format SS.uuuuuu
|
//fade is in format SS.uuuuuu
|
||||||
$data["fadein"] = $defaultFade;
|
$data["fadein"] = $defaultFade;
|
||||||
$data["fadeout"] = $defaultFade;
|
$data["fadeout"] = $defaultFade;
|
||||||
}
|
}
|
||||||
$data["type"] = 0;
|
$data["type"] = 0;
|
||||||
$files[] = $data;
|
$files[] = $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $files;
|
return $files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,8 +426,8 @@ class Application_Model_Scheduler
|
||||||
->setDbFadeOut($file['fadeout'])
|
->setDbFadeOut($file['fadeout'])
|
||||||
->setDbClipLength($file['cliplength'])
|
->setDbClipLength($file['cliplength'])
|
||||||
->setDbInstanceId($instance->getDbId());
|
->setDbInstanceId($instance->getDbId());
|
||||||
|
|
||||||
switch ($file["type"]){
|
switch ($file["type"]) {
|
||||||
case 0:
|
case 0:
|
||||||
$sched->setDbFileId($file['id']);
|
$sched->setDbFileId($file['id']);
|
||||||
break;
|
break;
|
||||||
|
@ -435,7 +436,7 @@ class Application_Model_Scheduler
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sched->save($this->con);
|
$sched->save($this->con);
|
||||||
|
|
||||||
$nextStartDT = $endTimeDT;
|
$nextStartDT = $endTimeDT;
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
class Application_Model_ServiceRegister
|
class Application_Model_ServiceRegister
|
||||||
{
|
{
|
||||||
public static function GetRemoteIpAddr()
|
public static function GetRemoteIpAddr()
|
||||||
{
|
{
|
||||||
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
||||||
//check ip from share internet
|
//check ip from share internet
|
||||||
$ip=$_SERVER['HTTP_CLIENT_IP'];
|
$ip=$_SERVER['HTTP_CLIENT_IP'];
|
||||||
} else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||||
//to check ip is pass from proxy
|
//to check ip is pass from proxy
|
||||||
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
|
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||||
} else {
|
} else {
|
||||||
$ip=$_SERVER['REMOTE_ADDR'];
|
$ip=$_SERVER['REMOTE_ADDR'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ip;
|
return $ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,32 +172,32 @@ class Application_Model_Show
|
||||||
if ($deltaDay > 0) {
|
if ($deltaDay > 0) {
|
||||||
return "Shows can have a max length of 24 hours.";
|
return "Shows can have a max length of 24 hours.";
|
||||||
}
|
}
|
||||||
|
|
||||||
$showInstances = CcShowInstancesQuery::create()
|
$showInstances = CcShowInstancesQuery::create()
|
||||||
->filterByDbShowId($this->_showId)
|
->filterByDbShowId($this->_showId)
|
||||||
->find($con);
|
->find($con);
|
||||||
|
|
||||||
/* Check if the show being resized and any of its repeats
|
/* Check if the show being resized and any of its repeats
|
||||||
* overlap with other scheduled shows
|
* overlap with other scheduled shows
|
||||||
*/
|
*/
|
||||||
foreach ($showInstances as $si) {
|
foreach ($showInstances as $si) {
|
||||||
$startsDateTime = new DateTime($si->getDbStarts(), new DateTimeZone("UTC"));
|
$startsDateTime = new DateTime($si->getDbStarts(), new DateTimeZone("UTC"));
|
||||||
$endsDateTime = new DateTime($si->getDbEnds(), new DateTimeZone("UTC"));
|
$endsDateTime = new DateTime($si->getDbEnds(), new DateTimeZone("UTC"));
|
||||||
|
|
||||||
/* The user is moving the show on the calendar from the perspective of local time.
|
/* The user is moving the show on the calendar from the perspective of local time.
|
||||||
* incase a show is moved across a time change border offsets should be added to the local
|
* incase a show is moved across a time change border offsets should be added to the local
|
||||||
* timestamp and then converted back to UTC to avoid show time changes
|
* timestamp and then converted back to UTC to avoid show time changes
|
||||||
*/
|
*/
|
||||||
$startsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
$startsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||||
$endsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
$endsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||||
|
|
||||||
$newStartsDateTime = Application_Model_ShowInstance::addDeltas($startsDateTime, $deltaDay, $deltaMin);
|
$newStartsDateTime = Application_Model_ShowInstance::addDeltas($startsDateTime, $deltaDay, $deltaMin);
|
||||||
$newEndsDateTime = Application_Model_ShowInstance::addDeltas($endsDateTime, $deltaDay, $deltaMin);
|
$newEndsDateTime = Application_Model_ShowInstance::addDeltas($endsDateTime, $deltaDay, $deltaMin);
|
||||||
|
|
||||||
//convert our new starts/ends to UTC.
|
//convert our new starts/ends to UTC.
|
||||||
$newStartsDateTime->setTimezone(new DateTimeZone("UTC"));
|
$newStartsDateTime->setTimezone(new DateTimeZone("UTC"));
|
||||||
$newEndsDateTime->setTimezone(new DateTimeZone("UTC"));
|
$newEndsDateTime->setTimezone(new DateTimeZone("UTC"));
|
||||||
|
|
||||||
$overlapping = Application_Model_Schedule::checkOverlappingShows($newStartsDateTime,
|
$overlapping = Application_Model_Schedule::checkOverlappingShows($newStartsDateTime,
|
||||||
$newEndsDateTime, true, $si->getDbId());
|
$newEndsDateTime, true, $si->getDbId());
|
||||||
if ($overlapping) {
|
if ($overlapping) {
|
||||||
|
@ -1583,6 +1583,7 @@ class Application_Model_Show
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $con->query($sql)->fetchAll();
|
$result = $con->query($sql)->fetchAll();
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1662,13 +1663,13 @@ class Application_Model_Show
|
||||||
}
|
}
|
||||||
$startsDT = DateTime::createFromFormat("Y-m-d G:i:s", $show["starts"], new DateTimeZone("UTC"));
|
$startsDT = DateTime::createFromFormat("Y-m-d G:i:s", $show["starts"], new DateTimeZone("UTC"));
|
||||||
$endsDT = DateTime::createFromFormat("Y-m-d G:i:s", $show["ends"], new DateTimeZone("UTC"));
|
$endsDT = DateTime::createFromFormat("Y-m-d G:i:s", $show["ends"], new DateTimeZone("UTC"));
|
||||||
|
|
||||||
$startsEpochStr = $startsDT->format("U");
|
$startsEpochStr = $startsDT->format("U");
|
||||||
$endsEpochStr = $endsDT->format("U");
|
$endsEpochStr = $endsDT->format("U");
|
||||||
|
|
||||||
$startsEpoch = intval($startsEpochStr);
|
$startsEpoch = intval($startsEpochStr);
|
||||||
$endsEpoch = intval($endsEpochStr);
|
$endsEpoch = intval($endsEpochStr);
|
||||||
|
|
||||||
$startsDT->setTimezone(new DateTimeZone($timezone));
|
$startsDT->setTimezone(new DateTimeZone($timezone));
|
||||||
$endsDT->setTimezone(new DateTimeZone($timezone));
|
$endsDT->setTimezone(new DateTimeZone($timezone));
|
||||||
|
|
||||||
|
@ -1679,7 +1680,7 @@ class Application_Model_Show
|
||||||
} elseif ($p_editable && $nowEpoch < $endsEpoch) {
|
} elseif ($p_editable && $nowEpoch < $endsEpoch) {
|
||||||
$options["editable"] = true;
|
$options["editable"] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$showInstance = new Application_Model_ShowInstance($show["instance_id"]);
|
$showInstance = new Application_Model_ShowInstance($show["instance_id"]);
|
||||||
$showContent = $showInstance->getShowListContent();
|
$showContent = $showInstance->getShowListContent();
|
||||||
if (empty($showContent)) {
|
if (empty($showContent)) {
|
||||||
|
@ -1687,7 +1688,7 @@ class Application_Model_Show
|
||||||
} else {
|
} else {
|
||||||
$options["show_empty"] = 0;
|
$options["show_empty"] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$events[] = &self::makeFullCalendarEvent($show, $options, $startsDT, $endsDT, $startsEpochStr, $endsEpochStr);
|
$events[] = &self::makeFullCalendarEvent($show, $options, $startsDT, $endsDT, $startsEpochStr, $endsEpochStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1727,15 +1728,15 @@ class Application_Model_Show
|
||||||
if ($show["color"] != "") {
|
if ($show["color"] != "") {
|
||||||
$event["textColor"] = "#".$show["color"];
|
$event["textColor"] = "#".$show["color"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($show["background_color"] != "") {
|
if ($show["background_color"] != "") {
|
||||||
$event["color"] = "#".$show["background_color"];
|
$event["color"] = "#".$show["background_color"];
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($options as $key => $value) {
|
foreach ($options as $key => $value) {
|
||||||
$event[$key] = $value;
|
$event[$key] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $event;
|
return $event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1806,6 +1807,7 @@ class Application_Model_Show
|
||||||
|
|
||||||
// Convert back to local timezone
|
// Convert back to local timezone
|
||||||
$rows = $con->query($sql)->fetchAll(PDO::FETCH_ASSOC);
|
$rows = $con->query($sql)->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1949,6 +1951,7 @@ class Application_Model_Show
|
||||||
}
|
}
|
||||||
|
|
||||||
$rows = $con->query($sql)->fetchAll(PDO::FETCH_ASSOC);
|
$rows = $con->query($sql)->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ class Application_Model_StoredFile
|
||||||
{
|
{
|
||||||
$this->_file->setDbFtype($p_format);
|
$this->_file->setDbFtype($p_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function is only called after liquidsoap
|
/* This function is only called after liquidsoap
|
||||||
* has notified that a track has started playing.
|
* has notified that a track has started playing.
|
||||||
*/
|
*/
|
||||||
|
@ -83,7 +83,7 @@ class Application_Model_StoredFile
|
||||||
{
|
{
|
||||||
$this->_file->setDbLPtime($p_now);
|
$this->_file->setDbLPtime($p_now);
|
||||||
/* Normally we would only call save after all columns have been set
|
/* Normally we would only call save after all columns have been set
|
||||||
* like in setDbColMetadata(). But since we are only setting one
|
* like in setDbColMetadata(). But since we are only setting one
|
||||||
* column in this case it is OK.
|
* column in this case it is OK.
|
||||||
*/
|
*/
|
||||||
$this->_file->save();
|
$this->_file->save();
|
||||||
|
@ -151,9 +151,9 @@ class Application_Model_StoredFile
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$owner = $this->_file->getFkOwner();
|
$owner = $this->_file->getFkOwner();
|
||||||
// if owner_id is already set we don't want to set it again.
|
// if owner_id is already set we don't want to set it again.
|
||||||
if(!$owner) { // no owner detected, we try to assign one.
|
if (!$owner) { // no owner detected, we try to assign one.
|
||||||
// if MDATA_OWNER_ID is not set then we default to the
|
// if MDATA_OWNER_ID is not set then we default to the
|
||||||
// first admin user we find
|
// first admin user we find
|
||||||
if (!array_key_exists('owner_id', $p_md)) {
|
if (!array_key_exists('owner_id', $p_md)) {
|
||||||
//$admins = Application_Model_User::getUsers(array('A'));
|
//$admins = Application_Model_User::getUsers(array('A'));
|
||||||
|
@ -170,10 +170,9 @@ class Application_Model_StoredFile
|
||||||
$owner = $user;
|
$owner = $user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($owner) {
|
if ($owner) {
|
||||||
$this->_file->setDbOwnerId( $owner->getDbId() );
|
$this->_file->setDbOwnerId( $owner->getDbId() );
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Logging::info("Could not find suitable owner for file
|
Logging::info("Could not find suitable owner for file
|
||||||
'".$p_md['MDATA_KEY_FILEPATH']."'");
|
'".$p_md['MDATA_KEY_FILEPATH']."'");
|
||||||
}
|
}
|
||||||
|
@ -415,6 +414,7 @@ class Application_Model_StoredFile
|
||||||
_file->getDbDirectory());
|
_file->getDbDirectory());
|
||||||
$directory = $music_dir->getDirectory();
|
$directory = $music_dir->getDirectory();
|
||||||
$filepath = $this->_file->getDbFilepath();
|
$filepath = $this->_file->getDbFilepath();
|
||||||
|
|
||||||
return Application_Common_OsPath::join($directory, $filepath);
|
return Application_Common_OsPath::join($directory, $filepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,9 +492,9 @@ class Application_Model_StoredFile
|
||||||
public static function Insert($md)
|
public static function Insert($md)
|
||||||
{
|
{
|
||||||
// save some work by checking if filepath is given right away
|
// save some work by checking if filepath is given right away
|
||||||
if( !isset($md['MDATA_KEY_FILEPATH']) ) {
|
if ( !isset($md['MDATA_KEY_FILEPATH']) ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = new CcFiles();
|
$file = new CcFiles();
|
||||||
$now = new DateTime("now", new DateTimeZone("UTC"));
|
$now = new DateTime("now", new DateTimeZone("UTC"));
|
||||||
|
@ -515,6 +515,7 @@ class Application_Model_StoredFile
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$storedFile->setMetadata($md);
|
$storedFile->setMetadata($md);
|
||||||
|
|
||||||
return $storedFile;
|
return $storedFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -682,7 +683,7 @@ class Application_Model_StoredFile
|
||||||
$blSelect[] = "NULL::int AS ".$key;
|
$blSelect[] = "NULL::int AS ".$key;
|
||||||
$fileSelect[] = $key;
|
$fileSelect[] = $key;
|
||||||
$streamSelect[] = "NULL::int AS ".$key;
|
$streamSelect[] = "NULL::int AS ".$key;
|
||||||
} else if ($key === "filepath") {
|
} elseif ($key === "filepath") {
|
||||||
$plSelect[] = "NULL::VARCHAR AS ".$key;
|
$plSelect[] = "NULL::VARCHAR AS ".$key;
|
||||||
$blSelect[] = "NULL::VARCHAR AS ".$key;
|
$blSelect[] = "NULL::VARCHAR AS ".$key;
|
||||||
$fileSelect[] = $key;
|
$fileSelect[] = $key;
|
||||||
|
@ -745,7 +746,7 @@ class Application_Model_StoredFile
|
||||||
$formatter = new BitrateFormatter($row['bit_rate']);
|
$formatter = new BitrateFormatter($row['bit_rate']);
|
||||||
$row['bit_rate'] = $formatter->format();
|
$row['bit_rate'] = $formatter->format();
|
||||||
}
|
}
|
||||||
|
|
||||||
//convert mtime and utime to localtime
|
//convert mtime and utime to localtime
|
||||||
$row['mtime'] = new DateTime($row['mtime'], new DateTimeZone('UTC'));
|
$row['mtime'] = new DateTime($row['mtime'], new DateTimeZone('UTC'));
|
||||||
$row['mtime']->setTimeZone(new DateTimeZone(date_default_timezone_get()));
|
$row['mtime']->setTimeZone(new DateTimeZone(date_default_timezone_get()));
|
||||||
|
@ -753,7 +754,7 @@ class Application_Model_StoredFile
|
||||||
$row['utime'] = new DateTime($row['utime'], new DateTimeZone('UTC'));
|
$row['utime'] = new DateTime($row['utime'], new DateTimeZone('UTC'));
|
||||||
$row['utime']->setTimeZone(new DateTimeZone(date_default_timezone_get()));
|
$row['utime']->setTimeZone(new DateTimeZone(date_default_timezone_get()));
|
||||||
$row['utime'] = $row['utime']->format('Y-m-d H:i:s');
|
$row['utime'] = $row['utime']->format('Y-m-d H:i:s');
|
||||||
|
|
||||||
// add checkbox row
|
// add checkbox row
|
||||||
$row['checkbox'] = "<input type='checkbox' name='cb_".$row['id']."'>";
|
$row['checkbox'] = "<input type='checkbox' name='cb_".$row['id']."'>";
|
||||||
|
|
||||||
|
@ -768,12 +769,12 @@ class Application_Model_StoredFile
|
||||||
if ($type == "au") {
|
if ($type == "au") {
|
||||||
$row['audioFile'] = $row['id'].".".pathinfo($row['filepath'], PATHINFO_EXTENSION);
|
$row['audioFile'] = $row['id'].".".pathinfo($row['filepath'], PATHINFO_EXTENSION);
|
||||||
$row['image'] = '<img title="Track preview" src="/css/images/icon_audioclip.png">';
|
$row['image'] = '<img title="Track preview" src="/css/images/icon_audioclip.png">';
|
||||||
} else if ($type == "pl") {
|
} elseif ($type == "pl") {
|
||||||
$row['image'] = '<img title="Playlist preview" src="/css/images/icon_playlist.png">';
|
$row['image'] = '<img title="Playlist preview" src="/css/images/icon_playlist.png">';
|
||||||
} else if ($type == "st") {
|
} elseif ($type == "st") {
|
||||||
$row['audioFile'] = $row['id'];
|
$row['audioFile'] = $row['id'];
|
||||||
$row['image'] = '<img title="Webstream preview" src="/css/images/record_icon.png">';
|
$row['image'] = '<img title="Webstream preview" src="/css/images/record_icon.png">';
|
||||||
} else if ($type == "bl") {
|
} elseif ($type == "bl") {
|
||||||
$row['image'] = '<img title="Smart Block" src="/css/images/delete.png">';
|
$row['image'] = '<img title="Smart Block" src="/css/images/delete.png">';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -915,8 +916,9 @@ class Application_Model_StoredFile
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we have enough space before copying
|
// Check if we have enough space before copying
|
||||||
if(!self::isEnoughDiskSpaceToCopy($stor, $audio_file)) {
|
if (!self::isEnoughDiskSpaceToCopy($stor, $audio_file)) {
|
||||||
$freeSpace = disk_free_space($stor);
|
$freeSpace = disk_free_space($stor);
|
||||||
|
|
||||||
return array("code" => 107,
|
return array("code" => 107,
|
||||||
"message" => "The file was not uploaded, there is
|
"message" => "The file was not uploaded, there is
|
||||||
".$freeSpace."MB of disk space left and the file you are
|
".$freeSpace."MB of disk space left and the file you are
|
||||||
|
@ -924,7 +926,7 @@ class Application_Model_StoredFile
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if liquidsoap can play this file
|
// Check if liquidsoap can play this file
|
||||||
if(!self::liquidsoapFilePlayabilityTest($audio_file)) {
|
if (!self::liquidsoapFilePlayabilityTest($audio_file)) {
|
||||||
return array(
|
return array(
|
||||||
"code" => 110,
|
"code" => 110,
|
||||||
"message" => "This file appears to be corrupted and will not
|
"message" => "This file appears to be corrupted and will not
|
||||||
|
@ -941,7 +943,7 @@ class Application_Model_StoredFile
|
||||||
$uid = $user->getId();
|
$uid = $user->getId();
|
||||||
}
|
}
|
||||||
$id_file = "$audio_stor.identifier";
|
$id_file = "$audio_stor.identifier";
|
||||||
if (file_put_contents($id_file,$uid) === false) {
|
if (file_put_contents($id_file,$uid) === false) {
|
||||||
Logging::info("Could not write file to identify user: '$uid'");
|
Logging::info("Could not write file to identify user: '$uid'");
|
||||||
Logging::info("Id file path: '$id_file'");
|
Logging::info("Id file path: '$id_file'");
|
||||||
Logging::info("Defaulting to admin (no identification file was
|
Logging::info("Defaulting to admin (no identification file was
|
||||||
|
@ -958,6 +960,7 @@ class Application_Model_StoredFile
|
||||||
//warn the user that the file wasn't uploaded and they should check if there is enough disk space.
|
//warn the user that the file wasn't uploaded and they should check if there is enough disk space.
|
||||||
unlink($audio_file); //remove the file after failed rename
|
unlink($audio_file); //remove the file after failed rename
|
||||||
unlink($id_file); // Also remove the identifier file
|
unlink($id_file); // Also remove the identifier file
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
"code" => 108,
|
"code" => 108,
|
||||||
"message" => "
|
"message" => "
|
||||||
|
@ -1044,8 +1047,9 @@ class Application_Model_StoredFile
|
||||||
if (!is_null($limit) && is_int($limit)) {
|
if (!is_null($limit) && is_int($limit)) {
|
||||||
$sql .= " LIMIT $limit";
|
$sql .= " LIMIT $limit";
|
||||||
}
|
}
|
||||||
|
|
||||||
$rows = $con->query($sql, PDO::FETCH_ASSOC)->fetchAll();
|
$rows = $con->query($sql, PDO::FETCH_ASSOC)->fetchAll();
|
||||||
|
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ class Application_Model_User
|
||||||
public function isHostOfShow($showId)
|
public function isHostOfShow($showId)
|
||||||
{
|
{
|
||||||
$userId = $this->_userInstance->getDbId();
|
$userId = $this->_userInstance->getDbId();
|
||||||
|
|
||||||
return CcShowHostsQuery::create()
|
return CcShowHostsQuery::create()
|
||||||
->filterByDbShow($showId)
|
->filterByDbShow($showId)
|
||||||
->filterByDbHost($userId)->count() > 0;
|
->filterByDbHost($userId)->count() > 0;
|
||||||
|
@ -238,15 +239,19 @@ class Application_Model_User
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getUsersOfType($type) {
|
public static function getUsersOfType($type)
|
||||||
|
{
|
||||||
return CcSubjsQuery::create()->filterByDbType($type)->find();
|
return CcSubjsQuery::create()->filterByDbType($type)->find();
|
||||||
}
|
}
|
||||||
public static function getFirstAdminId() {
|
public static function getFirstAdminId()
|
||||||
|
{
|
||||||
$admins = Application_Model_User::getUsersOfType('A');
|
$admins = Application_Model_User::getUsersOfType('A');
|
||||||
if (count($admins) > 0) { // found admin => pick first one
|
if (count($admins) > 0) { // found admin => pick first one
|
||||||
|
|
||||||
return $admins[0]->getDbId();
|
return $admins[0]->getDbId();
|
||||||
} else {
|
} else {
|
||||||
Logging::warn("Warning. no admins found in database");
|
Logging::warn("Warning. no admins found in database");
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -360,6 +365,7 @@ class Application_Model_User
|
||||||
//we get here if $userinfo->id is defined, but doesn't exist
|
//we get here if $userinfo->id is defined, but doesn't exist
|
||||||
//in the database anymore.
|
//in the database anymore.
|
||||||
Zend_Auth::getInstance()->clearIdentity();
|
Zend_Auth::getInstance()->clearIdentity();
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->webstream = $webstream;
|
$this->webstream = $webstream;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,8 +44,10 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
||||||
if (count($arr) == 3) {
|
if (count($arr) == 3) {
|
||||||
list($hours, $min, $sec) = $arr;
|
list($hours, $min, $sec) = $arr;
|
||||||
$di = new DateInterval("PT{$hours}H{$min}M{$sec}S");
|
$di = new DateInterval("PT{$hours}H{$min}M{$sec}S");
|
||||||
|
|
||||||
return $di->format("%Hh %Im");
|
return $di->format("%Hh %Im");
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,6 +71,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
||||||
$subjs = CcSubjsQuery::create()->findPK($this->webstream->getDbCreatorId());
|
$subjs = CcSubjsQuery::create()->findPK($this->webstream->getDbCreatorId());
|
||||||
|
|
||||||
$username = $subjs->getDbLogin();
|
$username = $subjs->getDbLogin();
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
"name" => $this->webstream->getDbName(),
|
"name" => $this->webstream->getDbName(),
|
||||||
"length" => $this->webstream->getDbLength(),
|
"length" => $this->webstream->getDbLength(),
|
||||||
|
@ -87,7 +90,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
||||||
throw new Exception("Invalid user permissions");
|
throw new Exception("Invalid user permissions");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function returns that are not owen by $p_user_id among $p_ids
|
// This function returns that are not owen by $p_user_id among $p_ids
|
||||||
private static function streamsNotOwnedByUser($p_ids, $p_userId)
|
private static function streamsNotOwnedByUser($p_ids, $p_userId)
|
||||||
{
|
{
|
||||||
|
@ -98,14 +101,15 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
||||||
$ownedStreams[] = $pl->getDbId();
|
$ownedStreams[] = $pl->getDbId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$leftOvers = array_diff($p_ids, $ownedStreams);
|
$leftOvers = array_diff($p_ids, $ownedStreams);
|
||||||
|
|
||||||
return $leftOvers;
|
return $leftOvers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function analyzeFormData($parameters)
|
public static function analyzeFormData($parameters)
|
||||||
{
|
{
|
||||||
$valid = array("length" => array(true, ''),
|
$valid = array("length" => array(true, ''),
|
||||||
"url" => array(true, ''),
|
"url" => array(true, ''),
|
||||||
"name" => array(true, ''));
|
"name" => array(true, ''));
|
||||||
|
|
||||||
|
@ -117,16 +121,14 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
||||||
if ($result == 1 && count($matches) == 2) {
|
if ($result == 1 && count($matches) == 2) {
|
||||||
$hours = $matches[1];
|
$hours = $matches[1];
|
||||||
$minutes = 0;
|
$minutes = 0;
|
||||||
} else if ($result == 1 && count($matches) == 3) {
|
} elseif ($result == 1 && count($matches) == 3) {
|
||||||
$hours = $matches[1];
|
$hours = $matches[1];
|
||||||
$minutes = $matches[2];
|
$minutes = $matches[2];
|
||||||
} else {
|
} else {
|
||||||
$invalid_date_interval = true;
|
$invalid_date_interval = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$invalid_date_interval) {
|
||||||
|
|
||||||
if (!$invalid_date_interval) {
|
|
||||||
|
|
||||||
//Due to the way our Regular Expression is set up, we could have $minutes or $hours
|
//Due to the way our Regular Expression is set up, we could have $minutes or $hours
|
||||||
//not set. Do simple test here
|
//not set. Do simple test here
|
||||||
|
@ -137,14 +139,12 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
||||||
$minutes = 0;
|
$minutes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//minutes cannot be over 59. Need to convert anything > 59 minutes into hours.
|
//minutes cannot be over 59. Need to convert anything > 59 minutes into hours.
|
||||||
$hours += intval($minutes/60);
|
$hours += intval($minutes/60);
|
||||||
$minutes = $minutes%60;
|
$minutes = $minutes%60;
|
||||||
|
|
||||||
$di = new DateInterval("PT{$hours}H{$minutes}M");
|
$di = new DateInterval("PT{$hours}H{$minutes}M");
|
||||||
|
|
||||||
|
|
||||||
$totalMinutes = $di->h * 60 + $di->i;
|
$totalMinutes = $di->h * 60 + $di->i;
|
||||||
|
|
||||||
if ($totalMinutes == 0) {
|
if ($totalMinutes == 0) {
|
||||||
|
@ -157,9 +157,8 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
||||||
$valid['length'][1] = 'Length should be of form "00h 00m"';
|
$valid['length'][1] = 'Length should be of form "00h 00m"';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$url = $parameters["url"];
|
$url = $parameters["url"];
|
||||||
//simple validator that checks to make sure that the url starts with
|
//simple validator that checks to make sure that the url starts with
|
||||||
//http(s),
|
//http(s),
|
||||||
//and that the domain is at least 1 letter long
|
//and that the domain is at least 1 letter long
|
||||||
$result = preg_match("/^(http|https):\/\/.+/", $url, $matches);
|
$result = preg_match("/^(http|https):\/\/.+/", $url, $matches);
|
||||||
|
@ -196,7 +195,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
||||||
|
|
||||||
$id = $parameters["id"];
|
$id = $parameters["id"];
|
||||||
|
|
||||||
return array($valid, $mime, $mediaUrl, $di);
|
return array($valid, $mime, $mediaUrl, $di);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isValid($analysis)
|
public static function isValid($analysis)
|
||||||
|
@ -210,16 +209,14 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setMetadata($key, $val)
|
public function setMetadata($key, $val)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setName($name)
|
||||||
public function setName($name)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getXspfUrl($url)
|
private static function getXspfUrl($url)
|
||||||
|
@ -270,7 +267,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
||||||
$delim = "\n";
|
$delim = "\n";
|
||||||
if (strpos($content, "\r\n") !== false) {
|
if (strpos($content, "\r\n") !== false) {
|
||||||
$delim = "\r\n";
|
$delim = "\r\n";
|
||||||
}
|
}
|
||||||
$lines = explode("$delim", $content);
|
$lines = explode("$delim", $content);
|
||||||
#$lines = preg_split('/$\R?^/m', $content);
|
#$lines = preg_split('/$\R?^/m', $content);
|
||||||
|
|
||||||
|
@ -282,23 +279,23 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getMediaUrl($url, $mime, $content_length_found)
|
private static function getMediaUrl($url, $mime, $content_length_found)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (preg_match("/x-mpegurl/", $mime)) {
|
if (preg_match("/x-mpegurl/", $mime)) {
|
||||||
$media_url = self::getM3uUrl($url);
|
$media_url = self::getM3uUrl($url);
|
||||||
} else if (preg_match("/xspf\+xml/", $mime)) {
|
} elseif (preg_match("/xspf\+xml/", $mime)) {
|
||||||
$media_url = self::getXspfUrl($url);
|
$media_url = self::getXspfUrl($url);
|
||||||
} else if (preg_match("/(mpeg|ogg)/", $mime)) {
|
} elseif (preg_match("/(mpeg|ogg)/", $mime)) {
|
||||||
if ($content_length_found) {
|
if ($content_length_found) {
|
||||||
throw new Exception("Invalid webstream - This appears to be a file download.");
|
throw new Exception("Invalid webstream - This appears to be a file download.");
|
||||||
}
|
}
|
||||||
$media_url = $url;
|
$media_url = $url;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Unrecognized stream type: $mime");
|
throw new Exception("Unrecognized stream type: $mime");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $media_url;
|
return $media_url;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function discoverStreamMime($url)
|
private static function discoverStreamMime($url)
|
||||||
|
@ -315,11 +312,10 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
||||||
if (preg_match("/^content-length:/i", $h)) {
|
if (preg_match("/^content-length:/i", $h)) {
|
||||||
$content_length_found = true;
|
$content_length_found = true;
|
||||||
//if content-length appears, this is not a web stream!!!!
|
//if content-length appears, this is not a web stream!!!!
|
||||||
//Aborting the save process.
|
//Aborting the save process.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return array($mime, $content_length_found);
|
return array($mime, $content_length_found);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,14 +334,14 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
||||||
$webstream->setDbDescription($parameters["description"]);
|
$webstream->setDbDescription($parameters["description"]);
|
||||||
$webstream->setDbUrl($mediaUrl);
|
$webstream->setDbUrl($mediaUrl);
|
||||||
|
|
||||||
$dblength = $di->format("%H:%I");
|
$dblength = $di->format("%H:%I");
|
||||||
$webstream->setDbLength($dblength);
|
$webstream->setDbLength($dblength);
|
||||||
$webstream->setDbCreatorId($userInfo->id);
|
$webstream->setDbCreatorId($userInfo->id);
|
||||||
$webstream->setDbUtime(new DateTime("now", new DateTimeZone('UTC')));
|
$webstream->setDbUtime(new DateTime("now", new DateTimeZone('UTC')));
|
||||||
$webstream->setDbMtime(new DateTime("now", new DateTimeZone('UTC')));
|
$webstream->setDbMtime(new DateTime("now", new DateTimeZone('UTC')));
|
||||||
|
|
||||||
$ws = new Application_Model_Webstream($webstream);
|
$ws = new Application_Model_Webstream($webstream);
|
||||||
|
|
||||||
$webstream->setDbMime($mime);
|
$webstream->setDbMime($mime);
|
||||||
$webstream->save();
|
$webstream->save();
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class BitrateFormatter {
|
class BitrateFormatter
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* @string length
|
* @string length
|
||||||
*/
|
*/
|
||||||
|
@ -19,7 +19,7 @@ class BitrateFormatter {
|
||||||
{
|
{
|
||||||
$Kbps = bcdiv($this->_bitrate, 1000, 0);
|
$Kbps = bcdiv($this->_bitrate, 1000, 0);
|
||||||
|
|
||||||
if($Kbps == 0) {
|
if ($Kbps == 0) {
|
||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
return "{$Kbps} Kbps";
|
return "{$Kbps} Kbps";
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class LengthFormatter {
|
class LengthFormatter
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* @string length
|
* @string length
|
||||||
*/
|
*/
|
||||||
|
@ -15,7 +15,8 @@ class LengthFormatter {
|
||||||
$this->_length = $length;
|
$this->_length = $length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function format() {
|
public function format()
|
||||||
|
{
|
||||||
if (!preg_match("/^[0-9]{2}:[0-9]{2}:[0-9]{2}/", $this->_length)) {
|
if (!preg_match("/^[0-9]{2}:[0-9]{2}:[0-9]{2}/", $this->_length)) {
|
||||||
return $this->_length;
|
return $this->_length;
|
||||||
}
|
}
|
||||||
|
@ -45,15 +46,13 @@ class LengthFormatter {
|
||||||
|
|
||||||
if (isset($hours) && isset($minutes) && isset($seconds)) {
|
if (isset($hours) && isset($minutes) && isset($seconds)) {
|
||||||
$time = sprintf("%d:%02d:%02d.%s", $hours, $minutes, $seconds, $milliStr);
|
$time = sprintf("%d:%02d:%02d.%s", $hours, $minutes, $seconds, $milliStr);
|
||||||
}
|
} elseif (isset($minutes) && isset($seconds)) {
|
||||||
else if (isset($minutes) && isset($seconds)) {
|
|
||||||
$time = sprintf("%d:%02d.%s", $minutes, $seconds, $milliStr);
|
$time = sprintf("%d:%02d.%s", $minutes, $seconds, $milliStr);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$time = sprintf("%d.%s", $seconds, $milliStr);
|
$time = sprintf("%d.%s", $seconds, $milliStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $time;
|
return $time;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class SamplerateFormatter {
|
class SamplerateFormatter
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* @string sample rate
|
* @string sample rate
|
||||||
*/
|
*/
|
||||||
|
@ -21,4 +21,4 @@ class SamplerateFormatter {
|
||||||
|
|
||||||
return "{$kHz} kHz";
|
return "{$kHz} kHz";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class TimeFilledFormatter {
|
class TimeFilledFormatter
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* @string seconds
|
* @string seconds
|
||||||
*/
|
*/
|
||||||
|
@ -51,4 +51,4 @@ class TimeFilledFormatter {
|
||||||
|
|
||||||
return $formatted;
|
return $formatted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue