adding end date check in get shows just incase nobody checks calendar for a while.
preferences had to be updated because there will be no user id if the daemon process updates the date pouplated until pref.
This commit is contained in:
parent
2033b904c8
commit
7f775105e2
4 changed files with 37 additions and 14 deletions
|
@ -257,7 +257,10 @@ class ApiController extends Zend_Controller_Action
|
||||||
}
|
}
|
||||||
|
|
||||||
$today_timestamp = date("Y-m-d H:i:s");
|
$today_timestamp = date("Y-m-d H:i:s");
|
||||||
$this->view->shows = Show::getShows($today_timestamp, null, $excludeInstance=NULL, $onlyRecord=TRUE);
|
$now = new DateTime($today_timestamp);
|
||||||
|
$end_timestamp = $now->add(new DateInterval("PT2H"));
|
||||||
|
$end_timestamp = $end_timestamp->format("Y-m-d H:i:s");
|
||||||
|
$this->view->shows = Show::getShows($today_timestamp, $end_timestamp, $excludeInstance=NULL, $onlyRecord=TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function uploadRecordedAction()
|
public function uploadRecordedAction()
|
||||||
|
|
|
@ -165,7 +165,7 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm
|
||||||
|
|
||||||
$show_end->add(new DateInterval("PT$duration[0]H"));
|
$show_end->add(new DateInterval("PT$duration[0]H"));
|
||||||
$show_end->add(new DateInterval("PT$duration[1]M"));
|
$show_end->add(new DateInterval("PT$duration[1]M"));
|
||||||
$show_end->add(new DateInterval("PT1H"));//min time to wait until a rebroadcast
|
$show_end->add(new DateInterval("PT1H"));//min time to wait until a rebroadcast
|
||||||
|
|
||||||
$rebroad_start = $formData['add_show_start_date']."".$formData['add_show_rebroadcast_time_'.$i];
|
$rebroad_start = $formData['add_show_start_date']."".$formData['add_show_rebroadcast_time_'.$i];
|
||||||
$rebroad_start = new DateTime($rebroad_start);
|
$rebroad_start = new DateTime($rebroad_start);
|
||||||
|
|
|
@ -6,19 +6,38 @@ class Application_Model_Preference
|
||||||
public static function SetValue($key, $value){
|
public static function SetValue($key, $value){
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
$auth = Zend_Auth::getInstance();
|
//called from a daemon process
|
||||||
$id = $auth->getIdentity()->id;
|
if(!Zend_Auth::getInstance()->hasIdentity()) {
|
||||||
|
$id = NULL;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$auth = Zend_Auth::getInstance();
|
||||||
|
$id = $auth->getIdentity()->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$key = pg_escape_string($key);
|
||||||
|
$value = pg_escape_string($value);
|
||||||
|
|
||||||
//Check if key already exists
|
//Check if key already exists
|
||||||
$sql = "SELECT COUNT(*) FROM cc_pref"
|
$sql = "SELECT COUNT(*) FROM cc_pref"
|
||||||
." WHERE keystr = '$key'";
|
." WHERE keystr = '$key'";
|
||||||
$result = $CC_DBC->GetOne($sql);
|
$result = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
if ($result == 1){
|
if ($result == 1 && is_null($id)){
|
||||||
|
$sql = "UPDATE cc_pref"
|
||||||
|
." SET subjid = NULL, valstr = '$value'"
|
||||||
|
." WHERE keystr = '$key'";
|
||||||
|
}
|
||||||
|
else if ($result == 1 && !is_null($id)){
|
||||||
$sql = "UPDATE cc_pref"
|
$sql = "UPDATE cc_pref"
|
||||||
." SET subjid = $id, valstr = '$value'"
|
." SET subjid = $id, valstr = '$value'"
|
||||||
." WHERE keystr = '$key'";
|
." WHERE keystr = '$key'";
|
||||||
} else {
|
}
|
||||||
|
else if(is_null($id)) {
|
||||||
|
$sql = "INSERT INTO cc_pref (keystr, valstr)"
|
||||||
|
." VALUES ('$key', '$value')";
|
||||||
|
}
|
||||||
|
else {
|
||||||
$sql = "INSERT INTO cc_pref (subjid, keystr, valstr)"
|
$sql = "INSERT INTO cc_pref (subjid, keystr, valstr)"
|
||||||
." VALUES ($id, '$key', '$value')";
|
." VALUES ($id, '$key', '$value')";
|
||||||
}
|
}
|
||||||
|
|
|
@ -275,6 +275,14 @@ class Show {
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
|
$showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
|
||||||
|
|
||||||
|
//if application is requesting shows past our previous populated until date, generate shows up until this point.
|
||||||
|
if ($showsPopUntil == "" || strtotime($showsPopUntil) < strtotime($end_timestamp)) {
|
||||||
|
Show::populateAllShowsInRange($showsPopUntil, $end_timestamp);
|
||||||
|
Application_Model_Preference::SetShowsPopulatedUntil($end_timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT starts, ends, record, rebroadcast, soundcloud_id, instance_id, show_id, name, description,
|
$sql = "SELECT starts, ends, record, rebroadcast, soundcloud_id, instance_id, show_id, name, description,
|
||||||
color, background_color, cc_show_instances.id AS instance_id
|
color, background_color, cc_show_instances.id AS instance_id
|
||||||
FROM cc_show_instances
|
FROM cc_show_instances
|
||||||
|
@ -283,7 +291,7 @@ class Show {
|
||||||
//only want shows that are starting at the time or later.
|
//only want shows that are starting at the time or later.
|
||||||
if ($onlyRecord) {
|
if ($onlyRecord) {
|
||||||
|
|
||||||
$sql = $sql." WHERE (starts >= '{$start_timestamp}' AND starts < timestamp '{$start_timestamp}' + interval '2 hours')";
|
$sql = $sql." WHERE (starts >= '{$start_timestamp}' AND starts < timestamp '{$end_timestamp}')";
|
||||||
$sql = $sql." AND (record = 1)";
|
$sql = $sql." AND (record = 1)";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -525,13 +533,6 @@ class Show {
|
||||||
public static function getFullCalendarEvents($start, $end, $editable=false)
|
public static function getFullCalendarEvents($start, $end, $editable=false)
|
||||||
{
|
{
|
||||||
$events = array();
|
$events = array();
|
||||||
$showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
|
|
||||||
|
|
||||||
//if fullcalendar is requesting shows past our previous populated until date, generate shows up until this point.
|
|
||||||
if ($showsPopUntil == "" || strtotime($showsPopUntil) < strtotime($end)) {
|
|
||||||
Show::populateAllShowsInRange($showsPopUntil, $end);
|
|
||||||
Application_Model_Preference::SetShowsPopulatedUntil($end);
|
|
||||||
}
|
|
||||||
|
|
||||||
$shows = Show::getShows($start, $end);
|
$shows = Show::getShows($start, $end);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue