Merge branch '2.2.x-saas' of dev.sourcefabric.org:airtime into 2.2.x-saas

This commit is contained in:
denise 2012-10-23 16:50:36 -04:00
commit 9cd389d16b
28 changed files with 329 additions and 139 deletions

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

@ -143,10 +143,12 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
* upto this point
*/
if ($valid) {
$utc = new DateTimeZone('UTC');
$localTimezone = new DateTimeZone(Application_Model_Preference::GetTimezone());
$show_start = new DateTime($start_time);
$show_start->setTimezone(new DateTimeZone('UTC'));
$show_start->setTimezone($utc);
$show_end = new DateTime($end_time);
$show_end->setTimezone(new DateTimeZone('UTC'));
$show_end->setTimezone($utc);
if ($formData["add_show_repeats"]) {
@ -155,7 +157,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
$date = Application_Model_Preference::GetShowsPopulatedUntil();
if (is_null($date)) {
$populateUntilDateTime = new DateTime("now", new DateTimeZone('UTC'));
$populateUntilDateTime = new DateTime("now", $utc);
Application_Model_Preference::SetShowsPopulatedUntil($populateUntilDateTime);
} else {
$populateUntilDateTime = clone $date;
@ -164,7 +166,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
} elseif (!$formData["add_show_no_end"]) {
$popUntil = $formData["add_show_end_date"]." ".$formData["add_show_end_time"];
$populateUntilDateTime = new DateTime($popUntil);
$populateUntilDateTime->setTimezone(new DateTimeZone('UTC'));
$populateUntilDateTime->setTimezone($utc);
}
//get repeat interval
@ -203,8 +205,18 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
else
$daysAdd = $day - $startDow;
/* In case we are crossing daylights saving time we need
* to convert show start and show end to local time before
* adding the interval for the next repeating show
*/
$repeatShowStart->setTimezone($localTimezone);
$repeatShowEnd->setTimezone($localTimezone);
$repeatShowStart->add(new DateInterval("P".$daysAdd."D"));
$repeatShowEnd->add(new DateInterval("P".$daysAdd."D"));
//set back to UTC
$repeatShowStart->setTimezone($utc);
$repeatShowEnd->setTimezone($utc);
}
/* Here we are checking each repeating show by
* the show day.
@ -238,8 +250,12 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
$this->getElement('add_show_duration')->setErrors(array('Cannot schedule overlapping shows'));
break 1;
} else {
$repeatShowStart->setTimezone($localTimezone);
$repeatShowEnd->setTimezone($localTimezone);
$repeatShowStart->add(new DateInterval($interval));
$repeatShowEnd->add(new DateInterval($interval));
$repeatShowStart->setTimezone($utc);
$repeatShowEnd->setTimezone($utc);
}
}
}

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

@ -319,12 +319,12 @@ SQL;
if ($mins >59) {
$hour = intval($mins/60);
$hour = str_pad($hour, 2, "0", STR_PAD_LEFT);
$value = $mins%60;
$mins = $mins%60;
}
}
$hour = str_pad($hour, 2, "0", STR_PAD_LEFT);
$value = str_pad($value, 2, "0", STR_PAD_LEFT);
$length = $hour.":".$value.":00";
$mins = str_pad($mins, 2, "0", STR_PAD_LEFT);
$length = $hour.":".$mins.":00";
}
return $length;

View file

@ -287,7 +287,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_start}'
AND sched.starts < '{$p_end}')
OR (sched.ends > '{$p_start}'
AND sched.ends <= '{$p_end}')
OR (sched.starts <= '{$p_start}'
AND sched.ends >= '{$p_end}'))
)
SQL;
@ -307,7 +314,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_start}'
AND sched.starts < '{$p_end}')
OR (sched.ends > '{$p_start}'
AND sched.ends <= '{$p_end}')
OR (sched.starts <= '{$p_start}'
AND sched.ends >= '{$p_end}'))
)
LEFT JOIN cc_subjs AS sub ON (ws.creator_id = sub.id)
SQL;
@ -713,6 +727,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 +1142,6 @@ SQL;
}
} else {
if ($isAdminOrPM) {
Logging::info( $data );
Application_Model_Show::create($data);
}

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"] = empty($showContent) ? 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;
@ -459,7 +461,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

@ -661,6 +661,53 @@ SQL;
return $returnStr;
}
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
SELECT s.starts
FROM cc_schedule AS s
WHERE s.instance_id = :instance_id
AND s.playout_status >= 0
AND ((s.stream_id IS NOT NULL)
OR (s.file_id IS NOT NULL)) LIMIT 1
SQL;
# TODO : use prepareAndExecute properly
$res = Application_Common_Database::prepareAndExecute($sql,
array( ':instance_id' => $this->_instanceId ), 'all' );
# TODO : A bit retarded. fix this later
foreach ($res as $r) {
return false;
}
return true;
}
public function getShowListContent()
{
$con = Propel::getConnection();
@ -670,15 +717,15 @@ SELECT *
FROM (
(SELECT s.starts,
0::INTEGER as type ,
f.id AS item_id,
f.id AS item_id,
f.track_title,
f.album_title AS album,
f.genre AS genre,
f.length AS length,
f.artist_name AS creator,
f.file_exists AS EXISTS,
f.filepath AS filepath,
f.mime AS mime
f.album_title AS album,
f.genre AS genre,
f.length AS length,
f.artist_name AS creator,
f.file_exists AS EXISTS,
f.filepath AS filepath,
f.mime AS mime
FROM cc_schedule AS s
LEFT JOIN cc_files AS f ON f.id = s.file_id
WHERE s.instance_id = :instance_id1
@ -689,12 +736,12 @@ FROM (
1::INTEGER as type,
ws.id AS item_id,
(ws.name || ': ' || ws.url) AS title,
null AS album,
null AS genre,
ws.length AS length,
sub.login AS creator,
't'::boolean AS EXISTS,
ws.url AS filepath,
null AS album,
null AS genre,
ws.length AS length,
sub.login AS creator,
't'::boolean AS EXISTS,
ws.url AS filepath,
ws.mime as mime
FROM cc_schedule AS s
LEFT JOIN cc_webstream AS ws ON ws.id = s.stream_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">

View file

@ -91,9 +91,6 @@
<index name="cc_files_name_idx">
<index-column name="name"/>
</index>
<index name="cc_files_file_exists_idx">
<index-column name="file_exists"/>
</index>
</table>
<table name="cc_perms" phpName="CcPerms">
<column name="permid" phpName="Permid" type="INTEGER" primaryKey="true" required="true"/>
@ -206,7 +203,7 @@
<parameter name="foreign_table" value="cc_playlistcontents" />
<parameter name="expression" value="SUM(cliplength)" />
</behavior>
<foreign-key foreignTable="cc_subjs" name="cc_playlist_createdby_fkey">
<foreign-key foreignTable="cc_subjs" name="cc_playlist_createdby_fkey" onDelete="CASCADE">
<reference local="creator_id" foreign="id"/>
</foreign-key>
</table>
@ -332,6 +329,9 @@
<foreign-key foreignTable="cc_webstream" name="cc_show_stream_fkey" onDelete="CASCADE">
<reference local="stream_id" foreign="id"/>
</foreign-key>
<index name="cc_schedule_instance_id_idx">
<index-column name="instance_id"/>
</index>
</table>
<table name="cc_sess" phpName="CcSess">
<column name="sessid" phpName="Sessid" type="CHAR" size="32" primaryKey="true" required="true"/>

View file

@ -105,8 +105,6 @@ CREATE INDEX "cc_files_md5_idx" ON "cc_files" ("md5");
CREATE INDEX "cc_files_name_idx" ON "cc_files" ("name");
CREATE INDEX "cc_files_file_exists_idx" ON "cc_files" ("file_exists");
-----------------------------------------------------------------------------
-- cc_perms
-----------------------------------------------------------------------------
@ -429,6 +427,8 @@ COMMENT ON TABLE "cc_schedule" IS '';
SET search_path TO public;
CREATE INDEX "cc_schedule_instance_id_idx" ON "cc_schedule" ("instance_id");
-----------------------------------------------------------------------------
-- cc_sess
-----------------------------------------------------------------------------
@ -689,7 +689,7 @@ ALTER TABLE "cc_show_hosts" ADD CONSTRAINT "cc_perm_show_fkey" FOREIGN KEY ("sho
ALTER TABLE "cc_show_hosts" ADD CONSTRAINT "cc_perm_host_fkey" FOREIGN KEY ("subjs_id") REFERENCES "cc_subjs" ("id") ON DELETE CASCADE;
ALTER TABLE "cc_playlist" ADD CONSTRAINT "cc_playlist_createdby_fkey" FOREIGN KEY ("creator_id") REFERENCES "cc_subjs" ("id");
ALTER TABLE "cc_playlist" ADD CONSTRAINT "cc_playlist_createdby_fkey" FOREIGN KEY ("creator_id") REFERENCES "cc_subjs" ("id") ON DELETE CASCADE;
ALTER TABLE "cc_playlistcontents" ADD CONSTRAINT "cc_playlistcontents_file_id_fkey" FOREIGN KEY ("file_id") REFERENCES "cc_files" ("id") ON DELETE CASCADE;

View file

@ -104,7 +104,8 @@ select {
line-height:16px !important;
}
.airtime_auth_help_icon, .custom_auth_help_icon, .stream_username_help_icon, .playlist_type_help_icon {
.airtime_auth_help_icon, .custom_auth_help_icon, .stream_username_help_icon,
.playlist_type_help_icon, .master_username_help_icon {
cursor: help;
position: relative;
display:inline-block; zoom:1;

View file

@ -0,0 +1,5 @@
$(document).ready(function() {
$.ajaxSetup({
cache: false
});
});

View file

@ -333,6 +333,27 @@ $(document).ready(function() {
})
$(".stream_username_help_icon").qtip({
content: {
text: "If your Icecast server expects a username of 'source', this field can be left blank."
},
hide: {
delay: 500,
fixed: true
},
style: {
border: {
width: 0,
radius: 4
},
classes: "ui-tooltip-dark ui-tooltip-rounded"
},
position: {
my: "left bottom",
at: "right center"
},
})
$(".master_username_help_icon").qtip({
content: {
text: "If your live streaming client does not ask for a username, this field should be 'source'."
},

View file

@ -206,7 +206,6 @@ function viewDisplay( view ) {
}
function eventRender(event, element, view) {
getCurrentShow();
$(element).data("event", event);
@ -371,7 +370,9 @@ function checkSCUploadStatus(){
});
});
}
/** This function adds and removes the current
* show icon
*/
function getCurrentShow(){
var url = '/Schedule/get-current-show/format/json',
id,

View file

@ -283,7 +283,7 @@ var AIRTIME = (function(AIRTIME){
mod.fnRemove = function(aItems) {
mod.disableUI();
if (confirm("Delete selected item(s)?")) {
if (confirm("Remove selected scheduled item(s)?")) {
$.post( "/showbuilder/schedule-remove",
{"items": aItems, "format": "json"},
mod.fnItemCallback