Merge branch '2.2.x' into devel
Conflicts: airtime_mvc/application/controllers/LibraryController.php airtime_mvc/application/views/scripts/library/library.phtml airtime_mvc/public/js/airtime/showbuilder/builder.js airtime_mvc/public/js/airtime/showbuilder/main_builder.js
This commit is contained in:
commit
135aadf16b
56 changed files with 5240 additions and 4806 deletions
|
@ -308,10 +308,11 @@ SQL;
|
|||
$length = $value." ".$modifier;
|
||||
} else {
|
||||
$hour = "00";
|
||||
$mins = "00";
|
||||
if ($modifier == "minutes") {
|
||||
if ($value >59) {
|
||||
$hour = intval($value/60);
|
||||
$value = $value%60;
|
||||
$mins = $value%60;
|
||||
|
||||
}
|
||||
} elseif ($modifier == "hours") {
|
||||
|
@ -1092,6 +1093,14 @@ SQL;
|
|||
->setDbValue($p_criteriaData['etc']['sp_limit_value'])
|
||||
->setDbBlockId($this->id)
|
||||
->save();
|
||||
|
||||
// insert repeate track option
|
||||
$qry = new CcBlockcriteria();
|
||||
$qry->setDbCriteria("repeat_tracks")
|
||||
->setDbModifier("N/A")
|
||||
->setDbValue($p_criteriaData['etc']['sp_repeat_tracks'])
|
||||
->setDbBlockId($this->id)
|
||||
->save();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1104,7 +1113,12 @@ SQL;
|
|||
$this->saveSmartBlockCriteria($p_criteria);
|
||||
$insertList = $this->getListOfFilesUnderLimit();
|
||||
$this->deleteAllFilesFromBlock();
|
||||
$this->addAudioClips(array_keys($insertList));
|
||||
// constrcut id array
|
||||
$ids = array();
|
||||
foreach ($insertList as $ele) {
|
||||
$ids[] = $ele['id'];
|
||||
}
|
||||
$this->addAudioClips(array_values($ids));
|
||||
// update length in playlist contents.
|
||||
$this->updateBlockLengthInAllPlaylist();
|
||||
|
||||
|
@ -1133,6 +1147,7 @@ SQL;
|
|||
$info = $this->getListofFilesMeetCriteria();
|
||||
$files = $info['files'];
|
||||
$limit = $info['limit'];
|
||||
$repeat = $info['repeat_tracks'];
|
||||
|
||||
$insertList = array();
|
||||
$totalTime = 0;
|
||||
|
@ -1141,19 +1156,37 @@ SQL;
|
|||
// this moves the pointer to the first element in the collection
|
||||
$files->getFirst();
|
||||
$iterator = $files->getIterator();
|
||||
while ($iterator->valid() && $totalTime < $limit['time']) {
|
||||
|
||||
$isBlockFull = false;
|
||||
|
||||
while ($iterator->valid()) {
|
||||
$id = $iterator->current()->getDbId();
|
||||
$length = Application_Common_DateHelper::calculateLengthInSeconds($iterator->current()->getDbLength());
|
||||
$insertList[$id] = $length;
|
||||
$insertList[] = array('id'=>$id, 'length'=>$length);
|
||||
$totalTime += $length;
|
||||
$totalItems++;
|
||||
|
||||
if ((!is_null($limit['items']) && $limit['items'] == count($insertList)) || $totalItems > 500) {
|
||||
|
||||
if ((!is_null($limit['items']) && $limit['items'] == count($insertList)) || $totalItems > 500 || $totalTime > $limit['time']) {
|
||||
$isBlockFull = true;
|
||||
break;
|
||||
}
|
||||
|
||||
$iterator->next();
|
||||
}
|
||||
|
||||
$sizeOfInsert = count($insertList);
|
||||
|
||||
// if block is not full and reapeat_track is check, fill up more
|
||||
while (!$isBlockFull && $repeat == 1) {
|
||||
$randomEleKey = array_rand(array_slice($insertList, 0, $sizeOfInsert));
|
||||
$insertList[] = $insertList[$randomEleKey];
|
||||
$totalTime += $insertList[$randomEleKey]['length'];
|
||||
$totalItems++;
|
||||
|
||||
if ((!is_null($limit['items']) && $limit['items'] == count($insertList)) || $totalItems > 500 || $totalTime > $limit['time']) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $insertList;
|
||||
}
|
||||
|
@ -1201,6 +1234,8 @@ SQL;
|
|||
|
||||
if ($criteria == "limit") {
|
||||
$storedCrit["limit"] = array("value"=>$value, "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]);
|
||||
}
|
||||
|
@ -1316,6 +1351,7 @@ SQL;
|
|||
}
|
||||
// construct limit restriction
|
||||
$limits = array();
|
||||
|
||||
if (isset($storedCrit['limit'])) {
|
||||
if ($storedCrit['limit']['modifier'] == "items") {
|
||||
$limits['time'] = 1440 * 60;
|
||||
|
@ -1327,10 +1363,16 @@ SQL;
|
|||
$limits['items'] = null;
|
||||
}
|
||||
}
|
||||
|
||||
$repeatTracks = 0;
|
||||
if (isset($storedCrit['repeat_tracks'])) {
|
||||
$repeatTracks = $storedCrit['repeat_tracks']['value'];
|
||||
}
|
||||
|
||||
try {
|
||||
$out = $qry->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find();
|
||||
|
||||
return array("files"=>$out, "limit"=>$limits, "count"=>$out->count());
|
||||
return array("files"=>$out, "limit"=>$limits, "repeat_tracks"=> $repeatTracks, "count"=>$out->count());
|
||||
} catch (Exception $e) {
|
||||
Logging::info($e);
|
||||
}
|
||||
|
@ -1376,7 +1418,7 @@ SQL;
|
|||
$output['etc'][$ele['name']] = $ele['value'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $output;
|
||||
}
|
||||
// smart block functions end
|
||||
|
|
|
@ -13,9 +13,9 @@ class Application_Model_Datatables
|
|||
if ($dbname == 'utime' || $dbname == 'mtime') {
|
||||
$input1 = isset($info[0])?Application_Common_DateHelper::ConvertToUtcDateTimeString($info[0]):null;
|
||||
$input2 = isset($info[1])?Application_Common_DateHelper::ConvertToUtcDateTimeString($info[1]):null;
|
||||
} else if($dbname == 'bit_rate') {
|
||||
$input1 = isset($info[0])?intval($info[0]) * 1000:null;
|
||||
$input2 = isset($info[1])?intval($info[1]) * 1000:null;
|
||||
} else if($dbname == 'bit_rate' || $dbname == 'sample_rate') {
|
||||
$input1 = isset($info[0])?doubleval($info[0]) * 1000:null;
|
||||
$input2 = isset($info[1])?doubleval($info[1]) * 1000:null;
|
||||
} else {
|
||||
$input1 = isset($info[0])?$info[0]:null;
|
||||
$input2 = isset($info[1])?$info[1]:null;
|
||||
|
|
|
@ -268,7 +268,7 @@ SQL;
|
|||
|
||||
|
||||
//We need to search 24 hours before and after the show times so that that we
|
||||
//capture all of the show's contents.
|
||||
//capture all of the show's contents.
|
||||
$p_track_start= $p_start->sub(new DateInterval("PT24H"))->format("Y-m-d H:i:s");
|
||||
$p_track_end = $p_end->add(new DateInterval("PT24H"))->format("Y-m-d H:i:s");
|
||||
|
||||
|
@ -292,7 +292,8 @@ SQL;
|
|||
ft.artist_name AS file_artist_name,
|
||||
ft.album_title AS file_album_title,
|
||||
ft.length AS file_length,
|
||||
ft.file_exists AS file_exists
|
||||
ft.file_exists AS file_exists,
|
||||
ft.mime AS file_mime
|
||||
SQL;
|
||||
$filesJoin = <<<SQL
|
||||
cc_schedule AS sched
|
||||
|
@ -319,7 +320,8 @@ SQL;
|
|||
sub.login AS file_artist_name,
|
||||
ws.description AS file_album_title,
|
||||
ws.length AS file_length,
|
||||
't'::BOOL AS file_exists
|
||||
't'::BOOL AS file_exists,
|
||||
NULL as file_mime
|
||||
SQL;
|
||||
$streamJoin = <<<SQL
|
||||
cc_schedule AS sched
|
||||
|
@ -661,6 +663,7 @@ SQL;
|
|||
$data["media"][$switch_start]['start'] = $switch_start;
|
||||
$data["media"][$switch_start]['end'] = $switch_start;
|
||||
$data["media"][$switch_start]['event_type'] = "switch_off";
|
||||
$data["media"][$switch_start]['type'] = "event";
|
||||
$data["media"][$switch_start]['independent_event'] = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -270,6 +270,13 @@ SQL;
|
|||
|
||||
try {
|
||||
//update the status flag in cc_schedule.
|
||||
|
||||
/* Since we didn't use a propel object when updating
|
||||
* cc_show_instances table we need to clear the instances
|
||||
* so the correct information is retrieved from the db
|
||||
*/
|
||||
CcShowInstancesPeer::clearInstancePool();
|
||||
|
||||
$instances = CcShowInstancesQuery::create()
|
||||
->filterByDbEnds($current_timestamp, Criteria::GREATER_THAN)
|
||||
->filterByDbShowId($this->_showId)
|
||||
|
@ -1253,6 +1260,7 @@ SQL;
|
|||
if ($data['add_show_id'] != -1) {
|
||||
$con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
|
||||
$con->beginTransaction();
|
||||
|
||||
|
||||
//current timesamp in UTC.
|
||||
$current_timestamp = gmdate("Y-m-d H:i:s");
|
||||
|
|
|
@ -41,6 +41,7 @@ class Application_Model_ShowBuilder
|
|||
"fadein" => "",
|
||||
"fadeout" => "",
|
||||
"image" => false,
|
||||
"mime" => null,
|
||||
"color" => "", //in hex without the '#' sign.
|
||||
"backgroundColor" => "", //in hex without the '#' sign.
|
||||
);
|
||||
|
@ -277,6 +278,7 @@ class Application_Model_ShowBuilder
|
|||
$row["cueout"] = $p_item["cue_out"];
|
||||
$row["fadein"] = round(substr($p_item["fade_in"], 6), 6);
|
||||
$row["fadeout"] = round(substr($p_item["fade_out"], 6), 6);
|
||||
$row["mime"] = $p_item["file_mime"];
|
||||
|
||||
$row["pos"] = $this->pos++;
|
||||
|
||||
|
@ -471,7 +473,7 @@ class Application_Model_ShowBuilder
|
|||
$display_items[] = $this->makeFooterRow($scheduled_items[
|
||||
count($scheduled_items)-1]);
|
||||
}
|
||||
|
||||
|
||||
return array(
|
||||
"schedule" => $display_items,
|
||||
"showInstances" => $this->showInstances);
|
||||
|
|
|
@ -344,6 +344,13 @@ SQL;
|
|||
throw new DeleteScheduledFileException();
|
||||
}
|
||||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new Application_Model_User($userInfo->id);
|
||||
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
||||
if (!$isAdminOrPM && $this->getFileOwnerId() != $user->getId()) {
|
||||
throw new FileNoPermissionException();
|
||||
}
|
||||
|
||||
$music_dir = Application_Model_MusicDir::getDirByPK($this->_file->getDbDirectory());
|
||||
$type = $music_dir->getType();
|
||||
|
||||
|
@ -1163,6 +1170,10 @@ SQL;
|
|||
return $this->_file->getDbFileExists();
|
||||
}
|
||||
|
||||
public function getFileOwnerId()
|
||||
{
|
||||
return $this->_file->getDbOwnerId();
|
||||
}
|
||||
|
||||
// note: never call this method from controllers because it does a sleep
|
||||
public function uploadToSoundCloud()
|
||||
|
@ -1211,3 +1222,4 @@ SQL;
|
|||
|
||||
class DeleteScheduledFileException extends Exception {}
|
||||
class FileDoesNotExistException extends Exception {}
|
||||
class FileNoPermissionException extends Exception {}
|
||||
|
|
|
@ -92,7 +92,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
if (count($leftOver) == 0) {
|
||||
CcWebstreamQuery::create()->findPKs($p_ids)->delete();
|
||||
} else {
|
||||
throw new Exception("Invalid user permissions");
|
||||
throw new WebstreamNoPermissionException;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
}
|
||||
$mediaUrl = self::getMediaUrl($url, $mime, $content_length_found);
|
||||
|
||||
if (preg_match("/(x-mpegurl)|(xspf\+xml)|(pls\+xml)/", $mime)) {
|
||||
if (preg_match("/(x-mpegurl)|(xspf\+xml)|(pls\+xml)|(x-scpls)/", $mime)) {
|
||||
list($mime, $content_length_found) = self::discoverStreamMime($mediaUrl);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
|
@ -307,7 +307,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
$media_url = self::getM3uUrl($url);
|
||||
} elseif (preg_match("/xspf\+xml/", $mime)) {
|
||||
$media_url = self::getXspfUrl($url);
|
||||
} elseif (preg_match("/pls\+xml/", $mime)) {
|
||||
} elseif (preg_match("/pls\+xml/", $mime) || preg_match("/x-scpls/", $mime)) {
|
||||
$media_url = self::getPlsUrl($url);
|
||||
} elseif (preg_match("/(mpeg|ogg)/", $mime)) {
|
||||
if ($content_length_found) {
|
||||
|
@ -370,3 +370,6 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
return $webstream->getDbId();
|
||||
}
|
||||
}
|
||||
|
||||
class WebstreamNoPermissionException extends Exception {}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ class CcBlockTableMap extends TableMap {
|
|||
*/
|
||||
public function buildRelations()
|
||||
{
|
||||
$this->addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('creator_id' => 'id', ), null, null);
|
||||
$this->addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('creator_id' => 'id', ), 'CASCADE', null);
|
||||
$this->addRelation('CcPlaylistcontents', 'CcPlaylistcontents', RelationMap::ONE_TO_MANY, array('id' => 'block_id', ), 'CASCADE', null);
|
||||
$this->addRelation('CcBlockcontents', 'CcBlockcontents', RelationMap::ONE_TO_MANY, array('id' => 'block_id', ), 'CASCADE', null);
|
||||
$this->addRelation('CcBlockcriteria', 'CcBlockcriteria', RelationMap::ONE_TO_MANY, array('id' => 'block_id', ), 'CASCADE', null);
|
||||
|
|
|
@ -64,7 +64,7 @@ class CcSubjsTableMap extends TableMap {
|
|||
$this->addRelation('CcPerms', 'CcPerms', RelationMap::ONE_TO_MANY, array('id' => 'subj', ), 'CASCADE', null);
|
||||
$this->addRelation('CcShowHosts', 'CcShowHosts', RelationMap::ONE_TO_MANY, array('id' => 'subjs_id', ), 'CASCADE', null);
|
||||
$this->addRelation('CcPlaylist', 'CcPlaylist', RelationMap::ONE_TO_MANY, array('id' => 'creator_id', ), 'CASCADE', null);
|
||||
$this->addRelation('CcBlock', 'CcBlock', RelationMap::ONE_TO_MANY, array('id' => 'creator_id', ), null, null);
|
||||
$this->addRelation('CcBlock', 'CcBlock', RelationMap::ONE_TO_MANY, array('id' => 'creator_id', ), 'CASCADE', null);
|
||||
$this->addRelation('CcPref', 'CcPref', RelationMap::ONE_TO_MANY, array('id' => 'subjid', ), 'CASCADE', null);
|
||||
$this->addRelation('CcSess', 'CcSess', RelationMap::ONE_TO_MANY, array('id' => 'userid', ), 'CASCADE', null);
|
||||
$this->addRelation('CcSubjsToken', 'CcSubjsToken', RelationMap::ONE_TO_MANY, array('id' => 'user_id', ), 'CASCADE', null);
|
||||
|
|
|
@ -407,6 +407,9 @@ abstract class BaseCcSubjsPeer {
|
|||
// Invalidate objects in CcPlaylistPeer instance pool,
|
||||
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
|
||||
CcPlaylistPeer::clearInstancePool();
|
||||
// Invalidate objects in CcBlockPeer instance pool,
|
||||
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
|
||||
CcBlockPeer::clearInstancePool();
|
||||
// Invalidate objects in CcPrefPeer instance pool,
|
||||
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
|
||||
CcPrefPeer::clearInstancePool();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue