diff --git a/airtime_mvc/application/common/OsPath.php b/airtime_mvc/application/common/OsPath.php index 47161301d..957545dc4 100644 --- a/airtime_mvc/application/common/OsPath.php +++ b/airtime_mvc/application/common/OsPath.php @@ -42,4 +42,25 @@ class Application_Common_OsPath{ else return '.'; } + + /* Similar to the os.path.join python method + * http://stackoverflow.com/a/1782990/276949 */ + function join() { + $args = func_get_args(); + $paths = array(); + + foreach($args as $arg) { + $paths = array_merge($paths, (array)$arg); + } + + foreach($paths as &$path) { + $path = trim($path, DIRECTORY_SEPARATOR); + } + + if (substr($args[0], 0, 1) == DIRECTORY_SEPARATOR) { + $paths[0] = DIRECTORY_SEPARATOR . $paths[0]; + } + + return join(DIRECTORY_SEPARATOR, $paths); + } } diff --git a/airtime_mvc/application/configs/ACL.php b/airtime_mvc/application/configs/ACL.php index f2f685a02..91167dd93 100644 --- a/airtime_mvc/application/configs/ACL.php +++ b/airtime_mvc/application/configs/ACL.php @@ -37,12 +37,13 @@ $ccAcl->allow('G', 'index') ->allow('H', 'usersettings') ->allow('H', 'plupload') ->allow('H', 'library') - ->allow('H', 'playlist') - ->allow('A', 'playouthistory') - ->allow('A', 'user') - ->allow('A', 'systemstatus') - ->allow('A', 'preference') - ->allow('A', 'audiopreview'); + ->allow('H', 'playlist') + ->allow('H', 'audiopreview') + ->allow('A', 'playouthistory') + ->allow('A', 'user') + ->allow('A', 'systemstatus') + ->allow('A', 'preference'); + $aclPlugin = new Zend_Controller_Plugin_Acl($ccAcl); diff --git a/airtime_mvc/application/controllers/AudiopreviewController.php b/airtime_mvc/application/controllers/AudiopreviewController.php index 607d39dd8..efb14b7e4 100644 --- a/airtime_mvc/application/controllers/AudiopreviewController.php +++ b/airtime_mvc/application/controllers/AudiopreviewController.php @@ -98,7 +98,7 @@ class AudiopreviewController extends Zend_Controller_Action $pl = new Application_Model_Playlist($playlistID); $result = Array(); - foreach ( $pl->getContents() as $track ){ + foreach ( $pl->getContents(true) as $track ){ $elementMap = array( 'element_title' => isset($track['CcFiles']['track_title'])?$track['CcFiles']['track_title']:"", 'element_artist' => isset($track['CcFiles']['artist_name'])?$track['CcFiles']['artist_name']:"", @@ -115,7 +115,7 @@ class AudiopreviewController extends Zend_Controller_Action } $result[] = $elementMap; } - + $this->_helper->json($result); } diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index c71794a83..bdcc4e2b7 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -373,7 +373,7 @@ class ScheduleController extends Zend_Controller_Action $this->view->switch_status = $switch_status; $this->view->entries = $range; - $this->view->show_name = $show[0]["name"]; + $this->view->show_name = isset($show[0])?$show[0]["name"]:""; } public function removeGroupAction() @@ -752,12 +752,11 @@ class ScheduleController extends Zend_Controller_Action //Changing the start date was disabled, since the //array key does not exist. We need to repopulate this entry from the db. //The start date will be returned in UTC time, so lets convert it to local time. - $dt = Application_Common_DateHelper::ConvertToLocalDateTime($show->getStartDate()); + $dt = Application_Common_DateHelper::ConvertToLocalDateTime($show->getStartDateAndTime()); $data['add_show_start_date'] = $dt->format("Y-m-d"); if (!array_key_exists('add_show_start_time', $data)){ - $startTime = Application_Common_DateHelper::ConvertToLocalDateTime($show->getStartTime()); - $data['add_show_start_time'] = $startTime->format("H:i"); + $data['add_show_start_time'] = $dt->format("H:i"); $validateStartTime = false; } $validateStartDate = false; diff --git a/airtime_mvc/application/forms/LiveStreamingPreferences.php b/airtime_mvc/application/forms/LiveStreamingPreferences.php index 9e89cae92..fe318d692 100644 --- a/airtime_mvc/application/forms/LiveStreamingPreferences.php +++ b/airtime_mvc/application/forms/LiveStreamingPreferences.php @@ -99,10 +99,8 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm $live_dj_connection_url = "N/A"; } - $overrideDescription = "If Airtime is behind a router or firewall, you may need to configure port forwarding and this field information will be incorrect. In this case you will need to manually update this field so it shows the correct host/port/mount that your DJ's need to connect to. The allowed range is between 1024 and 49151. For more detail, please read the Airtime manual."; - $this->setDecorators(array( - array('ViewScript', array('viewScript' => 'form/preferences_livestream.phtml', 'master_dj_connection_url'=>$master_dj_connection_url, 'live_dj_connection_url'=>$live_dj_connection_url,'overrideDescription' => $overrideDescription)) + array('ViewScript', array('viewScript' => 'form/preferences_livestream.phtml', 'master_dj_connection_url'=>$master_dj_connection_url, 'live_dj_connection_url'=>$live_dj_connection_url)) )); } diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php index bc48bb2d0..63d33409a 100644 --- a/airtime_mvc/application/models/Playlist.php +++ b/airtime_mvc/application/models/Playlist.php @@ -140,18 +140,26 @@ class Application_Model_Playlist { /** * Get the entire playlist as a two dimentional array, sorted in order of play. + * @param boolean $filterFiles if this is true, it will only return files that has + * file_exists flag set to true * @return array */ - public function getContents() { + public function getContents($filterFiles=false) { Logging::log("Getting contents for playlist {$this->id}"); $files = array(); - $rows = CcPlaylistcontentsQuery::create() - ->joinWith('CcFiles') - ->orderByDbPosition() - ->filterByDbPlaylistId($this->id) - ->find($this->con); + $query = CcPlaylistcontentsQuery::create() + ->filterByDbPlaylistId($this->id); + + if($filterFiles){ + $query->useCcFilesQuery() + ->filterByDbFileExists(true) + ->endUse(); + } + $query->orderByDbPosition() + ->leftJoinWith('CcFiles'); + $rows = $query->find($this->con); $i = 0; $offset = 0; diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 85107dfad..3675879b6 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -557,15 +557,15 @@ class Application_Model_Show { $con->exec($sql); } - + /** * Get the start date of the current show in UTC timezone. * * @return string * The start date in the format YYYY-MM-DD */ - public function getStartDate(){ - $con = Propel::getConnection(); + public function getStartDateAndTime(){ + $con = Propel::getConnection(); $showId = $this->getId(); $sql = "SELECT first_show, start_time, timezone FROM cc_show_days" @@ -583,10 +583,21 @@ class Application_Model_Show { $dt = new DateTime($row["first_show"]." ".$row["start_time"], new DateTimeZone($row["timezone"])); $dt->setTimezone(new DateTimeZone("UTC")); - return $dt->format("Y-m-d"); + return $dt->format("Y-m-d H:i"); } } + /** + * Get the start date of the current show in UTC timezone. + * + * @return string + * The start date in the format YYYY-MM-DD + */ + public function getStartDate(){ + list($date,) = explode(" ", $this->getStartDateAndTime()); + return $date; + } + /** * Get the start time of the current show in UTC timezone. * @@ -595,25 +606,8 @@ class Application_Model_Show { */ public function getStartTime(){ - $con = Propel::getConnection(); - - $showId = $this->getId(); - $sql = "SELECT first_show, start_time, timezone FROM cc_show_days" - ." WHERE show_id = $showId" - ." ORDER BY first_show" - ." LIMIT 1"; - - $query = $con->query($sql); - - if ($query->rowCount() == 0){ - return ""; - } else { - $rows = $query->fetchAll(); - $row = $rows[0]; - $dt = new DateTime($row["first_show"]." ".$row["start_time"], new DateTimeZone($row["timezone"])); - $dt->setTimezone(new DateTimeZone("UTC")); - return $dt->format("H:i"); - } + list(,$time) = explode(" ", $this->getStartDateAndTime()); + return $time; } /** @@ -856,8 +850,8 @@ class Application_Model_Show { ." WHERE date(starts) = date(TIMESTAMP '$timestamp') " ." AND show_id = $showId"; - $query = $con->query(); - $row = $query ? $query->fetchColumn(0) : null; + $query = $con->query($sql); + $row = ($query !== false) ? $query->fetchColumn(0) : null; return CcShowInstancesQuery::create() ->findPk($row); } diff --git a/airtime_mvc/application/models/ShowBuilder.php b/airtime_mvc/application/models/ShowBuilder.php index 25ff01933..7ca926e15 100644 --- a/airtime_mvc/application/models/ShowBuilder.php +++ b/airtime_mvc/application/models/ShowBuilder.php @@ -224,7 +224,7 @@ class Application_Model_ShowBuilder { $this->getScheduledStatus($startsEpoch, min($endsEpoch, $showEndEpoch), $row); $row["id"] = intval($p_item["sched_id"]); - $row["image"] = $p_item["file_exists"] == "t" ? true : false; + $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"); diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 06e788095..fcac1a8db 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -841,8 +841,7 @@ Logging::log("getting media! - 2"); //check to see if there is enough space in $stor to continue. $enough_space = Application_Model_StoredFile::checkForEnoughDiskSpaceToCopy($stor, $audio_file); if ($enough_space){ - $stor .= "/organize"; - $audio_stor = $stor . DIRECTORY_SEPARATOR . $fileName; + $audio_stor = Application_Common_OsPath::join($stor, "organize", $fileName); Logging::log("copyFileToStor: moving file $audio_file to $audio_stor"); //Martin K.: changed to rename: Much less load + quicker since this is an atomic operation diff --git a/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml b/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml index 9e48cb6ff..8fbafee9f 100644 --- a/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml @@ -77,10 +77,7 @@
master_dj_connection_url ?> override   - - - overrideDescription ?> - +
@@ -118,10 +115,7 @@
live_dj_connection_url ?> override   - - - overrideDescription?> - +
diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index d00131463..c58c3d3e4 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -93,6 +93,17 @@ select { } /* Version Notification Ends*/ +.override_help_icon { + cursor: help; + position: relative; + + display:inline-block; zoom:1; display:inline; + width:14px; height:14px; + background:url(/css/images/icon_info.png) 0 0 no-repeat; + float:right; position:relative; top:2px; right:7px; + line-height:16px !important; +} + /* Info Tooltip Starts */ .info-tooltip { cursor: help; diff --git a/airtime_mvc/public/js/airtime/audiopreview/preview_jplayer.js b/airtime_mvc/public/js/airtime/audiopreview/preview_jplayer.js index 6d4975f25..cfcbe2c86 100644 --- a/airtime_mvc/public/js/airtime/audiopreview/preview_jplayer.js +++ b/airtime_mvc/public/js/airtime/audiopreview/preview_jplayer.js @@ -114,7 +114,9 @@ function buildplaylist(p_url, p_playIndex) { } myPlaylist[index] = media; - _idToPostionLookUp[data[index]['element_id']] = data[index]['element_position']; + // we should create a map according to the new position in the player itself + // total is the index on the player + _idToPostionLookUp[data[index]['element_id']] = total; total++; } @@ -135,6 +137,9 @@ function buildplaylist(p_url, p_playIndex) { */ function play(p_playlistIndex){ playlistIndex = _idToPostionLookUp[p_playlistIndex]; + if(playlistIndex == undefined){ + playlistIndex = 0 + } //_playlist_jplayer.select(playlistIndex); _playlist_jplayer.play(playlistIndex); } diff --git a/airtime_mvc/public/js/airtime/dashboard/playlist.js b/airtime_mvc/public/js/airtime/dashboard/playlist.js index 077d9b780..c3b796da8 100644 --- a/airtime_mvc/public/js/airtime/dashboard/playlist.js +++ b/airtime_mvc/public/js/airtime/dashboard/playlist.js @@ -85,8 +85,8 @@ function updateProgressBarValue(){ if (songPercentDone < 0 || songPercentDone > 100){ songPercentDone = 0; currentSong = null; - } else { - if (currentSong.media_item_played == "t" && currentShow.length > 0){ + } else { + if (currentSong.media_item_played == true && currentShow.length > 0){ scheduled_play_line_to_switch.attr("class", "line-to-switch on"); scheduled_play_div.addClass("ready") scheduled_play_source = true; diff --git a/airtime_mvc/public/js/airtime/preferences/streamsetting.js b/airtime_mvc/public/js/airtime/preferences/streamsetting.js index 3c05bd8e5..20cd2d943 100644 --- a/airtime_mvc/public/js/airtime/preferences/streamsetting.js +++ b/airtime_mvc/public/js/airtime/preferences/streamsetting.js @@ -235,4 +235,26 @@ $(document).ready(function() { showErrorSections() setInterval('checkLiquidsoapStatus()', 1000) + + // qtip for help text + $(".override_help_icon").qtip({ + content: { + text: "If Airtime is behind a router or firewall, you may need to configure port forwarding and this field information will be incorrect. In this case you will need to manually update this field so it shows the correct host/port/mount that your DJ's need to connect to. The allowed range is between 1024 and 49151. For more detail, please read the Airtime manual." + }, + hide: { + delay: 500, + fixed: true + }, + style: { + border: { + width: 0, + radius: 4 + }, + classes: "ui-tooltip-dark ui-tooltip-rounded" + }, + position: { + my: "left bottom", + at: "right center" + }, + }) }); diff --git a/python_apps/media-monitor/MediaMonitor.py b/python_apps/media-monitor/MediaMonitor.py index 3fa9fe912..bcf9a0a3b 100644 --- a/python_apps/media-monitor/MediaMonitor.py +++ b/python_apps/media-monitor/MediaMonitor.py @@ -5,6 +5,7 @@ import sys import os import signal import traceback +import locale from api_clients import api_client as apc from std_err_override import LogWriter @@ -38,7 +39,16 @@ except Exception, e: logger.info("\n\n*** Media Monitor bootup ***\n\n") + try: + fs_encoding = locale.getdefaultlocale()[1].lower() + if fs_encoding not in ['utf-8', 'utf8']: + logger.error("Filesystem encoding needs to be UTF-8. Currently '%s'. Exiting..." % fs_encoding) + sys.exit(1) + else: + logger.debug("Filesystem encoding: '%s'" % fs_encoding) + + config = AirtimeMediaConfig(logger) api_client = apc.api_client_factory(config.cfg) api_client.register_component("media-monitor")