From 170d09545e4fcfeeb95f9fc5c355329764501854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 2 Feb 2024 19:04:12 +0100 Subject: [PATCH] feat(legacy): disable public radio page and redirect to login (#2903) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Description Many people don't need the public page and use libretime purely for playout management. This adds the ability to have libretime publicly available but only present the login page to the user. **I have updated the documentation to reflect these changes**: no, but i will add documentation if this PR is accepted. ### Testing Notes **What I did:** Toggle the new ceckbox on the general settings, log out and back in and check behaviour. note: this may have conflicts with the trim overbooked PR since the toggle sits in the same place. If both are accepted this needs to be formatted nicely :-) --------- Co-authored-by: Thomas Göttgens Co-authored-by: Jonas L. Co-authored-by: Kyle Robbertze Co-authored-by: jo --- docs/user-manual/settings.md | 19 +++++++++++++++---- .../controllers/IndexController.php | 6 ++++++ .../controllers/PreferenceController.php | 1 + .../application/forms/GeneralPreferences.php | 15 ++++++++++++++- legacy/application/models/Preference.php | 10 ++++++++++ .../scripts/form/preferences_general.phtml | 3 +++ 6 files changed, 49 insertions(+), 5 deletions(-) diff --git a/docs/user-manual/settings.md b/docs/user-manual/settings.md index 52d918049..7026cc7b2 100644 --- a/docs/user-manual/settings.md +++ b/docs/user-manual/settings.md @@ -21,6 +21,12 @@ time for the convenience of your station staff. You can also set the day of the week that you wish to start your station's weekly schedule on, which defaults to Sunday. +:::note + +The **Station Timezone** setting can not be modified on this page. It is set in the [configuration file](../admin-manual/configuration/#general). + +::: + The **Track Type Default** enables you to select a track type default for uploads. Initially, the **Default Fade In** and **Default Fade Out** times for automated @@ -60,15 +66,20 @@ wish. (There is more about this feature in the [_Exporting the schedule_](./playout-history.md) chapter, in the _Advanced Configuration_ section of this book). -The **Allowed CORS URLs** is intended to deal with situations where you want a -remote site with a different domain to access the API. This is relevant when -there is a reverse proxy server in front of LibreTime. If you are using a -reverse proxy, the URLs that will be used to access it should be added here. +:::note + +The **Allowed CORS URLs** you can still see in this screenshot was moved to the [configuration file](../admin-manual/configuration/#general). + +::: The **Display login button on your Radio Page?** will determine whether visitors to your site see a link to login. If this is disabled, DJs and admins will need to goto http://example.org/login to be able to login. +The **Disable the public radio page and redirect to the login page?** will +switch off the public radio page and redirect all visitors to the login page. +This is useful if you want to use LibreTime as a backend for a custom website. + The **Tune-In Settings** section is intended for stations that have partnered with TuneIn to automatically push their now playing metadata to TuneIn. This hasn't been tested and also requires special credentials from TuneIn. diff --git a/legacy/application/controllers/IndexController.php b/legacy/application/controllers/IndexController.php index 0347bd593..add9bf57e 100644 --- a/legacy/application/controllers/IndexController.php +++ b/legacy/application/controllers/IndexController.php @@ -8,6 +8,12 @@ class IndexController extends Zend_Controller_Action { $CC_CONFIG = Config::getConfig(); $baseUrl = Config::getBasePath(); + if (Application_Model_Preference::getRadioPageDisabled()) { + $this->_helper->redirector->gotoUrl($baseUrl . 'login'); + + return; + } + $this->view->headTitle(Application_Model_Preference::GetHeadTitle()); $this->view->headScript()->appendFile(Assets::url('js/libs/jquery-1.8.3.min.js'), 'text/javascript'); diff --git a/legacy/application/controllers/PreferenceController.php b/legacy/application/controllers/PreferenceController.php index 1351343e6..8dba80c22 100644 --- a/legacy/application/controllers/PreferenceController.php +++ b/legacy/application/controllers/PreferenceController.php @@ -50,6 +50,7 @@ class PreferenceController extends Zend_Controller_Action Application_Model_Preference::SetDefaultLocale($values['locale']); Application_Model_Preference::SetWeekStartDay($values['weekStartDay']); Application_Model_Preference::setRadioPageDisplayLoginButton($values['radioPageLoginButton']); + Application_Model_Preference::setRadioPageDisabled($values['radioPageDisabled']); Application_Model_Preference::SetFeaturePreviewMode($values['featurePreviewMode']); $logoUploadElement = $form->getSubForm('preferences_general')->getElement('stationLogo'); diff --git a/legacy/application/forms/GeneralPreferences.php b/legacy/application/forms/GeneralPreferences.php index e41eee368..bec987c56 100644 --- a/legacy/application/forms/GeneralPreferences.php +++ b/legacy/application/forms/GeneralPreferences.php @@ -202,11 +202,24 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm if ($displayRadioPageLoginButtonValue == '') { $displayRadioPageLoginButtonValue = true; } - $radioPageLoginButton->addDecorator('Label', ['class' => 'enable-tunein']); + $radioPageLoginButton->addDecorator('Label'); $radioPageLoginButton->setLabel(_('Display login button on your Radio Page?')); $radioPageLoginButton->setValue($displayRadioPageLoginButtonValue); $this->addElement($radioPageLoginButton); + // add a checkbox for completely disabling the radio page + $radioPageDisabled = new Zend_Form_Element_Checkbox('radioPageDisabled'); + $radioPageDisabled->setDecorators([ + 'ViewHelper', + 'Errors', + 'Label', + ]); + $radioPageDisabledValue = Application_Model_Preference::getRadioPageDisabled(); + $radioPageDisabled->addDecorator('Label'); + $radioPageDisabled->setLabel(_('Disable the public radio page and redirect to the login page?')); + $radioPageDisabled->setValue($radioPageDisabledValue); + $this->addElement($radioPageDisabled); + $feature_preview_mode = new Zend_Form_Element_Radio('featurePreviewMode'); $feature_preview_mode->setLabel(_('Feature Previews')); $feature_preview_mode->setMultiOptions([ diff --git a/legacy/application/models/Preference.php b/legacy/application/models/Preference.php index 4297e874c..0ea3034aa 100644 --- a/legacy/application/models/Preference.php +++ b/legacy/application/models/Preference.php @@ -1399,6 +1399,16 @@ class Application_Model_Preference self::setValue('radio_page_display_login_button', $value); } + public static function getRadioPageDisabled() + { + return boolval(self::getValue('radio_page_disabled', false)); + } + + public static function setRadioPageDisabled($value) + { + self::setValue('radio_page_disabled', $value); + } + public static function getLangTimezoneSetupComplete() { return self::getValue('lang_tz_setup_complete'); diff --git a/legacy/application/views/scripts/form/preferences_general.phtml b/legacy/application/views/scripts/form/preferences_general.phtml index 85b5bb2bc..31517aa2d 100644 --- a/legacy/application/views/scripts/form/preferences_general.phtml +++ b/legacy/application/views/scripts/form/preferences_general.phtml @@ -47,5 +47,8 @@ element->getElement('radioPageLoginButton')->renderViewHelper() ?> element->getElement('radioPageLoginButton')->renderLabel() ?> +
+ element->getElement('radioPageDisabled')->renderViewHelper() ?> + element->getElement('radioPageDisabled')->renderLabel() ?>