From c9644d4a73453825a03543c59a614d0d5fd3114a Mon Sep 17 00:00:00 2001 From: James Date: Fri, 25 Nov 2011 15:38:29 -0500 Subject: [PATCH 1/7] CC-3077: Preference/stream-setting page has no Vorbis metadata option - cleaning up some code --- airtime_mvc/application/controllers/PreferenceController.php | 1 - airtime_mvc/application/forms/StreamSetting.php | 2 +- airtime_mvc/application/models/StreamSetting.php | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index bf81e44af..ec846c52e 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -199,7 +199,6 @@ class PreferenceController extends Zend_Controller_Action $values['icecast_vorbis_metadata'] = $form->getValue('icecast_vorbis_metadata'); } - var_dump($form->getValue('icecast_vorbis_metadata')); if(!$error){ Application_Model_StreamSetting::setStreamSetting($values); $data = array(); diff --git a/airtime_mvc/application/forms/StreamSetting.php b/airtime_mvc/application/forms/StreamSetting.php index fc07544a5..857e4e3a8 100644 --- a/airtime_mvc/application/forms/StreamSetting.php +++ b/airtime_mvc/application/forms/StreamSetting.php @@ -28,7 +28,7 @@ class Application_Form_StreamSetting extends Zend_Form } $icecast_vorbis_metadata = new Zend_Form_Element_Checkbox('icecast_vorbis_metadata'); - $icecast_vorbis_metadata->setLabel('Icecast Vorbis Meatadata') + $icecast_vorbis_metadata->setLabel('Icecast Vorbis Metadata') ->setRequired(false) ->setValue(($setting['icecast_vorbis_metadata'] == "true")?1:0) ->setDecorators(array('ViewHelper')); diff --git a/airtime_mvc/application/models/StreamSetting.php b/airtime_mvc/application/models/StreamSetting.php index 577bab05c..a3c416ed4 100644 --- a/airtime_mvc/application/models/StreamSetting.php +++ b/airtime_mvc/application/models/StreamSetting.php @@ -66,7 +66,6 @@ class Application_Model_StreamSetting { $CC_DBC->query($sql); } else{ - var_dump($key); $temp = explode('_', $key); $prefix = $temp[0]; foreach($d as $k=>$v){ From 267d48f640cdcf9607a0aa4b5d0c4742bf8ac829 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 25 Nov 2011 17:33:59 -0500 Subject: [PATCH 2/7] SAAS-82: Add "airtime-system --status" command - add a function that returns just global data of stream setting --- .../application/models/StreamSetting.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/StreamSetting.php b/airtime_mvc/application/models/StreamSetting.php index a3c416ed4..d14843d8b 100644 --- a/airtime_mvc/application/models/StreamSetting.php +++ b/airtime_mvc/application/models/StreamSetting.php @@ -21,7 +21,23 @@ class Application_Model_StreamSetting { return $ids; } - + + /* Retruns only global data as array*/ + public static function getGlobalData(){ + global $CC_DBC; + $sql = "SELECT * " + ."FROM cc_stream_setting " + ."WHERE keyname IN ('output_sound_device', 'icecast_vorbis_metadata')"; + + $rows = $CC_DBC->getAll($sql); + $data = array(); + + foreach($rows as $row){ + $data[$row["keyname"]] = $row["value"]; + } + + return $data; + } /* Returns all information related to a specific stream. An example * of a stream id is 's1' or 's2'. */ public static function getStreamData($p_streamId){ From b1193318edb8513b4763795bd7df5797fa0ee6f0 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 25 Nov 2011 17:36:11 -0500 Subject: [PATCH 3/7] CC-3105: Settings dates (the popup select date calendar) shows Today by local machine timezone and not Airtime timezone. -fixed --- .../controllers/NowplayingController.php | 8 ++++++++ .../controllers/ScheduleController.php | 6 +++++- airtime_mvc/public/js/airtime/common/common.js | 13 +++++++++++++ .../js/airtime/nowplaying/nowplayingdatagrid.js | 2 +- .../public/js/airtime/schedule/add-show.js | 7 +++---- .../airtime/schedule/full-calendar-functions.js | 15 +-------------- .../public/js/fullcalendar/AIRTIME_DEV_README | 2 +- 7 files changed, 32 insertions(+), 21 deletions(-) diff --git a/airtime_mvc/application/controllers/NowplayingController.php b/airtime_mvc/application/controllers/NowplayingController.php index 0cf0a3850..39841ab78 100644 --- a/airtime_mvc/application/controllers/NowplayingController.php +++ b/airtime_mvc/application/controllers/NowplayingController.php @@ -18,7 +18,11 @@ class NowplayingController extends Zend_Controller_Action $baseUrl = $request->getBaseUrl(); $this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.min.js','text/javascript'); + + //nowplayingdatagrid.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/nowplaying/nowplayingdatagrid.js','text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/nowview.js','text/javascript'); $refer_sses = new Zend_Session_Namespace('referrer'); @@ -104,7 +108,11 @@ class NowplayingController extends Zend_Controller_Action $baseUrl = $request->getBaseUrl(); $this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.min.js','text/javascript'); + + //nowplayingdatagrid.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/nowplaying/nowplayingdatagrid.js','text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/dayview.js','text/javascript'); } diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index cd31e75bb..1e3d2b896 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -46,8 +46,12 @@ class ScheduleController extends Zend_Controller_Action $this->view->headScript()->appendFile($baseUrl.'/js/fullcalendar/fullcalendar.js','text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/timepicker/jquery.ui.timepicker-0.0.6.js','text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/colorpicker/js/colorpicker.js','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','text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/add-show.js','text/javascript'); + + $this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/add-show.js','text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/schedule.js','text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/meioMask/jquery.meio.mask.js','text/javascript'); diff --git a/airtime_mvc/public/js/airtime/common/common.js b/airtime_mvc/public/js/airtime/common/common.js index 10736e837..85fe984e6 100644 --- a/airtime_mvc/public/js/airtime/common/common.js +++ b/airtime_mvc/public/js/airtime/common/common.js @@ -6,3 +6,16 @@ $(document).ready(function() { savePanelSpace: true }); }); + +function adjustDateToServerDate(date, serverTimezoneOffset){ + //date object stores time in the browser's localtime. We need to artificially shift + //it to + var timezoneOffset = date.getTimezoneOffset()*60*1000; + + date.setTime(date.getTime() + timezoneOffset + serverTimezoneOffset*1000); + + /* date object has been shifted to artificial UTC time. Now let's + * shift it to the server's timezone */ + + return date; +} diff --git a/airtime_mvc/public/js/airtime/nowplaying/nowplayingdatagrid.js b/airtime_mvc/public/js/airtime/nowplaying/nowplayingdatagrid.js index d56d5b33a..2eea84acb 100644 --- a/airtime_mvc/public/js/airtime/nowplaying/nowplayingdatagrid.js +++ b/airtime_mvc/public/js/airtime/nowplaying/nowplayingdatagrid.js @@ -204,7 +204,7 @@ $(document).ready(function() { $("#datepicker").datepicker({ onSelect: function(dateText, inst) { getData();}}); - $("#datepicker").datepicker("setDate", new Date()); + $("#datepicker").datepicker("setDate", adjustDateToServerDate(new Date(), timezoneOffset)); } else { $('#day_view').click(function(){redirect('/Nowplaying/day-view')}); } diff --git a/airtime_mvc/public/js/airtime/schedule/add-show.js b/airtime_mvc/public/js/airtime/schedule/add-show.js index 49a0c4bea..65bafc04c 100644 --- a/airtime_mvc/public/js/airtime/schedule/add-show.js +++ b/airtime_mvc/public/js/airtime/schedule/add-show.js @@ -19,11 +19,10 @@ function startDpSelect(dateText, inst) { function endDpSelect(dateText, inst) { var time, date; - + time = dateText.split("-"); date = new Date(time[0], time[1] - 1, time[2]); - //$("#add_show_start_date").datepicker( "option", "maxDate", date); if (inst.input) inst.input.trigger('change'); } @@ -32,7 +31,7 @@ function createDateInput(el, onSelect) { var date; el.datepicker({ - minDate: new Date(), + minDate: adjustDateToServerDate(new Date(), timezoneOffset), onSelect: onSelect, dateFormat: 'yy-mm-dd' }); @@ -188,7 +187,7 @@ function setAddShowEvents() { }); form.find('input[name^="add_show_rebroadcast_date_absolute"]').datepicker({ - minDate: new Date(), + minDate: adjustDateToServerDate(new Date(), timezoneOffset), dateFormat: 'yy-mm-dd' }); form.find('input[name^="add_show_rebroadcast_time"]').timepicker({ diff --git a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js index 898144376..7910f498f 100644 --- a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js +++ b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js @@ -75,19 +75,6 @@ function makeTimeStamp(date){ return timestamp; } -function adjustDateToServerDate(date, serverTimezoneOffset){ - //date object stores time in the browser's localtime. We need to artificially shift - //it to - var timezoneOffset = date.getTimezoneOffset()*60*1000; - - date.setTime(date.getTime() + timezoneOffset + serverTimezoneOffset*1000); - - /* date object has been shifted to artificial UTC time. Now let's - * shift it to the server's timezone */ - - return date; -} - function pad(number, length) { var str = '' + number; while (str.length < length) { @@ -101,7 +88,7 @@ function dayClick(date, allDay, jsEvent, view) { var now, today, selected, chosenDate, chosenTime; now = adjustDateToServerDate(new Date(), serverTimezoneOffset); - + if(view.name === "month") { today = new Date(now.getFullYear(), now.getMonth(), now.getDate()); selected = new Date(date.getFullYear(), date.getMonth(), date.getDate()); diff --git a/airtime_mvc/public/js/fullcalendar/AIRTIME_DEV_README b/airtime_mvc/public/js/fullcalendar/AIRTIME_DEV_README index 468b1e497..ffa4294a0 100644 --- a/airtime_mvc/public/js/fullcalendar/AIRTIME_DEV_README +++ b/airtime_mvc/public/js/fullcalendar/AIRTIME_DEV_README @@ -50,7 +50,7 @@ martin@Thinkpad-T410:~/workspace/airtime/airtime_mvc/public/js/fullcalendar$ dif +})(jQuery); -adjustDateToServerDate() function is defined in "js/airtime/schedule/full-calendar-functions.js" +adjustDateToServerDate() function is defined in "js/airtime/common/common.js" Please make this change before updating!!! From 757b2cac4ff17bd6bc857e6a0f7fbeb54f83712f Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 25 Nov 2011 18:02:56 -0500 Subject: [PATCH 4/7] CC-3041: Module virtualenv was already imported -hid the error message. --- python_apps/python-virtualenv/virtualenv-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python_apps/python-virtualenv/virtualenv-install.sh b/python_apps/python-virtualenv/virtualenv-install.sh index 580c675e8..757d22008 100755 --- a/python_apps/python-virtualenv/virtualenv-install.sh +++ b/python_apps/python-virtualenv/virtualenv-install.sh @@ -38,14 +38,14 @@ echo -e "\n*** Creating Virtualenv for Airtime ***" EXTRAOPTION=$(virtualenv --help | grep extra-search-dir) if [ "$?" -eq "0" ]; then -virtualenv --extra-search-dir=${SCRIPTPATH}/3rd_party --no-site-package -p /usr/bin/python2.6 /usr/lib/airtime/airtime_virtualenv || exit 1 + virtualenv --extra-search-dir=${SCRIPTPATH}/3rd_party --no-site-package -p /usr/bin/python2.6 /usr/lib/airtime/airtime_virtualenv 2>/dev/null || exit 1 else # copy distribute-0.6.10.tar.gz to /usr/share/python-virtualenv/ # this is due to the bug in virtualenv 1.4.9 if [ -d "$VIRTUAL_ENV_SHARE" ]; then cp ${SCRIPTPATH}/3rd_party/distribute-0.6.10.tar.gz /usr/share/python-virtualenv/ fi - virtualenv --no-site-package -p /usr/bin/python2.6 /usr/lib/airtime/airtime_virtualenv || exit 1 + virtualenv --no-site-package -p /usr/bin/python2.6 /usr/lib/airtime/airtime_virtualenv 2>/dev/null || exit 1 fi echo -e "\n*** Installing Python Libraries ***" From f03b875e066e6c2326f3d8c1f2486217f729da9b Mon Sep 17 00:00:00 2001 From: Yuchen Wang Date: Fri, 25 Nov 2011 21:33:42 -0500 Subject: [PATCH 5/7] CC-3084: After canceling a repeating show that is being played currently, the progress bar is still going at the top Deleted show was being returned because we don't delete it from database if it's repeating, nor do we check if it's modified when querying the db. Fixed by checking modified_instance column; only return it if modified_instance != TRUE --- airtime_mvc/application/models/Show.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 1f90d15c5..bedc14a5b 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -1545,7 +1545,8 @@ class Application_Model_Show { ." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s" ." WHERE si.show_id = s.id" ." AND si.starts <= TIMESTAMP '$timeNow'" - ." AND si.ends > TIMESTAMP '$timeNow'"; + ." AND si.ends > TIMESTAMP '$timeNow'" + ." AND modified_instance != TRUE"; // Convert back to local timezone $rows = $CC_DBC->GetAll($sql); @@ -1583,6 +1584,7 @@ class Application_Model_Show { ." WHERE si.show_id = s.id" ." AND si.starts >= TIMESTAMP '$timeStart'" ." AND si.starts < TIMESTAMP $timeEnd" + ." AND modified_instance != TRUE" ." ORDER BY si.starts"; // defaults to retrieve all shows within the interval if $limit not set @@ -1605,6 +1607,9 @@ class Application_Model_Show { public static function ConvertToLocalTimeZone(&$rows, $columnsToConvert) { $timezone = date_default_timezone_get(); + if (!is_array($rows)) { + return; + } foreach($rows as &$row) { foreach($columnsToConvert as $column) { $row[$column] = Application_Model_DateHelper::ConvertToLocalDateTimeString($row[$column]); From 197997fee766ffecc5b528d03b10ba410756e448 Mon Sep 17 00:00:00 2001 From: Yuchen Wang Date: Fri, 25 Nov 2011 21:52:31 -0500 Subject: [PATCH 6/7] CC-3093: SoundCloud preferences do not have email or password as required fields + firefox auto-fills the password field Mask the password instead of hiding it --- airtime_mvc/application/forms/SoundcloudPreferences.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/forms/SoundcloudPreferences.php b/airtime_mvc/application/forms/SoundcloudPreferences.php index e948ba4f4..b2840d580 100644 --- a/airtime_mvc/application/forms/SoundcloudPreferences.php +++ b/airtime_mvc/application/forms/SoundcloudPreferences.php @@ -77,8 +77,9 @@ class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm // which is something we don't want 'allowEmpty' => false, 'validators' => array( - new PasswordNotEmpty(array('UploadToSoundcloudOption'=>'1')) - ) + new ConditionalNotEmpty(array('UploadToSoundcloudOption'=>'1')) + ), + 'renderPassword' => true )); // Add the description element From 317bed864387c798247cd650e1700ed7fad69534 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Sat, 26 Nov 2011 00:06:17 -0500 Subject: [PATCH 7/7] CC-3094: Rebroadcast editing problems -Fixed --- airtime_mvc/application/models/Show.php | 29 ++++++++++++++++--- .../application/models/ShowInstance.php | 10 +++++-- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index f7bfd060c..3730d3870 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -1524,21 +1524,42 @@ class Application_Model_Show { return $event; } - public function setShowFirstShow($s_date){ + /* Takes in a UTC DateTime object. + * Converts this to local time, since cc_show days + * requires local time. */ + public function setShowFirstShow($p_dt){ + + //clone object since we are modifying it and it was passed by reference. + $dt = clone $p_dt; + + $dt->setTimezone(new DateTimeZone(date_default_timezone_get())); + $showDay = CcShowDaysQuery::create() ->filterByDbShowId($this->_showId) ->findOne(); - $showDay->setDbFirstShow($s_date) + $showDay->setDbFirstShow($dt) ->save(); } - public function setShowLastShow($e_date){ + /* Takes in a UTC DateTime object + * Converts this to local time, since cc_show days + * requires local time. */ + public function setShowLastShow($p_dt){ + + //clone object since we are modifying it and it was passed by reference. + $dt = clone $p_dt; + + $dt->setTimezone(new DateTimeZone(date_default_timezone_get())); + + //add one day since the Last Show date in CcShowDays is non-inclusive. + $dt->add(new DateInterval("P1D")); + $showDay = CcShowDaysQuery::create() ->filterByDbShowId($this->_showId) ->findOne(); - $showDay->setDbLastShow($e_date) + $showDay->setDbLastShow($dt) ->save(); } diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index 058a00db3..f0bd25490 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -29,6 +29,10 @@ class Application_Model_ShowInstance { return new Application_Model_Show($this->getShowId()); } + /* This function is weird. It should return a boolean, but instead returns + * an integer if it is a rebroadcast, or returns null if it isn't. You can convert + * it to boolean by using is_null(isRebroadcast), where true means isn't and false + * means that it is. */ public function isRebroadcast() { return $this->_showInstance->getDbOriginalShow(); @@ -231,9 +235,9 @@ class Application_Model_ShowInstance { $this->correctScheduleStartTimes(); $show = new Application_Model_Show($this->getShowId()); - if(!$show->isRepeating()){ - $show->setShowFirstShow($new_starts); - $show->setShowLastShow($new_ends); + if(!$show->isRepeating() && is_null($this->isRebroadcast())){ + $show->setShowFirstShow($newStartsDateTime); + $show->setShowLastShow($newEndsDateTime); } Application_Model_RabbitMq::PushSchedule();