diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index bbbf5e05f..2cb298e51 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -652,6 +652,11 @@ class ScheduleController extends Zend_Controller_Action $this->view->newForm = $this->view->render('schedule/add-show-form.phtml'); } else { + //the form still needs to be "update" since + //the validity test failed. + if ($data['add_show_id'] != -1){ + $this->view->addNewShow = false; + } $this->view->form = $this->view->render('schedule/add-show-form.phtml'); } diff --git a/airtime_mvc/application/models/Shows.php b/airtime_mvc/application/models/Shows.php index 9cf1123c0..ed3f076a2 100644 --- a/airtime_mvc/application/models/Shows.php +++ b/airtime_mvc/application/models/Shows.php @@ -536,24 +536,26 @@ class Show { //repeat option was toggled or show is recorded. $p_show->deleteAllInstances(); } - if ($p_data['add_show_start_date'] != $p_show->getStartDate() - || $p_data['add_show_start_time'] != $p_show->getStartTime()){ - //start date/time has changed - - $newDate = strtotime($p_data['add_show_start_date']); - $oldDate = strtotime($p_show->getStartDate()); - if ($newDate > $oldDate){ - $p_show->removeAllInstancesBeforeDate($p_data['add_show_start_date']); - } - $p_show->updateStartDateTime($p_data, $p_endDate); - } if ($p_data['add_show_duration'] != $p_show->getDuration()){ //duration has changed $p_show->updateDurationTime($p_data); } if ($p_data['add_show_repeats']){ + if ($p_data['add_show_start_date'] != $p_show->getStartDate() + || $p_data['add_show_start_time'] != $p_show->getStartTime()){ + //start date/time has changed + + $newDate = strtotime($p_data['add_show_start_date']); + $oldDate = strtotime($p_show->getStartDate()); + if ($newDate > $oldDate){ + $p_show->removeAllInstancesBeforeDate($p_data['add_show_start_date']); + } + + $p_show->updateStartDateTime($p_data, $p_endDate); + } + if ($repeatType != $p_show->getRepeatType()){ //repeat type changed. $p_show->deleteAllInstances(); @@ -863,21 +865,26 @@ class Show { $show = new Show($show_id); if ($show->hasInstance()){ - $showInstance = $show->getInstance(); + $ccShowInstance = $show->getInstance(); + $newInstance = false; } else { - $showInstance = new CcShowInstances(); + $ccShowInstance = new CcShowInstances(); + $newInstance = true; } - $showInstance->setDbShowId($show_id); - $showInstance->setDbStarts($start); - $showInstance->setDbEnds($end); - $showInstance->setDbRecord($record); - $showInstance->save(); - //$show->addInstance($showInstance); - + $ccShowInstance->setDbShowId($show_id); + $ccShowInstance->setDbStarts($start); + $ccShowInstance->setDbEnds($end); + $ccShowInstance->setDbRecord($record); + $ccShowInstance->save(); - $show_instance_id = $showInstance->getDbId(); + $show_instance_id = $ccShowInstance->getDbId(); + $showInstance = new ShowInstance($show_instance_id); + if (!$newInstance){ + $showInstance->correctScheduleStartTimes(); + } + $sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}"; $rebroadcasts = $CC_DBC->GetAll($sql); @@ -929,19 +936,24 @@ class Show { $end = $CC_DBC->GetOne($sql); if ($show->hasInstanceOnDate($start)){ - $showInstance = $show->getInstanceOnDate($start); + $ccShowInstance = $show->getInstanceOnDate($start); + $newInstance = false; } else { - $showInstance = new CcShowInstances(); + $ccShowInstance = new CcShowInstances(); + $newInstance = true; } - $showInstance->setDbShowId($show_id); - $showInstance->setDbStarts($start); - $showInstance->setDbEnds($end); - $showInstance->setDbRecord($record); - $showInstance->save(); - //$show->addInstance($showInstance); - + $ccShowInstance->setDbShowId($show_id); + $ccShowInstance->setDbStarts($start); + $ccShowInstance->setDbEnds($end); + $ccShowInstance->setDbRecord($record); + $ccShowInstance->save(); - $show_instance_id = $showInstance->getDbId(); + $show_instance_id = $ccShowInstance->getDbId(); + $showInstance = new ShowInstance($show_instance_id); + + if (!$newInstance){ + $showInstance->correctScheduleStartTimes(); + } foreach($rebroadcasts as $rebroadcast) { @@ -1292,16 +1304,32 @@ class ShowInstance { $showInstance->updateDbTimeFilled($con); } - public function moveScheduledShowContent($deltaDay, $deltaHours, $deltaMin) - { + public function correctScheduleStartTimes(){ global $CC_DBC; + + $instance_id = $this->getShowInstanceId(); + $sql = "SELECT starts from cc_schedule" + ." WHERE instance_id = $instance_id" + ." ORDER BY starts" + ." LIMIT 1"; - $sql = "UPDATE cc_schedule - SET starts = (starts + interval '{$deltaDay} days' + interval '{$deltaHours}:{$deltaMin}'), - ends = (ends + interval '{$deltaDay} days' + interval '{$deltaHours}:{$deltaMin}') - WHERE instance_id = '{$this->_instanceId}'"; + $scheduleStarts = $CC_DBC->GetOne($sql); + + if (!is_null($scheduleStarts)){ + $scheduleStartsEpoch = strtotime($scheduleStarts); + $showStartsEpoch = strtotime($this->getShowStart()); - $CC_DBC->query($sql); + $diff = $showStartsEpoch - $scheduleStartsEpoch; + + if ($diff != 0){ + $sql = "UPDATE cc_schedule" + ." SET starts = starts + INTERVAL '$diff' second," + ." ends = ends + INTERVAL '$diff' second" + ." WHERE instance_id = $instance_id"; + + $CC_DBC->query($sql); + } + } RabbitMq::PushSchedule(); } @@ -1347,9 +1375,9 @@ class ShowInstance { } } - $this->moveScheduledShowContent($deltaDay, $hours, $mins); $this->setShowStart($new_starts); $this->setShowEnd($new_ends); + $this->correctScheduleStartTimes(); RabbitMq::PushSchedule(); } 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 1bb3d50ea..5330bc693 100644 --- a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js +++ b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js @@ -10,12 +10,15 @@ function scheduleRefetchEvents() { function openAddShowForm() { - if(($("#add-show-form").length == 1) && ($("#add-show-form").css('display')=='none')) { - $("#add-show-form").show(); - var y = $("#schedule_calendar").width(); - var z = $("#schedule-add-show").width(); - $("#schedule_calendar").width(y-z-50); - $("#schedule_calendar").fullCalendar('render'); + if($("#add-show-form").length == 1) { + if( ($("#add-show-form").css('display')=='none')) { + $("#add-show-form").show(); + var y = $("#schedule_calendar").width(); + var z = $("#schedule-add-show").width(); + $("#schedule_calendar").width(y-z-50); + $("#schedule_calendar").fullCalendar('render'); + } + $("#schedule-show-what").show(); } } diff --git a/python_apps/pypo/install/pypo-daemontools-logger.sh b/python_apps/pypo/install/pypo-daemontools-logger.sh index 9673575db..249bfd78b 100755 --- a/python_apps/pypo/install/pypo-daemontools-logger.sh +++ b/python_apps/pypo/install/pypo-daemontools-logger.sh @@ -1,2 +1,2 @@ #!/bin/sh -exec setuidgid pypo multilog t ./main +exec setuidgid pypo multilog t /var/log/airtime/pypo/main diff --git a/python_apps/pypo/install/pypo-install.py b/python_apps/pypo/install/pypo-install.py index 1171dfe23..66d94fcc5 100755 --- a/python_apps/pypo/install/pypo-install.py +++ b/python_apps/pypo/install/pypo-install.py @@ -72,9 +72,13 @@ try: create_user("pypo") print "Creating log directories" - create_path("/var/log/pypo") - os.system("chmod -R 755 /var/log/pypo") - os.system("chown -R pypo:pypo /var/log/pypo") + create_path("/var/log/airtime/pypo") + os.system("chmod -R 755 /var/log/airtime/pypo") + os.system("chown -R pypo:pypo /var/log/airtime/pypo") + + create_path("/var/log/airtime/pypo-liquidsoap") + os.system("chmod -R 755 /var/log/airtime/pypo-liquidsoap") + os.system("chown -R pypo:pypo /var/log/airtime/pypo-liquidsoap") create_path(BASE_PATH) create_path(BASE_PATH+"bin") @@ -112,7 +116,7 @@ try: create_path("/etc/service/pypo-liquidsoap") create_path("/etc/service/pypo-liquidsoap/log") shutil.copy("%s/pypo-daemontools-liquidsoap.sh"%current_script_dir, "/etc/service/pypo-liquidsoap/run") - shutil.copy("%s/pypo-daemontools-logger.sh"%current_script_dir, "/etc/service/pypo-liquidsoap/log/run") + shutil.copy("%s/pypo-liquidsoap-daemontools-logger.sh"%current_script_dir, "/etc/service/pypo-liquidsoap/log/run") os.system("chmod -R 755 /etc/service/pypo-liquidsoap") os.system("chown -R pypo:pypo /etc/service/pypo-liquidsoap") diff --git a/python_apps/pypo/install/pypo-liquidsoap-daemontools-logger.sh b/python_apps/pypo/install/pypo-liquidsoap-daemontools-logger.sh new file mode 100644 index 000000000..98ac88c3b --- /dev/null +++ b/python_apps/pypo/install/pypo-liquidsoap-daemontools-logger.sh @@ -0,0 +1,2 @@ +#!/bin/sh +exec setuidgid pypo multilog t /var/log/airtime/pypo-liquidsoap/main diff --git a/python_apps/pypo/install/pypo-uninstall.py b/python_apps/pypo/install/pypo-uninstall.py index cd22e9c4c..004556bf0 100755 --- a/python_apps/pypo/install/pypo-uninstall.py +++ b/python_apps/pypo/install/pypo-uninstall.py @@ -32,7 +32,8 @@ try: os.system("python %s/pypo-stop.py" % get_current_script_dir()) print "Removing log directories" - remove_path("/var/log/pypo") + remove_path("/var/log/airtime/pypo") + remove_path("/var/log/airtime/pypo-liquidsoap") print "Removing pypo files" remove_path(BASE_PATH) diff --git a/python_apps/pypo/scripts/liquidsoap.cfg b/python_apps/pypo/scripts/liquidsoap.cfg index a7f310f1a..467ece4d1 100644 --- a/python_apps/pypo/scripts/liquidsoap.cfg +++ b/python_apps/pypo/scripts/liquidsoap.cfg @@ -7,7 +7,7 @@ # general settings # ########################################### -log_file = "/var/log/pypo/