Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
cd1e55bffc
|
@ -96,7 +96,7 @@ $pages = array(
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'label' => 'User Manual',
|
'label' => 'User Manual',
|
||||||
'uri' => "http://en.flossmanuals.net/airtime/",
|
'uri' => "http://manuals.sourcefabric.org/",
|
||||||
'target' => "_blank"
|
'target' => "_blank"
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -172,6 +172,21 @@ class ApiController extends Zend_Controller_Action
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the currently playing show as well as upcoming shows.
|
||||||
|
* Number of shows returned and the time interval in which to
|
||||||
|
* get the next shows can be configured as post parameters.
|
||||||
|
*
|
||||||
|
* TODO: in the future, make interval length a parameter instead of hardcode to 48
|
||||||
|
*
|
||||||
|
* Possible parameters:
|
||||||
|
* type - Can have values of "endofday" or "interval". If set to "endofday",
|
||||||
|
* the function will retrieve shows from now to end of day.
|
||||||
|
* If set to "interval", shows in the next 48 hours will be retrived.
|
||||||
|
* Default is "interval".
|
||||||
|
* limit - How many shows to retrieve
|
||||||
|
* Default is "5".
|
||||||
|
*/
|
||||||
public function liveInfoAction()
|
public function liveInfoAction()
|
||||||
{
|
{
|
||||||
if (Application_Model_Preference::GetAllow3rdPartyApi()){
|
if (Application_Model_Preference::GetAllow3rdPartyApi()){
|
||||||
|
@ -181,11 +196,24 @@ class ApiController extends Zend_Controller_Action
|
||||||
|
|
||||||
$date = new Application_Model_DateHelper;
|
$date = new Application_Model_DateHelper;
|
||||||
$utcTimeNow = $date->getUtcTimestamp();
|
$utcTimeNow = $date->getUtcTimestamp();
|
||||||
|
$utcTimeEnd = ""; // if empty, GetNextShows will use interval instead of end of day
|
||||||
|
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$type = $request->getParam('type');
|
||||||
|
if($type == "endofday") {
|
||||||
|
// make GetNextShows use end of day
|
||||||
|
$utcTimeEnd = Application_Model_DateHelper::GetDayEndTimestampInUtc();
|
||||||
|
}
|
||||||
|
|
||||||
|
$limit = $request->getParam('limit');
|
||||||
|
if($limit == "") {
|
||||||
|
$limit = "5";
|
||||||
|
}
|
||||||
|
|
||||||
$result = array("env"=>APPLICATION_ENV,
|
$result = array("env"=>APPLICATION_ENV,
|
||||||
"schedulerTime"=>gmdate("Y-m-d H:i:s"),
|
"schedulerTime"=>gmdate("Y-m-d H:i:s"),
|
||||||
"currentShow"=>Application_Model_Show::GetCurrentShow($utcTimeNow),
|
"currentShow"=>Application_Model_Show::GetCurrentShow($utcTimeNow),
|
||||||
"nextShow"=>Application_Model_Show::GetNextShows($utcTimeNow, 5),
|
"nextShow"=>Application_Model_Show::GetNextShows($utcTimeNow, $limit, $utcTimeEnd),
|
||||||
"timezone"=> date("T"),
|
"timezone"=> date("T"),
|
||||||
"timezoneOffset"=> date("Z"));
|
"timezoneOffset"=> date("Z"));
|
||||||
|
|
||||||
|
@ -219,7 +247,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
$result = array();
|
$result = array();
|
||||||
for ($i=0; $i<7; $i++){
|
for ($i=0; $i<7; $i++){
|
||||||
$utcDayEnd = Application_Model_DateHelper::GetDayEndTimestamp($utcDayStart);
|
$utcDayEnd = Application_Model_DateHelper::GetDayEndTimestamp($utcDayStart);
|
||||||
$shows = Application_Model_Show::GetNextShows($utcDayStart, 0, $utcDayEnd);
|
$shows = Application_Model_Show::GetNextShows($utcDayStart, "0", $utcDayEnd);
|
||||||
$utcDayStart = $utcDayEnd;
|
$utcDayStart = $utcDayEnd;
|
||||||
|
|
||||||
Application_Model_Show::ConvertToLocalTimeZone($shows, array("starts", "ends", "start_timestamp", "end_timestamp"));
|
Application_Model_Show::ConvertToLocalTimeZone($shows, array("starts", "ends", "start_timestamp", "end_timestamp"));
|
||||||
|
|
|
@ -508,13 +508,16 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$formWhen->getElement('add_show_start_date')->setOptions(array('disabled' => true));
|
$formWhen->getElement('add_show_start_date')->setOptions(array('disabled' => true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//need to get the days of the week in the php timezone (for the front end).
|
||||||
$days = array();
|
$days = array();
|
||||||
$showDays = CcShowDaysQuery::create()->filterByDbShowId($showInstance->getShowId())->find();
|
$showDays = CcShowDaysQuery::create()->filterByDbShowId($showInstance->getShowId())->find();
|
||||||
foreach($showDays as $showDay){
|
foreach($showDays as $showDay){
|
||||||
array_push($days, $showDay->getDbDay());
|
$showStartDay = new DateTime($showDay->getDbFirstShow(), new DateTimeZone($showDay->getDbTimezone()));
|
||||||
|
$showStartDay->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||||
|
array_push($days, $showStartDay->format('w'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$displayedEndDate = new DateTime($show->getRepeatingEndDate(), new DateTimeZone("UTC"));
|
$displayedEndDate = new DateTime($show->getRepeatingEndDate(), new DateTimeZone($showDays[0]->getDbTimezone()));
|
||||||
$displayedEndDate->sub(new DateInterval("P1D"));//end dates are stored non-inclusively.
|
$displayedEndDate->sub(new DateInterval("P1D"));//end dates are stored non-inclusively.
|
||||||
$displayedEndDate->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
$displayedEndDate->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
require_once 'customvalidators/ConditionalNotEmpty.php';
|
require_once 'customvalidators/ConditionalNotEmpty.php';
|
||||||
|
require_once 'customvalidators/PasswordNotEmpty.php';
|
||||||
|
|
||||||
class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm
|
class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm
|
||||||
{
|
{
|
||||||
|
@ -76,7 +77,7 @@ class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm
|
||||||
// which is something we don't want
|
// which is something we don't want
|
||||||
'allowEmpty' => false,
|
'allowEmpty' => false,
|
||||||
'validators' => array(
|
'validators' => array(
|
||||||
new ConditionalNotEmpty(array('UploadToSoundcloudOption'=>'1'))
|
new PasswordNotEmpty(array('UploadToSoundcloudOption'=>'1'))
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class PasswordNotEmpty extends ConditionalNotEmpty {
|
||||||
|
public function isValid($value, $context = null)
|
||||||
|
{
|
||||||
|
$result = parent::isValid($value, $context);
|
||||||
|
if (!$result) {
|
||||||
|
// allow empty if username/email was set before and didn't change
|
||||||
|
$storedUser = Application_Model_Preference::GetSoundCloudUser();
|
||||||
|
if ($storedUser != '' && $storedUser == $context['SoundCloudUser']) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -84,7 +84,7 @@ class Application_Model_DateHelper
|
||||||
|
|
||||||
public static function GetDayEndTimestampInUtc($time = "") {
|
public static function GetDayEndTimestampInUtc($time = "") {
|
||||||
$dayEndTimestamp = Application_Model_DateHelper::GetDayEndTimestamp($time);
|
$dayEndTimestamp = Application_Model_DateHelper::GetDayEndTimestamp($time);
|
||||||
return Application_Model_DateHelper::ConvertToUtcDateTime($dayEndTimestamp);
|
return Application_Model_DateHelper::ConvertToUtcDateTimeString($dayEndTimestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -187,14 +187,16 @@ class Application_Model_Show {
|
||||||
$uncheckedDaysImploded = implode(",", $p_uncheckedDays);
|
$uncheckedDaysImploded = implode(",", $p_uncheckedDays);
|
||||||
$showId = $this->getId();
|
$showId = $this->getId();
|
||||||
|
|
||||||
$date = new Application_Model_DateHelper;
|
$timestamp = gmdate("Y-m-d H:i:s");
|
||||||
$timestamp = $date->getTimestamp();
|
|
||||||
|
|
||||||
$sql = "DELETE FROM cc_show_instances"
|
$sql = "DELETE FROM cc_show_instances"
|
||||||
." WHERE EXTRACT(DOW FROM starts) IN ($uncheckedDaysImploded)"
|
." WHERE EXTRACT(DOW FROM starts) IN ($uncheckedDaysImploded)"
|
||||||
." AND starts > TIMESTAMP '$timestamp'"
|
." AND starts > TIMESTAMP '$timestamp'"
|
||||||
." AND show_id = $showId";
|
." AND show_id = $showId";
|
||||||
|
|
||||||
|
Logging::log("sql for removing unchecked days");
|
||||||
|
Logging::log($sql);
|
||||||
|
|
||||||
$CC_DBC->query($sql);
|
$CC_DBC->query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -856,7 +858,8 @@ class Application_Model_Show {
|
||||||
//What we are doing here is checking if the show repeats or if
|
//What we are doing here is checking if the show repeats or if
|
||||||
//any repeating days have been checked. If not, then by default
|
//any repeating days have been checked. If not, then by default
|
||||||
//the "selected" DOW is the initial day.
|
//the "selected" DOW is the initial day.
|
||||||
$startDow = gmdate("w", $utcStartDateTime->getTimestamp());
|
//DOW in local time.
|
||||||
|
$startDow = date("w", $startDateTime->getTimestamp());
|
||||||
if (!$data['add_show_repeats']) {
|
if (!$data['add_show_repeats']) {
|
||||||
$data['add_show_day_check'] = array($startDow);
|
$data['add_show_day_check'] = array($startDow);
|
||||||
} else if ($data['add_show_repeats'] && $data['add_show_day_check'] == "") {
|
} else if ($data['add_show_repeats'] && $data['add_show_day_check'] == "") {
|
||||||
|
@ -907,7 +910,10 @@ class Application_Model_Show {
|
||||||
$showDay->setDbRecord($isRecorded);
|
$showDay->setDbRecord($isRecorded);
|
||||||
$showDay->save();
|
$showDay->save();
|
||||||
} else {
|
} else {
|
||||||
|
Logging::log("startDow is: {$startDow}");
|
||||||
foreach ($data['add_show_day_check'] as $day) {
|
foreach ($data['add_show_day_check'] as $day) {
|
||||||
|
Logging::log("day is: {$day}");
|
||||||
|
|
||||||
$daysAdd=0;
|
$daysAdd=0;
|
||||||
$startDateTimeClone = clone $startDateTime;
|
$startDateTimeClone = clone $startDateTime;
|
||||||
if ($startDow !== $day){
|
if ($startDow !== $day){
|
||||||
|
@ -916,7 +922,10 @@ class Application_Model_Show {
|
||||||
else
|
else
|
||||||
$daysAdd = $day - $startDow;
|
$daysAdd = $day - $startDow;
|
||||||
|
|
||||||
|
Logging::log("days to add: {$daysAdd}");
|
||||||
|
|
||||||
$startDateTimeClone->add(new DateInterval("P".$daysAdd."D"));
|
$startDateTimeClone->add(new DateInterval("P".$daysAdd."D"));
|
||||||
|
Logging::log("start date: {$startDateTimeClone->format("Y-m-d")}");
|
||||||
}
|
}
|
||||||
if (is_null($endDate) || $startDateTimeClone->getTimestamp() <= $endDateTime->getTimestamp()) {
|
if (is_null($endDate) || $startDateTimeClone->getTimestamp() <= $endDateTime->getTimestamp()) {
|
||||||
$showDay = new CcShowDays();
|
$showDay = new CcShowDays();
|
||||||
|
@ -1556,7 +1565,7 @@ class Application_Model_Show {
|
||||||
* @param String $timeEnd - interval end time (in UTC)
|
* @param String $timeEnd - interval end time (in UTC)
|
||||||
* @return array - the next $limit number of shows within the time interval
|
* @return array - the next $limit number of shows within the time interval
|
||||||
*/
|
*/
|
||||||
public static function GetNextShows($timeStart, $limit = 0, $timeEnd = "")
|
public static function GetNextShows($timeStart, $limit = "0", $timeEnd = "")
|
||||||
{
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
|
@ -1577,7 +1586,7 @@ class Application_Model_Show {
|
||||||
." ORDER BY si.starts";
|
." ORDER BY si.starts";
|
||||||
|
|
||||||
// defaults to retrieve all shows within the interval if $limit not set
|
// defaults to retrieve all shows within the interval if $limit not set
|
||||||
if($limit != 0) {
|
if($limit != "0") {
|
||||||
$sql = $sql . " LIMIT $limit";
|
$sql = $sql . " LIMIT $limit";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ function getContent() {
|
||||||
var msg = "";
|
var msg = "";
|
||||||
if(isUpToDate()) {
|
if(isUpToDate()) {
|
||||||
msg = "You are running the latest version";
|
msg = "You are running the latest version";
|
||||||
} else if(diff == 1) {
|
} else if(diff <= 1) { // new version is possible when major diff = 0
|
||||||
msg = "New version available: " + link;
|
msg = "New version available: " + link;
|
||||||
} else if(diff == 2) {
|
} else if(diff == 2) {
|
||||||
msg = "This version will soon be obsolete.<br/>Please upgrade to " + link;
|
msg = "This version will soon be obsolete.<br/>Please upgrade to " + link;
|
||||||
|
|
|
@ -52,9 +52,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function getServerData(){
|
function getServerData(){
|
||||||
$.ajax({ url: options.sourceDomain + "api/live-info/", dataType:"jsonp", success:function(data){
|
$.ajax({url: options.sourceDomain + "api/live-info/",
|
||||||
|
data: {type:"endofday",limit:"5"},
|
||||||
|
dataType: "jsonp",
|
||||||
|
success:function(data) {
|
||||||
processData(data);
|
processData(data);
|
||||||
}, error:airtimeScheduleJsonpError});
|
},
|
||||||
|
error: airtimeScheduleJsonpError});
|
||||||
setTimeout(getServerData, options.updatePeriod*1000);
|
setTimeout(getServerData, options.updatePeriod*1000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -130,9 +134,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function getServerData(){
|
function getServerData(){
|
||||||
$.ajax({ url: options.sourceDomain + "api/live-info/", dataType:"jsonp", success:function(data){
|
$.ajax({url: options.sourceDomain + "api/live-info/",
|
||||||
|
data: {type:"interval",limit:"5"},
|
||||||
|
dataType: "jsonp",
|
||||||
|
success: function(data) {
|
||||||
processData(data);
|
processData(data);
|
||||||
}, error:airtimeScheduleJsonpError});
|
},
|
||||||
|
error: airtimeScheduleJsonpError});
|
||||||
setTimeout(getServerData, options.updatePeriod*1000);
|
setTimeout(getServerData, options.updatePeriod*1000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue