From 4c5386c0f3f3c2ef5d108bd3707cd2154ba1b097 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Wed, 2 Nov 2011 15:19:27 -0400 Subject: [PATCH 01/23] 1.9.5 preparations --- CREDITS | 4 ++++ Changelog | 8 ++++++++ VERSION | 2 +- airtime_mvc/application/configs/constants.php | 2 +- python_apps/api_clients/api_client.py | 2 +- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CREDITS b/CREDITS index 745ae324b..162aa2ef9 100644 --- a/CREDITS +++ b/CREDITS @@ -1,6 +1,10 @@ ======= CREDITS ======= +Version 1.9.5 +------------- +Same as previous version. + Version 1.9.4 ------------- Same as previous version. diff --git a/Changelog b/Changelog index 2b25f4df9..f7f87c1f3 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,11 @@ +1.9.5 - Nov 2, 2011 + *(CC-2743, CC-2769) Fixed problem where Media-Monitor would try to parse a file's metadata while the OS was still copying it + *(CC-2882) Fixed a bug where a couldn't unregister an old directory name from Airtime after it was renamed. + *(CC-2891) Fixed a bug with parsing Unicode metadata in audio files. + *(CC-2972) Fixed a bug where systems behind a firewall would have Airtime services communicating via its external IP. + *(CC-2975) Issue with older python-virtualenv identified. Airtime installer now requires virtualenv >= 1.4.9 + *(CC-3012, CC-3013) Fixed an issue with Media-Monitor crashing when parsing certain audio tracks + 1.9.4 - Sept 13, 2011 *Improvements -DEB packages now available for Ubuntu & Debian diff --git a/VERSION b/VERSION index 753715b20..5bd3a7dff 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ PRODUCT_ID=Airtime -PRODUCT_RELEASE=1.9.4 +PRODUCT_RELEASE=1.9.5 diff --git a/airtime_mvc/application/configs/constants.php b/airtime_mvc/application/configs/constants.php index c9f0132f7..03661ac9a 100644 --- a/airtime_mvc/application/configs/constants.php +++ b/airtime_mvc/application/configs/constants.php @@ -1,6 +1,6 @@ Date: Wed, 2 Nov 2011 15:34:47 -0400 Subject: [PATCH 02/23] Airtime 1.9.5 upgrade script --- install_minimal/include/airtime-upgrade.php | 3 ++ .../airtime-1.9.5/airtime-upgrade.php | 37 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 install_minimal/upgrades/airtime-1.9.5/airtime-upgrade.php diff --git a/install_minimal/include/airtime-upgrade.php b/install_minimal/include/airtime-upgrade.php index c85c2f300..b7da2af24 100644 --- a/install_minimal/include/airtime-upgrade.php +++ b/install_minimal/include/airtime-upgrade.php @@ -77,6 +77,9 @@ if (strcmp($version, "1.9.3") < 0){ if (strcmp($version, "1.9.4") < 0){ passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-1.9.4/airtime-upgrade.php"); } +if (strcmp($version, "1.9.5") < 0){ + passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-1.9.5/airtime-upgrade.php"); +} //set the new version in the database. $sql = "DELETE FROM cc_pref WHERE keystr = 'system_version'"; diff --git a/install_minimal/upgrades/airtime-1.9.5/airtime-upgrade.php b/install_minimal/upgrades/airtime-1.9.5/airtime-upgrade.php new file mode 100644 index 000000000..7981a073a --- /dev/null +++ b/install_minimal/upgrades/airtime-1.9.5/airtime-upgrade.php @@ -0,0 +1,37 @@ + Date: Thu, 3 Nov 2011 15:25:09 -0400 Subject: [PATCH 03/23] CC-3016: Import files doesn't work on Debian(1.9.5, 2.0) - fixed --- python_apps/media-monitor/MediaMonitor.py | 2 +- .../airtimefilemonitor/airtimeprocessevent.py | 20 +++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/python_apps/media-monitor/MediaMonitor.py b/python_apps/media-monitor/MediaMonitor.py index 32ca17878..e5821049c 100644 --- a/python_apps/media-monitor/MediaMonitor.py +++ b/python_apps/media-monitor/MediaMonitor.py @@ -64,7 +64,7 @@ try: bootstrap = AirtimeMediaMonitorBootstrap(logger, pe, api_client, mmc) bootstrap.scan() - notifier = AirtimeNotifier(wm, pe, read_freq=0.1, timeout=0, airtime_config=config, api_client=api_client, bootstrap=bootstrap, mmc=mmc) + notifier = AirtimeNotifier(wm, pe, read_freq=0, timeout=0, airtime_config=config, api_client=api_client, bootstrap=bootstrap, mmc=mmc) notifier.coalesce_events() #create 5 worker threads diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py index 5c8e9f9d6..e66425651 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py @@ -1,6 +1,7 @@ import socket import logging import time +import os import pyinotify from pyinotify import ProcessEvent @@ -90,8 +91,9 @@ class AirtimeProcessEvent(ProcessEvent): def process_IN_CREATE(self, event): self.logger.info("event: %s", event) - # record the timestamp of the time on IN_CREATE event - self.create_dict[event.pathname] = time.time() + if not event.dir: + # record the timestamp of the time on IN_CREATE event + self.create_dict[event.pathname] = time.time() #event.dir: True if the event was raised against a directory. #event.name: filename @@ -268,8 +270,18 @@ class AirtimeProcessEvent(ProcessEvent): # this part is like a garbage collector for k, t in self.create_dict.items(): now = time.time() - if now - t > 300: - del self.create_dict[k] + if now - t > 5: + # check if file exist + if os.path.exists(k): + # check if file is open + command = "lsof "+k + f = os.popen(command) + if not f.readlines(): + self.logger.info("Handling file: %s", k) + self.handle_created_file(False, k, os.path.basename(k)) + del self.create_dict[k] + else: + del self.create_dict[k] #check for any events received from Airtime. try: From a156548ba623d23e958f2858c4364e3c9540c1ea Mon Sep 17 00:00:00 2001 From: James Date: Thu, 3 Nov 2011 15:35:04 -0400 Subject: [PATCH 04/23] CC-3016: Import files doesn't work on Debian(1.9.5, 2.0) - adding comment --- .../media-monitor/airtimefilemonitor/airtimeprocessevent.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py index e66425651..af8658c2a 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py @@ -272,6 +272,9 @@ class AirtimeProcessEvent(ProcessEvent): now = time.time() if now - t > 5: # check if file exist + # When whole directory is copied to the organized dir, + # inotify doesn't fire IN_CLOSE_WRITE, hench we need special way of + # handling those cases. if os.path.exists(k): # check if file is open command = "lsof "+k From 8e88c56bc6524920f164ae426b275c77ec779afe Mon Sep 17 00:00:00 2001 From: James Date: Thu, 27 Oct 2011 14:34:03 -0400 Subject: [PATCH 05/23] CC-2954: Exception in media monitor using Dropbox - This will take care of the exception issue --- .../airtimefilemonitor/mediamonitorcommon.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/python_apps/media-monitor/airtimefilemonitor/mediamonitorcommon.py b/python_apps/media-monitor/airtimefilemonitor/mediamonitorcommon.py index bf0ab3f8e..0bb86755b 100644 --- a/python_apps/media-monitor/airtimefilemonitor/mediamonitorcommon.py +++ b/python_apps/media-monitor/airtimefilemonitor/mediamonitorcommon.py @@ -26,9 +26,14 @@ class MediaMonitorCommon: def is_temp_file(self, filename): info = filename.split(".") - - if(info[-2] in self.supported_file_formats): - return True + + # if file doesn't have any extension, info[-2] throws exception + # Hence, checking length of info before we do anything + if(len(info) >= 3): + if(info[-2] in self.supported_file_formats): + return True + else: + return False else: return False From 9448728d636ff45d7069ad242ada82491da0eb9c Mon Sep 17 00:00:00 2001 From: James Date: Mon, 3 Oct 2011 14:26:10 -0400 Subject: [PATCH 06/23] CC-2904: Space missing between two boxes on "Playlist Builder" - fixed --- airtime_mvc/application/layouts/scripts/library.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/layouts/scripts/library.phtml b/airtime_mvc/application/layouts/scripts/library.phtml index 2e4536188..65573a592 100644 --- a/airtime_mvc/application/layouts/scripts/library.phtml +++ b/airtime_mvc/application/layouts/scripts/library.phtml @@ -20,7 +20,7 @@
-
layout()->library ?>
+
layout()->library ?>
layout()->spl ?>
From b33ced99c8017190e160b469400eecde10d28d2d Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Thu, 3 Nov 2011 22:12:03 -0400 Subject: [PATCH 07/23] CC-2954: Exception in media monitor using Dropbox -Need to check if size is >=2, not 3. --- .../media-monitor/airtimefilemonitor/mediamonitorcommon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python_apps/media-monitor/airtimefilemonitor/mediamonitorcommon.py b/python_apps/media-monitor/airtimefilemonitor/mediamonitorcommon.py index 0bb86755b..dc7e81768 100644 --- a/python_apps/media-monitor/airtimefilemonitor/mediamonitorcommon.py +++ b/python_apps/media-monitor/airtimefilemonitor/mediamonitorcommon.py @@ -29,7 +29,7 @@ class MediaMonitorCommon: # if file doesn't have any extension, info[-2] throws exception # Hence, checking length of info before we do anything - if(len(info) >= 3): + if(len(info) >= 2): if(info[-2] in self.supported_file_formats): return True else: From eca76dc2f06c678e611577cf02c9a28a53b776cc Mon Sep 17 00:00:00 2001 From: James Date: Mon, 7 Nov 2011 13:16:50 -0500 Subject: [PATCH 08/23] CC-2895: Manage Media Folder: Title disappears after adding watched folder - fixed --- airtime_mvc/public/js/airtime/preferences/musicdirs.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/airtime_mvc/public/js/airtime/preferences/musicdirs.js b/airtime_mvc/public/js/airtime/preferences/musicdirs.js index a71e7aa31..44974d483 100644 --- a/airtime_mvc/public/js/airtime/preferences/musicdirs.js +++ b/airtime_mvc/public/js/airtime/preferences/musicdirs.js @@ -69,6 +69,7 @@ function setWatchedDirEvents() { function(json) { $("#watched-folder-section").empty(); + $("#watched-folder-section").append("

Manage Media Folders

"); $("#watched-folder-section").append(json.subform); setWatchedDirEvents(); }); @@ -86,6 +87,7 @@ function setWatchedDirEvents() { function(json) { $("#watched-folder-section").empty(); + $("#watched-folder-section").append("

Manage Media Folders

