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

@ -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();