CC-5323: User's Timezone Can Improperly Edit Show
This commit is contained in:
parent
2ab5e6b26a
commit
107263ae20
7 changed files with 99 additions and 5 deletions
|
@ -35,6 +35,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
->addActionContext('calculate-duration', 'json')
|
->addActionContext('calculate-duration', 'json')
|
||||||
->addActionContext('get-current-show', 'json')
|
->addActionContext('get-current-show', 'json')
|
||||||
->addActionContext('update-future-is-scheduled', 'json')
|
->addActionContext('update-future-is-scheduled', 'json')
|
||||||
|
->addActionContext('localize-start-end-time', 'json')
|
||||||
->initContext();
|
->initContext();
|
||||||
|
|
||||||
$this->sched_sess = new Zend_Session_Namespace("schedule");
|
$this->sched_sess = new Zend_Session_Namespace("schedule");
|
||||||
|
@ -641,4 +642,24 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$redrawLibTable = Application_Model_StoredFile::setIsScheduled($schedId, false);
|
$redrawLibTable = Application_Model_StoredFile::setIsScheduled($schedId, false);
|
||||||
$this->_helper->json->sendJson(array("redrawLibTable" => $redrawLibTable));
|
$this->_helper->json->sendJson(array("redrawLibTable" => $redrawLibTable));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When the timezone is changed in add-show form this function
|
||||||
|
* applies the new timezone to the start and end time
|
||||||
|
*/
|
||||||
|
public function localizeStartEndTimeAction()
|
||||||
|
{
|
||||||
|
$service_showForm = new Application_Service_ShowFormService(
|
||||||
|
$this->_getParam("showId"));
|
||||||
|
$timezone = $this->_getParam('timezone');
|
||||||
|
$localTime = array();
|
||||||
|
|
||||||
|
$localTime["start"] = $service_showForm->localizeDateTime(
|
||||||
|
$this->_getParam('startDate'), $this->_getParam('startTime'), $timezone);
|
||||||
|
|
||||||
|
$localTime["end"] = $service_showForm->localizeDateTime(
|
||||||
|
$this->_getParam('endDate'), $this->_getParam('endTime'), $timezone);
|
||||||
|
|
||||||
|
$this->_helper->json->sendJson($localTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,15 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
||||||
'decorators' => array('ViewHelper')
|
'decorators' => array('ViewHelper')
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$timezone = new Zend_Form_Element_Select('add_show_timezone');
|
||||||
|
$timezone->setRequired(true)
|
||||||
|
->setLabel(_("Timezone:"))
|
||||||
|
->setMultiOptions(Application_Common_Timezone::getTimezones())
|
||||||
|
->setValue(Application_Model_Preference::GetDefaultTimezone())
|
||||||
|
->setAttrib('class', 'input_select add_show_input_select')
|
||||||
|
->setDecorators(array('ViewHelper'));
|
||||||
|
$this->addElement($timezone);
|
||||||
|
|
||||||
// Add repeats element
|
// Add repeats element
|
||||||
$this->addElement('checkbox', 'add_show_repeats', array(
|
$this->addElement('checkbox', 'add_show_repeats', array(
|
||||||
'label' => _('Repeats?'),
|
'label' => _('Repeats?'),
|
||||||
|
|
|
@ -31,6 +31,7 @@ class CcShowDays extends BaseCcShowDays {
|
||||||
return $dt;
|
return $dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns the start of a show in the timezone it was created in
|
||||||
public function getLocalStartDateAndTime()
|
public function getLocalStartDateAndTime()
|
||||||
{
|
{
|
||||||
$dt = new DateTime(
|
$dt = new DateTime(
|
||||||
|
@ -38,16 +39,16 @@ class CcShowDays extends BaseCcShowDays {
|
||||||
new DateTimeZone($this->getDbTimezone())
|
new DateTimeZone($this->getDbTimezone())
|
||||||
);
|
);
|
||||||
|
|
||||||
//make timezone current user specific
|
//set timezone to that of the show
|
||||||
$dt->setTimezone(new DateTimeZone(Application_Model_Preference::GetTimezone()));
|
$dt->setTimezone(new DateTimeZone($this->getDbTimezone()));
|
||||||
|
|
||||||
return $dt;
|
return $dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Enter description here ...
|
* Returns the end of a show in the timezone it was created in
|
||||||
* @param DateTime $startDateTime first show in user's local time
|
* @param DateTime $startDateTime first show in show's local time
|
||||||
*/
|
*/
|
||||||
public function getLocalEndDateAndTime($showStart)
|
public function getLocalEndDateAndTime($showStart)
|
||||||
{
|
{
|
||||||
|
|
|
@ -150,6 +150,7 @@ class Application_Service_ShowFormService
|
||||||
'add_show_end_date_no_repeat' => $showEnd->format("Y-m-d"),
|
'add_show_end_date_no_repeat' => $showEnd->format("Y-m-d"),
|
||||||
'add_show_end_time' => $showEnd->format("H:i"),
|
'add_show_end_time' => $showEnd->format("H:i"),
|
||||||
'add_show_duration' => $ccShowDay->formatDuration(true),
|
'add_show_duration' => $ccShowDay->formatDuration(true),
|
||||||
|
'add_show_timezone' => $ccShowDay->getDbTimezone(),
|
||||||
'add_show_repeats' => $ccShowDay->isRepeating() ? 1 : 0));
|
'add_show_repeats' => $ccShowDay->isRepeating() ? 1 : 0));
|
||||||
|
|
||||||
return $showStart;
|
return $showStart;
|
||||||
|
@ -159,7 +160,10 @@ class Application_Service_ShowFormService
|
||||||
{
|
{
|
||||||
$ccShowInstance = CcShowInstancesQuery::create()->findPk($this->instanceId);
|
$ccShowInstance = CcShowInstancesQuery::create()->findPk($this->instanceId);
|
||||||
|
|
||||||
$timezone = new DateTimeZone(Application_Model_Preference::GetTimezone());
|
//get timezone the show is created in
|
||||||
|
$timezone = $ccShowInstance->getCcShow()->getFirstCcShowDay()->getDbTimezone();
|
||||||
|
//$timezone = new DateTimeZone(Application_Model_Preference::GetDefaultTimezone());
|
||||||
|
|
||||||
//DateTime object in UTC
|
//DateTime object in UTC
|
||||||
$showStart = $ccShowInstance->getDbStarts(null);
|
$showStart = $ccShowInstance->getDbStarts(null);
|
||||||
$showStart->setTimezone($timezone);
|
$showStart->setTimezone($timezone);
|
||||||
|
@ -180,6 +184,7 @@ class Application_Service_ShowFormService
|
||||||
'add_show_end_time' => $showEnd->format("H:i"),
|
'add_show_end_time' => $showEnd->format("H:i"),
|
||||||
'add_show_duration' => $this->calculateDuration(
|
'add_show_duration' => $this->calculateDuration(
|
||||||
$showStart->format("Y-m-d H:i:s"), $showEnd->format("Y-m-d H:i:s")),
|
$showStart->format("Y-m-d H:i:s"), $showEnd->format("Y-m-d H:i:s")),
|
||||||
|
'add_show_timezone' => $timezone,
|
||||||
'add_show_repeats' => 0));
|
'add_show_repeats' => 0));
|
||||||
|
|
||||||
$form->getElement('add_show_repeats')->setOptions(array("disabled" => true));
|
$form->getElement('add_show_repeats')->setOptions(array("disabled" => true));
|
||||||
|
@ -482,4 +487,24 @@ class Application_Service_ShowFormService
|
||||||
return "Invalid Date";
|
return "Invalid Date";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Enter description here ...
|
||||||
|
* @param $date String
|
||||||
|
* @param $time String
|
||||||
|
* @param $timezone String
|
||||||
|
*/
|
||||||
|
public function localizeDateTime($date, $time, $timezone)
|
||||||
|
{
|
||||||
|
$dt = new DateTime($date." ".$time, new DateTimeZone(
|
||||||
|
$this->ccShow->getFirstCcShowDay()->getDbTimezone()));
|
||||||
|
|
||||||
|
$dt->setTimeZone(new DateTimeZone($timezone));
|
||||||
|
|
||||||
|
return array(
|
||||||
|
"date" => $dt->format("Y-m-d"),
|
||||||
|
"time" => $dt->format("h:i")
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -55,6 +55,16 @@
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</ul>
|
</ul>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
|
<dt id="add_show_timezone-label">
|
||||||
|
<label class="required">
|
||||||
|
<?php echo $this->element->getElement('add_show_timezone')->getLabel() ?>
|
||||||
|
</label>
|
||||||
|
</dt>
|
||||||
|
<dd id="add_show_timezone-element">
|
||||||
|
<?php echo $this->element->getElement('add_show_timezone') ?>
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt id="add_show_repeats-label">
|
<dt id="add_show_repeats-label">
|
||||||
<label><?php echo $this->element->getElement('add_show_repeats')->getLabel() ?></label>
|
<label><?php echo $this->element->getElement('add_show_repeats')->getLabel() ?></label>
|
||||||
</dt>
|
</dt>
|
||||||
|
|
|
@ -445,6 +445,10 @@ input[type="text"]:focus, input[type="password"]:focus, textarea:focus, .input_t
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.add_show_input_select{
|
||||||
|
width: 150px;
|
||||||
|
}
|
||||||
|
|
||||||
/***** LIBRARY QTIP METADATA SPECIFIC STYLES BEGIN *****/
|
/***** LIBRARY QTIP METADATA SPECIFIC STYLES BEGIN *****/
|
||||||
table.library-track-md{
|
table.library-track-md{
|
||||||
width: 280px;
|
width: 280px;
|
||||||
|
|
|
@ -227,6 +227,30 @@ function setAddShowEvents() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
$.post(baseUrl+"Schedule/localize-start-end-time",
|
||||||
|
{format: "json",
|
||||||
|
startDate: startDateField.val(),
|
||||||
|
startTime: startTimeField.val(),
|
||||||
|
endDate: endDateField.val(),
|
||||||
|
endTime: endTimeField.val(),
|
||||||
|
timezone: timezone,
|
||||||
|
showId: showId}, function(json){
|
||||||
|
|
||||||
|
startDateField.val(json.start.date);
|
||||||
|
startTimeField.val(json.start.time);
|
||||||
|
endDateField.val(json.end.date);
|
||||||
|
endTimeField.val(json.end.time);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
form.find("#add_show_repeat_type").change(function(){
|
form.find("#add_show_repeat_type").change(function(){
|
||||||
toggleRepeatDays();
|
toggleRepeatDays();
|
||||||
toggleMonthlyRepeatType();
|
toggleMonthlyRepeatType();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue