Skip to content

Commit

Permalink
get demo mode from environment and disable some settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Ribeiro committed Sep 23, 2024
1 parent b9c9b4c commit 8acf460
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 28 deletions.
2 changes: 2 additions & 0 deletions includes/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
exit();
}

$demoMode = getenv('DEMO_MODE');

$theme = "automatic";
if (isset($settings['theme'])) {
$theme = $settings['theme'];
Expand Down
9 changes: 9 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@
}
}
}

if ($demoMode) {
?>
<div class="demo-banner">
Running in <b>Demo Mode</b>, certain actions and settings are disabled.<br>
The database will be reset every 90 minutes.
</div>
<?php
}
?>

<header class="<?= $headerClass ?>" id="main-actions">
Expand Down
64 changes: 37 additions & 27 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,16 @@ class="avatar-option" data-src="images/uploads/logos/avatars/<?= $image ?>">
</div>
<div class="form-group">
<label for="email"><?= translate('email', $i18n) ?>:</label>
<input type="email" id="email" name="email" value="<?= $userData['email'] ?>" required>
<input type="email" id="email" name="email" value="<?= $userData['email'] ?>" required
<?= $demoMode ? 'disabled title="Not available on Demo Mode"' : '' ?>>
</div>
<div class="form-group">
<label for="password"><?= translate('password', $i18n) ?>:</label>
<input type="password" id="password" name="password">
<input type="password" id="password" name="password" <?= $demoMode ? 'disabled title="Not available on Demo Mode"' : '' ?>>
</div>
<div class="form-group">
<label for="confirm_password"><?= translate('confirm_password', $i18n) ?>:</label>
<input type="password" id="confirm_password" name="confirm_password">
<input type="password" id="confirm_password" name="confirm_password" <?= $demoMode ? 'disabled title="Not available on Demo Mode"' : '' ?>>
</div>
<?php
$currencies = array();
Expand Down Expand Up @@ -483,7 +484,7 @@ class="one-third" value="<?= $notificationsEmail['smtp_port'] ?>" />
placeholder="<?= translate('from_email', $i18n) ?>"
value="<?= $notificationsEmail['from_email'] ?>" />
</div>
<label for="otheremails" ><?= translate('send_to_other_emails', $i18n) ?></label>
<label for="otheremails"><?= translate('send_to_other_emails', $i18n) ?></label>
<div class="form-group-inline">
<input type="text" name="otheremails" id="otheremails"
placeholder="<?= translate('other_emails_placeholder', $i18n) ?>"
Expand Down Expand Up @@ -1193,19 +1194,25 @@ class="color-picker fa-solid fa-eye-dropper">
onClick="saveCustomColors()" class="buton thin mobile-grow" id="save-colors">
</div>
</div>
<div>
<h3><?= translate('custom_css', $i18n) ?></h3>
<div class="form-group">
<div class="form-group-inline">
<textarea name="customCss" id="customCss" placeholder="<?= translate('custom_css', $i18n) ?>"
class="thin"><?= $settings['customCss'] ?? "" ?></textarea>
</div>
<div class="form-group-inline">
<input type="button" value="<?= translate('save_custom_css', $i18n) ?>"
onClick="saveCustomCss()" class="buton thin mobile-grow" id="save-css">
<?php
if (!$demoMode) {
?>
<div>
<h3><?= translate('custom_css', $i18n) ?></h3>
<div class="form-group">
<div class="form-group-inline">
<textarea name="customCss" id="customCss" placeholder="<?= translate('custom_css', $i18n) ?>"
class="thin"><?= $settings['customCss'] ?? "" ?></textarea>
</div>
<div class="form-group-inline">
<input type="button" value="<?= translate('save_custom_css', $i18n) ?>"
onClick="saveCustomCss()" class="buton thin mobile-grow" id="save-css">
</div>
</div>
</div>
</div>
<?php
}
?>
</section>

