From 54bb414500c82f28a14a5208873bfb6f208688d0 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Mon, 17 Sep 2012 14:32:33 -0400 Subject: [PATCH 01/20] CC-4318: Widgets: Weekly show cannot show the schedule -fixed --- .../application/controllers/ApiController.php | 15 +++++++++----- airtime_mvc/application/models/Show.php | 20 ++++++++++++++----- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 033369802..d95481823 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -5,7 +5,12 @@ class ApiController extends Zend_Controller_Action public function init() { - $this->checkAuth(); + $ignoreAuth = array("live-info", "week-info"); + + $params = $this->getRequest()->getParams(); + if (!in_array($params['action'], $ignoreAuth)) { + $this->checkAuth(); + } /* Initialize action controller here */ $context = $this->_helper->getHelper('contextSwitch'); $context->addActionContext('version' , 'json') @@ -41,7 +46,6 @@ class ApiController extends Zend_Controller_Action public function checkAuth() { global $CC_CONFIG; - $api_key = $this->_getParam('api_key'); if (!in_array($api_key, $CC_CONFIG["apiKey"]) && @@ -298,7 +302,7 @@ class ApiController extends Zend_Controller_Action $result = array(); for ($i=0; $i<7; $i++) { $utcDayEnd = Application_Common_DateHelper::GetDayEndTimestamp($utcDayStart); - $shows = Application_Model_Show::getNextShows($utcDayStart, "0", $utcDayEnd); + $shows = Application_Model_Show::getNextShows($utcDayStart, "ALL", $utcDayEnd); $utcDayStart = $utcDayEnd; Application_Model_Show::convertToLocalTimeZone($shows, @@ -307,9 +311,10 @@ class ApiController extends Zend_Controller_Action $result[$dow[$i]] = $shows; } - $result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; //used by caller to determine if the airtime they are running or widgets in use is out of date. + + //used by caller to determine if the airtime they are running or widgets in use is out of date. + $result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; header("Content-type: text/javascript"); - Logging::info($result); // If a callback is not given, then just provide the raw JSON. echo isset($_GET['callback']) ? $_GET['callback'].'('.json_encode($result).')' : json_encode($result); } else { diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 7f905b687..9a0eaa452 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -2060,8 +2060,6 @@ SQL; // been specified if ($timeEnd == "") { $timeEnd = "'$timeStart' + INTERVAL '2 days'"; - } else { - $timeEnd = "'$timeEnd'"; } //TODO, returning starts + ends twice (once with an alias). Unify this after the 2.0 release. --Martin @@ -2083,12 +2081,24 @@ WHERE si.show_id = s.id AND si.starts < :timeEnd::timestamp AND modified_instance != TRUE ORDER BY si.starts -LIMIT :lim SQL; - return Application_Common_Database::prepareAndExecute( $sql, array( + + //PDO won't accept "ALL" as a limit value (complains it is not an + //integer, and so we must completely remove the limit clause if we + //want to show all results - MK + if ($limit != "ALL") { + $sql .= PHP_EOL."LIMIT :lim"; + $params = array( ':timeStart' => $timeStart, ':timeEnd' => $timeEnd, - ':lim' => $limit), 'all'); + ':lim' => $limit); + } else { + $params = array( + ':timeStart' => $timeStart, + ':timeEnd' => $timeEnd); + } + + return Application_Common_Database::prepareAndExecute( $sql, $params, 'all'); } /** From 1483fb92e5b41e677f029f5410244df4a36fd13c Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Mon, 17 Sep 2012 15:55:46 -0400 Subject: [PATCH 02/20] better detection of timezone during install (suppress PHP warnings if timezone is not set in php.ini) --- install_minimal/include/AirtimeInstall.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install_minimal/include/AirtimeInstall.php b/install_minimal/include/AirtimeInstall.php index d0c2ed3f7..cb054b429 100644 --- a/install_minimal/include/AirtimeInstall.php +++ b/install_minimal/include/AirtimeInstall.php @@ -320,7 +320,8 @@ class AirtimeInstall { $con = Propel::getConnection(); // we need to run php as commandline because we want to get the timezone in cli php.ini file - $defaultTimezone = exec("php -r 'echo date_default_timezone_get().PHP_EOL;'"); + //$defaultTimezone = exec("php -r 'echo date_default_timezone_get().PHP_EOL;'"); + $defaultTimezone = exec("cat /etc/timezone"); $defaultTimezone = trim($defaultTimezone); if((!in_array($defaultTimezone, DateTimeZone::listIdentifiers()))){ $defaultTimezone = "UTC"; From f3250ac6160c33c5bd01523a53b55627b768e60e Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Mon, 17 Sep 2012 16:06:16 -0400 Subject: [PATCH 03/20] CC-4447: Install minimal -> reinstall uring -r reports ERROR on existing database -fixed --- install_minimal/include/AirtimeInstall.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/install_minimal/include/AirtimeInstall.php b/install_minimal/include/AirtimeInstall.php index cb054b429..02a2b43b2 100644 --- a/install_minimal/include/AirtimeInstall.php +++ b/install_minimal/include/AirtimeInstall.php @@ -215,6 +215,15 @@ class AirtimeInstall $database = $CC_CONFIG['dsn']['database']; $username = $CC_CONFIG['dsn']['username']; #$command = "echo \"CREATE DATABASE $database OWNER $username\" | su postgres -c psql 2>/dev/null"; + + $command = "su postgres -c \"psql -l | cut -f2 -d' ' | grep -w 'airtime'\";"; + exec($command, $output, $rv); + + if ($rv == 0) { + //database already exists + return true; + } + $command = "su postgres -c \"createdb $database --encoding UTF8 --owner $username\""; @exec($command, $output, $results); From 8b445486b10bc152e5c59cc759c0e9dd4713e1f5 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Mon, 17 Sep 2012 16:17:53 -0400 Subject: [PATCH 04/20] CC-4427: Listen button does not work fixed --- airtime_mvc/application/models/StreamSetting.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/models/StreamSetting.php b/airtime_mvc/application/models/StreamSetting.php index 61a179d8a..a5740c70f 100644 --- a/airtime_mvc/application/models/StreamSetting.php +++ b/airtime_mvc/application/models/StreamSetting.php @@ -106,12 +106,12 @@ class Application_Model_StreamSetting public static function getStreamData($p_streamId) { $con = Propel::getConnection(); + $streamId = pg_escape_string($p_streamId); $sql = "SELECT * " ."FROM cc_stream_setting " - ."WHERE keyname LIKE :stream_id"; + ."WHERE keyname LIKE '{$streamId}_%'"; $stmt = $con->prepare($sql); - $stmt->bindParam(':stream_id', "${p_streamId}_%"); if ($stmt->execute()) { $rows = $stmt->fetchAll(); From ae1ae80d3604c70bd22ada159d88637281e27629 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 17 Sep 2012 16:40:22 -0400 Subject: [PATCH 05/20] in_array -> array_key_exists --- airtime_mvc/application/models/Preference.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index c73426a2d..9984e49bc 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -1101,7 +1101,7 @@ class Application_Model_Preference } else { $ds = unserialize($v); return function ($x) use ($ds) { - if ( in_array($x, $ds['ColReorder'] ) ) { + if ( array_key_exists($x, $ds['ColReorder'] ) ) { return $ds['ColReorder'][$x]; } else { Logging::warn("Index $x does not exist preferences"); From c310cecf406b9d2ab0a4edfb6a5d7df1485e3848 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Mon, 17 Sep 2012 16:40:27 -0400 Subject: [PATCH 06/20] CC-4463: do we need getFileExtension()? --- airtime_mvc/application/models/StoredFile.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 3469c75c9..420510953 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -407,11 +407,12 @@ SQL; */ public function getFileExtension() { + return ""; // TODO : what's the point of having this function? Can we not just use // the extension from the file_path column from cc_files? $mime = $this->_file->getDbMime(); - if ($mime == "audio/vorbis" || $mime == "application/ogg") { + if ($mime == "audio/ogg" || $mime == "application/ogg") { return "ogg"; } elseif ($mime == "audio/mp3" || $mime == "audio/mpeg") { return "mp3"; @@ -505,8 +506,6 @@ SQL; */ public function getRelativeFileUrl($baseUrl) { - Logging::info("getting media!"); - return $baseUrl."/api/get-media/file/".$this->getId().".".$this->getFileExtension(); } From d367c0f55c8a6d109ffe6309eecf6bfba4920857 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Mon, 17 Sep 2012 16:41:40 -0400 Subject: [PATCH 07/20] remove all newline characters from AirtimeInstall.php --- install_minimal/include/AirtimeInstall.php | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/install_minimal/include/AirtimeInstall.php b/install_minimal/include/AirtimeInstall.php index 02a2b43b2..b2d4bf451 100644 --- a/install_minimal/include/AirtimeInstall.php +++ b/install_minimal/include/AirtimeInstall.php @@ -107,16 +107,16 @@ class AirtimeInstall echo "done.\n"; } } catch (Exception $e) { - echo "Error!\n".$e->getMessage()."\n"; - echo " SQL statement was:\n"; + echo "Error!\n".$e->getMessage()."\n"; + echo " SQL statement was:\n"; echo " ".$sql."\n\n"; } } - public static function DropSequence($p_sequenceName) - { + public static function DropSequence($p_sequenceName) + { AirtimeInstall::InstallQuery("DROP SEQUENCE IF EXISTS $p_sequenceName"); - } + } /** * Try to connect to the database. Return true on success, false on failure. @@ -130,12 +130,12 @@ class AirtimeInstall try { $con = Propel::getConnection(); } catch (Exception $e) { - echo $e->getMessage().PHP_EOL; - echo "Database connection problem.".PHP_EOL; - echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists". - " with corresponding permissions.".PHP_EOL; - if ($p_exitOnError) { - exit(1); + echo $e->getMessage().PHP_EOL; + echo "Database connection problem.".PHP_EOL; + echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists". + " with corresponding permissions.".PHP_EOL; + if ($p_exitOnError) { + exit(1); } return false; } @@ -314,7 +314,7 @@ class AirtimeInstall public static function SetUniqueId() { - $con = Propel::getConnection(); + $con = Propel::getConnection(); $uniqueId = md5(uniqid("", true)); $sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('uniqueId', '$uniqueId')"; @@ -328,7 +328,7 @@ class AirtimeInstall public static function SetDefaultTimezone() { $con = Propel::getConnection(); - // we need to run php as commandline because we want to get the timezone in cli php.ini file + // we need to run php as commandline because we want to get the timezone in cli php.ini file //$defaultTimezone = exec("php -r 'echo date_default_timezone_get().PHP_EOL;'"); $defaultTimezone = exec("cat /etc/timezone"); $defaultTimezone = trim($defaultTimezone); @@ -345,7 +345,7 @@ class AirtimeInstall public static function SetImportTimestamp() { - $con = Propel::getConnection(); + $con = Propel::getConnection(); $sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('import_timestamp', '0')"; $result = $con->exec($sql); if ($result < 1) { From 81c72b8344531b0655d350b8a90dfb8844032452 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 17 Sep 2012 16:46:49 -0400 Subject: [PATCH 08/20] cc-4462: Bandaided --- airtime_mvc/application/models/Datatables.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/models/Datatables.php b/airtime_mvc/application/models/Datatables.php index dc196b35a..d9f807e7a 100644 --- a/airtime_mvc/application/models/Datatables.php +++ b/airtime_mvc/application/models/Datatables.php @@ -77,8 +77,21 @@ class Application_Model_Datatables // map that maps dbname to searchTerm $dbname2searchTerm = array(); foreach ($current2dbname as $currentPos => $dbname) { - $dbname2searchTerm[$dbname] = - $orig2searchTerm[$librarySetting($currentPos)]; + $new_index = $librarySetting($currentPos); + // TODO : Fix this retarded hack later. Just a band aid for + // now at least we print some warnings so that we don't + // forget about this + if ( array_key_exists($new_index, $orig2searchTerm) ) { + $dbname2searchTerm[$dbname] = $orig2searchTerm[$new_index]; + } else { + Logging::warn("Trying to reorder to unknown index + printing as much debugging as possible..."); + $debug = array( + '$new_index' => $new_index, + '$currentPos' => $currentPos, + '$orig2searchTerm' => $orig2searchTerm); + Logging::warn($debug); + } } $where = array(); From 75620be7615f91ec8a0ced8c5bbba2cb72d43120 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Mon, 17 Sep 2012 16:46:51 -0400 Subject: [PATCH 09/20] remove all mosty carriage return characters --- airtime_mvc/application/common/DateHelper.php | 100 ++++++------ .../models/airtime/CcBlockcontents.php | 152 +++++++++--------- .../models/airtime/CcShowInstances.php | 54 +++---- .../include/airtime-db-install.php | 2 +- 4 files changed, 154 insertions(+), 154 deletions(-) diff --git a/airtime_mvc/application/common/DateHelper.php b/airtime_mvc/application/common/DateHelper.php index eb32c0393..c13543d8e 100644 --- a/airtime_mvc/application/common/DateHelper.php +++ b/airtime_mvc/application/common/DateHelper.php @@ -366,56 +366,56 @@ class Application_Common_DateHelper return $retVal; } - /** - * This function is used for calculations! Don't modify for display purposes! - * - * Convert playlist time value to float seconds - * - * @param string $plt - * playlist interval value (HH:mm:ss.dddddd) - * @return int - * seconds - */ - public static function playlistTimeToSeconds($plt) - { - $arr = preg_split('/:/', $plt); - if (isset($arr[2])) { - return (intval($arr[0])*60 + intval($arr[1]))*60 + floatval($arr[2]); - } - if (isset($arr[1])) { - return intval($arr[0])*60 + floatval($arr[1]); - } - - return floatval($arr[0]); - } - - - /** - * This function is used for calculations! Don't modify for display purposes! - * - * Convert float seconds value to playlist time format - * - * @param float $seconds - * @return string - * interval in playlist time format (HH:mm:ss.d) - */ - public static function secondsToPlaylistTime($p_seconds) - { - $info = explode('.', $p_seconds); - $seconds = $info[0]; - if (!isset($info[1])) { - $milliStr = 0; - } else { - $milliStr = $info[1]; - } - $hours = floor($seconds / 3600); - $seconds -= $hours * 3600; - $minutes = floor($seconds / 60); - $seconds -= $minutes * 60; - - $res = sprintf("%02d:%02d:%02d.%s", $hours, $minutes, $seconds, $milliStr); - - return $res; + /** + * This function is used for calculations! Don't modify for display purposes! + * + * Convert playlist time value to float seconds + * + * @param string $plt + * playlist interval value (HH:mm:ss.dddddd) + * @return int + * seconds + */ + public static function playlistTimeToSeconds($plt) + { + $arr = preg_split('/:/', $plt); + if (isset($arr[2])) { + return (intval($arr[0])*60 + intval($arr[1]))*60 + floatval($arr[2]); + } + if (isset($arr[1])) { + return intval($arr[0])*60 + floatval($arr[1]); + } + + return floatval($arr[0]); + } + + + /** + * This function is used for calculations! Don't modify for display purposes! + * + * Convert float seconds value to playlist time format + * + * @param float $seconds + * @return string + * interval in playlist time format (HH:mm:ss.d) + */ + public static function secondsToPlaylistTime($p_seconds) + { + $info = explode('.', $p_seconds); + $seconds = $info[0]; + if (!isset($info[1])) { + $milliStr = 0; + } else { + $milliStr = $info[1]; + } + $hours = floor($seconds / 3600); + $seconds -= $hours * 3600; + $minutes = floor($seconds / 60); + $seconds -= $minutes * 60; + + $res = sprintf("%02d:%02d:%02d.%s", $hours, $minutes, $seconds, $milliStr); + + return $res; } } diff --git a/airtime_mvc/application/models/airtime/CcBlockcontents.php b/airtime_mvc/application/models/airtime/CcBlockcontents.php index f6de2dd45..5fcfbbf24 100644 --- a/airtime_mvc/application/models/airtime/CcBlockcontents.php +++ b/airtime_mvc/application/models/airtime/CcBlockcontents.php @@ -14,82 +14,82 @@ * @package propel.generator.airtime */ class CcBlockcontents extends BaseCcBlockcontents { - /** - * Get the [optionally formatted] temporal [fadein] column value. - * - * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getDbFadein($format = "s.u") - { - return parent::getDbFadein($format); - } - - /** - * Get the [optionally formatted] temporal [fadein] column value. - * - * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getDbFadeout($format = "s.u") - { - return parent::getDbFadeout($format); - } - - /** - * - * @param String in format SS.uuuuuu, Datetime, or DateTime accepted string. - * - * @return CcBlockcontents The current object (for fluent API support) - */ - public function setDbFadein($v) - { - if ($v instanceof DateTime) { - $dt = $v; - } - else if (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) { - $dt = DateTime::createFromFormat("s.u", $v); - } - else { - try { - $dt = new DateTime($v); - } catch (Exception $x) { - throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); - } - } - - $this->fadein = $dt->format('H:i:s.u'); - $this->modifiedColumns[] = CcBlockcontentsPeer::FADEIN; - - return $this; - } // setDbFadein() - - /** - * - * @param String in format SS.uuuuuu, Datetime, or DateTime accepted string. - * - * @return CcBlockcontents The current object (for fluent API support) - */ - public function setDbFadeout($v) - { - if ($v instanceof DateTime) { - $dt = $v; - } - else if (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) { - $dt = DateTime::createFromFormat("s.u", $v); - } - else { - try { - $dt = new DateTime($v); - } catch (Exception $x) { - throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); - } - } - - $this->fadeout = $dt->format('H:i:s.u'); - $this->modifiedColumns[] = CcBlockcontentsPeer::FADEOUT; - - return $this; + /** + * Get the [optionally formatted] temporal [fadein] column value. + * + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getDbFadein($format = "s.u") + { + return parent::getDbFadein($format); + } + + /** + * Get the [optionally formatted] temporal [fadein] column value. + * + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getDbFadeout($format = "s.u") + { + return parent::getDbFadeout($format); + } + + /** + * + * @param String in format SS.uuuuuu, Datetime, or DateTime accepted string. + * + * @return CcBlockcontents The current object (for fluent API support) + */ + public function setDbFadein($v) + { + if ($v instanceof DateTime) { + $dt = $v; + } + else if (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) { + $dt = DateTime::createFromFormat("s.u", $v); + } + else { + try { + $dt = new DateTime($v); + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + $this->fadein = $dt->format('H:i:s.u'); + $this->modifiedColumns[] = CcBlockcontentsPeer::FADEIN; + + return $this; + } // setDbFadein() + + /** + * + * @param String in format SS.uuuuuu, Datetime, or DateTime accepted string. + * + * @return CcBlockcontents The current object (for fluent API support) + */ + public function setDbFadeout($v) + { + if ($v instanceof DateTime) { + $dt = $v; + } + else if (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) { + $dt = DateTime::createFromFormat("s.u", $v); + } + else { + try { + $dt = new DateTime($v); + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + $this->fadeout = $dt->format('H:i:s.u'); + $this->modifiedColumns[] = CcBlockcontentsPeer::FADEOUT; + + return $this; } // setDbFadeout() } // CcBlockcontents diff --git a/airtime_mvc/application/models/airtime/CcShowInstances.php b/airtime_mvc/application/models/airtime/CcShowInstances.php index ed598c5ee..4625d1f91 100644 --- a/airtime_mvc/application/models/airtime/CcShowInstances.php +++ b/airtime_mvc/application/models/airtime/CcShowInstances.php @@ -139,40 +139,40 @@ class CcShowInstances extends BaseCcShowInstances { $this->save($con); } - /** - * Computes the value of the aggregate column time_filled - * - * @param PropelPDO $con A connection object - * - * @return mixed The scalar result from the aggregate query - */ - public function computeDbTimeFilled(PropelPDO $con) - { - $stmt = $con->prepare('SELECT SUM(clip_length) FROM "cc_schedule" WHERE cc_schedule.INSTANCE_ID = :p1'); - $stmt->bindValue(':p1', $this->getDbId()); - $stmt->execute(); - return $stmt->fetchColumn(); - } - - /** - * Updates the aggregate column time_filled - * - * @param PropelPDO $con A connection object - */ - public function updateDbTimeFilled(PropelPDO $con) + /** + * Computes the value of the aggregate column time_filled + * + * @param PropelPDO $con A connection object + * + * @return mixed The scalar result from the aggregate query + */ + public function computeDbTimeFilled(PropelPDO $con) + { + $stmt = $con->prepare('SELECT SUM(clip_length) FROM "cc_schedule" WHERE cc_schedule.INSTANCE_ID = :p1'); + $stmt->bindValue(':p1', $this->getDbId()); + $stmt->execute(); + return $stmt->fetchColumn(); + } + + /** + * Updates the aggregate column time_filled + * + * @param PropelPDO $con A connection object + */ + public function updateDbTimeFilled(PropelPDO $con) { $timefilled = $this->computeDbTimeFilled($con); if(is_null($timefilled)){ $timefilled = "00:00:00"; - } - $this->setDbTimeFilled($timefilled); - $this->save($con); + } + $this->setDbTimeFilled($timefilled); + $this->save($con); } public function preInsert(PropelPDO $con = null) { - $now = new DateTime("now", new DateTimeZone("UTC")); - $this->setDbCreated($now); - return true; + $now = new DateTime("now", new DateTimeZone("UTC")); + $this->setDbCreated($now); + return true; } } // CcShowInstances diff --git a/install_minimal/include/airtime-db-install.php b/install_minimal/include/airtime-db-install.php index 862ce3756..3d9a80ed3 100644 --- a/install_minimal/include/airtime-db-install.php +++ b/install_minimal/include/airtime-db-install.php @@ -11,7 +11,7 @@ require_once(__DIR__.'/airtime-constants.php'); require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php'); require_once 'propel/runtime/lib/Propel.php'; -Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/airtime-conf-production.php"); +Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/airtime-conf-production.php"); echo PHP_EOL."* Database Installation".PHP_EOL; From d0e67d8475238a98b2c15dd4a39cb7450ac4cf46 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 17 Sep 2012 16:47:33 -0400 Subject: [PATCH 10/20] cc-4462: Bandaided, marked as hack --- airtime_mvc/application/models/Datatables.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/Datatables.php b/airtime_mvc/application/models/Datatables.php index d9f807e7a..c022f2533 100644 --- a/airtime_mvc/application/models/Datatables.php +++ b/airtime_mvc/application/models/Datatables.php @@ -80,7 +80,7 @@ class Application_Model_Datatables $new_index = $librarySetting($currentPos); // TODO : Fix this retarded hack later. Just a band aid for // now at least we print some warnings so that we don't - // forget about this + // forget about this -- cc-4462 if ( array_key_exists($new_index, $orig2searchTerm) ) { $dbname2searchTerm[$dbname] = $orig2searchTerm[$new_index]; } else { From 9c5ebdc4c0d0312b6e3ebbf0b76818e4d42da97b Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 17 Sep 2012 17:02:59 -0400 Subject: [PATCH 11/20] Removed old commented code --- airtime_mvc/application/controllers/ScheduleController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index c2fe93dbb..41e1b5125 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -217,7 +217,6 @@ class ScheduleController extends Zend_Controller_Action $file = $show_inst->getRecordedFile(); $id = $file->getId(); - //$res = exec("/usr/lib/airtime/utils/soundcloud-uploader $id > /dev/null &"); Application_Model_Soundcloud::uploadSoundcloud($id); // we should die with ui info die(); From 5a37777cfd149aac1d2e2065460b1e2508dd3110 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 17 Sep 2012 17:04:49 -0400 Subject: [PATCH 12/20] formatting --- airtime_mvc/application/models/ShowBuilder.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/models/ShowBuilder.php b/airtime_mvc/application/models/ShowBuilder.php index b73a341d0..b6ecfd1fe 100644 --- a/airtime_mvc/application/models/ShowBuilder.php +++ b/airtime_mvc/application/models/ShowBuilder.php @@ -440,9 +440,12 @@ class Application_Model_ShowBuilder //make the last footer if there were any scheduled items. if (count($scheduled_items) > 0) { - $display_items[] = $this->makeFooterRow($scheduled_items[count($scheduled_items)-1]); + $display_items[] = $this->makeFooterRow($scheduled_items[ + count($scheduled_items)-1]); } - return array("schedule" => $display_items, "showInstances" => $this->showInstances); + return array( + "schedule" => $display_items, + "showInstances" => $this->showInstances); } } From 3ba3df07f858474f979634db9fa1923a33640016 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 17 Sep 2012 17:39:41 -0400 Subject: [PATCH 13/20] better logging --- .../application/models/ShowBuilder.php | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/airtime_mvc/application/models/ShowBuilder.php b/airtime_mvc/application/models/ShowBuilder.php index b6ecfd1fe..d708681ca 100644 --- a/airtime_mvc/application/models/ShowBuilder.php +++ b/airtime_mvc/application/models/ShowBuilder.php @@ -189,10 +189,13 @@ class Application_Model_ShowBuilder $row["record"] = true; if (Application_Model_Preference::GetUploadToSoundcloudOption()) { - $file = Application_Model_StoredFile::Recall($p_item["si_file_id"]); + Logging::info('$p_item contains:'); + Logging::info($p_item); + $file = Application_Model_StoredFile::Recall( + $p_item['si_file_id']); if (isset($file)) { $sid = $file->getSoundCloudId(); - $row["soundcloud_id"] = $sid; + $row['soundcloud_id'] = $sid; } } } @@ -204,18 +207,18 @@ class Application_Model_ShowBuilder $this->currentShow = false; } - $row["header"] = true; - $row["starts"] = $showStartDT->format("Y-m-d H:i"); + $row["header"] = true; + $row["starts"] = $showStartDT->format("Y-m-d H:i"); $row["startDate"] = $showStartDT->format("Y-m-d"); $row["startTime"] = $showStartDT->format("H:i"); - $row["refresh"] = floatval($showStartDT->format("U.u")) - $this->epoch_now; - $row["ends"] = $showEndDT->format("Y-m-d H:i"); - $row["endDate"] = $showEndDT->format("Y-m-d"); - $row["endTime"] = $showEndDT->format("H:i"); - $row["duration"] = floatval($showEndDT->format("U.u")) - floatval($showStartDT->format("U.u")); - $row["title"] = $p_item["show_name"]; - $row["instance"] = intval($p_item["si_id"]); - $row["image"] = ''; + $row["refresh"] = floatval($showStartDT->format("U.u")) - $this->epoch_now; + $row["ends"] = $showEndDT->format("Y-m-d H:i"); + $row["endDate"] = $showEndDT->format("Y-m-d"); + $row["endTime"] = $showEndDT->format("H:i"); + $row["duration"] = floatval($showEndDT->format("U.u")) - floatval($showStartDT->format("U.u")); + $row["title"] = $p_item["show_name"]; + $row["instance"] = intval($p_item["si_id"]); + $row["image"] = ''; $this->getScheduledStatus($startsEpoch, $endsEpoch, $row); From db52f1cfcf28fa187ce434e5cd99848f1e7e8f63 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 17 Sep 2012 17:47:32 -0400 Subject: [PATCH 14/20] CC-4383: Fatal error in phone_home_stat script (2.2.0 dev) - fixed --- utils/phone_home_stat.php | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/utils/phone_home_stat.php b/utils/phone_home_stat.php index d01a736c1..47929f5f7 100644 --- a/utils/phone_home_stat.php +++ b/utils/phone_home_stat.php @@ -35,23 +35,21 @@ get_include_path(), realpath($CC_CONFIG['phpDir'] . '/library') ))); -function __autoload($classname){ +function my_autoload($classname){ global $CC_CONFIG; $info = explode('_', $classname); - if (isset($info[2])) { + if (isset($info[1]) && isset($info[2])) { $filename = $info[2].".php"; - require_once($CC_CONFIG['phpDir'].'/application/models/'.$filename); + if ($info[1] == "Model") { + $folderName = "models"; + } else if ($info[1] == "Common") { + $folderName = "common"; + } + require_once($CC_CONFIG['phpDir'].'/application/'.$folderName.'/'.$filename); } } -require_once($CC_CONFIG['phpDir'].'/application/models/User.php'); -require_once($CC_CONFIG['phpDir'].'/application/models/StoredFile.php'); -require_once($CC_CONFIG['phpDir'].'/application/models/Playlist.php'); -require_once($CC_CONFIG['phpDir'].'/application/models/Schedule.php'); -require_once($CC_CONFIG['phpDir'].'/application/models/Show.php'); -require_once($CC_CONFIG['phpDir'].'/application/models/ShowInstance.php'); -require_once($CC_CONFIG['phpDir'].'/application/models/Preference.php'); -require_once($CC_CONFIG['phpDir'].'/application/models/StreamSetting.php'); -require_once($CC_CONFIG['phpDir'].'/application/models/LiveLog.php'); + +spl_autoload_register('my_autoload'); require_once 'propel/runtime/lib/Propel.php'; Propel::init($CC_CONFIG['phpDir']."/application/configs/airtime-conf-production.php"); @@ -64,20 +62,7 @@ if (file_exists('/usr/share/php/libzend-framework-php')){ require_once('Zend/Loader/Autoloader.php'); $autoloader = Zend_Loader_Autoloader::getInstance(); -try { - $opts = new Zend_Console_Getopt( - array( - 'test|t' => "Keep broadcast log data\n" - ) - ); - $opts->parse(); -} -catch (Zend_Console_Getopt_Exception $e) { - print $e->getMessage() .PHP_EOL; - exit(1); -} - -$infoArray = Application_Model_Preference::GetSystemInfo(true, isset($opts->t)); +$infoArray = Application_Model_Preference::GetSystemInfo(true); if(Application_Model_Preference::GetSupportFeedback() == '1'){ $url = 'http://stat.sourcefabric.org/index.php?p=airtime'; From ff22b80dfc2bfa4cb8cdf474ec66cd21d51e67c5 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 17 Sep 2012 17:49:16 -0400 Subject: [PATCH 15/20] formatting --- .../application/models/ShowBuilder.php | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/airtime_mvc/application/models/ShowBuilder.php b/airtime_mvc/application/models/ShowBuilder.php index d708681ca..80a5329a0 100644 --- a/airtime_mvc/application/models/ShowBuilder.php +++ b/airtime_mvc/application/models/ShowBuilder.php @@ -23,26 +23,26 @@ class Application_Model_ShowBuilder private $showInstances = array(); private $defaultRowArray = array( - "header" => false, - "footer" => false, - "empty" => false, - "allowed" => false, - "id" => 0, - "instance" => "", - "starts" => "", - "ends" => "", - "runtime" => "", - "title" => "", - "creator" => "", - "album" => "", - "timestamp" => null, - "cuein" => "", - "cueout" => "", - "fadein" => "", - "fadeout" => "", - "image" => false, - "color" => "", //in hex without the '#' sign. - "backgroundColor"=> "", //in hex without the '#' sign. + "header" => false, + "footer" => false, + "empty" => false, + "allowed" => false, + "id" => 0, + "instance" => "", + "starts" => "", + "ends" => "", + "runtime" => "", + "title" => "", + "creator" => "", + "album" => "", + "timestamp" => null, + "cuein" => "", + "cueout" => "", + "fadein" => "", + "fadeout" => "", + "image" => false, + "color" => "", //in hex without the '#' sign. + "backgroundColor" => "", //in hex without the '#' sign. ); /* From 69756f60ca10290395aa6af4f2911baf3dabca41 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 17 Sep 2012 17:49:25 -0400 Subject: [PATCH 16/20] formatting --- airtime_mvc/application/models/ShowBuilder.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/airtime_mvc/application/models/ShowBuilder.php b/airtime_mvc/application/models/ShowBuilder.php index 80a5329a0..184b58cad 100644 --- a/airtime_mvc/application/models/ShowBuilder.php +++ b/airtime_mvc/application/models/ShowBuilder.php @@ -51,12 +51,12 @@ class Application_Model_ShowBuilder */ public function __construct($p_startDT, $p_endDT, $p_opts) { - $this->startDT = $p_startDT; - $this->endDT = $p_endDT; - $this->timezone = date_default_timezone_get(); - $this->user = Application_Model_User::getCurrentUser(); - $this->opts = $p_opts; - $this->epoch_now = floatval(microtime(true)); + $this->startDT = $p_startDT; + $this->endDT = $p_endDT; + $this->timezone = date_default_timezone_get(); + $this->user = Application_Model_User::getCurrentUser(); + $this->opts = $p_opts; + $this->epoch_now = floatval(microtime(true)); $this->currentShow = false; } From 095a5cce4f6bc9ed3a9332a139a872089ec43031 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 17 Sep 2012 17:51:50 -0400 Subject: [PATCH 17/20] Added better debugging --- airtime_mvc/application/models/ShowBuilder.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/airtime_mvc/application/models/ShowBuilder.php b/airtime_mvc/application/models/ShowBuilder.php index 184b58cad..178533199 100644 --- a/airtime_mvc/application/models/ShowBuilder.php +++ b/airtime_mvc/application/models/ShowBuilder.php @@ -129,6 +129,7 @@ class Application_Model_ShowBuilder * 0 = past * 1 = current * 2 = future + * TODO : change all of the above to real constants -- RG */ private function getScheduledStatus($p_epochItemStart, $p_epochItemEnd, &$row) { @@ -157,6 +158,14 @@ class Application_Model_ShowBuilder //item is in the future. else if ($this->epoch_now < $p_epochItemStart) { $row["scheduled"] = 2; + } else { + Logging::warn("No-op? is this what should happen...printing + debug just in case"); + $d = array( + '$p_epochItemStart' => $p_epochItemStart, + '$p_epochItemEnd' => $p_epochItemEnd, + '$row' => $row); + Logging::warn($d); } } From 53c6d77821e0ff45cca229927c5dbc52eaff3db3 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 17 Sep 2012 17:52:56 -0400 Subject: [PATCH 18/20] Formatting --- .../application/models/ShowBuilder.php | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/airtime_mvc/application/models/ShowBuilder.php b/airtime_mvc/application/models/ShowBuilder.php index 178533199..924aad2cd 100644 --- a/airtime_mvc/application/models/ShowBuilder.php +++ b/airtime_mvc/application/models/ShowBuilder.php @@ -250,32 +250,32 @@ class Application_Model_ShowBuilder $this->getItemStatus($p_item, $row); - $startsEpoch = floatval($schedStartDT->format("U.u")); - $endsEpoch = floatval($schedEndDT->format("U.u")); + $startsEpoch = floatval($schedStartDT->format("U.u")); + $endsEpoch = floatval($schedEndDT->format("U.u")); $showEndEpoch = floatval($showEndDT->format("U.u")); //don't want an overbooked item to stay marked as current. $this->getScheduledStatus($startsEpoch, min($endsEpoch, $showEndEpoch), $row); - $row["id"] = intval($p_item["sched_id"]); - $row["image"] = $p_item["file_exists"]; + $row["id"] = intval($p_item["sched_id"]); + $row["image"] = $p_item["file_exists"]; $row["instance"] = intval($p_item["si_id"]); - $row["starts"] = $schedStartDT->format("H:i:s"); - $row["ends"] = $schedEndDT->format("H:i:s"); + $row["starts"] = $schedStartDT->format("H:i:s"); + $row["ends"] = $schedEndDT->format("H:i:s"); - $formatter = new LengthFormatter($p_item['file_length']); - $row['runtime'] = $formatter->format(); + $formatter = new LengthFormatter($p_item['file_length']); + $row['runtime'] = $formatter->format(); - $row["title"] = $p_item["file_track_title"]; - $row["creator"] = $p_item["file_artist_name"]; - $row["album"] = $p_item["file_album_title"]; + $row["title"] = $p_item["file_track_title"]; + $row["creator"] = $p_item["file_artist_name"]; + $row["album"] = $p_item["file_album_title"]; - $row["cuein"] = $p_item["cue_in"]; - $row["cueout"] = $p_item["cue_out"]; - $row["fadein"] = round(substr($p_item["fade_in"], 6), 6); - $row["fadeout"] = round(substr($p_item["fade_out"], 6), 6); + $row["cuein"] = $p_item["cue_in"]; + $row["cueout"] = $p_item["cue_out"]; + $row["fadein"] = round(substr($p_item["fade_in"], 6), 6); + $row["fadeout"] = round(substr($p_item["fade_out"], 6), 6); - $row["pos"] = $this->pos++; + $row["pos"] = $this->pos++; $this->contentDT = $schedEndDT; } From 542c5c857f8092d04c72aa13b0d25cb865a2b461 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 17 Sep 2012 17:54:10 -0400 Subject: [PATCH 19/20] alignment --- airtime_mvc/application/models/ShowBuilder.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/airtime_mvc/application/models/ShowBuilder.php b/airtime_mvc/application/models/ShowBuilder.php index 924aad2cd..869e3f2d8 100644 --- a/airtime_mvc/application/models/ShowBuilder.php +++ b/airtime_mvc/application/models/ShowBuilder.php @@ -91,7 +91,7 @@ class Application_Model_ShowBuilder private function getItemColor($p_item, &$row) { - $defaultColor = "ffffff"; + $defaultColor = "ffffff"; $defaultBackground = "3366cc"; $color = $p_item["show_color"]; @@ -103,7 +103,7 @@ class Application_Model_ShowBuilder $backgroundColor = $defaultBackground; } - $row["color"] = $color; + $row["color"] = $color; $row["backgroundColor"] = $backgroundColor; } @@ -281,19 +281,19 @@ class Application_Model_ShowBuilder } //show is empty or is a special kind of show (recording etc) else if (intval($p_item["si_record"]) === 1) { - $row["record"] = true; + $row["record"] = true; $row["instance"] = intval($p_item["si_id"]); - $showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC")); - $showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC")); + $showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC")); + $showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC")); - $startsEpoch = floatval($showStartDT->format("U.u")); - $endsEpoch = floatval($showEndDT->format("U.u")); + $startsEpoch = floatval($showStartDT->format("U.u")); + $endsEpoch = floatval($showEndDT->format("U.u")); $this->getScheduledStatus($startsEpoch, $endsEpoch, $row); } else { - $row["empty"] = true; - $row["id"] = 0 ; + $row["empty"] = true; + $row["id"] = 0 ; $row["instance"] = intval($p_item["si_id"]); } From 81a015dfac8250cab91a00fc2cf5075058e55915 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 17 Sep 2012 17:56:33 -0400 Subject: [PATCH 20/20] CC-4460: Differences between upgraded and fresh installed Airtime database - done --- install_minimal/upgrades/airtime-2.2.0/data/upgrade.sql | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/install_minimal/upgrades/airtime-2.2.0/data/upgrade.sql b/install_minimal/upgrades/airtime-2.2.0/data/upgrade.sql index 3b6bfbec6..4f5cc398f 100644 --- a/install_minimal/upgrades/airtime-2.2.0/data/upgrade.sql +++ b/install_minimal/upgrades/airtime-2.2.0/data/upgrade.sql @@ -101,6 +101,7 @@ CREATE TABLE cc_webstream ( creator_id integer NOT NULL, mtime timestamp(6) without time zone NOT NULL, utime timestamp(6) without time zone NOT NULL, + lptime timestamp(6) without time zone, mime character varying(255) ); @@ -113,10 +114,13 @@ CREATE TABLE cc_webstream_metadata ( ALTER TABLE cc_files DROP COLUMN gunid, - ADD COLUMN replay_gain character varying(16), + ADD COLUMN replay_gain numeric, ADD COLUMN owner_id integer, ALTER COLUMN bpm TYPE integer using airtime_to_int(bpm) /* TYPE change - table: cc_files original: character varying(8) new: integer */; +ALTER TABLE cc_files + ADD CONSTRAINT cc_files_owner_fkey FOREIGN KEY (owner_id) REFERENCES cc_subjs(id); + ALTER TABLE cc_playlistcontents ADD COLUMN block_id integer, ADD COLUMN stream_id integer,