diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 3348cbbe5..49f4ff723 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -96,6 +96,22 @@ class ScheduleController extends Zend_Controller_Action $this->view->preloadShowForm = true; } + $userInfo = Zend_Auth::getInstance()->getStorage()->read(); + $user = new Application_Model_User($userInfo->id); + if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { + $editable = true; + } else { + $editable = false; + } + + $calendar_interval = Application_Model_Preference::GetCalendarTimeInterval(); + if ($calendar_interval == "agendaDay") { + } else if ($calendar_interval == "agendaWeek") { + } else if ($calendar_interval == "month") { + } + list($start, $end) = Application_Model_Show::getStartEndCurrentMonthView(); + $events = &Application_Model_Show::getFullCalendarEvents($start, $end, $editable); + $this->view->headScript()->appendScript( "var calendarPref = {};\n". "calendarPref.weekStart = ".Application_Model_Preference::GetWeekStartDay().";\n". @@ -103,7 +119,8 @@ class ScheduleController extends Zend_Controller_Action "calendarPref.timezoneOffset = ".date("Z").";\n". "calendarPref.timeScale = '".Application_Model_Preference::GetCalendarTimeScale()."';\n". "calendarPref.timeInterval = ".Application_Model_Preference::GetCalendarTimeInterval().";\n". - "calendarPref.weekStartDay = ".Application_Model_Preference::GetWeekStartDay().";\n" + "calendarPref.weekStartDay = ".Application_Model_Preference::GetWeekStartDay().";\n". + "var calendarEvents = ".json_encode($events).";" ); } diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 6c0e5a0c8..7422cc1ae 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -2176,4 +2176,18 @@ SQL; } return $assocArray; } + + public static function getStartEndCurrentMonthView() { + $first_day_of_calendar_month_view = mktime(0, 0, 0, date("n"), 1); + $weekStart = Application_Model_Preference::GetWeekStartDay(); + while (date('w', $first_day_of_calendar_month_view) != $weekStart) { + $first_day_of_calendar_month_view -= 60*60*24; + } + $last_day_of_calendar_view = $first_day_of_calendar_month_view + 3600*24*41; + + $start = new DateTime("@".$first_day_of_calendar_month_view); + $end = new DateTime("@".$last_day_of_calendar_view); + + return array($start, $end); + } } diff --git a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js index 08dd31116..51cc4106a 100644 --- a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js +++ b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js @@ -326,19 +326,26 @@ function eventResize( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, vie }); } +var initialLoad = true; function getFullCalendarEvents(start, end, callback) { - var url, start_date, end_date; - - start_date = makeTimeStamp(start); - end_date = makeTimeStamp(end); - - url = baseUrl+'Schedule/event-feed'; - - var d = new Date(); - $.post(url, {format: "json", start: start_date, end: end_date, cachep: d.getTime()}, function(json){ - callback(json.events); - }); + if (initialLoad) { + initialLoad = false; + callback(calendarEvents); + } else { + var url, start_date, end_date; + + start_date = makeTimeStamp(start); + end_date = makeTimeStamp(end); + url = baseUrl+'Schedule/event-feed'; + + var d = new Date(); + $.post(url, {format: "json", start: start_date, end: end_date, cachep: d.getTime()}, function(json){ + callback(json.events); + }); + } + //TODO: Look at the type of calendar view...we may be returning too much information + } function checkSCUploadStatus(){