Skip to content

Commit

Permalink
feat(legacy): disable public radio page and redirect to login (#2903)
Browse files Browse the repository at this point in the history
### 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>
  • Loading branch information
5 people committed Feb 2, 2024
1 parent 1998314 commit 170d095
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 5 deletions.
19 changes: 15 additions & 4 deletions docs/user-manual/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions legacy/application/controllers/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ public function indexAction()
{
$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');

Expand Down
1 change: 1 addition & 0 deletions legacy/application/controllers/PreferenceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function indexAction()
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');
Expand Down
15 changes: 14 additions & 1 deletion legacy/application/forms/GeneralPreferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,24 @@ public function init()
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([
Expand Down
10 changes: 10 additions & 0 deletions legacy/application/models/Preference.php
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,16 @@ public static function setRadioPageDisplayLoginButton($value)
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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>

0 comments on commit 170d095

Please sign in to comment.