From 492c76cb2f671875ee0aa2421a117038b7848a82 Mon Sep 17 00:00:00 2001 From: Naomi Date: Wed, 13 Apr 2011 15:11:06 -0400 Subject: [PATCH 01/11] CC-2176 : Allow up to 10 rebroadcasts, add in the plus button with hidden elements creating elements inside for loop to be less redundant. --- .../forms/AddShowAbsoluteRebroadcastDates.php | 182 ++---------------- application/forms/AddShowRebroadcastDates.php | 141 ++------------ 2 files changed, 34 insertions(+), 289 deletions(-) diff --git a/application/forms/AddShowAbsoluteRebroadcastDates.php b/application/forms/AddShowAbsoluteRebroadcastDates.php index 7d173df2a..8c87b66c7 100644 --- a/application/forms/AddShowAbsoluteRebroadcastDates.php +++ b/application/forms/AddShowAbsoluteRebroadcastDates.php @@ -5,177 +5,29 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm public function init() { - //$this->setDisableLoadDefaultDecorators(true); - $this->setDecorators(array( array('ViewScript', array('viewScript' => 'form/add-show-rebroadcast-absolute.phtml')) )); - // Add start date element - $this->addElement('text', 'add_show_rebroadcast_absolute_date_1', array( - 'label' => 'Rebroadcast Date:', - 'class' => 'input_text', - 'required' => false, - 'value' => '', - 'filters' => array('StringTrim'), - 'validators' => array( - 'NotEmpty', - array('date', false, array('YYYY-MM-DD')) - ), - 'decorators' => array( - 'ViewHelper' - ) - )); + for($i=1; $i<=10; $i++) { - - // Add start time element - $this->addElement('text', 'add_show_rebroadcast_absolute_time_1', array( - 'label' => 'Rebroadcast Time:', - 'class' => 'input_text', - 'required' => false, - 'value' => '', - 'filters' => array('StringTrim'), - 'validators' => array( - array('date', false, array('HH:mm')), - array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered')) - ), - 'decorators' => array( - 'ViewHelper' - ) - )); - - // Add start date element - $this->addElement('text', 'add_show_rebroadcast_absolute_date_2', array( - 'label' => 'Rebroadcast Date:', - 'class' => 'input_text', - 'required' => false, - 'value' => '', - 'filters' => array('StringTrim'), - 'validators' => array( - 'NotEmpty', - array('date', false, array('YYYY-MM-DD')) - ), - 'decorators' => array( - 'ViewHelper' - ) - )); - - - // Add start time element - $this->addElement('text', 'add_show_rebroadcast_absolute_time_2', array( - 'label' => 'Rebroadcast Time:', - 'class' => 'input_text', - 'required' => false, - 'value' => '', - 'filters' => array('StringTrim'), - 'validators' => array( - array('date', false, array('HH:mm')), - array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered')) - ), - 'decorators' => array( - 'ViewHelper' - ) - )); - - // Add start date element - $this->addElement('text', 'add_show_rebroadcast_absolute_date_3', array( - 'label' => 'Rebroadcast Date:', - 'class' => 'input_text', - 'required' => false, - 'value' => '', - 'filters' => array('StringTrim'), - 'validators' => array( - 'NotEmpty', - array('date', false, array('YYYY-MM-DD')) - ), - 'decorators' => array( - 'ViewHelper' - ) - )); - - - // Add start time element - $this->addElement('text', 'add_show_rebroadcast_absolute_time_3', array( - 'label' => 'Rebroadcast Time:', - 'class' => 'input_text', - 'required' => false, - 'value' => '', - 'filters' => array('StringTrim'), - 'validators' => array( - array('date', false, array('HH:mm')), - array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered')) - ), - 'decorators' => array( - 'ViewHelper' - ) - )); - - // Add start date element - $this->addElement('text', 'add_show_rebroadcast_absolute_date_4', array( - 'label' => 'Rebroadcast Date:', - 'class' => 'input_text', - 'required' => false, - 'value' => '', - 'filters' => array('StringTrim'), - 'validators' => array( - 'NotEmpty', - array('date', false, array('YYYY-MM-DD')) - ), - 'decorators' => array( - 'ViewHelper' - ) - )); - - - // Add start time element - $this->addElement('text', 'add_show_rebroadcast_absolute_time_4', array( - 'label' => 'Rebroadcast Time:', - 'class' => 'input_text', - 'required' => false, - 'value' => '', - 'filters' => array('StringTrim'), - 'validators' => array( - array('date', false, array('HH:mm')), - array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered')) - ), - 'decorators' => array( - 'ViewHelper' - ) - )); - - // Add start date element - $this->addElement('text', 'add_show_rebroadcast_absolute_date_5', array( - 'label' => 'Rebroadcast Date:', - 'class' => 'input_text', - 'required' => false, - 'value' => '', - 'filters' => array('StringTrim'), - 'validators' => array( - 'NotEmpty', - array('date', false, array('YYYY-MM-DD')) - ), - 'decorators' => array( - 'ViewHelper' - ) - )); - - - // Add start time element - $this->addElement('text', 'add_show_rebroadcast_absolute_time_5', array( - 'label' => 'Rebroadcast Time:', - 'class' => 'input_text', - 'required' => false, - 'value' => '', - 'filters' => array('StringTrim'), - 'validators' => array( - array('date', false, array('HH:mm')), - array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered')) - ), - 'decorators' => array( - 'ViewHelper' - ) - )); + $text = new Zend_Form_Element_Text("add_show_rebroadcast_absolute_date_$i"); + $text->setAttrib('class', 'input_text'); + $text->addFilter('StringTrim'); + $text->addValidator('date', false, array('YYYY-MM-DD')); + $text->setRequired(false); + $text->setDecorators(array('ViewHelper')); + $this->addElement($text); + $text = new Zend_Form_Element_Text("add_show_rebroadcast_absolute_time_$i"); + $text->setAttrib('class', 'input_text'); + $text->addFilter('StringTrim'); + $text->addValidator('date', false, array('HH:mm')); + $text->addValidator('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered')); + $text->setRequired(false); + $text->setDecorators(array('ViewHelper')); + $this->addElement($text); + } } public function checkReliantFields($formData) { diff --git a/application/forms/AddShowRebroadcastDates.php b/application/forms/AddShowRebroadcastDates.php index 22e28a1a3..3a8cba562 100644 --- a/application/forms/AddShowRebroadcastDates.php +++ b/application/forms/AddShowRebroadcastDates.php @@ -9,137 +9,30 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm array('ViewScript', array('viewScript' => 'form/add-show-rebroadcast.phtml')) )); - $relativeDates = array(); $relativeDates[""] = ""; - for($i=0; $i <=30; $i++) { + for($i=0; $i<=30; $i++) { $relativeDates["$i days"] = "+$i days"; } - //Add date select - $this->addElement('select', 'add_show_rebroadcast_date_1', array( - 'required' => false, - 'class' => ' input_select', - 'multiOptions' => $relativeDates, - 'decorators' => array( - 'ViewHelper' - ) - )); + for($i=1; $i<=10; $i++) { - // Add start time element - $this->addElement('text', 'add_show_rebroadcast_time_1', array( - 'class' => 'input_text', - 'required' => false, - 'value' => '', - 'filters' => array('StringTrim'), - 'validators' => array( - array('date', false, array('HH:mm')), - array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered')) - ), - 'decorators' => array( - 'ViewHelper' - ) - )); + $select = new Zend_Form_Element_Select("add_show_rebroadcast_date_$i"); + $select->setAttrib('class', 'input_select'); + $select->setMultiOptions($relativeDates); + $select->setRequired(false); + $select->setDecorators(array('ViewHelper')); + $this->addElement($select); - //Add date select - $this->addElement('select', 'add_show_rebroadcast_date_2', array( - 'required' => false, - 'class' => ' input_select', - 'multiOptions' => $relativeDates, - 'decorators' => array( - 'ViewHelper' - ) - )); - - // Add start time element - $this->addElement('text', 'add_show_rebroadcast_time_2', array( - 'class' => 'input_text', - 'required' => false, - 'value' => '', - 'filters' => array('StringTrim'), - 'validators' => array( - array('date', false, array('HH:mm')), - array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered')) - ), - 'decorators' => array( - 'ViewHelper' - ) - )); - - //Add date select - $this->addElement('select', 'add_show_rebroadcast_date_3', array( - 'required' => false, - 'class' => ' input_select', - 'multiOptions' => $relativeDates, - 'decorators' => array( - 'ViewHelper' - ) - )); - - // Add start time element - $this->addElement('text', 'add_show_rebroadcast_time_3', array( - 'class' => 'input_text', - 'required' => false, - 'value' => '', - 'filters' => array('StringTrim'), - 'validators' => array( - array('date', false, array('HH:mm')), - array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered')) - ), - 'decorators' => array( - 'ViewHelper' - ) - )); - - //Add date select - $this->addElement('select', 'add_show_rebroadcast_date_4', array( - 'required' => false, - 'class' => ' input_select', - 'multiOptions' => $relativeDates, - 'decorators' => array( - 'ViewHelper' - ) - )); - - // Add start time element - $this->addElement('text', 'add_show_rebroadcast_time_4', array( - 'class' => 'input_text', - 'required' => false, - 'value' => '', - 'filters' => array('StringTrim'), - 'validators' => array( - array('date', false, array('HH:mm')), - array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered')) - ), - 'decorators' => array( - 'ViewHelper' - ) - )); - - //Add date select - $this->addElement('select', 'add_show_rebroadcast_date_5', array( - 'required' => false, - 'class' => ' input_select', - 'multiOptions' => $relativeDates, - 'decorators' => array( - 'ViewHelper' - ) - )); - - // Add start time element - $this->addElement('text', 'add_show_rebroadcast_time_5', array( - 'class' => 'input_text', - 'required' => false, - 'value' => '', - 'filters' => array('StringTrim'), - 'validators' => array( - array('date', false, array('HH:mm')), - array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered')) - ), - 'decorators' => array( - 'ViewHelper' - ) - )); + $text = new Zend_Form_Element_Text("add_show_rebroadcast_time_$i"); + $text->setAttrib('class', 'input_text'); + $text->addFilter('StringTrim'); + $text->addValidator('date', false, array('HH:mm')); + $text->addValidator('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered')); + $text->setRequired(false); + $text->setDecorators(array('ViewHelper')); + $this->addElement($text); + } } public function checkReliantFields($formData) { From 5b0121712b64e3503cf4876d1a46766e27e6ea1c Mon Sep 17 00:00:00 2001 From: martin Date: Wed, 13 Apr 2011 16:59:53 -0400 Subject: [PATCH 02/11] CC-2181: No cancel button on Update show -Pressing "Close" will now clear the form -Editing show will now hide "+ Show" button --- .../controllers/ScheduleController.php | 42 +++++++++++++++++-- .../views/scripts/schedule/edit-show.phtml | 3 +- .../views/scripts/schedule/get-form.phtml | 1 + public/js/airtime/schedule/add-show.js | 7 ++++ .../schedule/full-calendar-functions.js | 19 +++++---- public/js/playlist/nowplayingdatagrid.js | 4 +- 6 files changed, 62 insertions(+), 14 deletions(-) create mode 100644 application/views/scripts/schedule/get-form.phtml diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php index f713dc8cd..bada06562 100644 --- a/application/controllers/ScheduleController.php +++ b/application/controllers/ScheduleController.php @@ -25,6 +25,7 @@ class ScheduleController extends Zend_Controller_Action ->addActionContext('edit-show', 'json') ->addActionContext('add-show', 'json') ->addActionContext('cancel-show', 'json') + ->addActionContext('get-form', 'json') ->addActionContext('upload-to-sound-cloud', 'json') ->initContext(); @@ -48,8 +49,6 @@ class ScheduleController extends Zend_Controller_Action $this->view->headLink()->appendStylesheet('/css/add-show.css'); $this->view->headLink()->appendStylesheet('/css/contextmenu.css'); - $request = $this->getRequest(); - $formWhat = new Application_Form_AddShowWhat(); $formWho = new Application_Form_AddShowWho(); $formWhen = new Application_Form_AddShowWhen(); @@ -66,7 +65,6 @@ class ScheduleController extends Zend_Controller_Action $formStyle->removeDecorator('DtDdWrapper'); $formRecord->removeDecorator('DtDdWrapper'); - $this->view->what = $formWhat; $this->view->when = $formWhen; $this->view->repeats = $formRepeats; @@ -399,6 +397,12 @@ class ScheduleController extends Zend_Controller_Action public function editShowAction() { + $userInfo = Zend_Auth::getInstance()->getStorage()->read(); + $user = new User($userInfo->id); + if(!$user->isAdmin()) { + return; + } + $showInstanceId = $this->_getParam('id'); $formWhat = new Application_Form_AddShowWhat(); @@ -495,6 +499,38 @@ class ScheduleController extends Zend_Controller_Action $this->view->entries = 5; } + public function getFormAction(){ + $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(); + $formRecord = new Application_Form_AddShowRR(); + $formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates(); + $formRebroadcast = new Application_Form_AddShowRebroadcastDates(); + + $formWhat->removeDecorator('DtDdWrapper'); + $formWho->removeDecorator('DtDdWrapper'); + $formWhen->removeDecorator('DtDdWrapper'); + $formRepeats->removeDecorator('DtDdWrapper'); + $formStyle->removeDecorator('DtDdWrapper'); + $formRecord->removeDecorator('DtDdWrapper'); + + $this->view->what = $formWhat; + $this->view->when = $formWhen; + $this->view->repeats = $formRepeats; + $this->view->who = $formWho; + $this->view->style = $formStyle; + $this->view->rr = $formRecord; + $this->view->absoluteRebroadcast = $formAbsoluteRebroadcast; + $this->view->rebroadcast = $formRebroadcast; + $this->view->addNewShow = true; + + $formWhat->populate(array('add_show_id' => '-1')); + + $this->view->form = $this->view->render('schedule/add-show-form.phtml'); + } + public function addShowAction() { $js = $this->_getParam('data'); diff --git a/application/views/scripts/schedule/edit-show.phtml b/application/views/scripts/schedule/edit-show.phtml index 03bf357a5..bf01724e3 100644 --- a/application/views/scripts/schedule/edit-show.phtml +++ b/application/views/scripts/schedule/edit-show.phtml @@ -1,2 +1 @@ -entries; +//left empty on purpose diff --git a/application/views/scripts/schedule/get-form.phtml b/application/views/scripts/schedule/get-form.phtml new file mode 100644 index 000000000..bf01724e3 --- /dev/null +++ b/application/views/scripts/schedule/get-form.phtml @@ -0,0 +1 @@ +//left empty on purpose diff --git a/public/js/airtime/schedule/add-show.js b/public/js/airtime/schedule/add-show.js index b2449a608..0c4659fac 100644 --- a/public/js/airtime/schedule/add-show.js +++ b/public/js/airtime/schedule/add-show.js @@ -189,6 +189,13 @@ function setAddShowEvents() { $("#schedule_calendar").width(y+z+50); $("#schedule_calendar").fullCalendar('render'); $("#add-show-form").hide(); + $.get("/Schedule/get-form", {format:"json"}, function(json){ + $("#add-show-form") + .empty() + .append(json.form); + + setAddShowEvents(); + }); makeAddShowButton(); }); diff --git a/public/js/airtime/schedule/full-calendar-functions.js b/public/js/airtime/schedule/full-calendar-functions.js index ce53f9737..6a21d21af 100644 --- a/public/js/airtime/schedule/full-calendar-functions.js +++ b/public/js/airtime/schedule/full-calendar-functions.js @@ -25,21 +25,26 @@ function makeAddShowButton(){ .append('Show') .find('span.fc-button:last > a') .click(function(){ - openAddShowForm(); - - var span = $(this).parent(); - $(span).prev().remove(); - $(span).remove(); + openAddShowForm(); + removeAddShowButton(); }); } -function beginEditShow(data){ - //alert (data.entries); +function removeAddShowButton(){ + var aTag = $('.fc-header-left') + .find("span.fc-button:last > a"); + var span = aTag.parent(); + span.prev().remove(); + span.remove(); +} + +function beginEditShow(data){ $("#add-show-form") .empty() .append(data.newForm); + removeAddShowButton(); setAddShowEvents(); openAddShowForm(); } diff --git a/public/js/playlist/nowplayingdatagrid.js b/public/js/playlist/nowplayingdatagrid.js index 33e077a19..cbb25c1e4 100644 --- a/public/js/playlist/nowplayingdatagrid.js +++ b/public/js/playlist/nowplayingdatagrid.js @@ -76,7 +76,7 @@ function getDateString(){ return (date0.getFullYear() + "-" + (parseInt(date0.getMonth())+1) + "-" + date0.getDate()); } -function getAJAXURL(){ +function getAjaxUrl(){ var url = "/Nowplaying/get-data-grid-data/format/json/view/"+viewType; if (viewType == "day"){ @@ -99,7 +99,7 @@ function updateDataTable(){ } function getData(){ - $.ajax({ url: getAJAXURL(), dataType:"json", success:function(data){ + $.ajax({ url: getAjaxUrl(), dataType:"json", success:function(data){ datagridData = data.entries; if (datagridData.currentShow.length > 0) currentShowInstanceID = datagridData.currentShow[0].instance_id; From 7e6ce1514f30560cc4ca81dab1302da749792430 Mon Sep 17 00:00:00 2001 From: martin Date: Wed, 13 Apr 2011 18:22:56 -0400 Subject: [PATCH 03/11] -fixed airtime install not working. --- install/include/AirtimeInstall.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/install/include/AirtimeInstall.php b/install/include/AirtimeInstall.php index 847fc2a45..bf451757f 100644 --- a/install/include/AirtimeInstall.php +++ b/install/include/AirtimeInstall.php @@ -1,6 +1,9 @@ getMessage().PHP_EOL; echo $CC_DBC->getUserInfo().PHP_EOL; From 33b24b581c78e2bf0f52f516345367058a48eaff Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 14 Apr 2011 00:20:19 -0400 Subject: [PATCH 04/11] CC-2175: Overbooking: Cut off shows when they are done -fixed --- application/models/Schedule.php | 12 +++++++----- python_apps/pypo/pypofetch.py | 27 +++++++++++++-------------- python_apps/pypo/pypopush.py | 29 +++++++++++++++++------------ 3 files changed, 37 insertions(+), 31 deletions(-) diff --git a/application/models/Schedule.php b/application/models/Schedule.php index 0fb1468e0..8be208256 100644 --- a/application/models/Schedule.php +++ b/application/models/Schedule.php @@ -314,7 +314,9 @@ class Schedule { ." MIN(st.playlist_id) AS playlist_id," ." MIN(st.starts) AS starts," ." MAX(st.ends) AS ends," - ." MIN(sh.name) AS show_name" + ." MIN(sh.name) AS show_name," + ." MIN(si.starts) AS show_start," + ." MAX(si.ends) AS show_end" ." FROM $CC_CONFIG[scheduleTable] as st" ." LEFT JOIN $CC_CONFIG[playListTable] as pt" ." ON st.playlist_id = pt.id" @@ -608,10 +610,8 @@ class Schedule { $data = Schedule::GetItems($range_start, $range_end, true); $playlists = array(); - if (is_array($data)) - { - foreach ($data as $dx) - { + if (is_array($data)){ + foreach ($data as $dx){ $start = $dx['start']; //chop off subseconds @@ -628,6 +628,8 @@ class Schedule { $playlists[$pkey]['played'] = '0'; $playlists[$pkey]['schedule_id'] = $dx['group_id']; $playlists[$pkey]['show_name'] = $dx['show_name']; + $playlists[$pkey]['show_start'] = Schedule::AirtimeTimeToPypoTime($dx['show_start']); + $playlists[$pkey]['show_end'] = Schedule::AirtimeTimeToPypoTime($dx['show_end']); $playlists[$pkey]['user_id'] = 0; $playlists[$pkey]['id'] = $dx['group_id']; $playlists[$pkey]['start'] = Schedule::AirtimeTimeToPypoTime($dx["start"]); diff --git a/python_apps/pypo/pypofetch.py b/python_apps/pypo/pypofetch.py index aada900ff..224d256ee 100755 --- a/python_apps/pypo/pypofetch.py +++ b/python_apps/pypo/pypofetch.py @@ -101,7 +101,7 @@ class PypoFetch(Thread): """ def process_schedule(self, schedule_data, export_source): logger = logging.getLogger('fetch') - self.schedule = schedule_data["playlists"] + playlists = schedule_data["playlists"] self.check_matching_timezones(schedule_data["server_timezone"]) @@ -121,13 +121,13 @@ class PypoFetch(Thread): # Download all the media and put playlists in liquidsoap format try: - playlists = self.prepare_playlists() + liquidsoap_playlists = self.prepare_playlists(playlists) except Exception, e: logger.error("%s", e) # Send the data to pypo-push scheduled_data = dict() - scheduled_data['playlists'] = playlists - scheduled_data['schedule'] = self.schedule + scheduled_data['liquidsoap_playlists'] = liquidsoap_playlists + scheduled_data['schedule'] = playlists scheduled_data['stream_metadata'] = schedule_data["stream_metadata"] self.queue.put(scheduled_data) @@ -141,23 +141,22 @@ class PypoFetch(Thread): and stored in a playlist folder. file is e.g. 2010-06-23-15-00-00/17_cue_10.132-123.321.mp3 """ - def prepare_playlists(self): + def prepare_playlists(self, playlists): logger = logging.getLogger('fetch') - schedule = self.schedule - playlists = dict() + liquidsoap_playlists = dict() - # Dont do anything if schedule is empty - if not schedule: + # Dont do anything if playlists is empty + if not playlists: logger.debug("Schedule is empty.") - return playlists + return liquidsoap_playlists - scheduleKeys = sorted(schedule.iterkeys()) + scheduleKeys = sorted(playlists.iterkeys()) try: for pkey in scheduleKeys: logger.info("Playlist starting at %s", pkey) - playlist = schedule[pkey] + playlist = playlists[pkey] # create playlist directory try: @@ -181,10 +180,10 @@ class PypoFetch(Thread): elif int(playlist['subtype']) > 0 and int(playlist['subtype']) < 5: ls_playlist = self.handle_media_file(playlist, pkey) - playlists[pkey] = ls_playlist + liquidsoap_playlists[pkey] = ls_playlist except Exception, e: logger.info("%s", e) - return playlists + return liquidsoap_playlists """ diff --git a/python_apps/pypo/pypopush.py b/python_apps/pypo/pypopush.py index af207651a..573770694 100755 --- a/python_apps/pypo/pypopush.py +++ b/python_apps/pypo/pypopush.py @@ -48,6 +48,10 @@ class PypoPush(Thread): self.push_ahead = 10 self.push_ahead2 = self.push_ahead -5 + #toggle between "stop" and "play". Keeps track of the state of + #liquidsoap + self.liquidsoap_state_play = True + def set_export_source(self, export_source): self.export_source = export_source self.cache_dir = config["cache_dir"] + self.export_source + '/' @@ -67,14 +71,13 @@ class PypoPush(Thread): scheduled_data = self.queue.get() logger.debug("Received data from pypo-fetch") self.schedule = scheduled_data['schedule'] - self.playlists = scheduled_data['playlists'] + self.playlists = scheduled_data['liquidsoap_playlists'] self.stream_metadata = scheduled_data['stream_metadata'] + logger.debug('schedule %s' % json.dumps(self.schedule)) + logger.debug('playlists %s' % json.dumps(self.playlists)) schedule = self.schedule playlists = self.playlists - - logger.debug('schedule %s' % json.dumps(schedule)) - logger.debug('playlists %s' % json.dumps(playlists)) currently_on_air = False if schedule: @@ -92,9 +95,7 @@ class PypoPush(Thread): for pkey in schedule: plstart = pkey[0:19] - start = schedule[pkey]['start'] - end = schedule[pkey]['end'] - + playedFlag = (pkey in playedItems) and playedItems[pkey].get("played", 0) if plstart == str_tcoming_s or (plstart < str_tcoming_s and plstart > str_tcoming2_s and not playedFlag): @@ -120,21 +121,23 @@ class PypoPush(Thread): # Call API to update schedule states logger.debug("Doing callback to server to update 'played' status.") self.api_client.notify_scheduled_item_start_playing(pkey, schedule) - - start = schedule[pkey]['start'] - end = schedule[pkey]['end'] - if start <= str_tnow_s and str_tnow_s < end: + show_start = schedule[pkey]['show_start'] + show_end = schedule[pkey]['show_end'] + + if show_start <= str_tnow_s and str_tnow_s < show_end: currently_on_air = True else: pass #logger.debug('Empty schedule') - if not currently_on_air: + if not currently_on_air and self.liquidsoap_state_play: + logger.debug('Notifying Liquidsoap to stop playback.') tn = telnetlib.Telnet(LS_HOST, LS_PORT) tn.write('source.skip\n') tn.write('exit\n') tn.read_all() + self.liquidsoap_state_play = False def push_liquidsoap(self, pkey, schedule, playlists): logger = logging.getLogger('push') @@ -185,6 +188,8 @@ class PypoPush(Thread): tn.write("exit\n") logger.debug(tn.read_all()) + self.liquidsoap_state_play = True + status = 1 except Exception, e: logger.error('%s', e) From ac3853c0fbc9c802b52c0e3c5778b64ff6d577f4 Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 14 Apr 2011 00:45:20 -0400 Subject: [PATCH 05/11] CC-2175: Overbooking: Cut off shows when they are done -on-air light now turns off when show finishes before a song is able to finish. (before waited until song completed) --- public/js/playlist/playlist.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/playlist/playlist.js b/public/js/playlist/playlist.js index a72e94dc2..eff1dfc42 100644 --- a/public/js/playlist/playlist.js +++ b/public/js/playlist/playlist.js @@ -85,7 +85,7 @@ function updateProgressBarValue(){ songPercentDone = 0; currentSong = new Array(); } else { - if (currentSong[0].media_item_played == "t") + if (currentSong[0].media_item_played == "t" && currentShow.length > 0) $('#on-air-info').attr("class", "on-air-info on"); else $('#on-air-info').attr("class", "on-air-info off"); From 5b79a9f876292dc4b025126557d92cd6fe038cb0 Mon Sep 17 00:00:00 2001 From: Naomi Date: Thu, 14 Apr 2011 11:31:44 -0400 Subject: [PATCH 06/11] CC-2176 : Allow up to 10 rebroadcasts, add in the plus button with hidden elements tested with adding shows, need to test editing shows. --- .../controllers/ScheduleController.php | 4 +- .../forms/AddShowAbsoluteRebroadcastDates.php | 12 ++-- application/models/Shows.php | 10 +-- .../form/add-show-rebroadcast-absolute.phtml | 26 +++++--- .../scripts/form/add-show-rebroadcast.phtml | 54 +++++++++------- public/js/airtime/schedule/add-show.js | 64 ++++++++++++++++--- 6 files changed, 117 insertions(+), 53 deletions(-) diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php index bada06562..bbbf5e05f 100644 --- a/application/controllers/ScheduleController.php +++ b/application/controllers/ScheduleController.php @@ -478,8 +478,8 @@ class ScheduleController extends Zend_Controller_Action $rebroadcastAbsoluteFormValues = array(); $i = 1; foreach ($rebroadcastsAbsolute as $rebroadcast){ - $rebroadcastAbsoluteFormValues["add_show_rebroadcast_absolute_date_$i"] = $rebroadcast['start_date']; - $rebroadcastAbsoluteFormValues["add_show_rebroadcast_absolute_time_$i"] = Show::removeSecondsFromTime($rebroadcast['start_time']); + $rebroadcastAbsoluteFormValues["add_show_rebroadcast_date_absolute_$i"] = $rebroadcast['start_date']; + $rebroadcastAbsoluteFormValues["add_show_rebroadcast_time_absolute_$i"] = Show::removeSecondsFromTime($rebroadcast['start_time']); $i++; } $formAbsoluteRebroadcast->populate($rebroadcastAbsoluteFormValues); diff --git a/application/forms/AddShowAbsoluteRebroadcastDates.php b/application/forms/AddShowAbsoluteRebroadcastDates.php index 8c87b66c7..ab6f9891b 100644 --- a/application/forms/AddShowAbsoluteRebroadcastDates.php +++ b/application/forms/AddShowAbsoluteRebroadcastDates.php @@ -11,7 +11,7 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm for($i=1; $i<=10; $i++) { - $text = new Zend_Form_Element_Text("add_show_rebroadcast_absolute_date_$i"); + $text = new Zend_Form_Element_Text("add_show_rebroadcast_date_absolute_$i"); $text->setAttrib('class', 'input_text'); $text->addFilter('StringTrim'); $text->addValidator('date', false, array('YYYY-MM-DD')); @@ -19,7 +19,7 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm $text->setDecorators(array('ViewHelper')); $this->addElement($text); - $text = new Zend_Form_Element_Text("add_show_rebroadcast_absolute_time_$i"); + $text = new Zend_Form_Element_Text("add_show_rebroadcast_time_absolute_$i"); $text->setAttrib('class', 'input_text'); $text->addFilter('StringTrim'); $text->addValidator('date', false, array('HH:mm')); @@ -34,9 +34,9 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm $valid = true; - for($i=1; $i<=5; $i++) { + for($i=1; $i<=10; $i++) { - $day = $formData['add_show_rebroadcast_absolute_date_'.$i]; + $day = $formData['add_show_rebroadcast_date_absolute_'.$i]; if($day == "") { continue; @@ -52,11 +52,11 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm $show_end->add(new DateInterval("PT$duration[1]M")); $show_end->add(new DateInterval("PT1H"));//min time to wait until a rebroadcast - $rebroad_start = $day."".$formData['add_show_rebroadcast_absolute_time_'.$i]; + $rebroad_start = $day."".$formData['add_show_rebroadcast_time_absolute_'.$i]; $rebroad_start = new DateTime($rebroad_start); if($rebroad_start < $show_end) { - $this->getElement('add_show_rebroadcast_absolute_time_'.$i)->setErrors(array("Must wait at least 1 hour to rebroadcast")); + $this->getElement('add_show_rebroadcast_time_absolute_'.$i)->setErrors(array("Must wait at least 1 hour to rebroadcast")); $valid = false; } } diff --git a/application/models/Shows.php b/application/models/Shows.php index 6be170dd9..f973eba7d 100644 --- a/application/models/Shows.php +++ b/application/models/Shows.php @@ -656,7 +656,7 @@ class Show { //adding rows to cc_show_rebroadcast if ($isRecorded && $data['add_show_rebroadcast'] && $repeatType != -1) { - for ($i=1; $i<=5; $i++) { + for ($i=1; $i<=10; $i++) { if ($data['add_show_rebroadcast_date_'.$i]) { $showRebroad = new CcShowRebroadcast(); @@ -668,16 +668,16 @@ class Show { } } else if ($isRecorded && $data['add_show_rebroadcast'] && $repeatType == -1){ - for ($i=1; $i<=5; $i++) { + for ($i=1; $i<=10; $i++) { - if ($data['add_show_rebroadcast_absolute_date_'.$i]) { - $sql = "SELECT date '{$data['add_show_rebroadcast_absolute_date_'.$i]}' - date '{$data['add_show_start_date']}' "; + if ($data['add_show_rebroadcast_date_absolute_'.$i]) { + $sql = "SELECT date '{$data['add_show_rebroadcast_date_absolute_'.$i]}' - date '{$data['add_show_start_date']}' "; $r = $con->query($sql); $offset_days = $r->fetchColumn(0); $showRebroad = new CcShowRebroadcast(); $showRebroad->setDbDayOffset($offset_days." days"); - $showRebroad->setDbStartTime($data['add_show_rebroadcast_absolute_time_'.$i]); + $showRebroad->setDbStartTime($data['add_show_rebroadcast_time_absolute_'.$i]); $showRebroad->setDbShowId($showId); $showRebroad->save(); } diff --git a/application/views/scripts/form/add-show-rebroadcast-absolute.phtml b/application/views/scripts/form/add-show-rebroadcast-absolute.phtml index d235a6ae9..f8fc2d81c 100644 --- a/application/views/scripts/form/add-show-rebroadcast-absolute.phtml +++ b/application/views/scripts/form/add-show-rebroadcast-absolute.phtml @@ -5,18 +5,24 @@
    - -
  • - element->getElement('add_show_rebroadcast_absolute_date_'.$i) ?> + +
  • 1){echo 'style=display:none';} ?>> + element->getElement('add_show_rebroadcast_date_absolute_'.$i) ?> @ - element->getElement('add_show_rebroadcast_absolute_time_'.$i) ?> + element->getElement('add_show_rebroadcast_time_absolute_'.$i) ?> + 1): ?> + + + Remove + +
  • - element->getElement('add_show_rebroadcast_absolute_date_'.$i)->hasErrors()) - || ($this->element->getElement('add_show_rebroadcast_absolute_time_'.$i)->hasErrors())) : ?> + element->getElement('add_show_rebroadcast_date_absolute_'.$i)->hasErrors()) + || ($this->element->getElement('add_show_rebroadcast_time_absolute_'.$i)->hasErrors())) : ?>
      element->getElement('add_show_rebroadcast_absolute_date_'.$i)->getMessages(), - $this->element->getElement('add_show_rebroadcast_absolute_time_'.$i)->getMessages() + $this->element->getElement('add_show_rebroadcast_date_absolute_'.$i)->getMessages(), + $this->element->getElement('add_show_rebroadcast_time_absolute_'.$i)->getMessages() ); ?> @@ -27,6 +33,10 @@
    + + + Add +
diff --git a/application/views/scripts/form/add-show-rebroadcast.phtml b/application/views/scripts/form/add-show-rebroadcast.phtml index 44ae45b0c..2f090a00e 100644 --- a/application/views/scripts/form/add-show-rebroadcast.phtml +++ b/application/views/scripts/form/add-show-rebroadcast.phtml @@ -4,30 +4,40 @@
-
    - -
  • - element->getElement('add_show_rebroadcast_date_'.$i) ?> - @ - element->getElement('add_show_rebroadcast_time_'.$i) ?> -
  • +
      + +
    • 1){echo 'style=display:none';} ?>> + element->getElement('add_show_rebroadcast_date_'.$i) ?> + @ + element->getElement('add_show_rebroadcast_time_'.$i) ?> + 1): ?> + + + Remove + + +
    • - element->getElement('add_show_rebroadcast_date_'.$i)->hasErrors()) - || ($this->element->getElement('add_show_rebroadcast_time_'.$i)->hasErrors())) : ?> -
        - element->getElement('add_show_rebroadcast_date_'.$i)->getMessages(), - $this->element->getElement('add_show_rebroadcast_time_'.$i)->getMessages() - ); - ?> + element->getElement('add_show_rebroadcast_date_'.$i)->hasErrors()) + || ($this->element->getElement('add_show_rebroadcast_time_'.$i)->hasErrors())) : ?> +
          + element->getElement('add_show_rebroadcast_date_'.$i)->getMessages(), + $this->element->getElement('add_show_rebroadcast_time_'.$i)->getMessages() + ); + ?> - -
        • - -
        - - -
      + +
    • + +
    + + +
