diff --git a/airtime_mvc/application/controllers/DashboardController.php b/airtime_mvc/application/controllers/DashboardController.php index 8b918137d..afdb26f33 100644 --- a/airtime_mvc/application/controllers/DashboardController.php +++ b/airtime_mvc/application/controllers/DashboardController.php @@ -35,7 +35,7 @@ class DashboardController extends Zend_Controller_Action public function aboutAction() { - // action body + $this->view->airtime_version = Application_Model_Preference::GetAirtimeVersion(); } } diff --git a/airtime_mvc/application/controllers/UserController.php b/airtime_mvc/application/controllers/UserController.php index b84a0dede..37404931c 100644 --- a/airtime_mvc/application/controllers/UserController.php +++ b/airtime_mvc/application/controllers/UserController.php @@ -63,6 +63,7 @@ class UserController extends Zend_Controller_Action public function getHostsAction() { $search = $this->_getParam('term'); + $res = Application_Model_User::getHosts($search); $this->view->hosts = Application_Model_User::getHosts($search); } diff --git a/airtime_mvc/application/forms/AddShowWho.php b/airtime_mvc/application/forms/AddShowWho.php index 360a5abea..22dd109eb 100644 --- a/airtime_mvc/application/forms/AddShowWho.php +++ b/airtime_mvc/application/forms/AddShowWho.php @@ -16,7 +16,7 @@ class Application_Form_AddShowWho extends Zend_Form_SubForm $hosts = Application_Model_User::getHosts(); foreach ($hosts as $host) { - $options[$host['value']] = $host['label']; + $options[$host['index']] = $host['label']; } //Add hosts selection diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index e856681f0..82b29e387 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -526,6 +526,24 @@ class Application_Model_Preference self::SetValue("latest_version", $version); } } + + public static function GetLatestLink(){ + $link = self::GetValue("latest_link"); + if($link == null || strlen($link) == 0) { + return "http://www.sourcefabric.org/en/airtime/download/"; + } else { + return $link; + } + } + + public static function SetLatestLink($link){ + $pattern = "#^(http|https|ftp)://" . + "([a-zA-Z0-9]+\.)*[a-zA-Z0-9]+" . + "(/[a-zA-Z0-9\-\.\_\~\:\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=]+)*/?$#"; + if(preg_match($pattern, $link)) { + self::SetValue("latest_link", $link); + } + } public static function SetUploadToSoundcloudOption($upload) { self::SetValue("soundcloud_upload_option", $upload); @@ -559,19 +577,24 @@ class Application_Model_Preference /* User specific preferences start */ /** - * Sets the time scale preference (day/week/month) in Calendar. + * Sets the time scale preference (agendaDay/agendaWeek/month) in Calendar. * * @param $timeScale new time scale */ - public static function SetCalendarTimeScale($timeScale) { - return self::SetValue("calendar_time_scale", $timeScale, true /* user specific */); + public static function SetCalendarTimeScale($timeScale) { + self::SetValue("calendar_time_scale", $timeScale, true /* user specific */); } /** * Retrieves the time scale preference for the current user. + * Defaults to month if no entry exists */ public static function GetCalendarTimeScale() { - return self::GetValue("calendar_time_scale", true /* user specific */); + $val = self::GetValue("calendar_time_scale", true /* user specific */); + if(strlen($val) == 0) { + $val = "month"; + } + return $val; } /** @@ -580,14 +603,19 @@ class Application_Model_Preference * @param $numEntries new number of entries to show */ public static function SetLibraryNumEntries($numEntries) { - return self::SetValue("library_num_entries", $numEntries, true /* user specific */); + self::SetValue("library_num_entries", $numEntries, true /* user specific */); } /** * Retrieves the number of entries to show preference in library under Playlist Builder. + * Defaults to 10 if no entry exists */ public static function GetLibraryNumEntries() { - return self::GetValue("library_num_entries", true /* user specific */); + $val = self::GetValue("library_num_entries", true /* user specific */); + if(strlen($val) == 0) { + $val = "10"; + } + return $val; } /** @@ -595,15 +623,20 @@ class Application_Model_Preference * * @param $timeInterval new time interval */ - public static function SetCalendarTimeInterval($timeInterval) { - return self::SetValue("calendar_time_interval", $timeInterval, true /* user specific */); + public static function SetCalendarTimeInterval($timeInterval) { + self::SetValue("calendar_time_interval", $timeInterval, true /* user specific */); } /** * Retrieves the time interval preference for the current user. + * Defaults to 30 min if no entry exists */ public static function GetCalendarTimeInterval() { - return self::GetValue("calendar_time_interval", true /* user specific */); + $val = self::GetValue("calendar_time_interval", true /* user specific */); + if(strlen($val) == 0) { + $val = "30"; + } + return $val; } /* User specific preferences end */ diff --git a/airtime_mvc/application/models/User.php b/airtime_mvc/application/models/User.php index 6f0ec13c7..81548f013 100644 --- a/airtime_mvc/application/models/User.php +++ b/airtime_mvc/application/models/User.php @@ -163,7 +163,7 @@ class Application_Model_User { $sql; - $sql_gen = "SELECT id AS value, login AS label FROM cc_subjs "; + $sql_gen = "SELECT login AS value, login AS label, id as index FROM cc_subjs "; $sql = $sql_gen; if(is_array($type)) { diff --git a/airtime_mvc/application/views/helpers/VersionNotify.php b/airtime_mvc/application/views/helpers/VersionNotify.php index 655843f0e..430f7f2ed 100644 --- a/airtime_mvc/application/views/helpers/VersionNotify.php +++ b/airtime_mvc/application/views/helpers/VersionNotify.php @@ -19,6 +19,7 @@ class Airtime_View_Helper_VersionNotify extends Zend_View_Helper_Abstract{ // retrieve and validate current and latest versions, $current = Application_Model_Preference::GetAirtimeVersion(); $latest = Application_Model_Preference::GetLatestVersion(); + $link = Application_Model_Preference::GetLatestLink(); $pattern = "/^([0-9]+)\.([0-9]+)\.[0-9]+/"; preg_match($pattern, $current, $curMatch); preg_match($pattern, $latest, $latestMatch); @@ -50,6 +51,7 @@ class Airtime_View_Helper_VersionNotify extends Zend_View_Helper_Abstract{ $result = "" . "" . "" + . "" . "
"; return $result; } diff --git a/airtime_mvc/application/views/scripts/dashboard/about.phtml b/airtime_mvc/application/views/scripts/dashboard/about.phtml index 6a551c1e4..bdedfcfd2 100644 --- a/airtime_mvc/application/views/scripts/dashboard/about.phtml +++ b/airtime_mvc/application/views/scripts/dashboard/about.phtml @@ -1,7 +1,7 @@

About

-Airtime , the open radio software for scheduling and remote station management.
+Airtime airtime_version ?>, the open radio software for scheduling and remote station management.
© 2011 Sourcefabric o.p.s 2011. Airtime is distributed under the GNU GPL v.3

diff --git a/airtime_mvc/application/views/scripts/form/stream-setting-form.phtml b/airtime_mvc/application/views/scripts/form/stream-setting-form.phtml index 5417b35a6..020be44a9 100644 --- a/airtime_mvc/application/views/scripts/form/stream-setting-form.phtml +++ b/airtime_mvc/application/views/scripts/form/stream-setting-form.phtml @@ -1,7 +1,7 @@ stream_number; ?> -

Stream stream_number?>

+

">Stream stream_number?>

stream_number != '1'?'style="display: none;':''?> id="-config">
diff --git a/airtime_mvc/public/js/airtime/dashboard/playlist.js b/airtime_mvc/public/js/airtime/dashboard/playlist.js index 070ac4686..0c0e2f4c6 100644 --- a/airtime_mvc/public/js/airtime/dashboard/playlist.js +++ b/airtime_mvc/public/js/airtime/dashboard/playlist.js @@ -264,7 +264,7 @@ function init() { $('.listen-control-button').click(function() { if (stream_window == null || stream_window.closed) - stream_window=window.open(baseUrl+"Dashboard/stream-player", 'name', 'width=400,height=216'); + stream_window=window.open(baseUrl+"Dashboard/stream-player", 'name', 'width=400,height=178'); stream_window.focus(); return false; }); diff --git a/airtime_mvc/public/js/airtime/dashboard/versiontooltip.js b/airtime_mvc/public/js/airtime/dashboard/versiontooltip.js index e428cc7f3..6087bb6a2 100644 --- a/airtime_mvc/public/js/airtime/dashboard/versiontooltip.js +++ b/airtime_mvc/public/js/airtime/dashboard/versiontooltip.js @@ -40,6 +40,13 @@ function getLatestVersion() { return $("#version-latest").html(); } +/** + * Returns the download link to latest release in HTML + */ +function getLatestLink() { + return "" + getLatestVersion() + ""; +} + /** * Returns true if current version is up to date */ @@ -51,13 +58,6 @@ function isUpToDate() { return (diff == 0 && current == latest) || diff < 0; } -/** - * Returns the download link to latest release in HTML - */ -function getLatestLink() { - return "" + getLatestVersion() + ""; -} - /** * Sets up the tooltip for version notification */ diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index 46b29b29c..ec04a37c7 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -122,6 +122,7 @@ function dtRowCallback( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { function dtDrawCallback() { addLibraryItemEvents(); addMetadataQtip(); + saveNumEntriesSetting(); } function addProgressIcon(id) { @@ -280,19 +281,24 @@ function addMetadataQtip(){ } /** - * Use user preference for number of entries to show; - * defaults to 10 if preference was never set + * Updates pref db when user changes the # of entries to show + */ +function saveNumEntriesSetting() { + $('select[name=library_display_length]').change(function() { + var url = '/Library/set-num-entries/format/json'; + $.post(url, {numEntries: $(this).val()}); + }); +} + +/** + * Use user preference for number of entries to show */ function getNumEntriesPreference(data) { - var numEntries = data.libraryInit.numEntries; - if(numEntries == '') { - numEntries = '10'; - } - return parseInt(numEntries); + return parseInt(data.libraryInit.numEntries); } function createDataTable(data) { - var dTable = $('#library_display').dataTable( { + var dTable = $('#library_display').dataTable( { "bProcessing": true, "bServerSide": true, "sAjaxSource": "/Library/contents/format/json", @@ -320,35 +326,24 @@ function createDataTable(data) { "sPaginationType": "full_numbers", "bJQueryUI": true, "bAutoWidth": false, - "oLanguage": { - "sSearch": "" - }, - "iDisplayLength": getNumEntriesPreference(data), - "bStateSave": true - }); - dTable.fnSetFilteringDelay(350); - - // Updates pref db when user changes the # of entries to show - $('select[name=library_display_length]').change(function() { - var url = '/Library/set-num-entries/format/json'; - $.post(url, {numEntries: $(this).val()}, - function(json){ - if(json.error) { - alert(json.error); - } - }); - }); + "oLanguage": { + "sSearch": "" + }, + "iDisplayLength": getNumEntriesPreference(data), + "bStateSave": true + }); + dTable.fnSetFilteringDelay(350); } $(document).ready(function() { - $('.tabs').tabs(); - - $.ajax({ url: "/Api/library-init/format/json", dataType:"json", success:createDataTable - , error:function(jqXHR, textStatus, errorThrown){}}); - - checkImportStatus() - setInterval( "checkImportStatus()", 5000 ); - setInterval( "checkSCUploadStatus()", 5000 ); - - addQtipToSCIcons() + $('.tabs').tabs(); + + $.ajax({ url: "/Api/library-init/format/json", dataType:"json", success:createDataTable, + error:function(jqXHR, textStatus, errorThrown){}}); + + checkImportStatus() + setInterval( "checkImportStatus()", 5000 ); + setInterval( "checkSCUploadStatus()", 5000 ); + + addQtipToSCIcons() }); diff --git a/airtime_mvc/public/js/airtime/preferences/streamsetting.js b/airtime_mvc/public/js/airtime/preferences/streamsetting.js index bf29514c2..277d1e34a 100644 --- a/airtime_mvc/public/js/airtime/preferences/streamsetting.js +++ b/airtime_mvc/public/js/airtime/preferences/streamsetting.js @@ -2,9 +2,12 @@ function showErrorSections() { $(".errors").each(function(i){ if($(this).length > 0){ - $(window).scrollTop($(this).closest("div").position().top); - $(this).closest("fieldset").removeClass('closed'); - return false; + var div = $(this).closest("div") + if(div.attr('class') == "stream-setting-content"){ + $(this).closest("div").show(); + $(this).closest("fieldset").removeClass('closed'); + $(window).scrollTop($(this).closest("div").position().top); + } } }); } diff --git a/airtime_mvc/public/js/airtime/schedule/add-show.js b/airtime_mvc/public/js/airtime/schedule/add-show.js index 09e6a997e..0a7da3f8d 100644 --- a/airtime_mvc/public/js/airtime/schedule/add-show.js +++ b/airtime_mvc/public/js/airtime/schedule/add-show.js @@ -40,7 +40,7 @@ function createDateInput(el, onSelect) { function autoSelect(event, ui) { - $("#add_show_hosts-"+ui.item.value).attr("checked", "checked"); + $("#add_show_hosts-"+ui.item.index).attr("checked", "checked"); event.preventDefault(); } @@ -50,11 +50,21 @@ function findHosts(request, callback) { url = "/User/get-hosts"; search = request.term; + var noResult = new Array(); + noResult[0] = new Array(); + noResult[0]['value'] = $("#add_show_hosts_autocomplete").val(); + noResult[0]['label'] = "No result found"; + noResult[0]['index'] = null; + $.post(url, {format: "json", term: search}, function(json) { - callback(json.hosts); + if(json.hosts.length<1){ + callback(noResult); + }else{ + callback(json.hosts); + } }); } @@ -232,6 +242,12 @@ function setAddShowEvents() { select: autoSelect, delay: 200 }); + + form.find("#add_show_hosts_autocomplete").keypress(function(e){ + if( e.which == 13 ){ + return false; + } + }) form.find("#schedule-show-style input").ColorPicker({ onChange: function (hsb, hex, rgb, el) { diff --git a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js index 9b21086d1..dae0c5648 100644 --- a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js +++ b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js @@ -197,6 +197,10 @@ function viewDisplay( view ) { .fullCalendar('destroy') .fullCalendar(opt) .fullCalendar( 'gotoDate', date ); + + //save slotMin value to db + var url = '/Schedule/set-time-interval/format/json'; + $.post(url, {timeInterval: slotMin}); }); var topLeft = $(view.element).find("table.fc-agenda-days > thead th:first"); @@ -214,6 +218,10 @@ function viewDisplay( view ) { if(($("#add-show-form").length == 1) && ($("#add-show-form").css('display')=='none') && ($('.fc-header-left > span').length == 5)) { makeAddShowButton(); } + + //save view name to db + var url = '/Schedule/set-time-scale/format/json'; + $.post(url, {timeScale: view.name}); } function eventRender(event, element, view) { diff --git a/airtime_mvc/public/js/airtime/schedule/schedule.js b/airtime_mvc/public/js/airtime/schedule/schedule.js index e3cd1a523..6cc8858bf 100644 --- a/airtime_mvc/public/js/airtime/schedule/schedule.js +++ b/airtime_mvc/public/js/airtime/schedule/schedule.js @@ -306,26 +306,14 @@ function buildScheduleDialog(json){ * Use user preference for time scale; defaults to month if preference was never set */ function getTimeScalePreference(data) { - var timeScale = data.calendarInit.timeScale; - if(timeScale == 'day') { - timeScale = 'agendaDay'; - } else if(timeScale == 'week') { - timeScale = 'agendaWeek'; - } else { - timeScale = 'month'; - } - return timeScale; + return data.calendarInit.timeScale; } /** * Use user preference for time interval; defaults to 30m if preference was never set */ function getTimeIntervalPreference(data) { - var timeInterval = data.calendarInit.timeInterval; - if(timeInterval == '') { - timeInterval = '30'; - } - return parseInt(timeInterval); + return parseInt(data.calendarInit.timeInterval); } function createFullCalendar(data){ @@ -366,28 +354,6 @@ function createFullCalendar(data){ eventDrop: eventDrop, eventResize: eventResize }); - - //Update time scale preference when day/week/month button is clicked - $(".fc-button-content").click(function() { - var url = '/Schedule/set-time-scale/format/json'; - $.post(url, {timeScale: $(this).text()}, - function(json){ - if(json.error) { - alert(json.error); - } - }); - }); - - //Update time interval preference when dropdown is updated - $(".schedule_change_slots.input_select").change(function() { - var url = '/Schedule/set-time-interval/format/json'; - $.post(url, {timeInterval: $(this).val()}, - function(json){ - if(json.error) { - alert(json.error); - } - }); - }); } //Alert the error and reload the page diff --git a/utils/phone_home_stat.php b/utils/phone_home_stat.php index fd1f90b81..6b3d8ecde 100644 --- a/utils/phone_home_stat.php +++ b/utils/phone_home_stat.php @@ -72,6 +72,8 @@ if(Application_Model_Preference::GetSupportFeedback() == '1'){ curl_setopt($ch, CURLOPT_POSTFIELDS, $dataArray); $result = curl_exec($ch); + + curl_close($ch); } // Get latest version from stat server and store to db @@ -83,7 +85,15 @@ if(Application_Model_Preference::GetPlanLevel() == 'disabled'){ curl_setopt($ch, CURLOPT_URL, $url); $result = curl_exec($ch); - Application_Model_Preference::SetLatestVersion($result); + if(curl_errno($ch)) { + echo "curl error: " . curl_error($ch) . "\n"; + } else { + $resultArray = explode("\n", $result); + Application_Model_Preference::SetLatestVersion($resultArray[0]); + Application_Model_Preference::SetLatestLink($resultArray[1]); + } + + curl_close($ch); } /**