Skip to content

Commit

Permalink
Added and option to show a link to the public files repository under …
Browse files Browse the repository at this point in the history
…the log in form
  • Loading branch information
ignacionelson committed Oct 26, 2022
1 parent be430e1 commit 7604b87
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 37 deletions.
4 changes: 1 addition & 3 deletions includes/forms/2fa_verify.php
Expand Up @@ -50,6 +50,4 @@
</div>
</form>

<div class="login_form_links">
<p><a href="<?php echo BASE_URI; ?>"><?php _e('Go back','cftp_admin'); ?></a></p>
</div>
<?php login_form_links(['homepage']); ?>
16 changes: 1 addition & 15 deletions includes/forms/login.php
Expand Up @@ -55,18 +55,4 @@
</fieldset>
</form>

<div class="login_form_links">
<p id="reset_pass_link"><?php _e("Forgot your password?",'cftp_admin'); ?> <a href="<?php echo BASE_URI; ?>reset-password.php"><?php _e('Set up a new one.','cftp_admin'); ?></a></p>
<?php
if (get_option('clients_can_register') == '1') {
?>
<p id="register_link"><?php _e("Don't have an account yet?",'cftp_admin'); ?> <a href="<?php echo BASE_URI; ?>register.php"><?php _e('Register as a new client.','cftp_admin'); ?></a></p>
<?php
} else {
?>
<p><?php _e("This server does not allow self registrations.",'cftp_admin'); ?></p>
<p><?php _e("If you need an account, please contact a server administrator.",'cftp_admin'); ?></p>
<?php
}
?>
</div>
<?php login_form_links(['register', 'password_recovery', 'public_page']); ?>
8 changes: 8 additions & 0 deletions includes/forms/options/privacy.php
Expand Up @@ -95,4 +95,12 @@
</div>
</div>

<div class="form-group row">
<div class="col-sm-8 offset-sm-4">
<label for="public_listing_home_show_link">
<input type="checkbox" value="1" name="public_listing_home_show_link" id="public_listing_home_show_link" class="checkbox_options" <?php echo (get_option('public_listing_home_show_link') == 1) ? 'checked="checked"' : ''; ?> /> <?php _e('Show a link to the public page under the log in form','cftp_admin'); ?>
</label>
</div>
</div>

<div class="options_divide"></div>
40 changes: 39 additions & 1 deletion includes/functions.forms.php
Expand Up @@ -187,4 +187,42 @@ function format_form_value( $value )
else {
return;
}
}
}

// Render links under forms
function login_form_links($links)
{
if (empty($links)) {
return;
}

echo '<div class="login_form_links">';
foreach ($links as $link) {
switch ($link) {
case 'homepage':
echo '<p><a href="'.BASE_URI.'">'.__('Go back to the homepage','cftp_admin').'</a></p>';
break;

case 'password_recovery':
echo '<p>'.__("Forgot your password?",'cftp_admin').' <a href="'.BASE_URI.'reset-password.php">'.__('Set up a new one.','cftp_admin').'</a></p>';
break;

case 'register':
if (get_option('clients_can_register') == '1') {
echo '<p>'.__("Don't have an account yet?",'cftp_admin').' <a href="'.BASE_URI.'register.php">'.__('Register as a new client.','cftp_admin').'</a></p>';
} else {
echo '<p>'.__("This server does not allow self registrations.",'cftp_admin').'</p>
<p>'.__("If you need an account, please contact a server administrator.",'cftp_admin').'</p>
';
}
break;

case 'public_page':
if (get_option('public_listing_home_show_link') == '1') {
echo '<p><a href="'.BASE_URI.'public.php">'.__('Browse our public files repository','cftp_admin').'</a></p>';
}
break;
}
}
echo '</div>';
}
5 changes: 5 additions & 0 deletions includes/upgrades/2022102601.php
@@ -0,0 +1,5 @@
<?php
function upgrade_2022102601()
{
add_option_if_not_exists('public_listing_home_show_link', '0');
}
1 change: 1 addition & 0 deletions options.php
Expand Up @@ -41,6 +41,7 @@
'public_listing_show_all_files',
'public_listing_use_download_link',
'public_listing_enable_preview',
'public_listing_home_show_link',
);
break;
case 'email':
Expand Down
4 changes: 1 addition & 3 deletions register.php
Expand Up @@ -101,9 +101,7 @@
}
?>

<div class="login_form_links">
<p><a href="<?php echo BASE_URI; ?>" target="_self"><?php _e('Go back to the homepage.', 'cftp_admin'); ?></a></p>
</div>
<?php login_form_links(['homepage']); ?>
</div>
</div>
</div>
Expand Down
4 changes: 1 addition & 3 deletions reset-password.php
Expand Up @@ -83,9 +83,7 @@
}
?>

<div class="login_form_links">
<p><a href="<?php echo BASE_URI; ?>" target="_self"><?php _e('Go back to the homepage.', 'cftp_admin'); ?></a></p>
</div>
<?php login_form_links(['homepage']); ?>
</div>
</div>
</div>
Expand Down
4 changes: 1 addition & 3 deletions templates/default/public-download.php
Expand Up @@ -69,9 +69,7 @@
</div>
</div>

<div class="login_form_links">
<p><a href="<?php echo BASE_URI; ?>" target="_self"><?php _e('Go back to the homepage.', 'cftp_admin'); ?></a></p>
</div>
<?php login_form_links(['homepage']); ?>
</div>
</div>

Expand Down
16 changes: 7 additions & 9 deletions templates/default/public-list.php
Expand Up @@ -259,16 +259,14 @@

<div class="row">
<div class="col-12">
<div class="login_form_links">
<?php
if (!user_is_logged_in() && get_option('clients_can_register') == '1') {
?>
<p id="register_link"><?php _e("Don't have an account yet?", 'cftp_admin'); ?> <a href="<?php echo BASE_URI; ?>register.php"><?php _e('Register as a new client.', 'cftp_admin'); ?></a></p>
<?php
<?php
$links = [];
if (!user_is_logged_in()) {
$links[] = 'register';
}
?>
<p><a href="<?php echo BASE_URI; ?>" target="_self"><?php _e('Go back to the homepage.', 'cftp_admin'); ?></a></p>
</div>
$links[] = 'homepage';
login_form_links($links);
?>
</div>
</div>

Expand Down

0 comments on commit 7604b87

Please sign in to comment.