Merged baseUrl related conflicts

This commit is contained in:
Rudi Grinberg 2012-10-29 11:56:20 -04:00
commit dc00528cd5
62 changed files with 1155 additions and 1234 deletions

View file

@ -1,40 +1,40 @@
<?php
define('AIRTIME_COPYRIGHT_DATE', '2010-2012');
define('AIRTIME_REST_VERSION', '1.1');
define('AIRTIME_API_VERSION', '1.1');
define('AIRTIME_COPYRIGHT_DATE' , '2010-2012');
define('AIRTIME_REST_VERSION' , '1.1');
define('AIRTIME_API_VERSION' , '1.1');
// Metadata Keys for files
define('MDATA_KEY_FILEPATH', 'filepath');
define('MDATA_KEY_DIRECTORY', 'directory');
define('MDATA_KEY_MD5', 'md5');
define('MDATA_KEY_TITLE', 'track_title');
define('MDATA_KEY_CREATOR', 'artist_name');
define('MDATA_KEY_SOURCE', 'album_title');
define('MDATA_KEY_DURATION', 'length');
define('MDATA_KEY_MIME', 'mime');
define('MDATA_KEY_FTYPE', 'ftype');
define('MDATA_KEY_URL', 'info_url');
define('MDATA_KEY_GENRE', 'genre');
define('MDATA_KEY_MOOD', 'mood');
define('MDATA_KEY_LABEL', 'label');
define('MDATA_KEY_COMPOSER', 'composer');
define('MDATA_KEY_DESCRIPTION', 'description');
define('MDATA_KEY_SAMPLERATE', 'sample_rate');
define('MDATA_KEY_BITRATE', 'bit_rate');
define('MDATA_KEY_ENCODER', 'encoded_by');
define('MDATA_KEY_ISRC', 'isrc_number');
define('MDATA_KEY_COPYRIGHT', 'copyright');
define('MDATA_KEY_YEAR', 'year');
define('MDATA_KEY_BPM', 'bpm');
define('MDATA_KEY_TRACKNUMBER', 'track_number');
define('MDATA_KEY_CONDUCTOR', 'conductor');
define('MDATA_KEY_LANGUAGE', 'language');
define('MDATA_KEY_REPLAYGAIN', 'replay_gain');
define('MDATA_KEY_OWNER_ID', 'owner_id');
define('MDATA_KEY_FILEPATH' , 'filepath');
define('MDATA_KEY_DIRECTORY' , 'directory');
define('MDATA_KEY_MD5' , 'md5');
define('MDATA_KEY_TITLE' , 'track_title');
define('MDATA_KEY_CREATOR' , 'artist_name');
define('MDATA_KEY_SOURCE' , 'album_title');
define('MDATA_KEY_DURATION' , 'length');
define('MDATA_KEY_MIME' , 'mime');
define('MDATA_KEY_FTYPE' , 'ftype');
define('MDATA_KEY_URL' , 'info_url');
define('MDATA_KEY_GENRE' , 'genre');
define('MDATA_KEY_MOOD' , 'mood');
define('MDATA_KEY_LABEL' , 'label');
define('MDATA_KEY_COMPOSER' , 'composer');
define('MDATA_KEY_DESCRIPTION' , 'description');
define('MDATA_KEY_SAMPLERATE' , 'sample_rate');
define('MDATA_KEY_BITRATE' , 'bit_rate');
define('MDATA_KEY_ENCODER' , 'encoded_by');
define('MDATA_KEY_ISRC' , 'isrc_number');
define('MDATA_KEY_COPYRIGHT' , 'copyright');
define('MDATA_KEY_YEAR' , 'year');
define('MDATA_KEY_BPM' , 'bpm');
define('MDATA_KEY_TRACKNUMBER' , 'track_number');
define('MDATA_KEY_CONDUCTOR' , 'conductor');
define('MDATA_KEY_LANGUAGE' , 'language');
define('MDATA_KEY_REPLAYGAIN' , 'replay_gain');
define('MDATA_KEY_OWNER_ID' , 'owner_id');
define('UI_MDATA_VALUE_FORMAT_FILE', 'File');
define('UI_MDATA_VALUE_FORMAT_STREAM', 'live stream');
define('UI_MDATA_VALUE_FORMAT_FILE' , 'File');
define('UI_MDATA_VALUE_FORMAT_STREAM' , 'live stream');
// Session Keys
define('UI_PLAYLISTCONTROLLER_OBJ_SESSNAME', 'PLAYLISTCONTROLLER_OBJ');
@ -43,6 +43,6 @@ define('UI_BLOCK_SESSNAME', 'BLOCK');*/
// Soundcloud contants
define('SOUNDCLOUD_NOT_UPLOADED_YET', -1);
define('SOUNDCLOUD_PROGRESS', -2);
define('SOUNDCLOUD_ERROR', -3);
define('SOUNDCLOUD_NOT_UPLOADED_YET' , -1);
define('SOUNDCLOUD_PROGRESS' , -2);
define('SOUNDCLOUD_ERROR' , -3);

