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");
|
||||
$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()
|
||||
|
|
|
@ -6,19 +6,38 @@ class Application_Model_Preference
|
|||
public static function SetValue($key, $value){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
//called from a daemon process
|
||||
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
|
||||
$sql = "SELECT COUNT(*) FROM cc_pref"
|
||||
." WHERE keystr = '$key'";
|
||||
$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"
|
||||
." SET subjid = $id, valstr = '$value'"
|
||||
." 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)"
|
||||
." VALUES ($id, '$key', '$value')";
|
||||
}
|
||||
|
|
|
@ -275,6 +275,14 @@ class Show {
|
|||
{
|
||||
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,
|
||||
color, background_color, cc_show_instances.id AS instance_id
|
||||
FROM cc_show_instances
|
||||
|
@ -283,7 +291,7 @@ class Show {
|
|||
//only want shows that are starting at the time or later.
|
||||
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)";
|
||||
}
|
||||
else {
|
||||
|
@ -525,13 +533,6 @@ class Show {
|
|||
public static function getFullCalendarEvents($start, $end, $editable=false)
|
||||
{
|
||||
$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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue