CC-5594 : Remove all date_default_timezone_get()

removing unused old methods, changing listener stats to use the user timezone for display.
This commit is contained in:
Naomi 2013-12-04 15:06:07 -05:00
parent 82b40f52e7
commit c8cfdadb90
3 changed files with 9 additions and 274 deletions

View File

@ -36,11 +36,15 @@ WHERE (temp.rownum%:p4) = :p5;
SQL;
$result = Application_Common_Database::prepareAndExecute($sql,
array('p1'=>$p_start, 'p2'=>$p_end, 'p3'=>$d['mount_name'], 'p4'=>$jump, 'p5'=>$remainder));
$utcTimezone = new DateTimeZone("UTC");
$displayTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
foreach ($result as $r) {
$t = new DateTime($r['timestamp'], new DateTimeZone("UTC"));
$t->setTimezone(new DateTimeZone(date_default_timezone_get()));
$t = new DateTime($r['timestamp'], $utcTimezone);
$t->setTimezone($displayTimezone);
// tricking javascript so it thinks the server timezone is in UTC
$dt = new DateTime($t->format("Y-m-d H:i:s"), new DateTimeZone("UTC"));
$dt = new DateTime($t->format("Y-m-d H:i:s"), $utcTimezone);
$r['timestamp'] = $dt->format("U");
$out[$r['mount_name']][] = $r;

View File

@ -1009,275 +1009,6 @@ SQL;
Application_Common_Database::prepareAndExecute($sql, array(':file_id'=>$fileId), 'execute');
}
/*public static function createNewFormSections($p_view)
{
$formWhat = new Application_Form_AddShowWhat();
$formWho = new Application_Form_AddShowWho();
$formWhen = new Application_Form_AddShowWhen();
$formRepeats = new Application_Form_AddShowRepeats();
$formStyle = new Application_Form_AddShowStyle();
$formLive = new Application_Form_AddShowLiveStream();
$formWhat->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper');
$formRepeats->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper');
$formLive->removeDecorator('DtDdWrapper');
$p_view->what = $formWhat;
$p_view->when = $formWhen;
$p_view->repeats = $formRepeats;
$p_view->who = $formWho;
$p_view->style = $formStyle;
$p_view->live = $formLive;
$formWhat->populate(array('add_show_id' => '-1',
'add_show_instance_id' => '-1'));
$formWhen->populate(array('add_show_start_date' => date("Y-m-d"),
'add_show_start_time' => '00:00',
'add_show_end_date_no_repeate' => date("Y-m-d"),
'add_show_end_time' => '01:00',
'add_show_duration' => '01h 00m'));
$formRepeats->populate(array('add_show_end_date' => date("Y-m-d")));
$formRecord = new Application_Form_AddShowRR();
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
$formRebroadcast = new Application_Form_AddShowRebroadcastDates();
$formRecord->removeDecorator('DtDdWrapper');
$formAbsoluteRebroadcast->removeDecorator('DtDdWrapper');
$formRebroadcast->removeDecorator('DtDdWrapper');
$p_view->rr = $formRecord;
$p_view->absoluteRebroadcast = $formAbsoluteRebroadcast;
$p_view->rebroadcast = $formRebroadcast;
$p_view->addNewShow = true;
}*/
/* This function is responsible for handling the case where an individual
* show instance in a repeating show was edited (via the context menu in the Calendar).
* There is still lots of clean-up to do. For example we shouldn't be passing $controller into
* this method to manipulate the view (this should be done inside the controller function). With
* 2.1 deadline looming, this is OK for now. -Martin */
public static function updateShowInstance($data, $controller)
{
$formWhat = new Application_Form_AddShowWhat();
$formWhen = new Application_Form_AddShowWhen();
$formRepeats = new Application_Form_AddShowRepeats();
$formWho = new Application_Form_AddShowWho();
$formStyle = new Application_Form_AddShowStyle();
$formLive = new Application_Form_AddShowLiveStream();
$formWhat->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper');
$formRepeats->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper');
$formLive->removeDecorator('DtDdWrapper');
$formRecord = new Application_Form_AddShowRR();
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
$formRebroadcast = new Application_Form_AddShowRebroadcastDates();
$formRecord->removeDecorator('DtDdWrapper');
$formAbsoluteRebroadcast->removeDecorator('DtDdWrapper');
$formRebroadcast->removeDecorator('DtDdWrapper');
$when = $formWhen->isValid($data);
if ($when && $formWhen->checkReliantFields($data, true, null, true)) {
$start_dt = new DateTime($data['add_show_start_date']." ".$data['add_show_start_time'],
new DateTimeZone(date_default_timezone_get()));
$start_dt->setTimezone(new DateTimeZone('UTC'));
$end_dt = new DateTime($data['add_show_end_date_no_repeat']." ".$data['add_show_end_time'],
new DateTimeZone(date_default_timezone_get()));
$end_dt->setTimezone(new DateTimeZone('UTC'));
$ccShowInstance = CcShowInstancesQuery::create()->findPK($data["add_show_instance_id"]);
$ccShowInstance->setDbStarts($start_dt);
$ccShowInstance->setDbEnds($end_dt);
$ccShowInstance->save();
Application_Model_Schedule::createNewFormSections($controller->view);
return true;
} else {
$formWhat->disable();
$formWhen->disableRepeatCheckbox();
$formRepeats->disable();
$formWho->disable();
$formStyle->disable();
//$formLive->disable();
$controller->view->what = $formWhat;
$controller->view->when = $formWhen;
$controller->view->repeats = $formRepeats;
$controller->view->who = $formWho;
$controller->view->style = $formStyle;
$controller->view->live = $formLive;
$controller->view->rr = $formRecord;
$controller->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
$controller->view->rebroadcast = $formRebroadcast;
//$formRecord->disable();
//$formAbsoluteRebroadcast->disable();
//$formRebroadcast->disable();
return false;
}
}
/* This function is responsible for handling the case where the entire show (not a single show instance)
* was edited (via the context menu in the Calendar).
* There is still lots of clean-up to do. For example we shouldn't be passing $controller into
* this method to manipulate the view (this should be done inside the controller function). With
* 2.1 deadline looming, this is OK for now.
* Another clean-up is to move all the form manipulation to the proper form class.....
* -Martin
*/
/*public static function addUpdateShow($data, $controller, $validateStartDate,
$originalStartDate=null, $update=false, $instanceId=null)
{
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
$record = false;
$formWhat = new Application_Form_AddShowWhat();
$formWho = new Application_Form_AddShowWho();
$formWhen = new Application_Form_AddShowWhen();
$formRepeats = new Application_Form_AddShowRepeats();
$formStyle = new Application_Form_AddShowStyle();
$formLive = new Application_Form_AddShowLiveStream();
$formWhat->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper');
$formRepeats->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper');
$formLive->removeDecorator('DtDdWrapper');
$what = $formWhat->isValid($data);
$when = $formWhen->isValid($data);
$live = $formLive->isValid($data);
if ($when) {
$when = $formWhen->checkReliantFields($data, $validateStartDate, $originalStartDate, $update, $instanceId);
}
//The way the following code works is that is parses the hour and
//minute from a string with the format "1h 20m" or "2h" or "36m".
//So we are detecting whether an hour or minute value exists via strpos
//and then parse appropriately. A better way to do this in the future is
//actually pass the format from javascript in the format hh:mm so we don't
//have to do this extra String parsing.
$hPos = strpos($data["add_show_duration"], 'h');
$mPos = strpos($data["add_show_duration"], 'm');
$hValue = 0;
$mValue = 0;
if ($hPos !== false) {
$hValue = trim(substr($data["add_show_duration"], 0, $hPos));
}
if ($mPos !== false) {
$hPos = $hPos === false ? 0 : $hPos+1;
$mValue = trim(substr($data["add_show_duration"], $hPos, -1 ));
}
$data["add_show_duration"] = $hValue.":".$mValue;
$formRecord = new Application_Form_AddShowRR();
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
$formRebroadcast = new Application_Form_AddShowRebroadcastDates();
$formRecord->removeDecorator('DtDdWrapper');
$formAbsoluteRebroadcast->removeDecorator('DtDdWrapper');
$formRebroadcast->removeDecorator('DtDdWrapper');
$record = $formRecord->isValid($data);
if ($data["add_show_repeats"]) {
$repeats = $formRepeats->isValid($data);
if ($repeats) {
$repeats = $formRepeats->checkReliantFields($data);
}
$formAbsoluteRebroadcast->reset();
//make it valid, results don't matter anyways.
$rebroadAb = 1;
if ($data["add_show_rebroadcast"]) {
$rebroad = $formRebroadcast->isValid($data);
if ($rebroad) {
$rebroad = $formRebroadcast->checkReliantFields($data);
}
} else {
$rebroad = 1;
}
} else {
$repeats = 1;
$formRebroadcast->reset();
//make it valid, results don't matter anyways.
$rebroad = 1;
if ($data["add_show_rebroadcast"]) {
$rebroadAb = $formAbsoluteRebroadcast->isValid($data);
if ($rebroadAb) {
$rebroadAb = $formAbsoluteRebroadcast->checkReliantFields($data);
}
} else {
$rebroadAb = 1;
}
}
$who = $formWho->isValid($data);
$style = $formStyle->isValid($data);
if ($what && $when && $repeats && $who && $style && $live) {
if ($record && $rebroadAb && $rebroad) {
if ($isAdminOrPM) {
Application_Model_Show::create($data);
}
//send back a new form for the user.
Application_Model_Schedule::createNewFormSections($controller->view);
//$controller->view->newForm = $controller->view->render('schedule/add-show-form.phtml');
return true;
} else {
$controller->view->what = $formWhat;
$controller->view->when = $formWhen;
$controller->view->repeats = $formRepeats;
$controller->view->who = $formWho;
$controller->view->style = $formStyle;
$controller->view->rr = $formRecord;
$controller->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
$controller->view->rebroadcast = $formRebroadcast;
$controller->view->live = $formLive;
//$controller->view->addNewShow = !$editShow;
//$controller->view->form = $controller->view->render('schedule/add-show-form.phtml');
return false;
}
} else {
$controller->view->what = $formWhat;
$controller->view->when = $formWhen;
$controller->view->repeats = $formRepeats;
$controller->view->who = $formWho;
$controller->view->style = $formStyle;
$controller->view->live = $formLive;
$controller->view->rr = $formRecord;
$controller->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
$controller->view->rebroadcast = $formRebroadcast;
//$controller->view->addNewShow = !$editShow;
//$controller->view->form = $controller->view->render('schedule/add-show-form.phtml');
return false;
}
}*/
public static function checkOverlappingShows($show_start, $show_end,
$update=false, $instanceId=null, $showId=null)
{

View File

@ -977,8 +977,8 @@ SQL;
$content_count = Application_Model_ShowInstance::getContentCount(
$p_start, $p_end);
$isFull = Application_Model_ShowInstance::getIsFull($p_start, $p_end);
$userTimezone = Application_Model_Preference::GetUserTimezone();
$displayTimezone = new DateTimeZone($userTimezone);
$displayTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
$utc = new DateTimeZone("UTC");
$now = new DateTime("now", $utc);