Merge branch '2.1.x' into devel

This commit is contained in:
denise 2012-06-11 15:10:33 -04:00
commit d498c51814
14 changed files with 118 additions and 55 deletions

View file

@ -53,7 +53,7 @@ class DashboardController extends Zend_Controller_Action
$show_id = isset($show[0]['id'])?$show[0]['id']:0; $show_id = isset($show[0]['id'])?$show[0]['id']:0;
$source_connected = Application_Model_Preference::GetSourceStatus($sourcename); $source_connected = Application_Model_Preference::GetSourceStatus($sourcename);
if($user->canSchedule($show_id) && ($source_connected || $sourcename == 'scheduled_play')){ if($user->canSchedule($show_id) && ($source_connected || $sourcename == 'scheduled_play' || $current_status == "on")){
$change_status_to = "on"; $change_status_to = "on";

View file

@ -12,7 +12,7 @@ class Application_Model_Schedule {
global $CC_CONFIG; global $CC_CONFIG;
$con = Propel::getConnection(); $con = Propel::getConnection();
$sql = "SELECT COUNT(*) FROM ".$CC_CONFIG["scheduleTable"] $sql = "SELECT COUNT(*) FROM ".$CC_CONFIG["scheduleTable"]
." WHERE file_id = {$p_fileId} AND starts > NOW()"; ." WHERE file_id = {$p_fileId} AND ends > NOW() AT TIME ZONE 'UTC'";
$count = $con->query($sql)->fetchColumn(0); $count = $con->query($sql)->fetchColumn(0);
if (is_numeric($count) && ($count != '0')) { if (is_numeric($count) && ($count != '0')) {
return TRUE; return TRUE;

View file

@ -1061,7 +1061,7 @@ class Application_Model_Show {
//check if we are adding or updating a show, and if updating //check if we are adding or updating a show, and if updating
//erase all the show's future show_rebroadcast information first. //erase all the show's future show_rebroadcast information first.
if (($data['add_show_id'] != -1) && $data['add_show_rebroadcast']){ if (($data['add_show_id'] != -1) && isset($data['add_show_rebroadcast']) && $data['add_show_rebroadcast']){
CcShowRebroadcastQuery::create() CcShowRebroadcastQuery::create()
->filterByDbShowId($data['add_show_id']) ->filterByDbShowId($data['add_show_id'])
->delete(); ->delete();
@ -1309,8 +1309,9 @@ class Application_Model_Show {
$ccShowInstance = $show->getInstanceOnDate($utcStartDateTime); $ccShowInstance = $show->getInstanceOnDate($utcStartDateTime);
if ($ccShowInstance->getDbModifiedInstance()){ if ($ccShowInstance->getDbModifiedInstance()){
//show instance on this date has been deleted. //show instance on this date has been deleted.
continue; $utcStartDateTime = self::advanceRepeatingDate($p_interval, $start, $timezone);
continue;
} }
$newInstance = false; $newInstance = false;
@ -1342,44 +1343,48 @@ class Application_Model_Show {
$showInstance->deleteRebroadcasts(); $showInstance->deleteRebroadcasts();
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone); self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
$utcStartDateTime = self::advanceRepeatingDate($p_interval, $start, $timezone);
if ($p_interval == 'P1M'){
/* When adding months, there is a problem if we are on January 31st and add one month with PHP.
* What ends up happening is that since February 31st doesn't exist, the date returned is
* March 3rd. For now let's ignore the day and assume we are always working with the
* first of each month, and use PHP to add 1 month to this (this will take care of rolling
* over the years 2011->2012, etc.). Then let's append the actual day, and use the php
* checkdate() function, to see if it is valid. If not, then we'll just skip this month. */
$startDt = new DateTime($start, new DateTimeZone($timezone));
/* pass in only the year and month (not the day) */
$dt = new DateTime($startDt->format("Y-m"), new DateTimeZone($timezone));
/* Keep adding 1 month, until we find the next month that contains the day
* we are looking for (31st day for example) */
do {
$dt->add(new DateInterval($p_interval));
} while(!checkdate($dt->format("m"), $startDt->format("d"), $dt->format("Y")));
$dt->setDate($dt->format("Y"), $dt->format("m"), $startDt->format("d"));
$start = $dt->format("Y-m-d H:i:s");
$dt->setTimezone(new DateTimeZone('UTC'));
$utcStartDateTime = $dt;
} else {
$dt = new DateTime($start, new DateTimeZone($timezone));
$dt->add(new DateInterval($p_interval));
$start = $dt->format("Y-m-d H:i:s");
$dt->setTimezone(new DateTimeZone('UTC'));
$utcStartDateTime = $dt;
}
} }
Application_Model_Show::setNextPop($start, $show_id, $day); Application_Model_Show::setNextPop($start, $show_id, $day);
} }
private static function advanceRepeatingDate($p_interval, $start, $timezone){
if ($p_interval == 'P1M'){
/* When adding months, there is a problem if we are on January 31st and add one month with PHP.
* What ends up happening is that since February 31st doesn't exist, the date returned is
* March 3rd. For now let's ignore the day and assume we are always working with the
* first of each month, and use PHP to add 1 month to this (this will take care of rolling
* over the years 2011->2012, etc.). Then let's append the actual day, and use the php
* checkdate() function, to see if it is valid. If not, then we'll just skip this month. */
/* pass in only the year and month (not the day) */
$dt = new DateTime($startDt->format("Y-m"), new DateTimeZone($timezone));
$dt = new DateTime($startDt->format("Y-m"), new DateTimeZone($timezone));
/* Keep adding 1 month, until we find the next month that contains the day
* we are looking for (31st day for example) */
do {
$dt->add(new DateInterval($p_interval));
} while(!checkdate($dt->format("m"), $startDt->format("d"), $dt->format("Y")));
$dt->setDate($dt->format("Y"), $dt->format("m"), $startDt->format("d"));
$start = $dt->format("Y-m-d H:i:s");
$dt->setTimezone(new DateTimeZone('UTC'));
$utcStartDateTime = $dt;
} else {
$dt = new DateTime($start, new DateTimeZone($timezone));
$dt->add(new DateInterval($p_interval));
$start = $dt->format("Y-m-d H:i:s");
$dt->setTimezone(new DateTimeZone('UTC'));
$utcStartDateTime = $dt;
}
return $utcStartDateTime;
}
/* /*
* @param $p_start * @param $p_start
@ -1477,7 +1482,6 @@ class Application_Model_Show {
//UTC DateTime object //UTC DateTime object
$showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil(); $showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
//if application is requesting shows past our previous populated until date, generate shows up until this point. //if application is requesting shows past our previous populated until date, generate shows up until this point.
if (is_null($showsPopUntil) || $showsPopUntil->getTimestamp() < $end_timestamp->getTimestamp()) { if (is_null($showsPopUntil) || $showsPopUntil->getTimestamp() < $end_timestamp->getTimestamp()) {
Application_Model_Show::populateAllShowsInRange($showsPopUntil, $end_timestamp); Application_Model_Show::populateAllShowsInRange($showsPopUntil, $end_timestamp);
@ -1492,7 +1496,6 @@ class Application_Model_Show {
LEFT JOIN cc_show_instances AS si2 ON si1.instance_id = si2.id LEFT JOIN cc_show_instances AS si2 ON si1.instance_id = si2.id
LEFT JOIN cc_show AS show ON show.id = si1.show_id LEFT JOIN cc_show AS show ON show.id = si1.show_id
WHERE si1.modified_instance = FALSE"; WHERE si1.modified_instance = FALSE";
//only want shows that are starting at the time or later. //only want shows that are starting at the time or later.
$start_string = $start_timestamp->format("Y-m-d H:i:s"); $start_string = $start_timestamp->format("Y-m-d H:i:s");
$end_string = $end_timestamp->format("Y-m-d H:i:s"); $end_string = $end_timestamp->format("Y-m-d H:i:s");
@ -1563,7 +1566,6 @@ class Application_Model_Show {
//Logging::log($sql); //Logging::log($sql);
$res = $con->query($sql)->fetchAll(); $res = $con->query($sql)->fetchAll();
foreach ($res as $row) { foreach ($res as $row) {
Application_Model_Show::populateShow($row, $p_endTimestamp); Application_Model_Show::populateShow($row, $p_endTimestamp);
} }
@ -1584,7 +1586,7 @@ class Application_Model_Show {
$days = $interval->format('%a'); $days = $interval->format('%a');
$shows = Application_Model_Show::getShows($p_start, $p_end); $shows = Application_Model_Show::getShows($p_start, $p_end);
$nowEpoch = time(); $nowEpoch = time();
foreach ($shows as $show) { foreach ($shows as $show) {
$options = array(); $options = array();

View file

@ -160,8 +160,12 @@ class CcShowInstances extends BaseCcShowInstances {
* @param PropelPDO $con A connection object * @param PropelPDO $con A connection object
*/ */
public function updateDbTimeFilled(PropelPDO $con) public function updateDbTimeFilled(PropelPDO $con)
{ {
$this->setDbTimeFilled($this->computeDbTimeFilled($con)); $timefilled = $this->computeDbTimeFilled($con);
if($timefilled == null){
$timefilled = "00:00:00";
}
$this->setDbTimeFilled($timefilled);
$this->save($con); $this->save($con);
} }

View file

@ -21,6 +21,7 @@
<div id="custom_auth_div"> <div id="custom_auth_div">
<dt id="custom_username-label" class="block-display"> <dt id="custom_username-label" class="block-display">
<label class="optional" for="custom_username"><?php echo $this->element->getElement('custom_username')->getLabel() ?> : <label class="optional" for="custom_username"><?php echo $this->element->getElement('custom_username')->getLabel() ?> :
<span class='stream_username_help_icon'></span>
</label> </label>
</dt> </dt>
<dd id="custom_username-element" class="block-display"> <dd id="custom_username-element" class="block-display">

View file

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

View file

@ -68,7 +68,9 @@
</legend> </legend>
<dl class="zend_form"> <dl class="zend_form">
<dt id="outputUser-label"> <dt id="outputUser-label">
<label for="outputUser"><?php echo $this->element->getElement('user')->getLabel()?> :</label> <label for="outputUser"><?php echo $this->element->getElement('user')->getLabel()?> :
<span class='stream_username_help_icon'></span>
</label>
</dt> </dt>
<dd id="outputUser-element"> <dd id="outputUser-element">
<?php echo $this->element->getElement('user')?> <?php echo $this->element->getElement('user')?>

View file

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

View file

@ -304,4 +304,25 @@ $(document).ready(function() {
at: "right center" at: "right center"
}, },
}) })
$(".stream_username_help_icon").qtip({
content: {
text: "If your live streaming client does not ask for a username, this field should be 'source'."
},
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"
},
})
}); });

View file

@ -220,6 +220,26 @@ function setAddShowEvents() {
at: "right center" at: "right center"
} }
}); });
form.find(".stream_username_help_icon").qtip({
content: {
text: "If your live streaming client does not ask for a username, this field should be 'source'."
},
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"
}
});
function endDateVisibility(){ function endDateVisibility(){
if(form.find("#add_show_no_end").is(':checked')){ if(form.find("#add_show_no_end").is(':checked')){

View file

@ -91,16 +91,15 @@ denise@denise-DX4860:~/airtime/airtime_mvc/public/js/fullcalendar$ diff -u fullc
clearEvents(); clearEvents();
} }
- updateCells(firstTime); - updateCells(firstTime);
+ getOffset(); + getOffset(firstTime);
} }
- -
- -
+ function getOffset() { + function getOffset(firstTime) {
+ var timezoneOffset; + var timezoneOffset;
+ $.ajax({ url: "/Api/calendar-init/format/json", dataType:"json", success:function(data) { + $.ajax({ url: "/Api/calendar-init/format/json", dataType:"json", success:function(data) {
+ timezoneOffset = data.calendarInit.timezoneOffset*1000; + timezoneOffset = data.calendarInit.timezoneOffset*1000;
+ var firstTime = !body;
+ updateCells(firstTime, timezoneOffset); + updateCells(firstTime, timezoneOffset);
+ }, error:function(jqXHR, textStatus, errorThrown){}}); + }, error:function(jqXHR, textStatus, errorThrown){}});
+ } + }

View file

@ -2187,14 +2187,13 @@ function BasicView(element, calendar, viewName) {
}else{ }else{
clearEvents(); clearEvents();
} }
getOffset(); getOffset(firstTime);
} }
function getOffset() { function getOffset(firstTime) {
var timezoneOffset; var timezoneOffset;
$.ajax({ url: "/Api/calendar-init/format/json", dataType:"json", success:function(data) { $.ajax({ url: "/Api/calendar-init/format/json", dataType:"json", success:function(data) {
timezoneOffset = data.calendarInit.timezoneOffset*1000; timezoneOffset = data.calendarInit.timezoneOffset*1000;
var firstTime = !body;
updateCells(firstTime, timezoneOffset); updateCells(firstTime, timezoneOffset);
}, error:function(jqXHR, textStatus, errorThrown){}}); }, error:function(jqXHR, textStatus, errorThrown){}});
} }

View file

@ -35,7 +35,7 @@ class MediaMonitorCommon:
# if file doesn't have any extension, info[-2] throws exception # if file doesn't have any extension, info[-2] throws exception
# Hence, checking length of info before we do anything # Hence, checking length of info before we do anything
if(len(info) >= 2): if(len(info) >= 2):
if(info[-2] in self.supported_file_formats): if(info[-2].lower() in self.supported_file_formats):
return True return True
else: else:
return False return False
@ -45,7 +45,7 @@ class MediaMonitorCommon:
def is_audio_file(self, filename): def is_audio_file(self, filename):
info = filename.split(".") info = filename.split(".")
if(info[-1] in self.supported_file_formats): if(info[-1].lower() in self.supported_file_formats):
return True return True
else: else:
return False return False