<section class="account-section">
Expand All @@ -1227,25 +1234,28 @@ class="thin"><?= $settings['customCss'] ?? "" ?></textarea>
<?php
if ($settings['convert_currency'])
echo ' checked';
if ($apiKey == "")
if ($apiKey == "" || $demoMode)
echo ' disabled';
?>>
<label for="convertcurrency"><?= translate('convert_prices', $i18n) ?></label>
</div>
</div>
<div>
<div class="form-group-inline">
<input type="checkbox" id="showoriginalprice" name="showoriginalprice" onChange="setShowOriginalPrice()" <?php if ($settings['show_original_price'])
echo 'checked'; ?>>
<input type="checkbox" id="showoriginalprice" name="showoriginalprice"
onChange="setShowOriginalPrice()" <?php if ($settings['show_original_price'])
echo 'checked'; ?>>
<label for="showoriginalprice"><?= translate('show_original_price', $i18n) ?></label>
</div>
</div>
<h3><?= translate('disabled_subscriptions', $i18n) ?></h3>
<div>
<div class="form-group-inline">
<input type="checkbox" id="disabledtobottom" name="disabledtobottom" onChange="setDisabledToBottom()" <?php if ($settings['disabled_to_bottom'])
echo 'checked'; ?>>
<label for="disabledtobottom"><?= translate('show_disabled_subscriptions_at_the_bottom', $i18n) ?></label>
<input type="checkbox" id="disabledtobottom" name="disabledtobottom"
onChange="setDisabledToBottom()" <?php if ($settings['disabled_to_bottom'])
echo 'checked'; ?>>
<label
for="disabledtobottom"><?= translate('show_disabled_subscriptions_at_the_bottom', $i18n) ?></label>
</div>
</div>
<div>
Expand Down Expand Up @@ -1287,22 +1297,22 @@ class="thin"><?= $settings['customCss'] ?? "" ?></textarea>
<div class="account-list">
<div>
<h3><?= translate('export_subscriptions', $i18n) ?></h3>
<div class="form-group-inline">
<div class="form-group-inline wrap">
<input type="button" value="<?= translate('export_as_json', $i18n) ?>" onClick="exportAsJson()"
class="secondary-button thin mobile-grow" id="export-json">
class="secondary-button thin mobile-grow" id="export-json" <?= $demoMode ? 'disabled title="Not available on Demo Mode"' : '' ?>>
<input type="button" value="<?= translate('export_as_csv', $i18n) ?>" onClick="exportAsCsv()"
class="secondary-button thin mobile-grow" id="export-csv">
class="secondary-button thin mobile-grow" id="export-csv" <?= $demoMode ? 'disabled title="Not available on Demo Mode"' : '' ?>>
</div>
</div>
</div>
<div>
<?php
if ($userId != 1) {
if ($userId != 1 && !$demoMode) {
?>
<h3><?= translate('danger_zone', $i18n) ?></h3>
<div class="form-group-inline">
<input type="button" value="<?= translate('delete_account', $i18n) ?>" onClick="deleteAccount(<?= $userId ?>)"
class="warning-button thin mobile-grow" id="delete-account">
<input type="button" value="<?= translate('delete_account', $i18n) ?>"
onClick="deleteAccount(<?= $userId ?>)" class="warning-button thin mobile-grow" id="delete-account">
</div>
<div class="settings-notes">
<p>
Expand Down
13 changes: 12 additions & 1 deletion styles/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,9 @@ button.disabled {
cursor: not-allowed;
}

input[type="text"]:disabled {
input[type="text"]:disabled,
input[type="password"]:disabled,
input[type="email"]:disabled {
background-color: #f5f5f5;
border-color: #f5f5f5;
cursor: not-allowed;
Expand Down Expand Up @@ -2471,4 +2473,13 @@ input[type="radio"]:checked+label::after {

.update-banner > span {
font-weight: 500;
}

.demo-banner {
padding: 15px 20px;
background-color: rgba(var(--error-color-rgb), 0.5);
border: 1px solid #f45a40;
border-radius: 12px;
margin-bottom: 20px;
text-align: center;
}

0 comments on commit 8acf460

Please sign in to comment.