feat(legacy): disable public radio page and redirect to login (#2903)

### 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 <tgoettgens@mail.com>
Co-authored-by: Jonas L. <jooola@users.noreply.github.com>
Co-authored-by: Kyle Robbertze <paddatrapper@users.noreply.github.com>
Co-authored-by: jo <ljonas@riseup.net>
This commit is contained in:
Thomas Göttgens 2024-02-02 19:04:12 +01:00 committed by GitHub
parent 199831458f
commit 170d09545e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 49 additions and 5 deletions

View File

@ -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.

View File

@ -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');

View File

@ -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');

View File

@ -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([

View File

@ -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');

View File

@ -47,5 +47,8 @@
<?php echo $this->element->getElement('radioPageLoginButton')->renderViewHelper() ?>
<?php echo $this->element->getElement('radioPageLoginButton')->renderLabel() ?>
<br />
<?php echo $this->element->getElement('radioPageDisabled')->renderViewHelper() ?>
<?php echo $this->element->getElement('radioPageDisabled')->renderLabel() ?>
</dl>
</fieldset>