View file

@ -42,6 +42,8 @@ class PypoFetch(Thread):
self.fetch_queue = pypoFetch_q self.fetch_queue = pypoFetch_q
self.push_queue = pypoPush_q self.push_queue = pypoPush_q
self.media_prepare_queue = media_q self.media_prepare_queue = media_q
self.last_update_schedule_timestamp = time.time()
self.listener_timeout = 3600
self.telnet_lock = telnet_lock self.telnet_lock = telnet_lock
@ -78,6 +80,7 @@ class PypoFetch(Thread):
self.logger.info("Handling command: " + command) self.logger.info("Handling command: " + command)
if command == 'update_schedule': if command == 'update_schedule':
self.last_update_schedule_timestamp = time.time()
self.schedule_data = m['schedule'] self.schedule_data = m['schedule']
self.process_schedule(self.schedule_data) self.process_schedule(self.schedule_data)
elif command == 'update_stream_setting': elif command == 'update_stream_setting':
@ -98,6 +101,15 @@ class PypoFetch(Thread):
elif command == 'disconnect_source': elif command == 'disconnect_source':
self.logger.info("disconnect_on_source show command received...") self.logger.info("disconnect_on_source show command received...")
self.disconnect_source(self.logger, self.telnet_lock, m['sourcename']) self.disconnect_source(self.logger, self.telnet_lock, m['sourcename'])
# update timeout value
if command == 'update_schedule':
self.listener_timeout = 3600
else:
self.listener_timeout = self.last_update_schedule_timestamp - time.time() + 3600
if self.listener_timeout < 0:
self.listener_timeout = 0
self.logger.info("New timeout: %s" % self.listener_timeout)
except Exception, e: except Exception, e:
import traceback import traceback
top = traceback.format_exc() top = traceback.format_exc()
@ -476,7 +488,9 @@ class PypoFetch(Thread):
Currently we are checking every 3600 seconds (1 hour) Currently we are checking every 3600 seconds (1 hour)
""" """
message = self.fetch_queue.get(block=True, timeout=3600)
message = self.fetch_queue.get(block=True, timeout=self.listener_timeout)
self.handle_message(message) self.handle_message(message)
except Exception, e: except Exception, e:
import traceback import traceback