Merge branch '2.5.x' into 2.5.x-saas

Conflicts:
	airtime_mvc/application/forms/AddShowWhen.php
	airtime_mvc/application/forms/LiveStreamingPreferences.php
	airtime_mvc/application/models/Schedule.php
	airtime_mvc/application/views/scripts/form/preferences.phtml
	airtime_mvc/application/views/scripts/form/preferences_livestream.phtml
	airtime_mvc/application/views/scripts/form/support-setting.phtml
	airtime_mvc/application/views/scripts/schedule/add-show-form.phtml
This commit is contained in:
Naomi Aro 2013-12-17 17:20:38 -05:00
commit 49474ab5c4
214 changed files with 57623 additions and 61229 deletions

View file

@ -68,30 +68,6 @@ class ApiController extends Zend_Controller_Action
"version" => Application_Model_Preference::GetAirtimeVersion()));
}
/**
* Sets up and send init values used in the Calendar.
* This is only being used by schedule.js at the moment.
*/
public function calendarInitAction()
{
if (is_null(Zend_Auth::getInstance()->getStorage()->read())) {
header('HTTP/1.0 401 Unauthorized');
print _('You are not allowed to access this resource.');
return;
}
$this->view->calendarInit = array(
"timestamp" => time(),
"timezoneOffset" => date("Z"),
"timeScale" => Application_Model_Preference::GetCalendarTimeScale(),
"timeInterval" => Application_Model_Preference::GetCalendarTimeInterval(),
"weekStartDay" => Application_Model_Preference::GetWeekStartDay()
);
$this->_helper->json->sendJson(array());
}
/**
* Allows remote client to download requested media file.
*
@ -209,6 +185,7 @@ class ApiController extends Zend_Controller_Action
}
}
//Used by the SaaS monitoring
public function onAirLightAction()
{
$this->view->layout()->disableLayout();
@ -267,9 +244,8 @@ class ApiController extends Zend_Controller_Action
// disable the view and the layout
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$date = new Application_Common_DateHelper;
$utcTimeNow = $date->getUtcTimestamp();
$utcTimeNow = gmdate("Y-m-d H:i:s");
$utcTimeEnd = ""; // if empty, getNextShows will use interval instead of end of day
$request = $this->getRequest();
@ -284,44 +260,48 @@ class ApiController extends Zend_Controller_Action
}
// make getNextShows use end of day
$utcTimeEnd = Application_Common_DateHelper::GetDayEndTimestampInUtc();
$result = array("env"=>APPLICATION_ENV,
"schedulerTime"=>gmdate("Y-m-d H:i:s"),
"currentShow"=>Application_Model_Show::getCurrentShow($utcTimeNow),
"nextShow"=>Application_Model_Show::getNextShows($utcTimeNow, $limit, $utcTimeEnd)
);
// XSS exploit prevention
foreach ($result["currentShow"] as &$current) {
$current["name"] = htmlspecialchars($current["name"]);
}
foreach ($result["nextShow"] as &$next) {
$next["name"] = htmlspecialchars($next["name"]);
}
Application_Model_Show::convertToLocalTimeZone($result["currentShow"],
array("starts", "ends", "start_timestamp", "end_timestamp"));
Application_Model_Show::convertToLocalTimeZone($result["nextShow"],
array("starts", "ends", "start_timestamp", "end_timestamp"));
} else {
$end = Application_Common_DateHelper::getTodayStationEndDateTime();
$end->setTimezone(new DateTimeZone("UTC"));
$utcTimeEnd = $end->format("Y-m-d H:i:s");
$result = array(
"env" => APPLICATION_ENV,
"schedulerTime" => $utcTimeNow,
"currentShow" => Application_Model_Show::getCurrentShow($utcTimeNow),
"nextShow" => Application_Model_Show::getNextShows($utcTimeNow, $limit, $utcTimeEnd)
);
}
else {
$result = Application_Model_Schedule::GetPlayOrderRange();
// XSS exploit prevention
$result["previous"]["name"] = htmlspecialchars($result["previous"]["name"]);
$result["current"]["name"] = htmlspecialchars($result["current"]["name"]);
$result["next"]["name"] = htmlspecialchars($result["next"]["name"]);
foreach ($result["currentShow"] as &$current) {
$current["name"] = htmlspecialchars($current["name"]);
}
foreach ($result["nextShow"] as &$next) {
$next["name"] = htmlspecialchars($next["name"]);
}
//Convert from UTC to localtime for Web Browser.
Application_Model_Show::ConvertToLocalTimeZone($result["currentShow"],
array("starts", "ends", "start_timestamp", "end_timestamp"));
Application_Model_Show::ConvertToLocalTimeZone($result["nextShow"],
array("starts", "ends", "start_timestamp", "end_timestamp"));
$result["next"]["name"] = htmlspecialchars($result["next"]["name"]);
}
// XSS exploit prevention
foreach ($result["currentShow"] as &$current) {
$current["name"] = htmlspecialchars($current["name"]);
}
foreach ($result["nextShow"] as &$next) {
$next["name"] = htmlspecialchars($next["name"]);
}
//For consistency, all times here are being sent in the station timezone, which
//seems to be what we've normalized everything to.
//Convert the UTC scheduler time ("now") to the station timezone.
$result["schedulerTime"] = Application_Common_DateHelper::UTCStringToStationTimezoneString($result["schedulerTime"]);
$result["timezone"] = Application_Common_DateHelper::getStationTimezoneAbbreviation();
$result["timezoneOffset"] = Application_Common_DateHelper::getStationTimezoneOffset();
//Convert from UTC to station time for Web Browser.
Application_Common_DateHelper::convertTimestamps($result["currentShow"],
array("starts", "ends", "start_timestamp", "end_timestamp"),
"station");
Application_Common_DateHelper::convertTimestamps($result["nextShow"],
array("starts", "ends", "start_timestamp", "end_timestamp"),
"station");
//used by caller to determine if the airtime they are running or widgets in use is out of date.
$result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION;
@ -343,22 +323,37 @@ class ApiController extends Zend_Controller_Action
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$date = new Application_Common_DateHelper;
$dayStart = $date->getWeekStartDate();
$utcDayStart = Application_Common_DateHelper::ConvertToUtcDateTimeString($dayStart);
//weekStart is in station time.
$weekStartDateTime = Application_Common_DateHelper::getWeekStartDateTime();
$dow = array("monday", "tuesday", "wednesday", "thursday", "friday",
"saturday", "sunday");
"saturday", "sunday", "nextmonday", "nexttuesday", "nextwednesday",
"nextthursday", "nextfriday", "nextsaturday", "nextsunday");
$result = array();
for ($i=0; $i<7; $i++) {
$utcDayEnd = Application_Common_DateHelper::GetDayEndTimestamp($utcDayStart);
$utcTimezone = new DateTimeZone("UTC");
$stationTimezone = new DateTimeZone(Application_Model_Preference::GetDefaultTimezone());
$weekStartDateTime->setTimezone($utcTimezone);
$utcDayStart = $weekStartDateTime->format("Y-m-d H:i:s");
for ($i = 0; $i < 14; $i++) {
//have to be in station timezone when adding 1 day for daylight savings.
$weekStartDateTime->setTimezone($stationTimezone);
$weekStartDateTime->add(new DateInterval('P1D'));
//convert back to UTC to get the actual timestamp used for search.
$weekStartDateTime->setTimezone($utcTimezone);
$utcDayEnd = $weekStartDateTime->format("Y-m-d H:i:s");
$shows = Application_Model_Show::getNextShows($utcDayStart, "ALL", $utcDayEnd);
$utcDayStart = $utcDayEnd;
Application_Model_Show::convertToLocalTimeZone($shows,
array("starts", "ends", "start_timestamp",
"end_timestamp"));
Application_Common_DateHelper::convertTimestamps(
$shows,
array("starts", "ends", "start_timestamp","end_timestamp"),
"station"
);
$result[$dow[$i]] = $shows;
}
@ -434,23 +429,22 @@ class ApiController extends Zend_Controller_Action
public function recordedShowsAction()
{
$today_timestamp = date("Y-m-d H:i:s");
$now = new DateTime($today_timestamp);
$end_timestamp = $now->add(new DateInterval("PT2H"));
$end_timestamp = $end_timestamp->format("Y-m-d H:i:s");
$utcTimezone = new DateTimeZone("UTC");
$nowDateTime = new DateTime("now", $utcTimezone);
$endDateTime = clone $nowDateTime;
$endDateTime = $endDateTime->add(new DateInterval("PT2H"));
$this->view->shows =
Application_Model_Show::getShows(
Application_Common_DateHelper::ConvertToUtcDateTime($today_timestamp, date_default_timezone_get()),
Application_Common_DateHelper::ConvertToUtcDateTime($end_timestamp, date_default_timezone_get()),
$nowDateTime,
$endDateTime,
$onlyRecord = true);
$this->view->is_recording = false;
$this->view->server_timezone = Application_Model_Preference::GetTimezone();
$rows = Application_Model_Show::getCurrentShow($today_timestamp);
Application_Model_Show::convertToLocalTimeZone($rows, array("starts", "ends", "start_timestamp", "end_timestamp"));
$this->view->server_timezone = Application_Model_Preference::GetDefaultTimezone();
$rows = Application_Model_Show::getCurrentShow();
if (count($rows) > 0) {
$this->view->is_recording = ($rows[0]['record'] == 1);
}
@ -493,9 +487,8 @@ class ApiController extends Zend_Controller_Action
try {
$show_inst = new Application_Model_ShowInstance($show_instance_id);
$show_inst->setRecordedFile($file_id);
//$show_start_time = Application_Common_DateHelper::ConvertToLocalDateTimeString($show_inst->getShowInstanceStart());
} catch (Exception $e) {
}
catch (Exception $e) {
//we've reached here probably because the show was
//cancelled, and therefore the show instance does not exist
//anymore (ShowInstance constructor threw this error). We've
@ -1064,12 +1057,15 @@ class ApiController extends Zend_Controller_Action
{
$request = $this->getRequest();
$data = $request->getParam("data");
$media_id = $request->getParam("media_id");
$media_id = intval($request->getParam("media_id"));
$data_arr = json_decode($data);
//$media_id is -1 sometimes when a stream has stopped playing
if (!is_null($media_id) && $media_id > 0) {
if (!is_null($media_id)) {
if (isset($data_arr->title) &&
strlen($data_arr->title) < 1024) {
if (isset($data_arr->title)) {
$data_title = substr($data_arr->title, 0, 1024);
$previous_metadata = CcWebstreamMetadataQuery::create()
->orderByDbStartTime('desc')
@ -1078,23 +1074,27 @@ class ApiController extends Zend_Controller_Action
$do_insert = true;
if ($previous_metadata) {
if ($previous_metadata->getDbLiquidsoapData() == $data_arr->title) {
Logging::debug("Duplicate found: ".$data_arr->title);
if ($previous_metadata->getDbLiquidsoapData() == $data_title) {
Logging::debug("Duplicate found: ". $data_title);
$do_insert = false;
}
}
if ($do_insert) {
$startDT = new DateTime("now", new DateTimeZone("UTC"));
$webstream_metadata = new CcWebstreamMetadata();
$webstream_metadata->setDbInstanceId($media_id);
$webstream_metadata->setDbStartTime(new DateTime("now", new DateTimeZone("UTC")));
$webstream_metadata->setDbLiquidsoapData($data_arr->title);
$webstream_metadata->setDbStartTime($startDT);
$webstream_metadata->setDbLiquidsoapData($data_title);
$webstream_metadata->save();
$historyService = new Application_Service_HistoryService();
$historyService->insertWebstreamMetadata($media_id, $startDT, $data_arr);
}
}
} else {
throw new Exception("Null value of media_id");
}
}
$this->view->response = $data;
$this->view->media_id = $media_id;

View file

@ -97,7 +97,7 @@ class DashboardController extends Zend_Controller_Action
$baseUrl = Application_Common_OsPath::getBaseDir();
$this->view->headLink()->appendStylesheet($baseUrl.'js/jplayer/skin/jplayer.blue.monday.css?'.$CC_CONFIG['airtime_version']);
$this->_helper->layout->setLayout('bare');
$this->_helper->layout->setLayout('livestream');
$logo = Application_Model_Preference::GetStationLogo();
if ($logo) {

View file

@ -20,9 +20,6 @@ class ListenerstatController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'js/flot/jquery.flot.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/flot/jquery.flot.crosshair.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/listenerstat/listenerstat.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$offset = date("Z") * -1;
$this->view->headScript()->appendScript("var serverTimezoneOffset = {$offset}; //in seconds");
$this->view->headScript()->appendFile($baseUrl.'js/timepicker/jquery.ui.timepicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
@ -33,11 +30,14 @@ class ListenerstatController extends Zend_Controller_Action
$now = time();
$from = $request->getParam("from", $now - (24*60*60));
$to = $request->getParam("to", $now);
$utcTimezone = new DateTimeZone("UTC");
$displayTimeZone = new DateTimeZone(Application_Model_Preference::GetTimezone());
$start = DateTime::createFromFormat("U", $from, new DateTimeZone("UTC"));
$start->setTimezone(new DateTimeZone(date_default_timezone_get()));
$end = DateTime::createFromFormat("U", $to, new DateTimeZone("UTC"));
$end->setTimezone(new DateTimeZone(date_default_timezone_get()));
$start = DateTime::createFromFormat("U", $from, $utcTimezone);
$start->setTimezone($displayTimeZone);
$end = DateTime::createFromFormat("U", $to, $utcTimezone);
$end->setTimezone($displayTimeZone);
$form = new Application_Form_DateRange();
$form->populate(array(

View file

@ -148,17 +148,7 @@ class LocaleController extends Zend_Controller_Action
"is greater than" => _("is greater than"),
"is less than" => _("is less than"),
"is in the range" => _("is in the range"),
//playouthistory/historytable.js
"Title" => _("Title"),
"Creator" => _("Creator"),
"Played" => _("Played"),
"Length" => _("Length"),
"Composer" => _("Composer"),
"Copyright" => _("Copyright"),
"All" => _("All"),
"Copied %s row%s to the clipboard" => _("Copied %s row%s to the clipboard"),
"%sPrint view%sPlease use your browser's print function to print this table. Press escape when finished." => _("%sPrint view%sPlease use your browser's print function to print this table. Press escape when finished."),
//preferences/musicdirs.js
//preferences/musicdirs.js
"Choose Storage Folder" => _("Choose Storage Folder"),
"Choose Folder to Watch" => _("Choose Folder to Watch"),
"Are you sure you want to change the storage folder?\nThis will remove the files from your Airtime library!"
@ -187,6 +177,7 @@ class LocaleController extends Zend_Controller_Action
//preferences/support-setting.js
"Image must be one of jpg, jpeg, png, or gif" => _("Image must be one of jpg, jpeg, png, or gif"),
//schedule/add-show.js
"Warning: You cannot change this field while the show is currently playing" => _("Warning: You cannot change this field while the show is currently playing"),
"No result found" => _("No result found"),
"This follows the same security pattern for the shows: only users assigned to the show can connect." => _("This follows the same security pattern for the shows: only users assigned to the show can connect."),
"Specify custom authentication which will work only for this show." => _("Specify custom authentication which will work only for this show."),
@ -194,6 +185,7 @@ class LocaleController extends Zend_Controller_Action
"The show instance doesn't exist anymore!" => _("The show instance doesn't exist anymore!"),
"Warning: Shows cannot be re-linked" => _("Warning: Shows cannot be re-linked"),
"By linking your repeating shows any media items scheduled in any repeat show will also get scheduled in the other repeat shows" => _("By linking your repeating shows any media items scheduled in any repeat show will also get scheduled in the other repeat shows"),
"Timezone is set to the station timezone by default. Shows in the calendar will be displayed in your local time defined by the Interface Timezone in your user settings." => _("Timezone is set to the station timezone by default. Shows in the calendar will be displayed in your local time defined by the Interface Timezone in your user settings."),
//schedule/full-calendar-functions
//already in schedule/add-show.js
//"The show instance doesn't exist anymore!" => _("The show instance doesn't exist anymore!"),
@ -391,13 +383,20 @@ class LocaleController extends Zend_Controller_Action
"File: %f, size: %s, max file size: %m" => _("File: %f, size: %s, max file size: %m"),
"Upload URL might be wrong or doesn't exist" => _("Upload URL might be wrong or doesn't exist"),
"Error: File too large: " => _("Error: File too large: "),
"Error: Invalid file extension: " => _("Error: Invalid file extension: ")
"Error: Invalid file extension: " => _("Error: Invalid file extension: "),
//history translations
"Set Default" => _("Set Default"),
"Create Entry" => _("Create Entry"),
"Edit History Record" => _("Edit History Record"),
"No Show" => _("No Show"),
"All" => _("All"),
"Copied %s row%s to the clipboard" => _("Copied %s row%s to the clipboard"),
"%sPrint view%sPlease use your browser's print function to print this table. Press escape when finished." => _("%sPrint view%sPlease use your browser's print function to print this table. Press escape when finished.")
);
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
header("Content-type: text/javascript");
echo "var general_dict=".json_encode($translations);
}
}

View file

@ -70,7 +70,7 @@ class LoginController extends Zend_Controller_Action
$tempSess->referrer = 'login';
//set the user locale in case user changed it in when logging in
Application_Model_Preference::SetUserLocale($auth->getIdentity()->id, $locale);
Application_Model_Preference::SetUserLocale($locale);
$this->_redirect('Showbuilder');
} else {

View file

@ -32,10 +32,13 @@ class PlayouthistoryController extends Zend_Controller_Action
$from = $request->getParam("from", $now - (24*60*60));
$to = $request->getParam("to", $now);
$start = DateTime::createFromFormat("U", $from, new DateTimeZone("UTC"));
$start->setTimezone(new DateTimeZone(date_default_timezone_get()));
$end = DateTime::createFromFormat("U", $to, new DateTimeZone("UTC"));
$end->setTimezone(new DateTimeZone(date_default_timezone_get()));
$utcTimezone = new DateTimeZone("UTC");
$displayTimeZone = new DateTimeZone(Application_Model_Preference::GetTimezone());
$start = DateTime::createFromFormat("U", $from, $utcTimezone);
$start->setTimezone($displayTimeZone);
$end = DateTime::createFromFormat("U", $to, $utcTimezone);
$end->setTimezone($displayTimeZone);
$form = new Application_Form_DateRange();
$form->populate(array(
@ -54,8 +57,6 @@ class PlayouthistoryController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/TableTools-2.1.5/js/ZeroClipboard.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/TableTools-2.1.5/js/TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$offset = date("Z") * -1;
$this->view->headScript()->appendScript("var serverTimezoneOffset = {$offset}; //in seconds");
$this->view->headScript()->appendFile($baseUrl.'js/timepicker/jquery.ui.timepicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/bootstrap-datetime/bootstrap-datetimepicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');

View file

@ -35,6 +35,7 @@ class ScheduleController extends Zend_Controller_Action
->addActionContext('calculate-duration', 'json')
->addActionContext('get-current-show', 'json')
->addActionContext('update-future-is-scheduled', 'json')
->addActionContext('localize-start-end-time', 'json')
->initContext();
$this->sched_sess = new Zend_Session_Namespace("schedule");
@ -50,7 +51,7 @@ class ScheduleController extends Zend_Controller_Action
"var calendarPref = {};\n".
"calendarPref.weekStart = ".Application_Model_Preference::GetWeekStartDay().";\n".
"calendarPref.timestamp = ".time().";\n".
"calendarPref.timezoneOffset = ".date("Z").";\n".
"calendarPref.timezoneOffset = ".Application_Common_DateHelper::getUserTimezoneOffset().";\n".
"calendarPref.timeScale = '".Application_Model_Preference::GetCalendarTimeScale()."';\n".
"calendarPref.timeInterval = ".Application_Model_Preference::GetCalendarTimeInterval().";\n".
"calendarPref.weekStartDay = ".Application_Model_Preference::GetWeekStartDay().";\n".
@ -60,15 +61,17 @@ class ScheduleController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
//full-calendar-functions.js requires this variable, so that datePicker widget can be offset to server time instead of client time
$this->view->headScript()->appendScript("var timezoneOffset = ".date("Z")."; //in seconds");
$this->view->headScript()->appendFile($baseUrl.'js/airtime/schedule/full-calendar-functions.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
//this should be as a default, however with our new drop down timezone changing for shows, we should reset this offset then??
$this->view->headScript()->appendScript("var timezoneOffset = ".Application_Common_DateHelper::getStationTimezoneOffset()."; //in seconds");
//set offset to ensure it loads last
$this->view->headScript()->offsetSetFile(90, $baseUrl.'js/airtime/schedule/full-calendar-functions.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/fullcalendar/fullcalendar.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/timepicker/jquery.ui.timepicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/colorpicker/js/colorpicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/schedule/add-show.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/schedule/schedule.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->offsetSetFile(100, $baseUrl.'js/airtime/schedule/schedule.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/blockui/jquery.blockUI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']);
@ -78,7 +81,6 @@ class ScheduleController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']);
//Start Show builder JS/CSS requirements
$this->view->headScript()->appendFile($baseUrl.'js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
@ -114,9 +116,11 @@ class ScheduleController extends Zend_Controller_Action
$service_user = new Application_Service_UserService();
$currentUser = $service_user->getCurrentUser();
$start = new DateTime($this->_getParam('start', null));
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
$start = new DateTime($this->_getParam('start', null), $userTimezone);
$start->setTimezone(new DateTimeZone("UTC"));
$end = new DateTime($this->_getParam('end', null));
$end = new DateTime($this->_getParam('end', null), $userTimezone);
$end->setTimezone(new DateTimeZone("UTC"));
$events = &Application_Model_Show::getFullCalendarEvents($start, $end,
@ -182,6 +186,7 @@ class ScheduleController extends Zend_Controller_Action
$deltaDay = $this->_getParam('day');
$deltaMin = $this->_getParam('min');
$showId = $this->_getParam('showId');
$instanceId = $this->_getParam('instanceId');
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
@ -194,7 +199,7 @@ class ScheduleController extends Zend_Controller_Action
return false;
}
$error = $show->resizeShow($deltaDay, $deltaMin);
$error = $show->resizeShow($deltaDay, $deltaMin, $instanceId);
}
if (isset($error)) {
@ -260,22 +265,36 @@ class ScheduleController extends Zend_Controller_Action
$show = Application_Model_Show::getCurrentShow();
/* Convert all UTC times to localtime before sending back to user. */
$range["schedulerTime"] = Application_Common_DateHelper::UTCStringToUserTimezoneString($range["schedulerTime"]);
if (isset($range["previous"])) {
$range["previous"]["starts"] = Application_Common_DateHelper::ConvertToLocalDateTimeString($range["previous"]["starts"]);
$range["previous"]["ends"] = Application_Common_DateHelper::ConvertToLocalDateTimeString($range["previous"]["ends"]);
$range["previous"]["starts"] = Application_Common_DateHelper::UTCStringToUserTimezoneString($range["previous"]["starts"]);
$range["previous"]["ends"] = Application_Common_DateHelper::UTCStringToUserTimezoneString($range["previous"]["ends"]);
}
if (isset($range["current"])) {
$range["current"]["starts"] = Application_Common_DateHelper::ConvertToLocalDateTimeString($range["current"]["starts"]);
$range["current"]["ends"] = Application_Common_DateHelper::ConvertToLocalDateTimeString($range["current"]["ends"]);
$range["current"]["starts"] = Application_Common_DateHelper::UTCStringToUserTimezoneString($range["current"]["starts"]);
$range["current"]["ends"] = Application_Common_DateHelper::UTCStringToUserTimezoneString($range["current"]["ends"]);
}
if (isset($range["next"])) {
$range["next"]["starts"] = Application_Common_DateHelper::ConvertToLocalDateTimeString($range["next"]["starts"]);
$range["next"]["ends"] = Application_Common_DateHelper::ConvertToLocalDateTimeString($range["next"]["ends"]);
$range["next"]["starts"] = Application_Common_DateHelper::UTCStringToUserTimezoneString($range["next"]["starts"]);
$range["next"]["ends"] = Application_Common_DateHelper::UTCStringToUserTimezoneString($range["next"]["ends"]);
}
Application_Common_DateHelper::convertTimestamps(
$range["currentShow"],
array("starts", "ends", "start_timestamp", "end_timestamp"),
"user"
);
Application_Common_DateHelper::convertTimestamps(
$range["nextShow"],
array("starts", "ends", "start_timestamp", "end_timestamp"),
"user"
);
Application_Model_Show::convertToLocalTimeZone($range["currentShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
Application_Model_Show::convertToLocalTimeZone($range["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
//TODO: Add timezone and timezoneOffset back into the ApiController's results.
$range["timezone"] = Application_Common_DateHelper::getUserTimezoneAbbreviation();
$range["timezoneOffset"] = Application_Common_DateHelper::getUserTimezoneOffset();
$source_status = array();
$switch_status = array();
$live_dj = Application_Model_Preference::GetSourceStatus("live_dj");
@ -323,9 +342,10 @@ class ScheduleController extends Zend_Controller_Action
$originalShowStart = $originalShow->getShowInstanceStart();
//convert from UTC to user's timezone for display.
$displayTimeZone = new DateTimeZone(Application_Model_Preference::GetTimezone());
$originalDateTime = new DateTime($originalShowStart, new DateTimeZone("UTC"));
$originalDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
//$timestamp = Application_Common_DateHelper::ConvertToLocalDateTimeString($originalDateTime->format("Y-m-d H:i:s"));
$originalDateTime->setTimezone($displayTimeZone);
$this->view->additionalShowInfo =
sprintf(_("Rebroadcast of show %s from %s at %s"),
$originalShowName,
@ -417,7 +437,7 @@ class ScheduleController extends Zend_Controller_Action
if ($service_showForm->validateShowForms($forms, $data, $validateStartDate,
$originalShowStartDateTime, true, $data["add_show_instance_id"])) {
$service_show->createShowFromRepeatingInstance($data);
$service_show->editRepeatingShowInstance($data);
$this->view->addNewShow = true;
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
@ -430,7 +450,7 @@ class ScheduleController extends Zend_Controller_Action
}
$this->view->rr->getElement('add_show_record')->setOptions(array('disabled' => true));
$this->view->addNewShow = false;
$this->view->action = "edit-show";
$this->view->action = "edit-repeating-show-instance";
$this->view->form = $this->view->render('schedule/add-show-form.phtml');
}
}
@ -627,9 +647,12 @@ class ScheduleController extends Zend_Controller_Action
public function calculateDurationAction()
{
$start = $this->_getParam('startTime');
$end = $this->_getParam('endTime');
$timezone = $this->_getParam('timezone');
$service_showForm = new Application_Service_ShowFormService();
$result = $service_showForm->calculateDuration($this->_getParam('startTime'),
$this->_getParam('endTime'));
$result = $service_showForm->calculateDuration($start, $end, $timezone);
echo Zend_Json::encode($result);
exit();
@ -638,7 +661,25 @@ class ScheduleController extends Zend_Controller_Action
public function updateFutureIsScheduledAction()
{
$schedId = $this->_getParam('schedId');
$redrawLibTable = Application_Model_StoredFile::setIsScheduled($schedId, false);
$scheduleService = new Application_Service_SchedulerService();
$redrawLibTable = $scheduleService->updateFutureIsScheduled($schedId, false);
$this->_helper->json->sendJson(array("redrawLibTable" => $redrawLibTable));
}
public function localizeStartEndTimeAction()
{
$newTimezone = $this->_getParam('newTimezone');
$oldTimezone = $this->_getParam('oldTimezone');
$localTime = array();
$localTime["start"] = Application_Service_ShowFormService::localizeDateTime(
$this->_getParam('startDate'), $this->_getParam('startTime'), $newTimezone, $oldTimezone);
$localTime["end"] = Application_Service_ShowFormService::localizeDateTime(
$this->_getParam('endDate'), $this->_getParam('endTime'), $newTimezone, $oldTimezone);
$this->_helper->json->sendJson($localTime);
}
}

View file

@ -20,31 +20,15 @@ class ShowbuilderController extends Zend_Controller_Action
{
$CC_CONFIG = Config::getConfig();
$request = $this->getRequest();
$baseUrl = Application_Common_OsPath::getBaseDir();
$user = Application_Model_User::GetCurrentUser();
$userType = $user->getType();
$this->view->headScript()->appendScript("localStorage.setItem( 'user-type', '$userType' );");
$data = Application_Model_Preference::getCurrentLibraryTableSetting();
if (!is_null($data)) {
$libraryTable = json_encode($data);
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-library', JSON.stringify($libraryTable) );");
} else {
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-library', '' );");
}
$data = Application_Model_Preference::getTimelineDatatableSetting();
if (!is_null($data)) {
$timelineTable = json_encode($data);
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-timeline', JSON.stringify($timelineTable) );");
} else {
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-timeline', '' );");
}
$this->view->headScript()->appendFile($baseUrl.'js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
@ -57,14 +41,12 @@ class ShowbuilderController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'js/blockui/jquery.blockUI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/library/library.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'css/media_library.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']);
$this->view->headScript()->appendFile($baseUrl.'js/airtime/library/events/library_showbuilder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$refer_sses = new Zend_Session_Namespace('referrer');
if ($request->isPost()) {
@ -141,16 +123,40 @@ class ShowbuilderController extends Zend_Controller_Action
$this->view->disableLib = $disableLib;
$this->view->showLib = $showLib;
//only include library things on the page if the user can see it.
if (!$disableLib) {
$this->view->headScript()->appendFile($baseUrl.'js/airtime/library/library.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/library/events/library_showbuilder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$data = Application_Model_Preference::getCurrentLibraryTableSetting();
if (!is_null($data)) {
$libraryTable = json_encode($data);
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-library', JSON.stringify($libraryTable) );");
} else {
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-library', '' );");
}
}
$data = Application_Model_Preference::getTimelineDatatableSetting();
if (!is_null($data)) {
$timelineTable = json_encode($data);
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-timeline', JSON.stringify($timelineTable) );");
} else {
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-timeline', '' );");
}
//populate date range form for show builder.
$now = time();
$from = $request->getParam("from", $now);
$to = $request->getParam("to", $now + (24*60*60));
$start = DateTime::createFromFormat("U", $from, new DateTimeZone("UTC"));
$start->setTimezone(new DateTimeZone(date_default_timezone_get()));
$utcTimezone = new DateTimeZone("UTC");
$displayTimeZone = new DateTimeZone(Application_Model_Preference::GetTimezone());
$end = DateTime::createFromFormat("U", $to, new DateTimeZone("UTC"));
$end->setTimezone(new DateTimeZone(date_default_timezone_get()));
$start = DateTime::createFromFormat("U", $from, $utcTimezone);
$start->setTimezone($displayTimeZone);
$end = DateTime::createFromFormat("U", $to, $utcTimezone);
$end->setTimezone($displayTimeZone);
$form = new Application_Form_ShowBuilder();
$form->populate(array(
@ -162,8 +168,6 @@ class ShowbuilderController extends Zend_Controller_Action
$this->view->sb_form = $form;
$offset = date("Z") * -1;
$this->view->headScript()->appendScript("var serverTimezoneOffset = {$offset}; //in seconds");
$this->view->headScript()->appendFile($baseUrl.'js/timepicker/jquery.ui.timepicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/showbuilder/builder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/showbuilder/main_builder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
@ -214,10 +218,12 @@ class ShowbuilderController extends Zend_Controller_Action
return;
}
$displayTimeZone = new DateTimeZone(Application_Model_Preference::GetTimezone());
$start = $instance->getDbStarts(null);
$start->setTimezone(new DateTimeZone(date_default_timezone_get()));
$start->setTimezone($displayTimeZone);
$end = $instance->getDbEnds(null);
$end->setTimezone(new DateTimeZone(date_default_timezone_get()));
$end->setTimezone($displayTimeZone);
$show_name = $instance->getCcShow()->getDbName();
$start_time = $start->format("Y-m-d H:i:s");
@ -270,8 +276,8 @@ class ShowbuilderController extends Zend_Controller_Action
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
$opts = array("myShows" => $my_shows,
"showFilter" => $show_filter,
$opts = array("myShows" => $my_shows,
"showFilter" => $show_filter,
"showInstanceFilter" => $show_instance_filter);
$showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT, $opts);

View file

@ -72,8 +72,8 @@ class UserController extends Zend_Controller_Action
// Language and timezone settings are saved on a per-user basis
// By default, the default language, and timezone setting on
// preferences page is what gets assigned.
Application_Model_Preference::SetUserLocale($user->getId());
Application_Model_Preference::SetUserTimezone($user->getId());
Application_Model_Preference::SetUserLocale();
Application_Model_Preference::SetUserTimezone();
$form->reset();
$this->view->form = $form;
@ -143,8 +143,8 @@ class UserController extends Zend_Controller_Action
$user->setJabber($formData['cu_jabber']);
$user->save();
Application_Model_Preference::SetUserLocale($user->getId(), $formData['cu_locale']);
Application_Model_Preference::SetUserTimezone($user->getId(), $formData['cu_timezone']);
Application_Model_Preference::SetUserLocale($formData['cu_locale']);
Application_Model_Preference::SetUserTimezone($formData['cu_timezone']);
//configure localization with new locale setting
Application_Model_Locale::configureLocalization($formData['cu_locale']);