CC-5323: User's Timezone Can Improperly Edit Show

This commit is contained in:
denise 2013-09-24 16:23:45 -04:00
parent 9e8fdb50ca
commit ad778ec971
4 changed files with 19 additions and 15 deletions

View File

@ -649,16 +649,16 @@ class ScheduleController extends Zend_Controller_Action
*/
public function localizeStartEndTimeAction()
{
$service_showForm = new Application_Service_ShowFormService(
$this->_getParam("showId"));
$timezone = $this->_getParam('timezone');
$service_showForm = new Application_Service_ShowFormService();
$newTimezone = $this->_getParam('newTimezone');
$oldTimezone = $this->_getParam('oldTimezone');
$localTime = array();
$localTime["start"] = $service_showForm->localizeDateTime(
$this->_getParam('startDate'), $this->_getParam('startTime'), $timezone);
$this->_getParam('startDate'), $this->_getParam('startTime'), $newTimezone, $oldTimezone);
$localTime["end"] = $service_showForm->localizeDateTime(
$this->_getParam('endDate'), $this->_getParam('endTime'), $timezone);
$this->_getParam('endDate'), $this->_getParam('endTime'), $newTimezone, $oldTimezone);
$this->_helper->json->sendJson($localTime);
}

View File

@ -495,16 +495,15 @@ class Application_Service_ShowFormService
* @param $time String
* @param $timezone String
*/
public function localizeDateTime($date, $time, $timezone)
public function localizeDateTime($date, $time, $newTimezone, $oldTimezone)
{
$dt = new DateTime($date." ".$time, new DateTimeZone(
$this->ccShow->getFirstCcShowDay()->getDbTimezone()));
$dt = new DateTime($date." ".$time, new DateTimeZone($oldTimezone));
$dt->setTimeZone(new DateTimeZone($timezone));
$dt->setTimeZone(new DateTimeZone($newTimezone));
return array(
"date" => $dt->format("Y-m-d"),
"time" => $dt->format("h:i")
"time" => $dt->format("H:i")
);
}
}

View File

@ -1330,7 +1330,7 @@ SQL;
$showDay->setDbFirstShow($startDateTime->format("Y-m-d"));
$showDay->setDbLastShow($endDate);
$showDay->setDbStartTime($startDateTime->format("H:i:s"));
$showDay->setDbTimezone(Application_Model_Preference::GetTimezone());
$showDay->setDbTimezone($showData['add_show_timezone']);
$showDay->setDbDuration($showData['add_show_duration']);
$showDay->setDbRepeatType($this->repeatType);
$showDay->setDbShowId($showId);

View File

@ -227,13 +227,18 @@ function setAddShowEvents() {
}
});
// in case user is creating a new show, there will be
// no show_id so we have to store the default timezone
// to be able to do the conversion when the timezone
// setting changes
var currentTimezone = form.find("#add_show_timezone").val();
form.find("#add_show_timezone").change(function(){
var startDateField = form.find("#add_show_start_date"),
startTimeField = form.find("#add_show_start_time"),
endDateField = form.find("#add_show_end_date_no_repeat"),
endTimeField = form.find("#add_show_end_time"),
timezone = form.find("#add_show_timezone").val(),
showId = form.find("#add_show_id").val();
newTimezone = form.find("#add_show_timezone").val();
$.post(baseUrl+"Schedule/localize-start-end-time",
{format: "json",
@ -241,8 +246,8 @@ function setAddShowEvents() {
startTime: startTimeField.val(),
endDate: endDateField.val(),
endTime: endTimeField.val(),
timezone: timezone,
showId: showId}, function(json){
newTimezone: newTimezone,
oldTimezone: currentTimezone}, function(json){
startDateField.val(json.start.date);
startTimeField.val(json.start.time);