"); $("#watched-folder-section").append(json.subform); setWatchedDirEvents(); }); From 97b0807a67a1a7fdb081dfcaf6e74bc8daf08db1 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 8 Nov 2011 17:19:46 -0500 Subject: [PATCH 09/23] do a --force-yes for non-free packages --- install_full/ubuntu/airtime-full-install | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/install_full/ubuntu/airtime-full-install b/install_full/ubuntu/airtime-full-install index 190c7ebb9..f95064b17 100755 --- a/install_full/ubuntu/airtime-full-install +++ b/install_full/ubuntu/airtime-full-install @@ -24,11 +24,14 @@ echo "----------------------------------------------------" # Updated package list apt-get -y install tar gzip curl apache2 php5-pgsql libapache2-mod-php5 \ -php-pear php5-gd postgresql odbc-postgresql python2.6 lame libsoundtouch-ocaml \ -libvorbis-ocaml-dev libmp3lame-dev libtaglib-ocaml libao-ocaml libmad-ocaml \ +php-pear php5-gd postgresql odbc-postgresql python2.6 libsoundtouch-ocaml \ +libvorbis-ocaml-dev libtaglib-ocaml libao-ocaml libmad-ocaml \ libesd0 icecast2 libportaudio2 libsamplerate0 libcamomile-ocaml-dev \ ecasound php5-curl mpg123 rabbitmq-server monit python-virtualenv patch +#install packages with --force-yes option +apt-get -y --force-yes libmp3lame-dev lame + if [ "$?" -ne "0" ]; then echo "" echo "There was a problem with apt-get. Please check the above error and try again." From a551e08fce9998b59f55f3f6236112afe23c86ae Mon Sep 17 00:00:00 2001 From: James Date: Wed, 9 Nov 2011 11:27:17 -0500 Subject: [PATCH 10/23] - cleaning up a dirty code --- airtime_mvc/application/models/MusicDir.php | 1 - 1 file changed, 1 deletion(-) diff --git a/airtime_mvc/application/models/MusicDir.php b/airtime_mvc/application/models/MusicDir.php index b1416ef7f..5e44b7bbd 100644 --- a/airtime_mvc/application/models/MusicDir.php +++ b/airtime_mvc/application/models/MusicDir.php @@ -282,7 +282,6 @@ class MusicDir { } public static function removeWatchedDir($p_dir){ - $p_dir = realpath($p_dir)."/"; $real_path = realpath($p_dir)."/"; if($real_path != "/"){ $p_dir = $real_path; From acc32df0609ca88fdbc2ee896fe891315c219535 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Wed, 9 Nov 2011 11:51:58 -0500 Subject: [PATCH 11/23] 1.9.5 upgrade script had incorrect class name. --- install_minimal/upgrades/airtime-1.9.5/airtime-upgrade.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install_minimal/upgrades/airtime-1.9.5/airtime-upgrade.php b/install_minimal/upgrades/airtime-1.9.5/airtime-upgrade.php index 7981a073a..99de832f2 100644 --- a/install_minimal/upgrades/airtime-1.9.5/airtime-upgrade.php +++ b/install_minimal/upgrades/airtime-1.9.5/airtime-upgrade.php @@ -1,6 +1,6 @@ Date: Wed, 9 Nov 2011 13:35:22 -0500 Subject: [PATCH 12/23] CC-3016: Import files doesn't work on Debian(1.9.5, 2.0) - added extra comment --- .../media-monitor/airtimefilemonitor/airtimeprocessevent.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py index af8658c2a..cfd605cf2 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py @@ -274,7 +274,8 @@ class AirtimeProcessEvent(ProcessEvent): # check if file exist # When whole directory is copied to the organized dir, # inotify doesn't fire IN_CLOSE_WRITE, hench we need special way of - # handling those cases. + # handling those cases. We are manully calling handle_created_file + # function. if os.path.exists(k): # check if file is open command = "lsof "+k From 86d316a2f9ad3062886cc22ffd2c1477919b4325 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Wed, 9 Nov 2011 15:09:15 -0500 Subject: [PATCH 13/23] -airtime install script fixes. --- install_full/ubuntu/airtime-full-install | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/install_full/ubuntu/airtime-full-install b/install_full/ubuntu/airtime-full-install index f95064b17..89f98e976 100755 --- a/install_full/ubuntu/airtime-full-install +++ b/install_full/ubuntu/airtime-full-install @@ -22,6 +22,8 @@ echo "----------------------------------------------------" echo " 1. Install Packages" echo "----------------------------------------------------" +apt-get update + # Updated package list apt-get -y install tar gzip curl apache2 php5-pgsql libapache2-mod-php5 \ php-pear php5-gd postgresql odbc-postgresql python2.6 libsoundtouch-ocaml \ @@ -30,7 +32,7 @@ libesd0 icecast2 libportaudio2 libsamplerate0 libcamomile-ocaml-dev \ ecasound php5-curl mpg123 rabbitmq-server monit python-virtualenv patch #install packages with --force-yes option -apt-get -y --force-yes libmp3lame-dev lame +apt-get -y --force-yes install libmp3lame-dev lame if [ "$?" -ne "0" ]; then echo "" From 45d3d75d1a2b1c659fbf7358b3ce751bf6ac9b2b Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Thu, 10 Nov 2011 12:33:54 -0500 Subject: [PATCH 14/23] CC-2870: Create testing infrastructure for testing upgrades -small fix for debian. icecast2 needs to be force-yes installed. (unverified package) --- install_full/ubuntu/airtime-full-install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install_full/ubuntu/airtime-full-install b/install_full/ubuntu/airtime-full-install index 89f98e976..9f0b7344d 100755 --- a/install_full/ubuntu/airtime-full-install +++ b/install_full/ubuntu/airtime-full-install @@ -28,11 +28,11 @@ apt-get update apt-get -y install tar gzip curl apache2 php5-pgsql libapache2-mod-php5 \ php-pear php5-gd postgresql odbc-postgresql python2.6 libsoundtouch-ocaml \ libvorbis-ocaml-dev libtaglib-ocaml libao-ocaml libmad-ocaml \ -libesd0 icecast2 libportaudio2 libsamplerate0 libcamomile-ocaml-dev \ +libesd0 libportaudio2 libsamplerate0 libcamomile-ocaml-dev \ ecasound php5-curl mpg123 rabbitmq-server monit python-virtualenv patch #install packages with --force-yes option -apt-get -y --force-yes install libmp3lame-dev lame +apt-get -y --force-yes install libmp3lame-dev lame icecast2 if [ "$?" -ne "0" ]; then echo "" From 2fc46cd29b87c33566315d64de4c5fd21933fef2 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Mon, 14 Nov 2011 21:28:27 -0500 Subject: [PATCH 15/23] CC-3039: Install script doesnt check whether virtualenv exists (Ubuntu 11.10) -fixed -moved virtualenv version check into virtualenv-install.sh --- install_minimal/airtime-install | 15 ------------- .../python-virtualenv/virtualenv-install.sh | 21 +++++++++++++++++++ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/install_minimal/airtime-install b/install_minimal/airtime-install index 7859e1c23..f242b12a9 100755 --- a/install_minimal/airtime-install +++ b/install_minimal/airtime-install @@ -15,21 +15,6 @@ if [[ "$DEB" = "Status: install ok installed" ]]; then exit 1 fi -#Check whether version of virtualenv is <= 1.4.8. If so exit install. -BAD_VERSION="1.4.8" -VERSION=$(virtualenv --version) -NEWEST_VERSION=$(echo -e "$BAD_VERSION\n$VERSION\n'" | sort -t '.' -g | tail -n 1) -echo -n "Ensuring python-virtualenv version > $BAD_VERSION..." -if [[ "$NEWEST_VERSION" = "$BAD_VERSION" ]]; then - URL="http://apt.sourcefabric.org/pool/main/p/python-virtualenv/python-virtualenv_1.4.9-3_all.deb" - echo "Failed!" - echo "You have version $BAD_VERSION or older installed. Please install package at $URL first and then try installing Airtime again." - exit 1 -else - echo "Success!" -fi - - echo -e "\n******************************** Install Begin *********************************" # Absolute path to this script, e.g. /home/user/bin/foo.sh diff --git a/python_apps/python-virtualenv/virtualenv-install.sh b/python_apps/python-virtualenv/virtualenv-install.sh index c38e48c43..580c675e8 100755 --- a/python_apps/python-virtualenv/virtualenv-install.sh +++ b/python_apps/python-virtualenv/virtualenv-install.sh @@ -4,6 +4,27 @@ SCRIPT=`readlink -f $0` # Absolute directory this script is in SCRIPTPATH=`dirname $SCRIPT` +which virtualenv > /dev/null +if [ "$?" -ne "0" ]; then + echo "virtualenv not found!" + echo -e "Please install virtualenv and retry Airtime installation.\n" + exit 1 +fi + +#Check whether version of virtualenv is <= 1.4.8. If so exit install. +BAD_VERSION="1.4.8" +VERSION=$(virtualenv --version) +NEWEST_VERSION=$(echo -e "$BAD_VERSION\n$VERSION\n'" | sort -t '.' -g | tail -n 1) +echo -n "Ensuring python-virtualenv version > $BAD_VERSION..." +if [[ "$NEWEST_VERSION" = "$BAD_VERSION" ]]; then + URL="http://apt.sourcefabric.org/pool/main/p/python-virtualenv/python-virtualenv_1.4.9-3_all.deb" + echo "Failed!" + echo "You have version $BAD_VERSION or older installed. Please install package at $URL first and then try installing Airtime again." + exit 1 +else + echo "Success!" +fi + VIRTUAL_ENV_DIR="/usr/lib/airtime/airtime_virtualenv" VIRTUAL_ENV_SHARE="/usr/share/python-virtualenv/" From e3395ae1e5e62d8cc52ab55469240cf6336b2c79 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Mon, 14 Nov 2011 22:37:34 -0500 Subject: [PATCH 16/23] CC-3036: Deleted Show instances reappear -done. --- airtime_mvc/application/models/Show.php | 29 +++++----- .../application/models/ShowInstance.php | 18 +++++- .../airtime/map/CcShowInstancesTableMap.php | 1 + .../models/airtime/om/BaseCcShowInstances.php | 56 ++++++++++++++++++- .../airtime/om/BaseCcShowInstancesPeer.php | 31 +++++----- .../airtime/om/BaseCcShowInstancesQuery.php | 21 +++++++ airtime_mvc/build/schema.xml | 5 ++ airtime_mvc/build/sql/schema.sql | 1 + install_full/ubuntu/airtime-full-install | 3 +- .../Version20111114222927.php | 20 +++++++ .../airtime-2.0.0/airtime-upgrade.php | 2 +- 11 files changed, 155 insertions(+), 32 deletions(-) create mode 100644 install_minimal/DoctrineMigrations/Version20111114222927.php diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 38c911bb0..1990663df 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -1176,7 +1176,7 @@ class Application_Model_Show { } $sql = "SELECT starts, ends, record, rebroadcast, instance_id, show_id, name, description, - color, background_color, file_id, cc_show_instances.id AS instance_id + color, background_color, file_id, deleted_instance, cc_show_instances.id AS instance_id FROM cc_show_instances LEFT JOIN cc_show ON cc_show.id = cc_show_instances.show_id"; @@ -1275,20 +1275,22 @@ class Application_Model_Show { $today_timestamp = date("Y-m-d H:i:s"); foreach ($shows as $show) { - $options = array(); - //only bother calculating percent for week or day view. - if(intval($days) <= 7) { - $show_instance = new Application_Model_ShowInstance($show["instance_id"]); - $options["percent"] = $show_instance->getPercentScheduled(); - } + if ($show["deleted_instance"] != "t"){ + $options = array(); - if ($editable && (strtotime($today_timestamp) < strtotime($show["starts"]))) { - $options["editable"] = true; - $events[] = Application_Model_Show::makeFullCalendarEvent($show, $options); - } - else { - $events[] = Application_Model_Show::makeFullCalendarEvent($show, $options); + //only bother calculating percent for week or day view. + if(intval($days) <= 7) { + $show_instance = new Application_Model_ShowInstance($show["instance_id"]); + $options["percent"] = $show_instance->getPercentScheduled(); + } + + if ($editable && (strtotime($today_timestamp) < strtotime($show["starts"]))) { + $options["editable"] = true; + $events[] = Application_Model_Show::makeFullCalendarEvent($show, $options); + } else { + $events[] = Application_Model_Show::makeFullCalendarEvent($show, $options); + } } } @@ -1317,6 +1319,7 @@ class Application_Model_Show { $event["description"] = $show["description"]; $event["showId"] = $show["show_id"]; $event["record"] = intval($show["record"]); + $event["deleted_instance"] = $show["deleted_instance"]; $event["rebroadcast"] = intval($show["rebroadcast"]); // get soundcloud_id diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index 7d1f81d1b..937db958f 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -136,6 +136,11 @@ class Application_Model_ShowInstance { $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME); $this->_showInstance->updateDbTimeFilled($con); } + + public function isDeleted() + { + $this->_showInstance->getDbDeletedInstance(); + } public function correctScheduleStartTimes(){ global $CC_DBC; @@ -392,16 +397,23 @@ class Application_Model_ShowInstance { CcShowInstancesQuery::create() ->findPK($this->_instanceId) - ->delete(); + ->setDbDeletedInstance(true) + ->save(); // check if we can safely delete the show $showInstancesRow = CcShowInstancesQuery::create() ->filterByDbShowId($showId) + ->filterByDbDeletedInstance(false) ->findOne(); + /* If we didn't find any instances of the show that haven't + * been deleted, then just erase everything related to that show. + * We can just delete, the show and the foreign key-constraint should + * take care of deleting all of its instances. */ if(is_null($showInstancesRow)){ - $sql = "DELETE FROM cc_show WHERE id = '$showId'"; - $CC_DBC->query($sql); + CcShowQuery::create() + ->filterByDbId($showId) + ->delete(); } Application_Model_RabbitMq::PushSchedule(); diff --git a/airtime_mvc/application/models/airtime/map/CcShowInstancesTableMap.php b/airtime_mvc/application/models/airtime/map/CcShowInstancesTableMap.php index 69efea1dd..73e39484c 100644 --- a/airtime_mvc/application/models/airtime/map/CcShowInstancesTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcShowInstancesTableMap.php @@ -47,6 +47,7 @@ class CcShowInstancesTableMap extends TableMap { $this->addForeignKey('INSTANCE_ID', 'DbOriginalShow', 'INTEGER', 'cc_show_instances', 'ID', false, null, null); $this->addForeignKey('FILE_ID', 'DbRecordedFile', 'INTEGER', 'cc_files', 'ID', false, null, null); $this->addColumn('TIME_FILLED', 'DbTimeFilled', 'TIME', false, null, null); + $this->addColumn('DELETED_INSTANCE', 'DbDeletedInstance', 'BOOLEAN', true, null, false); // validators } // initialize() diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowInstances.php b/airtime_mvc/application/models/airtime/om/BaseCcShowInstances.php index ebadd9600..9739710e1 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowInstances.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowInstances.php @@ -80,6 +80,13 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent */ protected $time_filled; + /** + * The value for the deleted_instance field. + * Note: this column has a database default value of: false + * @var boolean + */ + protected $deleted_instance; + /** * @var CcShow */ @@ -129,6 +136,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent { $this->record = 0; $this->rebroadcast = 0; + $this->deleted_instance = false; } /** @@ -300,6 +308,16 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent } } + /** + * Get the [deleted_instance] column value. + * + * @return boolean + */ + public function getDbDeletedInstance() + { + return $this->deleted_instance; + } + /** * Set the value of [id] column. * @@ -579,6 +597,26 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent return $this; } // setDbTimeFilled() + /** + * Set the value of [deleted_instance] column. + * + * @param boolean $v new value + * @return CcShowInstances The current object (for fluent API support) + */ + public function setDbDeletedInstance($v) + { + if ($v !== null) { + $v = (boolean) $v; + } + + if ($this->deleted_instance !== $v || $this->isNew()) { + $this->deleted_instance = $v; + $this->modifiedColumns[] = CcShowInstancesPeer::DELETED_INSTANCE; + } + + return $this; + } // setDbDeletedInstance() + /** * Indicates whether the columns in this object are only set to default values. * @@ -597,6 +635,10 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent return false; } + if ($this->deleted_instance !== false) { + return false; + } + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -628,6 +670,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent $this->instance_id = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null; $this->file_id = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null; $this->time_filled = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; + $this->deleted_instance = ($row[$startcol + 9] !== null) ? (boolean) $row[$startcol + 9] : null; $this->resetModified(); $this->setNew(false); @@ -636,7 +679,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent $this->ensureConsistency(); } - return $startcol + 9; // 9 = CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS). + return $startcol + 10; // 10 = CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS). } catch (Exception $e) { throw new PropelException("Error populating CcShowInstances object", $e); @@ -1060,6 +1103,9 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent case 8: return $this->getDbTimeFilled(); break; + case 9: + return $this->getDbDeletedInstance(); + break; default: return null; break; @@ -1093,6 +1139,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent $keys[6] => $this->getDbOriginalShow(), $keys[7] => $this->getDbRecordedFile(), $keys[8] => $this->getDbTimeFilled(), + $keys[9] => $this->getDbDeletedInstance(), ); if ($includeForeignObjects) { if (null !== $this->aCcShow) { @@ -1162,6 +1209,9 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent case 8: $this->setDbTimeFilled($value); break; + case 9: + $this->setDbDeletedInstance($value); + break; } // switch() } @@ -1195,6 +1245,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent if (array_key_exists($keys[6], $arr)) $this->setDbOriginalShow($arr[$keys[6]]); if (array_key_exists($keys[7], $arr)) $this->setDbRecordedFile($arr[$keys[7]]); if (array_key_exists($keys[8], $arr)) $this->setDbTimeFilled($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setDbDeletedInstance($arr[$keys[9]]); } /** @@ -1215,6 +1266,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent if ($this->isColumnModified(CcShowInstancesPeer::INSTANCE_ID)) $criteria->add(CcShowInstancesPeer::INSTANCE_ID, $this->instance_id); if ($this->isColumnModified(CcShowInstancesPeer::FILE_ID)) $criteria->add(CcShowInstancesPeer::FILE_ID, $this->file_id); if ($this->isColumnModified(CcShowInstancesPeer::TIME_FILLED)) $criteria->add(CcShowInstancesPeer::TIME_FILLED, $this->time_filled); + if ($this->isColumnModified(CcShowInstancesPeer::DELETED_INSTANCE)) $criteria->add(CcShowInstancesPeer::DELETED_INSTANCE, $this->deleted_instance); return $criteria; } @@ -1284,6 +1336,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent $copyObj->setDbOriginalShow($this->instance_id); $copyObj->setDbRecordedFile($this->file_id); $copyObj->setDbTimeFilled($this->time_filled); + $copyObj->setDbDeletedInstance($this->deleted_instance); if ($deepCopy) { // important: temporarily setNew(false) because this affects the behavior of @@ -1801,6 +1854,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent $this->instance_id = null; $this->file_id = null; $this->time_filled = null; + $this->deleted_instance = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; $this->clearAllReferences(); diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesPeer.php index bbbfc3da9..3a4c42583 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesPeer.php @@ -26,7 +26,7 @@ abstract class BaseCcShowInstancesPeer { const TM_CLASS = 'CcShowInstancesTableMap'; /** The total number of columns. */ - const NUM_COLUMNS = 9; + const NUM_COLUMNS = 10; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; @@ -58,6 +58,9 @@ abstract class BaseCcShowInstancesPeer { /** the column name for the TIME_FILLED field */ const TIME_FILLED = 'cc_show_instances.TIME_FILLED'; + /** the column name for the DELETED_INSTANCE field */ + const DELETED_INSTANCE = 'cc_show_instances.DELETED_INSTANCE'; + /** * An identiy map to hold any loaded instances of CcShowInstances objects. * This must be public so that other peer classes can access this when hydrating from JOIN @@ -74,12 +77,12 @@ abstract class BaseCcShowInstancesPeer { * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ private static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('DbId', 'DbStarts', 'DbEnds', 'DbShowId', 'DbRecord', 'DbRebroadcast', 'DbOriginalShow', 'DbRecordedFile', 'DbTimeFilled', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbShowId', 'dbRecord', 'dbRebroadcast', 'dbOriginalShow', 'dbRecordedFile', 'dbTimeFilled', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::STARTS, self::ENDS, self::SHOW_ID, self::RECORD, self::REBROADCAST, self::INSTANCE_ID, self::FILE_ID, self::TIME_FILLED, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'SHOW_ID', 'RECORD', 'REBROADCAST', 'INSTANCE_ID', 'FILE_ID', 'TIME_FILLED', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'show_id', 'record', 'rebroadcast', 'instance_id', 'file_id', 'time_filled', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbStarts', 'DbEnds', 'DbShowId', 'DbRecord', 'DbRebroadcast', 'DbOriginalShow', 'DbRecordedFile', 'DbTimeFilled', 'DbDeletedInstance', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbShowId', 'dbRecord', 'dbRebroadcast', 'dbOriginalShow', 'dbRecordedFile', 'dbTimeFilled', 'dbDeletedInstance', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::STARTS, self::ENDS, self::SHOW_ID, self::RECORD, self::REBROADCAST, self::INSTANCE_ID, self::FILE_ID, self::TIME_FILLED, self::DELETED_INSTANCE, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'SHOW_ID', 'RECORD', 'REBROADCAST', 'INSTANCE_ID', 'FILE_ID', 'TIME_FILLED', 'DELETED_INSTANCE', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'show_id', 'record', 'rebroadcast', 'instance_id', 'file_id', 'time_filled', 'deleted_instance', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) ); /** @@ -89,12 +92,12 @@ abstract class BaseCcShowInstancesPeer { * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ private static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbStarts' => 1, 'DbEnds' => 2, 'DbShowId' => 3, 'DbRecord' => 4, 'DbRebroadcast' => 5, 'DbOriginalShow' => 6, 'DbRecordedFile' => 7, 'DbTimeFilled' => 8, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbShowId' => 3, 'dbRecord' => 4, 'dbRebroadcast' => 5, 'dbOriginalShow' => 6, 'dbRecordedFile' => 7, 'dbTimeFilled' => 8, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::STARTS => 1, self::ENDS => 2, self::SHOW_ID => 3, self::RECORD => 4, self::REBROADCAST => 5, self::INSTANCE_ID => 6, self::FILE_ID => 7, self::TIME_FILLED => 8, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'SHOW_ID' => 3, 'RECORD' => 4, 'REBROADCAST' => 5, 'INSTANCE_ID' => 6, 'FILE_ID' => 7, 'TIME_FILLED' => 8, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'show_id' => 3, 'record' => 4, 'rebroadcast' => 5, 'instance_id' => 6, 'file_id' => 7, 'time_filled' => 8, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbStarts' => 1, 'DbEnds' => 2, 'DbShowId' => 3, 'DbRecord' => 4, 'DbRebroadcast' => 5, 'DbOriginalShow' => 6, 'DbRecordedFile' => 7, 'DbTimeFilled' => 8, 'DbDeletedInstance' => 9, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbShowId' => 3, 'dbRecord' => 4, 'dbRebroadcast' => 5, 'dbOriginalShow' => 6, 'dbRecordedFile' => 7, 'dbTimeFilled' => 8, 'dbDeletedInstance' => 9, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::STARTS => 1, self::ENDS => 2, self::SHOW_ID => 3, self::RECORD => 4, self::REBROADCAST => 5, self::INSTANCE_ID => 6, self::FILE_ID => 7, self::TIME_FILLED => 8, self::DELETED_INSTANCE => 9, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'SHOW_ID' => 3, 'RECORD' => 4, 'REBROADCAST' => 5, 'INSTANCE_ID' => 6, 'FILE_ID' => 7, 'TIME_FILLED' => 8, 'DELETED_INSTANCE' => 9, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'show_id' => 3, 'record' => 4, 'rebroadcast' => 5, 'instance_id' => 6, 'file_id' => 7, 'time_filled' => 8, 'deleted_instance' => 9, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) ); /** @@ -175,6 +178,7 @@ abstract class BaseCcShowInstancesPeer { $criteria->addSelectColumn(CcShowInstancesPeer::INSTANCE_ID); $criteria->addSelectColumn(CcShowInstancesPeer::FILE_ID); $criteria->addSelectColumn(CcShowInstancesPeer::TIME_FILLED); + $criteria->addSelectColumn(CcShowInstancesPeer::DELETED_INSTANCE); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.STARTS'); @@ -185,6 +189,7 @@ abstract class BaseCcShowInstancesPeer { $criteria->addSelectColumn($alias . '.INSTANCE_ID'); $criteria->addSelectColumn($alias . '.FILE_ID'); $criteria->addSelectColumn($alias . '.TIME_FILLED'); + $criteria->addSelectColumn($alias . '.DELETED_INSTANCE'); } } diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesQuery.php index cdd85beed..247b26fba 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesQuery.php @@ -15,6 +15,7 @@ * @method CcShowInstancesQuery orderByDbOriginalShow($order = Criteria::ASC) Order by the instance_id column * @method CcShowInstancesQuery orderByDbRecordedFile($order = Criteria::ASC) Order by the file_id column * @method CcShowInstancesQuery orderByDbTimeFilled($order = Criteria::ASC) Order by the time_filled column + * @method CcShowInstancesQuery orderByDbDeletedInstance($order = Criteria::ASC) Order by the deleted_instance column * * @method CcShowInstancesQuery groupByDbId() Group by the id column * @method CcShowInstancesQuery groupByDbStarts() Group by the starts column @@ -25,6 +26,7 @@ * @method CcShowInstancesQuery groupByDbOriginalShow() Group by the instance_id column * @method CcShowInstancesQuery groupByDbRecordedFile() Group by the file_id column * @method CcShowInstancesQuery groupByDbTimeFilled() Group by the time_filled column + * @method CcShowInstancesQuery groupByDbDeletedInstance() Group by the deleted_instance column * * @method CcShowInstancesQuery leftJoin($relation) Adds a LEFT JOIN clause to the query * @method CcShowInstancesQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query @@ -62,6 +64,7 @@ * @method CcShowInstances findOneByDbOriginalShow(int $instance_id) Return the first CcShowInstances filtered by the instance_id column * @method CcShowInstances findOneByDbRecordedFile(int $file_id) Return the first CcShowInstances filtered by the file_id column * @method CcShowInstances findOneByDbTimeFilled(string $time_filled) Return the first CcShowInstances filtered by the time_filled column + * @method CcShowInstances findOneByDbDeletedInstance(boolean $deleted_instance) Return the first CcShowInstances filtered by the deleted_instance column * * @method array findByDbId(int $id) Return CcShowInstances objects filtered by the id column * @method array findByDbStarts(string $starts) Return CcShowInstances objects filtered by the starts column @@ -72,6 +75,7 @@ * @method array findByDbOriginalShow(int $instance_id) Return CcShowInstances objects filtered by the instance_id column * @method array findByDbRecordedFile(int $file_id) Return CcShowInstances objects filtered by the file_id column * @method array findByDbTimeFilled(string $time_filled) Return CcShowInstances objects filtered by the time_filled column + * @method array findByDbDeletedInstance(boolean $deleted_instance) Return CcShowInstances objects filtered by the deleted_instance column * * @package propel.generator.airtime.om */ @@ -446,6 +450,23 @@ abstract class BaseCcShowInstancesQuery extends ModelCriteria return $this->addUsingAlias(CcShowInstancesPeer::TIME_FILLED, $dbTimeFilled, $comparison); } + /** + * Filter the query on the deleted_instance column + * + * @param boolean|string $dbDeletedInstance The value to use as filter. + * Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function filterByDbDeletedInstance($dbDeletedInstance = null, $comparison = null) + { + if (is_string($dbDeletedInstance)) { + $deleted_instance = in_array(strtolower($dbDeletedInstance), array('false', 'off', '-', 'no', 'n', '0')) ? false : true; + } + return $this->addUsingAlias(CcShowInstancesPeer::DELETED_INSTANCE, $dbDeletedInstance, $comparison); + } + /** * Filter the query by a related CcShow object * diff --git a/airtime_mvc/build/schema.xml b/airtime_mvc/build/schema.xml index 7259ccaae..466e9252d 100644 --- a/airtime_mvc/build/schema.xml +++ b/airtime_mvc/build/schema.xml @@ -149,6 +149,11 @@ + + diff --git a/airtime_mvc/build/sql/schema.sql b/airtime_mvc/build/sql/schema.sql index 3f4392bd3..52b2bc507 100644 --- a/airtime_mvc/build/sql/schema.sql +++ b/airtime_mvc/build/sql/schema.sql @@ -196,6 +196,7 @@ CREATE TABLE "cc_show_instances" "instance_id" INTEGER, "file_id" INTEGER, "time_filled" TIME, + "deleted_instance" BOOLEAN default 'f' NOT NULL, PRIMARY KEY ("id") ); diff --git a/install_full/ubuntu/airtime-full-install b/install_full/ubuntu/airtime-full-install index 3ac057731..c4c3f82c9 100755 --- a/install_full/ubuntu/airtime-full-install +++ b/install_full/ubuntu/airtime-full-install @@ -32,7 +32,8 @@ libesd0 libportaudio2 libsamplerate0 rabbitmq-server patch \ php5-curl mpg123 monit python-virtualenv multitail libcamomile-ocaml-data \ libvorbis-ocaml -#install packages with --force-yes option +#install packages with --force-yes option (this is useful in the case +#of Debian, where these packages are unauthorized) apt-get -y --force-yes install libmp3lame-dev lame icecast2 if [ "$?" -ne "0" ]; then diff --git a/install_minimal/DoctrineMigrations/Version20111114222927.php b/install_minimal/DoctrineMigrations/Version20111114222927.php new file mode 100644 index 000000000..5672e951f --- /dev/null +++ b/install_minimal/DoctrineMigrations/Version20111114222927.php @@ -0,0 +1,20 @@ +getTable('cc_show_instances'); + $cc_show_instances->addColumn('deleted_instance', 'boolean', array('notnull' => true, 'default'=> '0')); + } + + public function down(Schema $schema) + { + + } +} diff --git a/install_minimal/upgrades/airtime-2.0.0/airtime-upgrade.php b/install_minimal/upgrades/airtime-2.0.0/airtime-upgrade.php index fd815d745..bbec671ce 100644 --- a/install_minimal/upgrades/airtime-2.0.0/airtime-upgrade.php +++ b/install_minimal/upgrades/airtime-2.0.0/airtime-upgrade.php @@ -141,7 +141,7 @@ class AirtimeDatabaseUpgrade{ } } - UpgradeCommon::MigrateTablesToVersion(__DIR__, '20111103141311'); + UpgradeCommon::MigrateTablesToVersion(__DIR__, '20111114222927'); } private static function SetDefaultStreamSetting() From 3c6410aebd1da089a58767d704b5cb51aa749518 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Mon, 14 Nov 2011 23:55:23 -0500 Subject: [PATCH 17/23] -make it so that uninstaller doesn't exit on first error. Should try to remove everything. --- install_minimal/airtime-uninstall | 2 +- install_minimal/include/airtime-remove-files.sh | 2 +- install_minimal/include/airtime-uninitialize.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/install_minimal/airtime-uninstall b/install_minimal/airtime-uninstall index a33c7bde2..cf6ae6d75 100755 --- a/install_minimal/airtime-uninstall +++ b/install_minimal/airtime-uninstall @@ -1,4 +1,4 @@ -#!/bin/bash -e +#!/bin/bash #Check if root user if [ `whoami` != 'root' ]; then diff --git a/install_minimal/include/airtime-remove-files.sh b/install_minimal/include/airtime-remove-files.sh index 47c021d28..ae17f7cba 100755 --- a/install_minimal/include/airtime-remove-files.sh +++ b/install_minimal/include/airtime-remove-files.sh @@ -1,4 +1,4 @@ -#!/bin/bash -e +#!/bin/bash #-e Causes bash script to exit if any of the installers #return with a non-zero return value. diff --git a/install_minimal/include/airtime-uninitialize.sh b/install_minimal/include/airtime-uninitialize.sh index f79a9c90a..fc38ed85a 100755 --- a/install_minimal/include/airtime-uninitialize.sh +++ b/install_minimal/include/airtime-uninitialize.sh @@ -1,4 +1,4 @@ -#!/bin/bash -e +#!/bin/bash #-e Causes bash script to exit if any of the installers #return with a non-zero return value. From c2639b895a5b5b48a8e57d58d24cac659162a700 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 15 Nov 2011 00:08:31 -0500 Subject: [PATCH 18/23] CC-2997: Daylight savings time affects repeating shows. -fix upgrade script --- .../DoctrineMigrations/Version20111103141311.php | 2 +- install_minimal/upgrades/airtime-2.0.0/airtime-upgrade.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/install_minimal/DoctrineMigrations/Version20111103141311.php b/install_minimal/DoctrineMigrations/Version20111103141311.php index 970880e57..9be485e29 100644 --- a/install_minimal/DoctrineMigrations/Version20111103141311.php +++ b/install_minimal/DoctrineMigrations/Version20111103141311.php @@ -11,7 +11,7 @@ class Version20111103141311 extends AbstractMigration { // add timezone column to cc_show_days $cc_subjs = $schema->getTable('cc_show_days'); - $cc_subjs->addColumn('timezone', 'string', array('required' => true)); + $cc_subjs->addColumn('timezone', 'string', array('required' => true, 'default'=> '')); } public function down(Schema $schema) diff --git a/install_minimal/upgrades/airtime-2.0.0/airtime-upgrade.php b/install_minimal/upgrades/airtime-2.0.0/airtime-upgrade.php index bbec671ce..c685f763a 100644 --- a/install_minimal/upgrades/airtime-2.0.0/airtime-upgrade.php +++ b/install_minimal/upgrades/airtime-2.0.0/airtime-upgrade.php @@ -103,6 +103,7 @@ class AirtimeDatabaseUpgrade{ $showDays = CcShowDaysQuery::create()->find(); foreach ($showDays as $sd){ + /* $dt = new DateTime($sd->getDbFirstShow()." ".$sd->getDbStartTime(), new DateTimeZone(date_default_timezone_get())); $dt->setTimezone(new DateTimeZone("UTC")); $sd->setDbFirstShow($dt->format("Y-m-d")); @@ -113,6 +114,11 @@ class AirtimeDatabaseUpgrade{ $sd->setDbLastShow($dt->format("Y-m-d")); $sd->save(); + * */ + + $sd->setDbTimezone(date_default_timezone_get())->save(); + + } } From fe5191eac187118eff73f3b0c973e95b9c2156b9 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 15 Nov 2011 00:34:48 -0500 Subject: [PATCH 19/23] CC-3042: Disappearing shows from beginning when clicking edit. -initial commit --- .../application/controllers/ScheduleController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index e72d4cd84..d244097ca 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -465,11 +465,11 @@ class ScheduleController extends Zend_Controller_Action 'add_show_genre' => $show->getGenre(), 'add_show_description' => $show->getDescription())); - $startsDateTime = new DateTime($showInstance->getShowInstanceStart(), new DateTimeZone("UTC")); - $endsDateTime = new DateTime($showInstance->getShowInstanceEnd(), new DateTimeZone("UTC")); + $startsDateTime = new DateTime($show->getStartDate()." ".$show->getStartTime(), new DateTimeZone(date_default_timezone_get())); + $endsDateTime = new DateTime($show->getEndDate()." ".$show->getEndTime(), new DateTimeZone(date_default_timezone_get())); - $startsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); - $endsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); + //$startsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); + //$endsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); $formWhen->populate(array('add_show_start_date' => $startsDateTime->format("Y-m-d"), 'add_show_start_time' => $startsDateTime->format("H:i"), From 61d8fa7baa39341bee1336ff08180a62e9c57497 Mon Sep 17 00:00:00 2001 From: Naomi Aro Date: Tue, 15 Nov 2011 15:20:33 +0100 Subject: [PATCH 20/23] CC-3034 Record/Rebroadcast Shows have time problems fixing some UTC to non UTC comparisons, adding offsets properly to create a rebroadcast show's start/end time. --- airtime_mvc/application/models/Show.php | 247 +++++++++++++----------- 1 file changed, 138 insertions(+), 109 deletions(-) diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 1990663df..81f872516 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -119,17 +119,17 @@ class Application_Model_Show { WHERE starts >= '{$day_timestamp}' AND show_id = {$this->_showId}"; $CC_DBC->query($sql); - + // check if we can safely delete the show $showInstancesRow = CcShowInstancesQuery::create() ->filterByDbShowId($this->_showId) ->findOne(); - + if(is_null($showInstancesRow)){ $sql = "DELETE FROM cc_show WHERE id = {$this->_showId}"; $CC_DBC->query($sql); } - + Application_Model_RabbitMq::PushSchedule(); } @@ -137,10 +137,10 @@ class Application_Model_Show { * This function is called when a repeating show is edited and the * days that is repeats on have changed. More specifically, a day * that the show originally repeated on has been "unchecked". - * + * * Removes Show Instances that occur on days of the week specified * by input array. For example, if array contains one value of "0", - * (0 = Sunday, 1=Monday) then all show instances that occur on + * (0 = Sunday, 1=Monday) then all show instances that occur on * Sunday are removed. * * @param array p_uncheckedDays @@ -385,8 +385,8 @@ class Application_Model_Show { /** * Deletes all show instances of current show before a - * certain date. - * + * certain date. + * * This function is used in the case where a repeating show is being * edited and the start date of the first show has been changed more * into the future. In this case, delete any show instances that @@ -454,11 +454,11 @@ class Application_Model_Show { return $startTime; } } - + /** * Get the end date of the current show. * Note that this is not the end date of repeated show - * + * * @return string * The end date in the format YYYY-MM-DD */ @@ -466,12 +466,12 @@ class Application_Model_Show { $startDate = $this->getStartDate(); $startTime = $this->getStartTime(); $duration = $this->getDuration(); - + $startDateTime = new DateTime($startDate.' '.$startTime); $duration = explode(":", $duration); - + $endDate = $startDateTime->add(new DateInterval('PT'.$duration[0].'H'.$duration[1].'M')); - + return $endDate->format('Y-m-d'); } @@ -485,12 +485,12 @@ class Application_Model_Show { $startDate = $this->getStartDate(); $startTime = $this->getStartTime(); $duration = $this->getDuration(); - + $startDateTime = new DateTime($startDate.' '.$startTime); $duration = explode(":", $duration); - + $endDate = $startDateTime->add(new DateInterval('PT'.$duration[0].'H'.$duration[1].'M')); - + return $endDate->format('H:i:s'); } @@ -511,7 +511,7 @@ class Application_Model_Show { * Get the ID's of future instance of the current show. * * @return array - * A simple array containing all ID's of show instance + * A simple array containing all ID's of show instance * scheduled in the future. */ public function getAllFutureInstanceIds(){ @@ -535,11 +535,11 @@ class Application_Model_Show { } /* Called when a show's duration is changed (edited). - * + * * @param array $p_data - * array containing the POST data about the show from the + * array containing the POST data about the show from the * browser. - * + * */ private function updateDurationTime($p_data){ //need to update cc_show_instances, cc_show_days @@ -640,7 +640,7 @@ class Application_Model_Show { public function getInstanceOnDate($p_dateTime){ global $CC_DBC; $timestamp = $p_dateTime->format("Y-m-d H:i:s"); - + $showId = $this->getId(); $sql = "SELECT id FROM cc_show_instances" ." WHERE date(starts) = date(TIMESTAMP '$timestamp') " @@ -836,7 +836,7 @@ class Application_Model_Show { $daysAdd = 6 - $startDow + 1 + $day; else $daysAdd = $day - $startDow; - + $startDateTimeClone->add(new DateInterval("P".$daysAdd."D")); } if (is_null($endDate) || $startDateTimeClone->getTimestamp() <= $endDateTime->getTimestamp()) { @@ -905,12 +905,12 @@ class Application_Model_Show { $showHost->save(); } } - + Application_Model_Show::populateShowUntil($showId); Application_Model_RabbitMq::PushSchedule(); return $showId; } - + /** * Generate repeating show instances for a single show up to the given date. * If no date is given, use the one in the user's preferences, which is stored @@ -934,7 +934,7 @@ class Application_Model_Show { $p_dateTime = $date; } } - + $sql = "SELECT * FROM cc_show_days WHERE show_id = $p_showId"; $res = $CC_DBC->GetAll($sql); @@ -942,7 +942,7 @@ class Application_Model_Show { Application_Model_Show::populateShow($showRow, $p_dateTime); } } - + /** * We are going to use cc_show_days as a template, to generate Show Instances. This function * is basically a dispatcher that looks at the show template, and sends it to the correct function @@ -953,8 +953,8 @@ class Application_Model_Show { * A row from cc_show_days table * @param DateTime $p_dateTime * DateTime object in UTC time. - */ - private static function populateShow($p_showRow, $p_dateTime) { + */ + private static function populateShow($p_showRow, $p_dateTime) { if($p_showRow["repeat_type"] == -1) { Application_Model_Show::populateNonRepeatingShow($p_showRow, $p_dateTime); } @@ -969,7 +969,7 @@ class Application_Model_Show { } Application_Model_RabbitMq::PushSchedule(); } - + /** * Creates a single show instance. If the show is recorded, it may have multiple * rebroadcast dates, and so this function will create those as well. @@ -978,11 +978,11 @@ class Application_Model_Show { * A row from cc_show_days table * @param DateTime $p_dateTime * DateTime object in UTC time. - */ + */ private static function populateNonRepeatingShow($p_showRow, $p_dateTime) { global $CC_DBC; - + $show_id = $p_showRow["show_id"]; $first_show = $p_showRow["first_show"]; //non-UTC $start_time = $p_showRow["start_time"]; //non-UTC @@ -990,7 +990,7 @@ class Application_Model_Show { $day = $p_showRow["day"]; $record = $p_showRow["record"]; $timezone = $p_showRow["timezone"]; - + $start = $first_show." ".$start_time; $utcStartDateTime = Application_Model_DateHelper::ConvertToUtcDateTime($start, $timezone); @@ -1012,7 +1012,7 @@ class Application_Model_Show { $newInstance = true; } - if ($newInstance || $ccShowInstance->getDbStarts() > $currentUtcTimestamp){ + if ($newInstance || $ccShowInstance->getDbStarts() > $currentUtcTimestamp){ $ccShowInstance->setDbShowId($show_id); $ccShowInstance->setDbStarts($utcStartDateTime); $ccShowInstance->setDbEnds($utcEndDateTime); @@ -1029,27 +1029,29 @@ class Application_Model_Show { $sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}"; $rebroadcasts = $CC_DBC->GetAll($sql); - - self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $utcStartDateTime, $duration); + + Logging::log('$start time of non repeating record '.$start); + + self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone); } } - + /** - * Creates a 1 or more than 1 show instances (user has stated this show repeats). If the show - * is recorded, it may have multiple rebroadcast dates, and so this function will create + * Creates a 1 or more than 1 show instances (user has stated this show repeats). If the show + * is recorded, it may have multiple rebroadcast dates, and so this function will create * those as well. * * @param array $p_showRow * A row from cc_show_days table * @param DateTime $p_dateTime - * DateTime object in UTC time. + * DateTime object in UTC time. "shows_populated_until" date YY-mm-dd in cc_pref * @param string $p_interval - * Period of time between repeating shows - */ + * Period of time between repeating shows (in php DateInterval notation 'P7D') + */ private static function populateRepeatingShow($p_showRow, $p_dateTime, $p_interval) { global $CC_DBC; - + $show_id = $p_showRow["show_id"]; $next_pop_date = $p_showRow["next_pop_date"]; $first_show = $p_showRow["first_show"]; //non-UTC @@ -1060,26 +1062,27 @@ class Application_Model_Show { $record = $p_showRow["record"]; $timezone = $p_showRow["timezone"]; + $date = new Application_Model_DateHelper(); + $currentUtcTimestamp = $date->getUtcTimestamp(); if(isset($next_pop_date)) { $start = $next_pop_date." ".$start_time; } else { $start = $first_show." ".$start_time; } - + $utcStartDateTime = Application_Model_DateHelper::ConvertToUtcDateTime($start, $timezone); - + //convert $last_show into a UTC DateTime object, or null if there is no last show. + $utcLastShowDateTime = $last_show ? Application_Model_DateHelper::ConvertToUtcDateTime($last_show, $timezone) : null; + $sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}"; $rebroadcasts = $CC_DBC->GetAll($sql); + $show = new Application_Model_Show($show_id); - $date = new Application_Model_DateHelper(); - $currentUtcTimestamp = $date->getUtcTimestamp(); - - while($utcStartDateTime->getTimestamp() - <= $p_dateTime->getTimestamp() && - ($utcStartDateTime->getTimestamp() < strtotime($last_show) || is_null($last_show))) { - + while($utcStartDateTime->getTimestamp() <= $p_dateTime->getTimestamp() + && (is_null($utcLastShowDateTime) || $utcStartDateTime->getTimestamp() < $utcLastShowDateTime->getTimestamp())){ + $utcStart = $utcStartDateTime->format("Y-m-d H:i:s"); $sql = "SELECT timestamp '{$utcStart}' + interval '{$duration}'"; $utcEndDateTime = new DateTime($CC_DBC->GetOne($sql), new DateTimeZone("UTC")); @@ -1113,37 +1116,63 @@ class Application_Model_Show { $showInstance->correctScheduleStartTimes(); } - self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $utcStartDateTime, $duration); + self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone); $dt = new DateTime($start, new DateTimeZone($timezone)); $dt->add(new DateInterval($p_interval)); $start = $dt->format("Y-m-d H:i:s"); - + $dt->setTimezone(new DateTimeZone('UTC')); $utcStartDateTime = $dt; - + } - + Application_Model_Show::setNextPop($start, $show_id, $day); } - - private static function createRebroadcastInstances($p_rebroadcasts, $p_currentUtcTimestamp, $p_showId, $p_showInstanceId, $p_utcStartDateTime, $p_duration){ - global $CC_DBC; - - foreach($p_rebroadcasts as $rebroadcast) { - $timeinfo = $p_utcStartDateTime->format("Y-m-d H:i:s"); - $sql = "SELECT timestamp '{$timeinfo}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'"; + /* Create rebroadcast instances for a created show marked for recording + * + * @param $p_rebroadcasts rows gotten from the db table cc_show_rebroadcasts, tells airtime when to schedule the rebroadcasts. + * @param $p_currentUtcTimestamp a timestring in format "Y-m-d H:i:s", current UTC time. + * @param $p_showId int of the show it belongs to (from cc_show) + * @param $p_showInstanceId the instance id of the created recorded show instance + * (from cc_show_instances), used to associate rebroadcasts to this show. + * @param $p_startTime a timestring in format "Y-m-d H:i:s" in the timezone, not UTC of the rebroadcasts' parent recorded show. + * @param $p_duration duration of the show in format 1:0 + * @param $p_timezone string of user's timezone "Europe/Prague" + * + */ + private static function createRebroadcastInstances($p_rebroadcasts, $p_currentUtcTimestamp, $p_showId, $p_showInstanceId, $p_startTime, $p_duration, $p_timezone=null){ + global $CC_DBC; + + Logging::log('Count of rebroadcasts '. count($p_rebroadcasts)); + + foreach($p_rebroadcasts as $rebroadcast) { + + //use only the date part of the show start time stamp for the offsets to work properly. + $sql = "SELECT date '{$p_startTime}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'"; $rebroadcast_start_time = $CC_DBC->GetOne($sql); + Logging::log('rebroadcast start '.$rebroadcast_start_time); $sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$p_duration}'"; $rebroadcast_end_time = $CC_DBC->GetOne($sql); - - if ($rebroadcast_start_time > $p_currentUtcTimestamp){ + Logging::log('rebroadcast end '.$rebroadcast_end_time); + + //convert to UTC, after we have used the defined offsets to calculate rebroadcasts. + $utc_rebroadcast_start_time = Application_Model_DateHelper::ConvertToUtcDateTime($rebroadcast_start_time, $p_timezone); + $utc_rebroadcast_end_time = Application_Model_DateHelper::ConvertToUtcDateTime($rebroadcast_end_time, $p_timezone); + + Logging::log('UTC rebroadcast start '.$utc_rebroadcast_start_time->format("Y-m-d H:i:s")); + Logging::log('UTC rebroadcast end '.$utc_rebroadcast_end_time->format("Y-m-d H:i:s")); + Logging::log('Current UTC timestamp '.$p_currentUtcTimestamp); + + if ($utc_rebroadcast_start_time->format("Y-m-d H:i:s") > $p_currentUtcTimestamp){ + Logging::log('Creating rebroadcast show starting at UTC '.$utc_rebroadcast_start_time->format("Y-m-d H:i:s")); + $newRebroadcastInstance = new CcShowInstances(); $newRebroadcastInstance->setDbShowId($p_showId); - $newRebroadcastInstance->setDbStarts($rebroadcast_start_time); - $newRebroadcastInstance->setDbEnds($rebroadcast_end_time); + $newRebroadcastInstance->setDbStarts($utc_rebroadcast_start_time->format("Y-m-d H:i:s")); + $newRebroadcastInstance->setDbEnds($utc_rebroadcast_end_time->format("Y-m-d H:i:s")); $newRebroadcastInstance->setDbRecord(0); $newRebroadcastInstance->setDbRebroadcast(1); $newRebroadcastInstance->setDbOriginalShow($p_showInstanceId); @@ -1233,7 +1262,7 @@ class Application_Model_Show { public static function populateAllShowsInRange($p_startTimestamp, $p_endTimestamp) { global $CC_DBC; - + $endTimeString = $p_endTimestamp->format("Y-m-d H:i:s"); if (!is_null($p_startTimestamp)) { $startTimeString = $p_startTimestamp->format("Y-m-d H:i:s"); @@ -1272,7 +1301,7 @@ class Application_Model_Show { $days = $interval->format('%a'); $shows = Application_Model_Show::getShows($start, $end); - + $today_timestamp = date("Y-m-d H:i:s"); foreach ($shows as $show) { @@ -1284,7 +1313,7 @@ class Application_Model_Show { $show_instance = new Application_Model_ShowInstance($show["instance_id"]); $options["percent"] = $show_instance->getPercentScheduled(); } - + if ($editable && (strtotime($today_timestamp) < strtotime($show["starts"]))) { $options["editable"] = true; $events[] = Application_Model_Show::makeFullCalendarEvent($show, $options); @@ -1304,10 +1333,10 @@ class Application_Model_Show { if($show["rebroadcast"]) { $event["disableResizing"] = true; } - + $startDateTime = new DateTime($show["starts"], new DateTimeZone("UTC")); $startDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); - + $endDateTime = new DateTime($show["ends"], new DateTimeZone("UTC")); $endDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); @@ -1321,7 +1350,7 @@ class Application_Model_Show { $event["record"] = intval($show["record"]); $event["deleted_instance"] = $show["deleted_instance"]; $event["rebroadcast"] = intval($show["rebroadcast"]); - + // get soundcloud_id if(!is_null($show["file_id"])){ $file = Application_Model_StoredFile::Recall($show["file_id"]); @@ -1345,28 +1374,28 @@ class Application_Model_Show { return $event; } - + public function setShowFirstShow($s_date){ $showDay = CcShowDaysQuery::create() ->filterByDbShowId($this->_showId) ->findOne(); - + $showDay->setDbFirstShow($s_date) ->save(); } - + public function setShowLastShow($e_date){ $showDay = CcShowDaysQuery::create() ->filterByDbShowId($this->_showId) ->findOne(); - + $showDay->setDbLastShow($e_date) ->save(); } /** * Given local current time $timeNow, returns the show being played right now. - * + * * @param type $timeNow local current time * @return type show being played right now */ @@ -1374,10 +1403,10 @@ class Application_Model_Show { { global $CC_CONFIG, $CC_DBC; - // Need this in the query below, so that we are NOT comparing UTC + // Need this in the query below, so that we are NOT comparing UTC // timestamps si.starts/si.ends with local timestamps $timeNow $timezoneInterval = Application_Model_Show::GetTimezoneIntervalString(true); - + $sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record, s.url" ." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s" ." WHERE si.show_id = s.id" @@ -1387,15 +1416,15 @@ class Application_Model_Show { // Convert back to local timezone $rows = $CC_DBC->GetAll($sql); Application_Model_Show::ConvertToLocalTimeZone($rows, array("starts", "ends", "start_timestamp", "end_timestamp")); - + return $rows; } /** - * Given local current time $timeNow, returns the next $limit number of - * shows within 2 days if $timeEnd is not given; Otherwise, returns the + * Given local current time $timeNow, returns the next $limit number of + * shows within 2 days if $timeEnd is not given; Otherwise, returns the * next $limit number of shows from $timeNow to $timeEnd, both in local time. - * + * * @param type $timeNow local current time * @param type $limit number of shows to return * @param type $timeEnd optional: interval end time @@ -1404,11 +1433,11 @@ class Application_Model_Show { public static function GetNextShows($timeNow, $limit, $timeEnd = "") { global $CC_CONFIG, $CC_DBC; - - // Need this in the query below, so that we are NOT comparing UTC + + // Need this in the query below, so that we are NOT comparing UTC // timestamps si.starts with local timestamps $timeNow $timezoneInterval = Application_Model_Show::GetTimezoneIntervalString(true); - + // defaults to retrieving shows from next 2 days if no end time has // been specified if($timeEnd == "") { @@ -1416,7 +1445,7 @@ class Application_Model_Show { } else { $timeEnd = "'$timeEnd' + $timezoneInterval"; } - + $sql = "SELECT *, si.starts as start_timestamp, si.ends as end_timestamp FROM " ." $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s" ." WHERE si.show_id = s.id" @@ -1428,14 +1457,14 @@ class Application_Model_Show { // Convert timestamps to local timezone $rows = $CC_DBC->GetAll($sql); Application_Model_Show::ConvertToLocalTimeZone($rows, array("starts", "ends", "start_timestamp", "end_timestamp")); - + return $rows; } - + /** - * Given a day of the week variable $day, based in local time, returns the + * Given a day of the week variable $day, based in local time, returns the * shows being played on this day of the week we're in right now. - * + * * @param type $day day of the week * @return type shows being played on this day */ @@ -1445,14 +1474,14 @@ class Application_Model_Show { //SELECT EXTRACT(DOW FROM TIMESTAMP '2001-02-16 20:38:40'); //Result: 5 - + global $CC_CONFIG, $CC_DBC; - + // Need this in the query below, so that we are NOT extracting DOW and WEEK - // information from UTC timestamps si.starts, and comparing with a local + // information from UTC timestamps si.starts, and comparing with a local // timezone based variable $day and localtimestamp $timezoneInterval = Application_Model_Show::GetTimezoneIntervalString(); - + $sql = "SELECT" ." si.starts as show_starts," ." si.ends as show_ends," @@ -1464,69 +1493,69 @@ class Application_Model_Show { ." WHERE EXTRACT(DOW FROM si.starts + $timezoneInterval) = $day" ." AND EXTRACT(WEEK FROM si.starts + $timezoneInterval) = EXTRACT(WEEK FROM localtimestamp)" ." ORDER BY si.starts"; - + // Convert result timestamps to local timezone $rows = $CC_DBC->GetAll($sql); Application_Model_Show::ConvertToLocalTimeZone($rows, array("show_starts", "show_ends")); return $rows; } - + /** - * Convert the columns given in the array $columnsToConvert in the + * Convert the columns given in the array $columnsToConvert in the * database result $rows to local timezone. - * + * * @param type $rows arrays of arrays containing database query result * @param type $columnsToConvert array of column names to convert */ public static function ConvertToLocalTimeZone(&$rows, $columnsToConvert) { $timezone = date_default_timezone_get(); - + foreach($rows as &$row) { foreach($columnsToConvert as $column) { $row[$column] = Application_Model_DateHelper::ConvertToLocalDateTimeString($row[$column]); } } } - + /** * Returns the timezone difference as an INTERVAL string that can be used * by SQL queries. - * + * * E.g., if local timezone is -4:30, this function returns: * INTERVAL '-4 hours -30 minutes' - * + * * Note that if $fromLocalToUtc is true, then it returns: * INTERVAL '4 hours 30 minutes' - * - * @param type $fromLocalToUtc true if we're converting from local to UTC + * + * @param type $fromLocalToUtc true if we're converting from local to UTC */ public static function GetTimeZoneIntervalString($fromLocalToUtc = false) { $date = new Application_Model_DateHelper; $timezoneHour = $date->getLocalOffsetHour(); $timezoneMin = $date->getLocalOffsetMinute(); - + // negate the hour and min if converting from local to UTC if($fromLocalToUtc) { $timezoneHour = -$timezoneHour; $timezoneMin = -$timezoneMin; } - + return "INTERVAL '$timezoneHour hours $timezoneMin minutes'"; } - + public static function GetMaxLengths() { global $CC_CONFIG, $CC_DBC; $sql = "SELECT column_name, character_maximum_length FROM information_schema.columns" ." WHERE table_name = 'cc_show' AND character_maximum_length > 0"; $result = $CC_DBC->GetAll($sql); - + // store result into assoc array $assocArray = array(); foreach($result as $row) { $assocArray[$row['column_name']] = $row['character_maximum_length']; } - + return $assocArray; } } From 6f91a9b1070e1ee532a4f52e38f6edfb1ca6dd5b Mon Sep 17 00:00:00 2001 From: Naomi Aro Date: Tue, 15 Nov 2011 15:56:52 +0100 Subject: [PATCH 21/23] CC-3046 : Show contents for Rebroadcast in wrong timezone --- .../controllers/ScheduleController.php | 102 +++++++++--------- 1 file changed, 52 insertions(+), 50 deletions(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index d244097ca..59077cc42 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -56,7 +56,7 @@ class ScheduleController extends Zend_Controller_Action $this->view->headLink()->appendStylesheet($baseUrl.'/css/colorpicker/css/colorpicker.css'); $this->view->headLink()->appendStylesheet($baseUrl.'/css/add-show.css'); $this->view->headLink()->appendStylesheet($baseUrl.'/css/contextmenu.css'); - + Application_Model_Schedule::createNewFormSections($this->view); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); @@ -141,7 +141,7 @@ class ScheduleController extends Zend_Controller_Action $this->view->show_error = true; return false; } - + $show->deleteShow(); } } @@ -177,15 +177,15 @@ class ScheduleController extends Zend_Controller_Action $this->view->show_error = true; return false; } - + $params = '/format/json/id/#id#'; - + $showStartDateHelper = Application_Model_DateHelper::ConvertToLocalDateTime($show->getShowInstanceStart()); $showEndDateHelper = Application_Model_DateHelper::ConvertToLocalDateTime($show->getShowInstanceEnd()); - + $menu = array(); - + if ($epochNow < $showStartDateHelper->getTimestamp()) { if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId()) && !$show->isRecorded() && !$show->isRebroadcast()) { @@ -239,7 +239,7 @@ class ScheduleController extends Zend_Controller_Action 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance and All Following'); } } - + //returns format jjmenu is looking for. die(json_encode($menu)); } @@ -305,12 +305,12 @@ class ScheduleController extends Zend_Controller_Action $this->view->show_error = true; return false; } - + $playlists = $show->searchPlaylistsForShow($post); foreach( $playlists['aaData'] as &$data){ // calling two functions to format time to 1 decimal place $sec = Application_Model_Playlist::playlistTimeToSeconds($data[4]); - $data[4] = Application_Model_Playlist::secondsToPlaylistTime($sec); + $data[4] = Application_Model_Playlist::secondsToPlaylistTime($sec); } //for datatables @@ -354,13 +354,13 @@ class ScheduleController extends Zend_Controller_Action $this->view->show_error = true; return false; } - + $start_timestamp = $show->getShowInstanceStart(); $end_timestamp = $show->getShowInstanceEnd(); //check to make sure show doesn't overlap. - if(Application_Model_Show::getShows(new DateTime($start_timestamp, new DateTimeZone("UTC")), - new DateTime($end_timestamp, new DateTimeZone("UTC")), + if(Application_Model_Show::getShows(new DateTime($start_timestamp, new DateTimeZone("UTC")), + new DateTime($end_timestamp, new DateTimeZone("UTC")), array($showInstanceId))) { $this->view->error = "cannot schedule an overlapping show."; return; @@ -368,7 +368,7 @@ class ScheduleController extends Zend_Controller_Action $dateInfo_s = getDate(strtotime(Application_Model_DateHelper::ConvertToLocalDateTimeString($start_timestamp))); $dateInfo_e = getDate(strtotime(Application_Model_DateHelper::ConvertToLocalDateTimeString($end_timestamp))); - + $this->view->showContent = $show->getShowContent(); $this->view->timeFilled = $show->getTimeScheduled(); $this->view->showName = $show->getName(); @@ -410,7 +410,9 @@ class ScheduleController extends Zend_Controller_Action $originalShowName = $originalShow->getName(); $originalShowStart = $originalShow->getShowInstanceStart(); - $timestamp = strtotime($originalShowStart); + //convert from UTC to user's timezone for display. + $originalDateTime = new DateTime($originalShowStart, new DateTimeZone("UTC")); + $timestamp = strtotime(Application_Model_DateHelper::ConvertToLocalDateTimeString($originalDateTime->format("Y-m-d H:i:s"))); $this->view->additionalShowInfo = "Rebroadcast of show \"$originalShowName\" from " .date("l, F jS", $timestamp)." at ".date("G:i", $timestamp); @@ -427,7 +429,7 @@ class ScheduleController extends Zend_Controller_Action if(!$user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { return; } - + $isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true; $showInstanceId = $this->_getParam('id'); @@ -464,10 +466,10 @@ class ScheduleController extends Zend_Controller_Action 'add_show_url' => $show->getUrl(), 'add_show_genre' => $show->getGenre(), 'add_show_description' => $show->getDescription())); - + $startsDateTime = new DateTime($show->getStartDate()." ".$show->getStartTime(), new DateTimeZone(date_default_timezone_get())); $endsDateTime = new DateTime($show->getEndDate()." ".$show->getEndTime(), new DateTimeZone(date_default_timezone_get())); - + //$startsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); //$endsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); @@ -505,27 +507,27 @@ class ScheduleController extends Zend_Controller_Action $formWho->populate(array('add_show_hosts' => $hosts)); $formStyle->populate(array('add_show_background_color' => $show->getBackgroundColor(), 'add_show_color' => $show->getColor())); - + if(!$isSaas){ $formRecord = new Application_Form_AddShowRR(); $formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates(); $formRebroadcast = new Application_Form_AddShowRebroadcastDates(); - + $formRecord->removeDecorator('DtDdWrapper'); $formAbsoluteRebroadcast->removeDecorator('DtDdWrapper'); $formRebroadcast->removeDecorator('DtDdWrapper'); - + $this->view->rr = $formRecord; $this->view->absoluteRebroadcast = $formAbsoluteRebroadcast; $this->view->rebroadcast = $formRebroadcast; - + $formRecord->populate(array('add_show_record' => $show->isRecorded(), 'add_show_rebroadcast' => $show->isRebroadcast())); - + $formRecord->getElement('add_show_record')->setOptions(array('disabled' => true)); - - - + + + $rebroadcastsRelative = $show->getRebroadcastsRelative(); $rebroadcastFormValues = array(); $i = 1; @@ -535,7 +537,7 @@ class ScheduleController extends Zend_Controller_Action $i++; } $formRebroadcast->populate($rebroadcastFormValues); - + $rebroadcastsAbsolute = $show->getRebroadcastsAbsolute(); $rebroadcastAbsoluteFormValues = array(); $i = 1; @@ -551,7 +553,7 @@ class ScheduleController extends Zend_Controller_Action $this->view->entries = 5; } - public function getFormAction(){ + public function getFormAction(){ Application_Model_Schedule::createNewFormSections($this->view); $this->view->form = $this->view->render('schedule/add-show-form.phtml'); } @@ -565,7 +567,7 @@ class ScheduleController extends Zend_Controller_Action foreach($js as $j){ $data[$j["name"]] = $j["value"]; } - + $show = new Application_Model_Show($data['add_show_id']); $startDateModified = true; @@ -582,10 +584,10 @@ class ScheduleController extends Zend_Controller_Action if($data['add_show_day_check'] == "") { $data['add_show_day_check'] = null; } - + $isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true; $record = false; - + $formWhat = new Application_Form_AddShowWhat(); $formWho = new Application_Form_AddShowWho(); $formWhen = new Application_Form_AddShowWhen(); @@ -604,8 +606,8 @@ class ScheduleController extends Zend_Controller_Action $when = $formWhen->checkReliantFields($data, $startDateModified); } - - //The way the following code works is that is parses the hour and + + //The way the following code works is that is parses the hour and //minute from a string with the format "1h 20m" or "2h" or "36m". //So we are detecting whether an hour or minute value exists via strpos //and then parse appropriately. A better way to do this in the future is @@ -613,10 +615,10 @@ class ScheduleController extends Zend_Controller_Action //have to do this extra String parsing. $hPos = strpos($data["add_show_duration"], 'h'); $mPos = strpos($data["add_show_duration"], 'm'); - + $hValue = 0; $mValue = 0; - + if($hPos !== false){ $hValue = trim(substr($data["add_show_duration"], 0, $hPos)); } @@ -624,18 +626,18 @@ class ScheduleController extends Zend_Controller_Action $hPos = $hPos === FALSE ? 0 : $hPos+1; $mValue = trim(substr($data["add_show_duration"], $hPos, -1 )); } - + $data["add_show_duration"] = $hValue.":".$mValue; - + if(!$isSaas){ $formRecord = new Application_Form_AddShowRR(); $formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates(); $formRebroadcast = new Application_Form_AddShowRebroadcastDates(); - + $formRecord->removeDecorator('DtDdWrapper'); $formAbsoluteRebroadcast->removeDecorator('DtDdWrapper'); $formRebroadcast->removeDecorator('DtDdWrapper'); - + //If show is a new show (not updated), then get //isRecorded from POST data. Otherwise get it from //the database since the user is not allowed to @@ -648,7 +650,7 @@ class ScheduleController extends Zend_Controller_Action $record = $formRecord->isValid($data); } } - + if($data["add_show_repeats"]) { $repeats = $formRepeats->isValid($data); if($repeats) { @@ -658,7 +660,7 @@ class ScheduleController extends Zend_Controller_Action $formAbsoluteRebroadcast->reset(); //make it valid, results don't matter anyways. $rebroadAb = 1; - + if ($data["add_show_rebroadcast"]) { $rebroad = $formRebroadcast->isValid($data); if($rebroad) { @@ -676,7 +678,7 @@ class ScheduleController extends Zend_Controller_Action $formRebroadcast->reset(); //make it valid, results don't matter anyways. $rebroad = 1; - + if ($data["add_show_rebroadcast"]) { $rebroadAb = $formAbsoluteRebroadcast->isValid($data); if($rebroadAb) { @@ -699,10 +701,10 @@ class ScheduleController extends Zend_Controller_Action if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { Application_Model_Show::create($data); } - + //send back a new form for the user. Application_Model_Schedule::createNewFormSections($this->view); - + $this->view->newForm = $this->view->render('schedule/add-show-form.phtml'); } }else{ @@ -711,14 +713,14 @@ class ScheduleController extends Zend_Controller_Action if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { Application_Model_Show::create($data); } - + //send back a new form for the user. Application_Model_Schedule::createNewFormSections($this->view); - + $this->view->newForm = $this->view->render('schedule/add-show-form.phtml'); } } - else { + else { $this->view->what = $formWhat; $this->view->when = $formWhen; $this->view->repeats = $formRepeats; @@ -730,7 +732,7 @@ class ScheduleController extends Zend_Controller_Action $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){ @@ -798,7 +800,7 @@ class ScheduleController extends Zend_Controller_Action $file_id = $this->_getParam('id', null); $file = Application_Model_StoredFile::Recall($file_id); - + $baseUrl = $this->getRequest()->getBaseUrl(); $url = $file->getRelativeFileUrl($baseUrl).'/download/true'; $menu[] = array('action' => array('type' => 'gourl', 'url' => $url), @@ -807,7 +809,7 @@ class ScheduleController extends Zend_Controller_Action //returns format jjmenu is looking for. die(json_encode($menu)); } - + /** * Sets the user specific preference for which time scale to use in Calendar. * This is only being used by schedule.js at the moment. @@ -815,7 +817,7 @@ class ScheduleController extends Zend_Controller_Action public function setTimeScaleAction() { Application_Model_Preference::SetCalendarTimeScale($this->_getParam('timeScale')); } - + /** * Sets the user specific preference for which time interval to use in Calendar. * This is only being used by schedule.js at the moment. From 63d0163f15eaa5edaebf357e00752e240700636d Mon Sep 17 00:00:00 2001 From: Naomi Aro Date: Tue, 15 Nov 2011 16:32:07 +0100 Subject: [PATCH 22/23] CC-3047 : getting full calendar events setting editable flag incorrectly --- airtime_mvc/application/models/DateHelper.php | 59 ++++++++++--------- airtime_mvc/application/models/Show.php | 3 +- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/airtime_mvc/application/models/DateHelper.php b/airtime_mvc/application/models/DateHelper.php index 1ab295d7b..2ca559d39 100644 --- a/airtime_mvc/application/models/DateHelper.php +++ b/airtime_mvc/application/models/DateHelper.php @@ -17,7 +17,7 @@ class Application_Model_DateHelper { return date("Y-m-d H:i:s", $this->_dateTime); } - + /** * Get time of object construction in the format * YYYY-MM-DD HH:mm:ss @@ -59,10 +59,10 @@ class Application_Model_DateHelper /** * Calculate and return the timestamp for end of day today * in local time. - * + * * For example, if local time is 2PM on 2011-11-01, * then the function would return 2011-11-02 00:00:00 - * + * * @return End of day timestamp in local timezone */ function getDayEndTimestamp() { @@ -70,7 +70,7 @@ class Application_Model_DateHelper $dateTime->add(new DateInterval('P1D')); return $dateTime->format('Y-m-d H:i:s'); } - + /** * Find the epoch timestamp difference from "now" to the beginning of today. */ @@ -98,7 +98,7 @@ class Application_Model_DateHelper * Returns the offset in seconds, between local and UTC timezones. * E.g., if local timezone is -4, this function * returns -14400. - * + * * @return type offset in int, between local and UTC timezones */ function getLocalTimeZoneOffset() { @@ -106,31 +106,31 @@ class Application_Model_DateHelper $timezone = new DateTimeZone(date_default_timezone_get()); return $timezone->getOffset($dateTime); } - + /** * Returns the offset hour in int, between local and UTC timezones. * E.g., if local timezone is -4:30, this function * returns -4. - * + * * @return type offset hour in int, between local and UTC timezones */ function getLocalOffsetHour() { $offset = $this->getLocalTimeZoneOffset(); return (int)($offset / 3600); } - + /** * Returns the offset minute in int, between local and UTC timezones. * E.g., if local timezone is -4:30, this function * returns -30. - * + * * @return type offset minute in int, between local and UTC timezones */ function getLocalOffsetMinute() { $offset = $this->getLocalTimeZoneOffset(); return (int)(($offset % 3600) / 60); } - + public static function TimeDiff($time1, $time2) { return strtotime($time2) - strtotime($time1); @@ -193,11 +193,11 @@ class Application_Model_DateHelper $explode = explode(" ", $p_dateTime); return $explode[1]; } - - /* Given a track length in the format HH:MM:SS.mm, we want to + + /* Given a track length in the format HH:MM:SS.mm, we want to * convert this to seconds. This is useful for Liquidsoap which - * likes input parameters give in seconds. - * For example, 00:06:31.444, should be converted to 391.444 seconds + * likes input parameters give in seconds. + * For example, 00:06:31.444, should be converted to 391.444 seconds * @param int $p_time * The time interval in format HH:MM:SS.mm we wish to * convert to seconds. @@ -205,46 +205,51 @@ class Application_Model_DateHelper * The input parameter converted to seconds. */ public static function calculateLengthInSeconds($p_time){ - + if (2 !== substr_count($p_time, ":")){ return FALSE; } - + if (1 === substr_count($p_time, ".")){ list($hhmmss, $ms) = explode(".", $p_time); } else { $hhmmss = $p_time; $ms = 0; } - + list($hours, $minutes, $seconds) = explode(":", $hhmmss); - + $totalSeconds = $hours*3600 + $minutes*60 + $seconds + $ms/1000; - + return $totalSeconds; } - - public static function ConvertToUtcDateTime($p_dateString, $timezone){ - $dateTime = new DateTime($p_dateString, new DateTimeZone($timezone)); + + public static function ConvertToUtcDateTime($p_dateString, $timezone=null){ + if (isset($timezone)) { + $dateTime = new DateTime($p_dateString, new DateTimeZone($timezone)); + } + else { + $dateTime = new DateTime($p_dateString, new DateTimeZone(date_default_timezone_get())); + } $dateTime->setTimezone(new DateTimeZone("UTC")); - - return $dateTime; + + return $dateTime; } - + public static function ConvertToSpecificTimezoneDateTime($p_dateString, $timezone){ $dateTime = new DateTime($p_dateString, new DateTimeZone("UTC")); $dateTime->setTimezone(new DateTimeZone($timezone)); return $dateTime; } - + public static function ConvertToLocalDateTime($p_dateString){ $dateTime = new DateTime($p_dateString, new DateTimeZone("UTC")); $dateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); return $dateTime; } - + public static function ConvertToLocalDateTimeString($p_dateString, $format="Y-m-d H:i:s"){ $dateTime = new DateTime($p_dateString, new DateTimeZone("UTC")); $dateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 81f872516..e0b5175db 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -1302,7 +1302,8 @@ class Application_Model_Show { $shows = Application_Model_Show::getShows($start, $end); - $today_timestamp = date("Y-m-d H:i:s"); + $today_timestamp = Application_Model_DateHelper::ConvertToUtcDateTime(date("Y-m-d H:i:s"))->format("Y-m-d H:i:s"); + foreach ($shows as $show) { if ($show["deleted_instance"] != "t"){ From 4bdf866acaa40aa461bf987a973c5614c4cd8eab Mon Sep 17 00:00:00 2001 From: Naomi Aro Date: Tue, 15 Nov 2011 18:22:21 +0100 Subject: [PATCH 23/23] CC-3035 : Should be able to resize a show, have it affect all future instances of the show resizing is only working for single instance currently like the past. --- .../controllers/ScheduleController.php | 7 +++- airtime_mvc/application/models/Show.php | 1 + .../application/models/ShowInstance.php | 37 ++++++++++--------- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 59077cc42..10f5c860a 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -68,7 +68,9 @@ class ScheduleController extends Zend_Controller_Action public function eventFeedAction() { $start = new DateTime($this->_getParam('start', null)); + $start->setTimezone(new DateTimeZone("UTC")); $end = new DateTime($this->_getParam('end', null)); + $end->setTimezone(new DateTimeZone("UTC")); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new Application_Model_User($userInfo->id); @@ -113,7 +115,7 @@ class ScheduleController extends Zend_Controller_Action $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new Application_Model_User($userInfo->id); - if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { + if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { try{ $show = new Application_Model_ShowInstance($showInstanceId); }catch(Exception $e){ @@ -123,8 +125,9 @@ class ScheduleController extends Zend_Controller_Action $error = $show->resizeShow($deltaDay, $deltaMin); } - if(isset($error)) + if (isset($error)) { $this->view->error = $error; + } } public function deleteShowAction() diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index e0b5175db..09c6b80b6 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -1196,6 +1196,7 @@ class Application_Model_Show { { global $CC_DBC; + //UTC DateTime object $showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil(); //if application is requesting shows past our previous populated until date, generate shows up until this point. diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index 937db958f..865b5b71b 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -24,7 +24,7 @@ class Application_Model_ShowInstance { { return $this->_instanceId; } - + public function getShow(){ return new Application_Model_Show($this->getShowId()); } @@ -136,7 +136,7 @@ class Application_Model_ShowInstance { $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME); $this->_showInstance->updateDbTimeFilled($con); } - + public function isDeleted() { $this->_showInstance->getDbDeletedInstance(); @@ -174,7 +174,7 @@ class Application_Model_ShowInstance { public function moveShow($deltaDay, $deltaMin) { global $CC_DBC; - + if ($this->getShow()->isRepeating()){ return "Can't drag and drop repeating shows"; } @@ -190,7 +190,7 @@ class Application_Model_ShowInstance { $today_timestamp = time(); $starts = $this->getShowInstanceStart(); $ends = $this->getShowInstanceEnd(); - + $startsDateTime = new DateTime($starts, new DateTimeZone("UTC")); if($today_timestamp > $startsDateTime->getTimestamp()) { @@ -205,13 +205,13 @@ class Application_Model_ShowInstance { $new_ends = $CC_DBC->GetOne($sql); $newEndsDateTime = new DateTime($new_ends, new DateTimeZone("UTC")); - + if($today_timestamp > $newStartsDateTime->getTimestamp()) { return "Can't move show into past"; } $overlap = Application_Model_Show::getShows($newStartsDateTime, $newEndsDateTime, array($this->_instanceId)); - + if(count($overlap) > 0) { return "Should not overlap shows"; } @@ -229,13 +229,13 @@ class Application_Model_ShowInstance { $this->setShowStart($new_starts); $this->setShowEnd($new_ends); $this->correctScheduleStartTimes(); - + $show = new Application_Model_Show($this->getShowId()); if(!$show->isRepeating()){ $show->setShowFirstShow($new_starts); $show->setShowLastShow($new_ends); } - + Application_Model_RabbitMq::PushSchedule(); } @@ -251,7 +251,7 @@ class Application_Model_ShowInstance { $mins = abs($deltaMin%60); - $today_timestamp = date("Y-m-d H:i:s"); + $today_timestamp = Application_Model_DateHelper::ConvertToUtcDateTime(date("Y-m-d H:i:s"))->format("Y-m-d H:i:s"); $starts = $this->getShowInstanceStart(); $ends = $this->getShowInstanceEnd(); @@ -264,8 +264,11 @@ class Application_Model_ShowInstance { //only need to check overlap if show increased in size. if(strtotime($new_ends) > strtotime($ends)) { - //TODO --martin - $overlap = Application_Model_Show::getShows($ends, $new_ends); + + $utcStartDateTime = new DateTime($ends, new DateTimeZone("UTC")); + $utcEndDateTime = new DateTime($new_ends, new DateTimeZone("UTC")); + + $overlap = Application_Model_Show::getShows($utcStartDateTime, $utcEndDateTime); if(count($overlap) > 0) { return "Should not overlap shows"; @@ -385,7 +388,7 @@ class Application_Model_ShowInstance { public function deleteShow() { global $CC_DBC; - + // see if it was recording show $recording = CcShowInstancesQuery::create() ->findPK($this->_instanceId) @@ -394,18 +397,18 @@ class Application_Model_ShowInstance { $showId = CcShowInstancesQuery::create() ->findPK($this->_instanceId) ->getDbShowId(); - + CcShowInstancesQuery::create() ->findPK($this->_instanceId) ->setDbDeletedInstance(true) ->save(); - + // check if we can safely delete the show $showInstancesRow = CcShowInstancesQuery::create() ->filterByDbShowId($showId) ->filterByDbDeletedInstance(false) ->findOne(); - + /* If we didn't find any instances of the show that haven't * been deleted, then just erase everything related to that show. * We can just delete, the show and the foreign key-constraint should @@ -415,7 +418,7 @@ class Application_Model_ShowInstance { ->filterByDbId($showId) ->delete(); } - + Application_Model_RabbitMq::PushSchedule(); if($recording){ Application_Model_RabbitMq::SendMessageToShowRecorder("cancel_recording"); @@ -671,7 +674,7 @@ class Application_Model_ShowInstance { return new Application_Model_ShowInstance($id); } } - + // returns number of show instances that ends later than $day public static function GetShowInstanceCount($day){ global $CC_CONFIG, $CC_DBC;