diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 74c324ee9..b25ba74fb 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -25,6 +25,7 @@ class ApiController extends Zend_Controller_Action ->addActionContext('register-component', 'json') ->addActionContext('update-liquidsoap-error', 'json') ->addActionContext('update-liquidsoap-connection', 'json') + ->addActionContext('library-init', 'json') ->initContext(); } @@ -77,9 +78,11 @@ class ApiController extends Zend_Controller_Action } $this->view->calendarInit = array( - "timestamp"=>time(), - "timezoneOffset"=> date("Z"), - "timeScale"=>Application_Model_Preference::GetCalendarTimeScale() + "timestamp" => time(), + "timezoneOffset" => date("Z"), + "timeScale" => Application_Model_Preference::GetCalendarTimeScale(), + "timeInterval" => Application_Model_Preference::GetCalendarTimeInterval(), + "weekStartDay" => Application_Model_Preference::GetWeekStartDay() ); } @@ -731,5 +734,25 @@ class ApiController extends Zend_Controller_Action // setting error_msg as "" when there is no error_msg Application_Model_StreamSetting::setLiquidsoapError($stream_id, ""); } + + /** + * Sets up and send init values used in the Library. + * This is being used by library.js + */ + public function libraryInitAction(){ + $this->view->layout()->disableLayout(); + $this->_helper->viewRenderer->setNoRender(true); + + if(is_null(Zend_Auth::getInstance()->getStorage()->read())) { + header('HTTP/1.0 401 Unauthorized'); + print 'You are not allowed to access this resource.'; + return; + } + + $this->view->libraryInit = array( + "numEntries"=>Application_Model_Preference::GetLibraryNumEntries() + ); + + } } diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index 06f195a40..6aa4a5b43 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -15,6 +15,7 @@ class LibraryController extends Zend_Controller_Action ->addActionContext('get-file-meta-data', 'html') ->addActionContext('upload-file-soundcloud', 'json') ->addActionContext('get-upload-to-soundcloud-status', 'json') + ->addActionContext('set-num-entries', 'json') ->initContext(); $this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME); @@ -278,4 +279,14 @@ class LibraryController extends Zend_Controller_Action $this->view->error_msg = $file->getSoundCloudErrorMsg(); } } + + /** + * Stores the number of entries user chose to show in the Library + * to the pref db + */ + public function setNumEntriesAction() { + $request = $this->getRequest(); + $numEntries = $request->getParam('numEntries'); + Application_Model_Preference::SetLibraryNumEntries($numEntries); + } } diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index cc9080e53..ece06790e 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -36,6 +36,7 @@ class PreferenceController extends Zend_Controller_Action Application_Model_Preference::SetStreamLabelFormat($values["preferences_general"]["streamFormat"]); Application_Model_Preference::SetAllow3rdPartyApi($values["preferences_general"]["thirdPartyApi"]); Application_Model_Preference::SetTimezone($values["preferences_general"]["timezone"]); + Application_Model_Preference::SetWeekStartDay($values["preferences_general"]["weekStartDay"]); Application_Model_Preference::SetAutoUploadRecordedShowToSoundcloud($values["preferences_soundcloud"]["UseSoundCloud"]); Application_Model_Preference::SetUploadToSoundcloudOption($values["preferences_soundcloud"]["UploadToSoundcloudOption"]); diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 716051390..6e8e445fa 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -29,6 +29,7 @@ class ScheduleController extends Zend_Controller_Action ->addActionContext('upload-to-sound-cloud', 'json') ->addActionContext('content-context-menu', 'json') ->addActionContext('set-time-scale', 'json') + ->addActionContext('set-time-interval', 'json') ->initContext(); $this->sched_sess = new Zend_Session_Namespace("schedule"); @@ -737,6 +738,14 @@ 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. + */ + public function setTimeIntervalAction() { + Application_Model_Preference::SetCalendarTimeInterval($this->_getParam('timeInterval')); + } } diff --git a/airtime_mvc/application/forms/GeneralPreferences.php b/airtime_mvc/application/forms/GeneralPreferences.php index 7b0da1400..61b79dbc8 100644 --- a/airtime_mvc/application/forms/GeneralPreferences.php +++ b/airtime_mvc/application/forms/GeneralPreferences.php @@ -65,6 +65,14 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm $timezone->setValue(Application_Model_Preference::GetTimezone()); $timezone->setDecorators(array('ViewHelper')); $this->addElement($timezone); + + /* Form Element for setting which day is the start of the week */ + $week_start_day = new Zend_Form_Element_Select("weekStartDay"); + $week_start_day->setLabel("Week Starts On"); + $week_start_day->setMultiOptions($this->getWeekStartDays()); + $week_start_day->setValue(Application_Model_Preference::GetWeekStartDay()); + $week_start_day->setDecorators(array('ViewHelper')); + $this->addElement($week_start_day); } private function getTimezones(){ @@ -90,7 +98,19 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm return $tzlist; } + - + private function getWeekStartDays() { + $days = array( + 'Sunday', + 'Monday', + 'Tuesday', + 'Wednesday', + 'Thursday', + 'Friday', + 'Saturday' + ); + return $days; + } } diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index e58dafb5f..200b4448f 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -485,6 +485,21 @@ class Application_Model_Preference public static function GetSoundCloudDownloadbleOption() { return self::GetValue("soundcloud_downloadable"); } + + public static function SetWeekStartDay($day) { + self::SetValue("week_start_day", $day); + } + + public static function GetWeekStartDay() { + $val = self::GetValue("week_start_day"); + if (strlen($val) == 0){ + return "0"; + } else { + return $val; + } + } + + /* User specific preferences start */ /** * Sets the time scale preference (day/week/month) in Calendar. @@ -501,5 +516,39 @@ class Application_Model_Preference public static function GetCalendarTimeScale() { return self::GetValue("calendar_time_scale", true /* user specific */); } + + /** + * Sets the number of entries to show preference in library under Playlist Builder. + * + * @param $numEntries new number of entries to show + */ + public static function SetLibraryNumEntries($numEntries) { + return self::SetValue("library_num_entries", $numEntries, true /* user specific */); + } + + /** + * Retrieves the number of entries to show preference in library under Playlist Builder. + */ + public static function GetLibraryNumEntries() { + return self::GetValue("library_num_entries", true /* user specific */); + } + + /** + * Sets the time interval preference in Calendar. + * + * @param $timeInterval new time interval + */ + public static function SetCalendarTimeInterval($timeInterval) { + return self::SetValue("calendar_time_interval", $timeInterval, true /* user specific */); + } + + /** + * Retrieves the time interval preference for the current user. + */ + public static function GetCalendarTimeInterval() { + return self::GetValue("calendar_time_interval", true /* user specific */); + } + + /* User specific preferences end */ } diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 28856510a..90cb2970e 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -443,7 +443,7 @@ class Application_Model_StoredFile { $serverName = $_SERVER['SERVER_NAME']; $serverPort = $_SERVER['SERVER_PORT']; - return constructGetFileUrl($serverName, $serverPort); + return $this->constructGetFileUrl($serverName, $serverPort); } /** @@ -456,7 +456,7 @@ class Application_Model_StoredFile { $serverName = $CC_CONFIG['baseUrl']; $serverPort = $CC_CONFIG['basePort']; - return constructGetFileUrl($serverName, $serverPort); + return $this->constructGetFileUrl($serverName, $serverPort); } private function constructGetFileUrl($p_serverName, $p_serverPort){ diff --git a/airtime_mvc/application/views/scripts/dashboard/stream-player.phtml b/airtime_mvc/application/views/scripts/dashboard/stream-player.phtml index 21e9d9a30..7b9d6a796 100644 --- a/airtime_mvc/application/views/scripts/dashboard/stream-player.phtml +++ b/airtime_mvc/application/views/scripts/dashboard/stream-player.phtml @@ -42,7 +42,7 @@ $(document).ready(function(){ ?> }); -