From 5c7828c1f5866696f7b7cb05927e580b3cdc48ae Mon Sep 17 00:00:00 2001 From: Naomi Aro Date: Thu, 24 Nov 2011 11:56:24 +0100 Subject: [PATCH 1/8] CC-3102 : Show Editing, how it uses day of the week --- airtime_mvc/application/models/Show.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 799c98e08..1c5f8880e 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -856,7 +856,8 @@ class Application_Model_Show { //What we are doing here is checking if the show repeats or if //any repeating days have been checked. If not, then by default //the "selected" DOW is the initial day. - $startDow = gmdate("w", $utcStartDateTime->getTimestamp()); + //DOW is in the local timezone. + $startDow = date("w", $startDateTime); if (!$data['add_show_repeats']) { $data['add_show_day_check'] = array($startDow); } else if ($data['add_show_repeats'] && $data['add_show_day_check'] == "") { From e68d7afa3f3a40b1162c405eff59a1c333e43139 Mon Sep 17 00:00:00 2001 From: Naomi Aro Date: Thu, 24 Nov 2011 16:20:17 +0100 Subject: [PATCH 2/8] CC-3102 : Show Editing, how it uses day of the week --- airtime_mvc/application/models/Show.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 1c5f8880e..9dbd8b6ec 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -857,7 +857,7 @@ class Application_Model_Show { //any repeating days have been checked. If not, then by default //the "selected" DOW is the initial day. //DOW is in the local timezone. - $startDow = date("w", $startDateTime); + $startDow = date("w", $startDateTime->format('Y-m-d')); if (!$data['add_show_repeats']) { $data['add_show_day_check'] = array($startDow); } else if ($data['add_show_repeats'] && $data['add_show_day_check'] == "") { From 54ef9f2b03c91d3d60e0ea2a15b794732c459579 Mon Sep 17 00:00:00 2001 From: Naomi Aro Date: Thu, 24 Nov 2011 17:10:49 +0100 Subject: [PATCH 3/8] CC-3102 : Show Editing, how it uses day of the week not sure if this change should be here anymore yet. --- airtime_mvc/application/models/Show.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 9dbd8b6ec..799c98e08 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -856,8 +856,7 @@ class Application_Model_Show { //What we are doing here is checking if the show repeats or if //any repeating days have been checked. If not, then by default //the "selected" DOW is the initial day. - //DOW is in the local timezone. - $startDow = date("w", $startDateTime->format('Y-m-d')); + $startDow = gmdate("w", $utcStartDateTime->getTimestamp()); if (!$data['add_show_repeats']) { $data['add_show_day_check'] = array($startDow); } else if ($data['add_show_repeats'] && $data['add_show_day_check'] == "") { From 40b99dfc0f5702de9119253f4c9ecdbced707f1f Mon Sep 17 00:00:00 2001 From: Naomi Aro Date: Thu, 24 Nov 2011 19:39:08 +0100 Subject: [PATCH 4/8] CC-3085 : Repeating shows get added to the wrong days --- .../controllers/ScheduleController.php | 15 +++++++++------ airtime_mvc/application/models/Show.php | 15 ++++++++++++--- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 975824733..cd31e75bb 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -493,7 +493,7 @@ class ScheduleController extends Zend_Controller_Action $startsDateTime = new DateTime($show->getStartDate()." ".$show->getStartTime(), new DateTimeZone("UTC")); $endsDateTime = new DateTime($show->getEndDate()." ".$show->getEndTime(), new DateTimeZone("UTC")); - + $startsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); $endsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); @@ -508,13 +508,16 @@ class ScheduleController extends Zend_Controller_Action $formWhen->getElement('add_show_start_date')->setOptions(array('disabled' => true)); } + //need to get the days of the week in the php timezone (for the front end). $days = array(); $showDays = CcShowDaysQuery::create()->filterByDbShowId($showInstance->getShowId())->find(); foreach($showDays as $showDay){ - array_push($days, $showDay->getDbDay()); + $showStartDay = new DateTime($showDay->getDbFirstShow(), new DateTimeZone($showDay->getDbTimezone())); + $showStartDay->setTimezone(new DateTimeZone(date_default_timezone_get())); + array_push($days, $showStartDay->format('w')); } - $displayedEndDate = new DateTime($show->getRepeatingEndDate(), new DateTimeZone("UTC")); + $displayedEndDate = new DateTime($show->getRepeatingEndDate(), new DateTimeZone($showDays[0]->getDbTimezone())); $displayedEndDate->sub(new DateInterval("P1D"));//end dates are stored non-inclusively. $displayedEndDate->setTimezone(new DateTimeZone(date_default_timezone_get())); @@ -742,7 +745,7 @@ class ScheduleController extends Zend_Controller_Action $this->view->absoluteRebroadcast = $formAbsoluteRebroadcast; $this->view->rebroadcast = $formRebroadcast; $this->view->addNewShow = true; - + //the form still needs to be "update" since //the validity test failed. if ($data['add_show_id'] != -1){ @@ -751,9 +754,9 @@ class ScheduleController extends Zend_Controller_Action if (!$startDateModified){ $formWhen->getElement('add_show_start_date')->setOptions(array('disabled' => true)); } - + $this->view->form = $this->view->render('schedule/add-show-form.phtml'); - + } }else{ $userInfo = Zend_Auth::getInstance()->getStorage()->read(); diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 799c98e08..59cfbe4bc 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -187,14 +187,16 @@ class Application_Model_Show { $uncheckedDaysImploded = implode(",", $p_uncheckedDays); $showId = $this->getId(); - $date = new Application_Model_DateHelper; - $timestamp = $date->getTimestamp(); + $timestamp = gmdate("Y-m-d H:i:s"); $sql = "DELETE FROM cc_show_instances" ." WHERE EXTRACT(DOW FROM starts) IN ($uncheckedDaysImploded)" ." AND starts > TIMESTAMP '$timestamp'" ." AND show_id = $showId"; + Logging::log("sql for removing unchecked days"); + Logging::log($sql); + $CC_DBC->query($sql); } @@ -856,7 +858,8 @@ class Application_Model_Show { //What we are doing here is checking if the show repeats or if //any repeating days have been checked. If not, then by default //the "selected" DOW is the initial day. - $startDow = gmdate("w", $utcStartDateTime->getTimestamp()); + //DOW in local time. + $startDow = date("w", $startDateTime->getTimestamp()); if (!$data['add_show_repeats']) { $data['add_show_day_check'] = array($startDow); } else if ($data['add_show_repeats'] && $data['add_show_day_check'] == "") { @@ -907,7 +910,10 @@ class Application_Model_Show { $showDay->setDbRecord($isRecorded); $showDay->save(); } else { + Logging::log("startDow is: {$startDow}"); foreach ($data['add_show_day_check'] as $day) { + Logging::log("day is: {$day}"); + $daysAdd=0; $startDateTimeClone = clone $startDateTime; if ($startDow !== $day){ @@ -916,7 +922,10 @@ class Application_Model_Show { else $daysAdd = $day - $startDow; + Logging::log("days to add: {$daysAdd}"); + $startDateTimeClone->add(new DateInterval("P".$daysAdd."D")); + Logging::log("start date: {$startDateTimeClone->format("Y-m-d")}"); } if (is_null($endDate) || $startDateTimeClone->getTimestamp() <= $endDateTime->getTimestamp()) { $showDay = new CcShowDays(); From 276607c302ef9a0c9699867c315d5f0148b667f8 Mon Sep 17 00:00:00 2001 From: Yuchen Wang Date: Thu, 24 Nov 2011 13:54:58 -0500 Subject: [PATCH 5/8] CC-3104: Timezone issues in the widget For a previous ticket, I changed the code so that both "Today's Program" widget and "Now Playing" widget both use the liveInfoAction, but forgot that for "Now Playing" widget, it retrieves the shows within next 48 hours instead of within end of day today... Fixed by passing GET parameters to liveInfoAction, specify whether we want to retrieve shows within an interval or end of day. Also added a GET parameter for specifying the number of shows to display. --- .../application/controllers/ApiController.php | 32 +++++++++++++++++-- airtime_mvc/application/models/DateHelper.php | 2 +- airtime_mvc/application/models/Show.php | 4 +-- widgets/js/jquery.showinfo.js | 16 +++++++--- 4 files changed, 45 insertions(+), 9 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 7a4e81f4d..d70476e06 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -172,6 +172,21 @@ class ApiController extends Zend_Controller_Action return; } + /** + * Retrieve the currently playing show as well as upcoming shows. + * Number of shows returned and the time interval in which to + * get the next shows can be configured as post parameters. + * + * TODO: in the future, make interval length a parameter instead of hardcode to 48 + * + * Possible parameters: + * type - Can have values of "endofday" or "interval". If set to "endofday", + * the function will retrieve shows from now to end of day. + * If set to "interval", shows in the next 48 hours will be retrived. + * Default is "interval". + * limit - How many shows to retrieve + * Default is "5". + */ public function liveInfoAction() { if (Application_Model_Preference::GetAllow3rdPartyApi()){ @@ -181,11 +196,24 @@ class ApiController extends Zend_Controller_Action $date = new Application_Model_DateHelper; $utcTimeNow = $date->getUtcTimestamp(); + $utcTimeEnd = ""; // if empty, GetNextShows will use interval instead of end of day + + $request = $this->getRequest(); + $type = $request->getParam('type'); + if($type == "endofday") { + // make GetNextShows use end of day + $utcTimeEnd = Application_Model_DateHelper::GetDayEndTimestampInUtc(); + } + + $limit = $request->getParam('limit'); + if($limit == "") { + $limit = "5"; + } $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, 5), + "nextShow"=>Application_Model_Show::GetNextShows($utcTimeNow, $limit, $utcTimeEnd), "timezone"=> date("T"), "timezoneOffset"=> date("Z")); @@ -219,7 +247,7 @@ class ApiController extends Zend_Controller_Action $result = array(); for ($i=0; $i<7; $i++){ $utcDayEnd = Application_Model_DateHelper::GetDayEndTimestamp($utcDayStart); - $shows = Application_Model_Show::GetNextShows($utcDayStart, 0, $utcDayEnd); + $shows = Application_Model_Show::GetNextShows($utcDayStart, "0", $utcDayEnd); $utcDayStart = $utcDayEnd; Application_Model_Show::ConvertToLocalTimeZone($shows, array("starts", "ends", "start_timestamp", "end_timestamp")); diff --git a/airtime_mvc/application/models/DateHelper.php b/airtime_mvc/application/models/DateHelper.php index c223a909f..3ebc6f51d 100644 --- a/airtime_mvc/application/models/DateHelper.php +++ b/airtime_mvc/application/models/DateHelper.php @@ -84,7 +84,7 @@ class Application_Model_DateHelper public static function GetDayEndTimestampInUtc($time = "") { $dayEndTimestamp = Application_Model_DateHelper::GetDayEndTimestamp($time); - return Application_Model_DateHelper::ConvertToUtcDateTime($dayEndTimestamp); + return Application_Model_DateHelper::ConvertToUtcDateTimeString($dayEndTimestamp); } /** diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 799c98e08..f44855d46 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -1556,7 +1556,7 @@ class Application_Model_Show { * @param String $timeEnd - interval end time (in UTC) * @return array - the next $limit number of shows within the time interval */ - public static function GetNextShows($timeStart, $limit = 0, $timeEnd = "") + public static function GetNextShows($timeStart, $limit = "0", $timeEnd = "") { global $CC_CONFIG, $CC_DBC; @@ -1577,7 +1577,7 @@ class Application_Model_Show { ." ORDER BY si.starts"; // defaults to retrieve all shows within the interval if $limit not set - if($limit != 0) { + if($limit != "0") { $sql = $sql . " LIMIT $limit"; } diff --git a/widgets/js/jquery.showinfo.js b/widgets/js/jquery.showinfo.js index 1c75b7918..d1bdd7f3f 100644 --- a/widgets/js/jquery.showinfo.js +++ b/widgets/js/jquery.showinfo.js @@ -52,9 +52,13 @@ } function getServerData(){ - $.ajax({ url: options.sourceDomain + "api/live-info/", dataType:"jsonp", success:function(data){ + $.ajax({url: options.sourceDomain + "api/live-info/", + data: {type:"endofday",limit:"5"}, + dataType: "jsonp", + success:function(data) { processData(data); - }, error:airtimeScheduleJsonpError}); + }, + error: airtimeScheduleJsonpError}); setTimeout(getServerData, options.updatePeriod*1000); } }); @@ -130,9 +134,13 @@ } function getServerData(){ - $.ajax({ url: options.sourceDomain + "api/live-info/", dataType:"jsonp", success:function(data){ + $.ajax({url: options.sourceDomain + "api/live-info/", + data: {type:"interval",limit:"5"}, + dataType: "jsonp", + success: function(data) { processData(data); - }, error:airtimeScheduleJsonpError}); + }, + error: airtimeScheduleJsonpError}); setTimeout(getServerData, options.updatePeriod*1000); } }); From 00cb9e87538ed96f9308716444c8537bdc3137a3 Mon Sep 17 00:00:00 2001 From: Yuchen Wang Date: Thu, 24 Nov 2011 14:03:37 -0500 Subject: [PATCH 6/8] CC-3108: Version update indicator: Wrong message for minor version update Fixed --- airtime_mvc/public/js/airtime/dashboard/versiontooltip.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/public/js/airtime/dashboard/versiontooltip.js b/airtime_mvc/public/js/airtime/dashboard/versiontooltip.js index 1032a83f7..7e70e732e 100644 --- a/airtime_mvc/public/js/airtime/dashboard/versiontooltip.js +++ b/airtime_mvc/public/js/airtime/dashboard/versiontooltip.js @@ -8,7 +8,7 @@ function getContent() { var msg = ""; if(isUpToDate()) { msg = "You are running the latest version"; - } else if(diff == 1) { + } else if(diff <= 1) { // new version is possible when major diff = 0 msg = "New version available: " + link; } else if(diff == 2) { msg = "This version will soon be obsolete.
Please upgrade to " + link; From ee3a6ecd848b40acfd326abdfd63ba26635b113a Mon Sep 17 00:00:00 2001 From: Yuchen Wang Date: Thu, 24 Nov 2011 14:10:04 -0500 Subject: [PATCH 7/8] CC-3089: Link to manual in Help menu should point to manuals.sourcefabric.org rather than flossmanuals.net Fixed --- airtime_mvc/application/configs/navigation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/configs/navigation.php b/airtime_mvc/application/configs/navigation.php index 82037006a..74c360b08 100644 --- a/airtime_mvc/application/configs/navigation.php +++ b/airtime_mvc/application/configs/navigation.php @@ -96,7 +96,7 @@ $pages = array( ), array( 'label' => 'User Manual', - 'uri' => "http://en.flossmanuals.net/airtime/", + 'uri' => "http://manuals.sourcefabric.org/", 'target' => "_blank" ), array( From 485a0e8cc63072e3731bdbab9392270c27a3278c Mon Sep 17 00:00:00 2001 From: Yuchen Wang Date: Thu, 24 Nov 2011 15:45:39 -0500 Subject: [PATCH 8/8] CC-3093: SoundCloud preferences do not have email or password as required fields + firefox auto-fills the password field I just realized this: 1. Enable "Enable Soundcloud Upload" in preference and fill in the username+password, click save 2. Go back to preference, change unrelated setting like "Station Name", click save 3. Now since soundcloud password field is empty (expected, as we don't want others to see how many digits are there), the save failed This commit is to fix this. Created another custom validator for the password field, which does the same thing as ConditionalNotEmpty validator but allow password field to be empty when the username/email field wasn't changed. --- .../forms/SoundcloudPreferences.php | 3 ++- .../customvalidators/PasswordNotEmpty.php | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 airtime_mvc/application/forms/customvalidators/PasswordNotEmpty.php diff --git a/airtime_mvc/application/forms/SoundcloudPreferences.php b/airtime_mvc/application/forms/SoundcloudPreferences.php index 8fe460c15..e948ba4f4 100644 --- a/airtime_mvc/application/forms/SoundcloudPreferences.php +++ b/airtime_mvc/application/forms/SoundcloudPreferences.php @@ -1,5 +1,6 @@ false, 'validators' => array( - new ConditionalNotEmpty(array('UploadToSoundcloudOption'=>'1')) + new PasswordNotEmpty(array('UploadToSoundcloudOption'=>'1')) ) )); diff --git a/airtime_mvc/application/forms/customvalidators/PasswordNotEmpty.php b/airtime_mvc/application/forms/customvalidators/PasswordNotEmpty.php new file mode 100644 index 000000000..11e62b933 --- /dev/null +++ b/airtime_mvc/application/forms/customvalidators/PasswordNotEmpty.php @@ -0,0 +1,18 @@ +