+ + + Add +
diff --git a/public/js/airtime/schedule/add-show.js b/public/js/airtime/schedule/add-show.js index 0c4659fac..2bc224686 100644 --- a/public/js/airtime/schedule/add-show.js +++ b/public/js/airtime/schedule/add-show.js @@ -150,14 +150,55 @@ function setAddShowEvents() { defaultTime: '01:00' }); - form.find('input[name^="add_show_rebroadcast_absolute_date"]').datepicker({ + form.find('input[name^="add_show_rebroadcast_date_absolute"]').datepicker({ minDate: new Date(), dateFormat: 'yy-mm-dd' }); - form.find('input[name^="add_show_rebroadcast_absolute_time"], input[name^="add_show_rebroadcast_time"]').timepicker({ + form.find('input[name^="add_show_rebroadcast_time"]').timepicker({ amPmText: ['', ''], defaultTime: '' }); + + form.find(".add_absolute_rebroadcast_day").click(function(){ + var li = $(this).prev().find("li:visible:last").next(); + + li.show(); + li = li.next(); + if(li.length === 0) { + $(this).hide(); + } + }); + + form.find('a[id^="remove_rebroadcast"]').click(function(){ + var list = $(this).parent().parent(); + var li_num = $(this).parent().index(); + var num = list.find("li").length; + var count = num - li_num; + + var curr = $(this).parent(); + var next = curr.next(); + + for(var i=0; i<=count; i++) { + var date = next.find('[name^="add_show_rebroadcast_date"]').val(); + curr.find('[name^="add_show_rebroadcast_date"]').val(date); + var time = next.find('[name^="add_show_rebroadcast_time"]').val(); + curr.find('[name^="add_show_rebroadcast_time"]').val(time); + + curr = next; + next = curr.next(); + } + + list.find("li:visible:last") + .find('[name^="add_show_rebroadcast_date"]') + .val('') + .end() + .find('[name^="add_show_rebroadcast_time"]') + .val('') + .end() + .hide(); + + list.next().show(); + }); form.find("#add_show_hosts_autocomplete").autocomplete({ source: findHosts, @@ -166,7 +207,7 @@ function setAddShowEvents() { }); form.find("#schedule-show-style input").ColorPicker({ - onChange: function (hsb, hex, rgb, el) { + onChange: function (hsb, hex, rgb, el) { $(el).val(hex); }, onSubmit: function(hsb, hex, rgb, el) { @@ -186,15 +227,17 @@ function setAddShowEvents() { var y = $("#schedule_calendar").width(); var z = $("#schedule-add-show").width(); - $("#schedule_calendar").width(y+z+50); - $("#schedule_calendar").fullCalendar('render'); + + $("#schedule_calendar").width(y+z+50) + .fullCalendar('render'); + $("#add-show-form").hide(); $.get("/Schedule/get-form", {format:"json"}, function(json){ - $("#add-show-form") - .empty() - .append(json.form); + $("#add-show-form") + .empty() + .append(json.form); - setAddShowEvents(); + setAddShowEvents(); }); makeAddShowButton(); }); @@ -204,7 +247,8 @@ function setAddShowEvents() { var addShowButton = $(this); if (!addShowButton.hasClass("disabled")){ addShowButton.addClass("disabled"); - } else { + } + else { return; } From fc8f9f18fc0beb886228cd1682e16a00ef222c39 Mon Sep 17 00:00:00 2001 From: Naomi Date: Thu, 14 Apr 2011 12:32:25 -0400 Subject: [PATCH 07/11] CC-2176 : Allow up to 10 rebroadcasts, add in the plus button with hidden elements tested with editing shows. --- .../views/scripts/form/add-show-rebroadcast-absolute.phtml | 2 +- application/views/scripts/form/add-show-rebroadcast.phtml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/application/views/scripts/form/add-show-rebroadcast-absolute.phtml b/application/views/scripts/form/add-show-rebroadcast-absolute.phtml index f8fc2d81c..ae0977bc9 100644 --- a/application/views/scripts/form/add-show-rebroadcast-absolute.phtml +++ b/application/views/scripts/form/add-show-rebroadcast-absolute.phtml @@ -6,7 +6,7 @@
    -
  • 1){echo 'style=display:none';} ?>> +
  • 1) && ($this->element->getElement('add_show_rebroadcast_date_absolute_'.$i)->getValue() == "")){echo 'style=display:none';} ?>> element->getElement('add_show_rebroadcast_date_absolute_'.$i) ?> @ element->getElement('add_show_rebroadcast_time_absolute_'.$i) ?> diff --git a/application/views/scripts/form/add-show-rebroadcast.phtml b/application/views/scripts/form/add-show-rebroadcast.phtml index 2f090a00e..e3cf4962f 100644 --- a/application/views/scripts/form/add-show-rebroadcast.phtml +++ b/application/views/scripts/form/add-show-rebroadcast.phtml @@ -6,7 +6,7 @@
      -
    • 1){echo 'style=display:none';} ?>> +
    • 1) && (is_null($this->element->getElement('add_show_rebroadcast_date_'.$i)->getValue()))){echo 'style=display:none';} ?>> element->getElement('add_show_rebroadcast_date_'.$i) ?> @ element->getElement('add_show_rebroadcast_time_'.$i) ?> From 804f9c66b9a0e63268b841af2a2d9582f082516e Mon Sep 17 00:00:00 2001 From: Naomi Date: Thu, 14 Apr 2011 13:47:50 -0400 Subject: [PATCH 08/11] require order screwed up. --- install/airtime-install.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/install/airtime-install.php b/install/airtime-install.php index 24d427638..d56b9f9a1 100644 --- a/install/airtime-install.php +++ b/install/airtime-install.php @@ -8,14 +8,15 @@ echo "******************************** Install Begin *********************************".PHP_EOL; require_once(dirname(__FILE__).'/include/AirtimeIni.php'); -require_once(dirname(__FILE__).'/include/AirtimeInstall.php'); -AirtimeInstall::ExitIfNotRoot(); AirtimeIni::CreateIniFile(); AirtimeIni::UpdateIniFiles(); +require_once(dirname(__FILE__).'/include/AirtimeInstall.php'); require_once(dirname(__FILE__).'/../application/configs/conf.php'); +AirtimeInstall::ExitIfNotRoot(); + echo PHP_EOL."*** Installing Airtime ".AIRTIME_VERSION." ***".PHP_EOL; echo PHP_EOL."*** Database Installation ***".PHP_EOL; From 6899dca0a3217fe1d6f12bec95d2f2b5aa5ce599 Mon Sep 17 00:00:00 2001 From: Naomi Date: Thu, 14 Apr 2011 14:01:14 -0400 Subject: [PATCH 09/11] removing confusing redundant imports --- install/include/AirtimeInstall.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/install/include/AirtimeInstall.php b/install/include/AirtimeInstall.php index bf451757f..c31db8e1e 100644 --- a/install/include/AirtimeInstall.php +++ b/install/include/AirtimeInstall.php @@ -2,9 +2,7 @@ //Pear classes. set_include_path(__DIR__.'/../../library/pear' . PATH_SEPARATOR . get_include_path()); - require_once('DB.php'); -require_once(dirname(__FILE__).'/../../application/configs/conf.php'); class AirtimeInstall { /** From bf146e7f85ecedc032c1cac7bdafa4dd84b6d5e9 Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 14 Apr 2011 14:17:56 -0400 Subject: [PATCH 10/11] -commented some functions -removed usage of "current_timestamp" in postgresql queries in favour of php time. --- application/Bootstrap.php | 1 + application/controllers/ApiController.php | 4 +- application/models/DateHelper.php | 4 +- application/models/Nowplaying.php | 16 +-- application/models/Schedule.php | 4 +- application/models/Shows.php | 129 +++++++++++++++++----- 6 files changed, 117 insertions(+), 41 deletions(-) diff --git a/application/Bootstrap.php b/application/Bootstrap.php index 277bd9cab..511ab92e3 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -21,6 +21,7 @@ require_once 'Schedule.php'; require_once 'Shows.php'; require_once 'Users.php'; require_once 'RabbitMq.php'; +require_once 'DateHelper.php'; require_once __DIR__.'/controllers/plugins/RabbitMqPlugin.php'; global $CC_CONFIG, $CC_DBC; diff --git a/application/controllers/ApiController.php b/application/controllers/ApiController.php index 1b0e8ac51..4c6e344d2 100644 --- a/application/controllers/ApiController.php +++ b/application/controllers/ApiController.php @@ -112,8 +112,8 @@ class ApiController extends Zend_Controller_Action $result = Schedule::GetPlayOrderRange(0, 1); - $date = new Application_Model_DateHelper; - $timeNow = $date->getDate(); + $date = new DateHelper; + $timeNow = $date->getTimestamp(); $result = array("env"=>APPLICATION_ENV, "schedulerTime"=>gmdate("Y-m-d H:i:s"), "currentShow"=>Show_DAL::GetCurrentShow($timeNow), diff --git a/application/models/DateHelper.php b/application/models/DateHelper.php index d0f56f647..97b7d9ae9 100644 --- a/application/models/DateHelper.php +++ b/application/models/DateHelper.php @@ -1,6 +1,6 @@ _timestamp); } diff --git a/application/models/Nowplaying.php b/application/models/Nowplaying.php index 7536f1044..6df81c310 100644 --- a/application/models/Nowplaying.php +++ b/application/models/Nowplaying.php @@ -57,8 +57,8 @@ class Application_Model_Nowplaying } public static function FilterRowsByDate($rows, $date, $startCutoff, $endCutoff){ - $dateNow = new Application_Model_DateHelper; - $timeNow = $dateNow->getDate(); + $dateNow = new DateHelper; + $timeNow = $dateNow->getTimestamp(); $data = array(); //iterate over each show, and calculate information for it. @@ -117,16 +117,16 @@ class Application_Model_Nowplaying public static function GetDataGridData($viewType, $dateString){ if ($viewType == "now"){ - $date = new Application_Model_DateHelper; - $timeNow = $date->getDate(); + $date = new DateHelper; + $timeNow = $date->getTimestamp(); $startCutoff = 60; $endCutoff = 86400; //60*60*24 - seconds in a day } else { - $date = new Application_Model_DateHelper; + $date = new DateHelper; $time = $date->getTime(); $date->setDate($dateString." ".$time); - $timeNow = $date->getDate(); + $timeNow = $date->getTimestamp(); $startCutoff = $date->getNowDayStartDiff(); $endCutoff = $date->getNowDayEndDiff(); @@ -139,8 +139,8 @@ class Application_Model_Nowplaying //$rows = FindGapsBetweenShows() $data = Application_Model_Nowplaying::FilterRowsByDate($rows, $date, $startCutoff, $endCutoff); - $date = new Application_Model_DateHelper; - $timeNow = $date->getDate(); + $date = new DateHelper; + $timeNow = $date->getTimestamp(); return array("currentShow"=>Show_DAL::GetCurrentShow($timeNow), "rows"=>$data); } } diff --git a/application/models/Schedule.php b/application/models/Schedule.php index 8be208256..4f2b4cd8d 100644 --- a/application/models/Schedule.php +++ b/application/models/Schedule.php @@ -361,8 +361,8 @@ class Schedule { global $CC_CONFIG; - $date = new Application_Model_DateHelper; - $timeNow = $date->getDate(); + $date = new DateHelper; + $timeNow = $date->getTimestamp(); return array("env"=>APPLICATION_ENV, "schedulerTime"=>gmdate("Y-m-d H:i:s"), "previous"=>Schedule::GetScheduledItemData($timeNow, -1, $prev, "24 hours"), diff --git a/application/models/Shows.php b/application/models/Shows.php index 6be170dd9..a817e2738 100644 --- a/application/models/Shows.php +++ b/application/models/Shows.php @@ -136,9 +136,13 @@ class Show { $uncheckedDaysImploded = implode(",", $p_uncheckedDays); $showId = $this->getId(); + + $date = new DateHelper; + $timestamp = $date->getTimestamp(); + $sql = "DELETE FROM cc_show_instances" ." WHERE EXTRACT(DOW FROM starts) IN ($uncheckedDaysImploded)" - ." AND starts > current_timestamp " + ." AND starts > TIMESTAMP '$timestamp'" ." AND show_id = $showId"; $CC_DBC->query($sql); @@ -177,6 +181,14 @@ class Show { return !is_null($showInstancesRow); } + /** + * Get start time and absolute start date for a recorded + * shows rebroadcasts. For example start date format would be + * YYYY-MM-DD and time would HH:MM + * + * @return array + * array of associate arrays containing "start_date" and "start_time" + */ public function getRebroadcastsAbsolute() { global $CC_DBC; @@ -199,6 +211,14 @@ class Show { return $CC_DBC->GetAll($sql); } + /** + * Get start time and relative start date for a recorded + * shows rebroadcasts. For example start date format would be + * "x days" and time would HH:MM:SS + * + * @return array + * array of associate arrays containing "day_offset" and "start_time" + */ public function getRebroadcastsRelative() { global $CC_DBC; @@ -272,42 +292,76 @@ class Show { return $endDate; } } - + + /** + * Deletes all future instances of the current show object + * from the show_instances table. + * + */ public function deleteAllInstances(){ global $CC_DBC; + $date = new DateHelper; + $timestamp = $date->getTimestamp(); + $showId = $this->getId(); - $sql = "DELETE FROM cc_show_instances " - ."WHERE starts > current_timestamp " - ."AND show_id = $showId"; + $sql = "DELETE FROM cc_show_instances" + ." WHERE starts > TIMESTAMP '$timestamp'" + ." AND show_id = $showId"; $CC_DBC->query($sql); } - + + /** + * Deletes all show instances of current show after a + * certain date. + * + * @param string $p_date + * The date which to delete after + */ public function removeAllInstancesAfterDate($p_date){ global $CC_DBC; - $showId = $this->getId(); - $sql = "DELETE FROM cc_show_instances " - ."WHERE date(starts) > DATE '$p_date' " - ."AND starts > current_timestamp " - ."AND show_id = $showId"; - - $CC_DBC->query($sql); - } - - public function removeAllInstancesBeforeDate($p_date){ - global $CC_DBC; + $date = new DateHelper; + $timestamp = $date->getTimestamp(); $showId = $this->getId(); $sql = "DELETE FROM cc_show_instances " - ."WHERE date(starts) < DATE '$p_date' " - ."AND starts > current_timestamp " - ."AND show_id = $showId"; + ." WHERE date(starts) > DATE '$p_date'" + ." AND starts > TIMESTAMP '$timestamp'" + ." AND show_id = $showId"; + + $CC_DBC->query($sql); + } + + /** + * Deletes all show instances of current show before a + * certain date. + * + * @param string $p_date + * The date which to delete before + */ + public function removeAllInstancesBeforeDate($p_date){ + global $CC_DBC; + + $date = new DateHelper; + $timestamp = $date->getTimestamp(); + + $showId = $this->getId(); + $sql = "DELETE FROM cc_show_instances " + ." WHERE date(starts) < DATE '$p_date'" + ." AND starts > TIMESTAMP '$timestamp'" + ." AND show_id = $showId"; $CC_DBC->query($sql); } - + + /** + * Get the start date of the current show. + * + * @return string + * The start date in the format YYYY-MM-DD + */ public function getStartDate(){ global $CC_DBC; @@ -323,7 +377,13 @@ class Show { return $firstDate; } } - + + /** + * Get the start time of the current show. + * + * @return string + * The start time in the format HH:MM:SS + */ public function getStartTime(){ global $CC_DBC; @@ -339,14 +399,23 @@ class Show { return $startTime; } } - + + /** + * Get the ID's of future instance of the current show. + * + * @return array + * A simple array containing all future instance ID's + */ public function getAllFutureInstanceIds(){ global $CC_DBC; + + $date = new DateHelper; + $timestamp = $date->getTimestamp(); $showId = $this->getId(); - $sql = "SELECT id from cc_show_instances " + $sql = "SELECT id from cc_show_instances" ." WHERE show_id = $showId" - ." AND starts > current_timestamp"; + ." AND starts > TIMESTAMP '$timestamp'"; $rows = $CC_DBC->GetAll($sql); @@ -361,6 +430,9 @@ class Show { //need to update cc_show_instances, cc_show_days global $CC_DBC; + + $date = new DateHelper; + $timestamp = $date->getTimestamp(); $sql = "UPDATE cc_show_days " ."SET duration = '$p_data[add_show_duration]' " @@ -370,7 +442,7 @@ class Show { $sql = "UPDATE cc_show_instances " ."SET ends = starts + INTERVAL '$p_data[add_show_duration]' " ."WHERE show_id = $p_data[add_show_id] " - ."AND starts > current_timestamp"; + ."AND starts > TIMESTAMP '$timestamp'"; $CC_DBC->query($sql); } @@ -379,6 +451,9 @@ class Show { //need to update cc_schedule, cc_show_instances, cc_show_days global $CC_DBC; + + $date = new DateHelper; + $timestamp = $date->getTimestamp(); $sql = "UPDATE cc_show_days " ."SET start_time = TIME '$p_data[add_show_start_time]', " @@ -399,7 +474,7 @@ class Show { ."SET starts = starts + INTERVAL '$diff sec', " ."ends = ends + INTERVAL '$diff sec' " ."WHERE show_id = $p_data[add_show_id] " - ."AND starts > current_timestamp"; + ."AND starts > TIMESTAMP '$timestamp'"; $CC_DBC->query($sql); $showInstanceIds = $this->getAllFutureInstanceIds(); From 88362a2c5217d1c51cb7629d4713de8e508a51cc Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 14 Apr 2011 14:57:52 -0400 Subject: [PATCH 11/11] CC-2179: Creating a record + rebroadcast show with no rebroadcast times causes DB error -fixed --- .../forms/AddShowAbsoluteRebroadcastDates.php | 18 ++++++++++++------ application/forms/AddShowRebroadcastDates.php | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/application/forms/AddShowAbsoluteRebroadcastDates.php b/application/forms/AddShowAbsoluteRebroadcastDates.php index ab6f9891b..bb3c79125 100644 --- a/application/forms/AddShowAbsoluteRebroadcastDates.php +++ b/application/forms/AddShowAbsoluteRebroadcastDates.php @@ -35,12 +35,18 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm $valid = true; for($i=1; $i<=10; $i++) { - + $day = $formData['add_show_rebroadcast_date_absolute_'.$i]; - if($day == "") { + if(trim($day) == "") { continue; } + + $time = $formData['add_show_rebroadcast_time_absolute_'.$i]; + if (trim($time) == ""){ + $this->getElement('add_show_rebroadcast_time_absolute_'.$i)->setErrors(array("Time must be specified")); + $valid = false; + } $show_start_time = $formData['add_show_start_date']."".$formData['add_show_start_time']; $show_end = new DateTime($show_start_time); @@ -51,16 +57,16 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm $show_end->add(new DateInterval("PT$duration[0]H")); $show_end->add(new DateInterval("PT$duration[1]M")); $show_end->add(new DateInterval("PT1H"));//min time to wait until a rebroadcast - + $rebroad_start = $day."".$formData['add_show_rebroadcast_time_absolute_'.$i]; $rebroad_start = new DateTime($rebroad_start); - + if($rebroad_start < $show_end) { $this->getElement('add_show_rebroadcast_time_absolute_'.$i)->setErrors(array("Must wait at least 1 hour to rebroadcast")); $valid = false; } - } - + } + return $valid; } } diff --git a/application/forms/AddShowRebroadcastDates.php b/application/forms/AddShowRebroadcastDates.php index 3a8cba562..e51bcf570 100644 --- a/application/forms/AddShowRebroadcastDates.php +++ b/application/forms/AddShowRebroadcastDates.php @@ -12,7 +12,7 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm $relativeDates = array(); $relativeDates[""] = ""; for($i=0; $i<=30; $i++) { - $relativeDates["$i days"] = "+$i days"; + $relativeDates["$i days"] = "+$i days"; } for($i=1; $i<=10; $i++) { @@ -40,12 +40,18 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm $valid = true; for($i=1; $i<=5; $i++) { - + $days = $formData['add_show_rebroadcast_date_'.$i]; - if($days == "") { + if(trim($days) == "") { continue; } + + $time = $formData['add_show_rebroadcast_time_'.$i]; + if (trim($time) == ""){ + $this->getElement('add_show_rebroadcast_time_'.$i)->setErrors(array("Time must be specified")); + $valid = false; + } $days = explode(" ", $days); $day = $days[0]; @@ -59,7 +65,7 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm $show_end->add(new DateInterval("PT$duration[0]H")); $show_end->add(new DateInterval("PT$duration[1]M")); $show_end->add(new DateInterval("PT1H"));//min time to wait until a rebroadcast - + $rebroad_start = $formData['add_show_start_date']."".$formData['add_show_rebroadcast_time_'.$i]; $rebroad_start = new DateTime($rebroad_start); $rebroad_start->add(new DateInterval("P".$day."D")); @@ -68,8 +74,8 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm $this->getElement('add_show_rebroadcast_time_'.$i)->setErrors(array("Must wait at least 1 hour to rebroadcast")); $valid = false; } - } - + } + return $valid; } }