View file

@ -490,6 +490,10 @@ class ApiController extends Zend_Controller_Action
$file->setFileExistsFlag(true);
$file->setMetadata($md);
}
if ($md['is_record'] != 0) {
$this->uploadRecordedActionParam($md['MDATA_KEY_TRACKNUMBER'], $file->getId());
}
} elseif ($mode == "modify") {
$filepath = $md['MDATA_KEY_FILEPATH'];
$file = Application_Model_StoredFile::RecallByFilepath($filepath);
@ -562,7 +566,6 @@ class ApiController extends Zend_Controller_Action
// least 1 digit
if ( !preg_match('/^md\d+$/', $k) ) { continue; }
$info_json = json_decode($raw_json, $assoc = true);
unset( $info_json["is_record"] );
// Log invalid requests
if ( !array_key_exists('mode', $info_json) ) {
Logging::info("Received bad request(key=$k), no 'mode' parameter. Bad request is:");

View file

@ -454,7 +454,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
$column = CcFilesPeer::getTableMap()->getColumnByPhpName($criteria2PeerMap[$d['sp_criteria_field']]);
// validation on type of column
if ($d['sp_criteria_field'] == 'length') {
if (!preg_match("/(\d{2}):(\d{2}):(\d{2})/", $d['sp_criteria_value'])) {
if (!preg_match("/^(\d{2}):(\d{2}):(\d{2})/", $d['sp_criteria_value'])) {
$element->addError("'Length' should be in '00:00:00' format");
$isValid = false;
}

View file

@ -263,6 +263,15 @@ SQL;
global $CC_CONFIG;
$con = Propel::getConnection();
$p_start_str = $p_start->format("Y-m-d H:i:s");
$p_end_str = $p_end->format("Y-m-d H:i:s");
//We need to search 24 hours before and after the show times so that that we
//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");
$templateSql = <<<SQL
SELECT DISTINCT sched.starts AS sched_starts,
sched.ends AS sched_ends,
@ -287,7 +296,14 @@ SQL;
SQL;
$filesJoin = <<<SQL
cc_schedule AS sched
JOIN cc_files AS ft ON (sched.file_id = ft.id)
JOIN cc_files AS ft ON (sched.file_id = ft.id
AND ((sched.starts >= '{$p_track_start}'
AND sched.starts < '{$p_track_end}')
OR (sched.ends > '{$p_track_start}'
AND sched.ends <= '{$p_track_end}')
OR (sched.starts <= '{$p_track_start}'
AND sched.ends >= '{$p_track_end}'))
)
SQL;
@ -307,7 +323,14 @@ SQL;
SQL;
$streamJoin = <<<SQL
cc_schedule AS sched
JOIN cc_webstream AS ws ON (sched.stream_id = ws.id)
JOIN cc_webstream AS ws ON (sched.stream_id = ws.id
AND ((sched.starts >= '{$p_track_start}'
AND sched.starts < '{$p_track_end}')
OR (sched.ends > '{$p_track_start}'
AND sched.ends <= '{$p_track_end}')
OR (sched.starts <= '{$p_track_start}'
AND sched.ends >= '{$p_track_end}'))
)
LEFT JOIN cc_subjs AS sub ON (ws.creator_id = sub.id)
SQL;
@ -344,12 +367,12 @@ SELECT showt.name AS show_name,
JOIN cc_show AS showt ON (showt.id = si.show_id)
WHERE si.modified_instance = FALSE
$showPredicate
AND ((si.starts >= '{$p_start}'
AND si.starts < '{$p_end}')
OR (si.ends > '{$p_start}'
AND si.ends <= '{$p_end}')
OR (si.starts <= '{$p_start}'
AND si.ends >= '{$p_end}'))
AND ((si.starts >= '{$p_start_str}'
AND si.starts < '{$p_end_str}')
OR (si.ends > '{$p_start_str}'
AND si.ends <= '{$p_end_str}')
OR (si.starts <= '{$p_start_str}'
AND si.ends >= '{$p_end_str}'))
ORDER BY si_starts,
sched_starts;
SQL;
@ -713,6 +736,7 @@ SQL;
'end' => $stream_end,
'uri' => $uri,
'type' => 'stream_buffer_end',
'row_id' => $item["id"],
'independent_event' => true
);
self::appendScheduleItem($data, $stream_end, $schedule_item);
@ -1127,7 +1151,6 @@ SQL;
}
} else {
if ($isAdminOrPM) {
Logging::info( $data );
Application_Model_Show::create($data);
}

View file

@ -366,12 +366,11 @@ class Application_Model_Scheduler
* @param array $fileIds
* @param array $playlistIds
*/
private function insertAfter($scheduleItems, $schedFiles, $adjustSched = true)
private function insertAfter($scheduleItems, $schedFiles, $adjustSched = true, $mediaItems = null)
{
try {
$affectedShowInstances = array();
//dont want to recalculate times for moved items.
$excludeIds = array();
foreach ($schedFiles as $file) {
@ -384,7 +383,17 @@ class Application_Model_Scheduler
foreach ($scheduleItems as $schedule) {
$id = intval($schedule["id"]);
// if mediaItmes is passed in, we want to create contents
// at the time of insert. This is for dyanmic blocks or
// playlist that contains dynamic blocks
if ($mediaItems != null) {
$schedFiles = array();
foreach ($mediaItems as $media) {
$schedFiles = array_merge($schedFiles, $this->retrieveMediaFiles($media["id"], $media["type"]));
}
}
if ($id !== 0) {
$schedItem = CcScheduleQuery::create()->findPK($id, $this->con);
$instance = $schedItem->getCcShowInstances($this->con);
@ -527,10 +536,32 @@ class Application_Model_Scheduler
$this->validateRequest($scheduleItems);
$requireDynamicContentCreation = false;
foreach ($mediaItems as $media) {
$schedFiles = array_merge($schedFiles, $this->retrieveMediaFiles($media["id"], $media["type"]));
if ($media['type'] == "playlist") {
$pl = new Application_Model_Playlist($media['id']);
if ($pl->hasDynamicBlock()) {
$requireDynamicContentCreation = true;
break;
}
} else if ($media['type'] == "block") {
$bl = new Application_Model_Block($media['id']);
if (!$bl->isStatic()) {
$requireDynamicContentCreation = true;
break;
}
}
}
if ($requireDynamicContentCreation) {
$this->insertAfter($scheduleItems, $schedFiles, $adjustSched, $mediaItems);
} else {
foreach ($mediaItems as $media) {
$schedFiles = array_merge($schedFiles, $this->retrieveMediaFiles($media["id"], $media["type"]));
}
$this->insertAfter($scheduleItems, $schedFiles, $adjustSched);
}
$this->insertAfter($scheduleItems, $schedFiles, $adjustSched);
$this->con->commit();

View file

@ -1743,7 +1743,8 @@ SQL;
$days = $interval->format('%a');
$shows = Application_Model_Show::getShows($p_start, $p_end);
$nowEpoch = time();
$content_count = Application_Model_ShowInstance::getContentCount(
$p_start, $p_end);
$timezone = date_default_timezone_get();
foreach ($shows as $show) {
@ -1789,9 +1790,9 @@ SQL;
$showInstance = new Application_Model_ShowInstance(
$show["instance_id"]);
//$showContent = $showInstance->getShowListContent();
$options["show_empty"] = ($showInstance->showEmpty()) ? 1 : 0;
$options["show_empty"] = (array_key_exists($show['instance_id'],
$content_count)) ? 0 : 1;
$events[] = &self::makeFullCalendarEvent($show, $options,
$startsDT, $endsDT, $startsEpochStr, $endsEpochStr);

View file

@ -198,7 +198,9 @@ class Application_Model_ShowBuilder
} elseif (intval($p_item["si_record"]) === 1) {
$row["record"] = true;
if (Application_Model_Preference::GetUploadToSoundcloudOption()) {
// at the time of creating on show, the recorded file is not in the DB yet.
// therefore, 'si_file_id' is null. So we need to check it.
if (Application_Model_Preference::GetUploadToSoundcloudOption() && isset($p_item['si_file_id'])) {
$file = Application_Model_StoredFile::Recall(
$p_item['si_file_id']);
if (isset($file)) {
@ -398,7 +400,7 @@ class Application_Model_ShowBuilder
//see if the displayed show instances have changed. (deleted,
//empty schedule etc)
if ($outdated === false && count($instances)
if ($outdated === false && count($instances)
!== count($currentInstances)) {
Logging::debug("show instances have changed.");
$outdated = true;
@ -421,8 +423,7 @@ class Application_Model_ShowBuilder
}
$scheduled_items = Application_Model_Schedule::GetScheduleDetailItems(
$this->startDT->format("Y-m-d H:i:s"), $this->endDT->format(
"Y-m-d H:i:s"), $shows);
$this->startDT, $this->endDT, $shows);
for ($i = 0, $rows = count($scheduled_items); $i < $rows; $i++) {
@ -459,7 +460,7 @@ class Application_Model_ShowBuilder
$display_items[] = $row;
}
if ($current_id !== -1 &&
if ($current_id !== -1 &&
!in_array($current_id, $this->showInstances)) {
$this->showInstances[] = $current_id;
}

View file

@ -662,6 +662,31 @@ SQL;
}
public static function getContentCount($p_start, $p_end)
{
$sql = <<<SQL
SELECT instance_id,
count(*) AS instance_count
FROM cc_schedule
WHERE ends > :p_start::TIMESTAMP
AND starts < :p_end::TIMESTAMP
GROUP BY instance_id
SQL;
$counts = Application_Common_Database::prepareAndExecute($sql, array(
':p_start' => $p_start->format("Y-m-d G:i:s"),
':p_end' => $p_end->format("Y-m-d G:i:s"))
, 'all');
$real_counts = array();
foreach ($counts as $c) {
$real_counts[$c['instance_id']] = $c['instance_count'];
}
return $real_counts;
}
public function showEmpty()
{
$sql = <<<SQL

View file

@ -25,66 +25,67 @@ class Application_Model_Soundcloud
public function uploadTrack($filepath, $filename, $description,
$tags=array(), $release=null, $genre=null)
{
if ($this->getToken()) {
if (count($tags)) {
$tags = join(" ", $tags);
$tags = $tags." ".Application_Model_Preference::GetSoundCloudTags();
} else {
$tags = Application_Model_Preference::GetSoundCloudTags();
}
{
$downloadable = Application_Model_Preference::GetSoundCloudDownloadbleOption() == '1';
$track_data = array(
'track[sharing]' => 'private',
'track[title]' => $filename,
'track[asset_data]' => '@' . $filepath,
'track[tag_list]' => $tags,
'track[description]' => $description,
'track[downloadable]' => $downloadable,
);
if (isset($release)) {
$release = str_replace(" ", "-", $release);
$release = str_replace(":", "-", $release);
//YYYY-MM-DD-HH-mm-SS
$release = explode("-", $release);
$track_data['track[release_year]'] = $release[0];
$track_data['track[release_month]'] = $release[1];
$track_data['track[release_day]'] = $release[2];
}
if (isset($genre) && $genre != "") {
$track_data['track[genre]'] = $genre;
} else {
$default_genre = Application_Model_Preference::GetSoundCloudGenre();
if ($default_genre != "") {
$track_data['track[genre]'] = $default_genre;
}
}
$track_type = Application_Model_Preference::GetSoundCloudTrackType();
if ($track_type != "") {
$track_data['track[track_type]'] = $track_type;
}
$license = Application_Model_Preference::GetSoundCloudLicense();
if ($license != "") {
$track_data['track[license]'] = $license;
}
$response = json_decode(
$this->_soundcloud->post('tracks', $track_data),
true
);
return $response;
} else {
if (!$this->getToken()) {
throw new NoSoundCloundToken();
}
if (count($tags)) {
$tags = join(" ", $tags);
$tags = $tags." ".Application_Model_Preference::GetSoundCloudTags();
} else {
$tags = Application_Model_Preference::GetSoundCloudTags();
}
$downloadable = Application_Model_Preference::GetSoundCloudDownloadbleOption() == '1';
$track_data = array(
'track[sharing]' => 'private',
'track[title]' => $filename,
'track[asset_data]' => '@' . $filepath,
'track[tag_list]' => $tags,
'track[description]' => $description,
'track[downloadable]' => $downloadable,
);
if (isset($release)) {
$release = str_replace(" ", "-", $release);
$release = str_replace(":", "-", $release);
//YYYY-MM-DD-HH-mm-SS
$release = explode("-", $release);
$track_data['track[release_year]'] = $release[0];
$track_data['track[release_month]'] = $release[1];
$track_data['track[release_day]'] = $release[2];
}
if (isset($genre) && $genre != "") {
$track_data['track[genre]'] = $genre;
} else {
$default_genre = Application_Model_Preference::GetSoundCloudGenre();
if ($default_genre != "") {
$track_data['track[genre]'] = $default_genre;
}
}
$track_type = Application_Model_Preference::GetSoundCloudTrackType();
if ($track_type != "") {
$track_data['track[track_type]'] = $track_type;
}
$license = Application_Model_Preference::GetSoundCloudLicense();
if ($license != "") {
$track_data['track[license]'] = $license;
}
$response = json_decode(
$this->_soundcloud->post('tracks', $track_data),
true
);
return $response;
}
public static function uploadSoundcloud($id)

View file

@ -127,9 +127,9 @@ class CcSchedule extends BaseCcSchedule {
}
if ($microsecond == 0) {
$this->fadein = $dt->format('H:i:s.u');
$this->fade_in = $dt->format('H:i:s.u');
} else {
$this->fadein = $dt->format('H:i:s').".".$microsecond;
$this->fade_in = $dt->format('H:i:s').".".$microsecond;
}
$this->modifiedColumns[] = CcSchedulePeer::FADE_IN;
@ -164,9 +164,9 @@ class CcSchedule extends BaseCcSchedule {
}
if ($microsecond == 0) {
$this->fadeout = $dt->format('H:i:s.u');
$this->fade_out = $dt->format('H:i:s.u');
} else {
$this->fadeout = $dt->format('H:i:s').".".$microsecond;
$this->fade_out = $dt->format('H:i:s').".".$microsecond;
}
$this->modifiedColumns[] = CcSchedulePeer::FADE_OUT;

View file

@ -53,7 +53,7 @@ class CcPlaylistTableMap 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' => 'playlist_id', ), 'CASCADE', null);
} // buildRelations()

View file

@ -63,7 +63,7 @@ class CcSubjsTableMap extends TableMap {
$this->addRelation('CcFilesRelatedByDbEditedby', 'CcFiles', RelationMap::ONE_TO_MANY, array('id' => 'editedby', ), null, null);
$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', ), null, 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('CcPref', 'CcPref', RelationMap::ONE_TO_MANY, array('id' => 'subjid', ), 'CASCADE', null);
$this->addRelation('CcSess', 'CcSess', RelationMap::ONE_TO_MANY, array('id' => 'userid', ), 'CASCADE', null);

View file

@ -404,6 +404,9 @@ abstract class BaseCcSubjsPeer {
// Invalidate objects in CcShowHostsPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
CcShowHostsPeer::clearInstancePool();
// 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 CcPrefPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
CcPrefPeer::clearInstancePool();

View file

@ -49,7 +49,7 @@
</dd>
<dt id="master_username-label">
<label class="optional" for="master_username"><?php echo $this->element->getElement('master_username')->getLabel() ?> :
<span class='stream_username_help_icon'></span>
<span class='master_username_help_icon'></span>
</label>
</dt>
<dd id="master_username-element">