Skip to content

Commit

Permalink
fix contact form terms check
Browse files Browse the repository at this point in the history
  • Loading branch information
bobimicroweber committed Jun 3, 2022
1 parent 047d091 commit 02bc85e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
16 changes: 11 additions & 5 deletions userfiles/modules/contact_form/index.php
Expand Up @@ -166,17 +166,22 @@
$template_file_def = module_templates( $config['module'], 'default');


$require_terms = get_option('require_terms', $params['module'] . '_default');
$require_terms_when = '';
$require_terms_default = get_option('require_terms', $params['module'] . '_default');
$require_terms = get_option('require_terms', $params['id']);

if($require_terms) {
$require_terms_when = 'b';

if($require_terms == 'y') {
if(is_logged()){
if(mw()->user_manager->terms_check('terms_contact', user_id())) {
$require_terms = 'n';
}
}
if($require_terms) {
$require_terms_when = get_option('require_terms_when', $params['module'] . '_default');
if($require_terms == 'y') {

//$require_terms_when_default = get_option('require_terms_when', $params['module'] . '_default');
//$require_terms_when = get_option('require_terms_when', $params['id']);

if($require_terms_when == 'b') {
$terms_label = get_option('terms_label', 'users');
$terms_url = get_option('terms_url', 'users');
Expand All @@ -187,6 +192,7 @@
$terms_label_cleared = str_replace(' ', '', $terms_label);
$terms_label_cleared = strip_tags($terms_label_cleared);
$terms_label_cleared = mb_trim($terms_label_cleared);

if ($terms_label_cleared == '') {
$terms_label = 'I agree with the <a href="' . $terms_url . '" target="_blank">Terms and Conditions</a>';
}
Expand Down
9 changes: 5 additions & 4 deletions userfiles/modules/contact_form/privacy_settings.php
Expand Up @@ -49,12 +49,13 @@
<div class="<?php if (!$simple): ?>card-body pt-3<?php endif; ?>">
<div class="row">
<div class="col-12">

<div class="form-group mb-3">
<label class="control-label"><?php _e("Users must agree to the terms and conditions") ?></label>
<small class="text-muted d-block mb-2"><?php _e("If the user does not agree to the terms, he will not be able to use the contact form") ?></small>
</div>

<module type="users/terms/set_for_module" for_module="contact_form"/>
<module type="users/terms/set_for_module" for_module="<?php echo $params['parent-module-id']; ?>"/>

<div class="form-group mb-3">
<label class="control-label"><?php _e("Saving data and emails") ?></label>
Expand All @@ -63,8 +64,8 @@

<div class="form-group mb-4">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="mw_option_field custom-control-input" id="skip_saving_emails_<?php $params['id']; ?>" parent-reload="true" name="skip_saving_emails" value="y" data-value-unchecked="n" data-value-checked="y" option-group="<?php print $mod_id ?>" <?php if (get_option('skip_saving_emails', $mod_id) == 'y'): ?>checked<?php endif; ?> />
<label class="custom-control-label" for="skip_saving_emails_<?php $params['id']; ?>"><?php _e("Skip saving emails in my website database."); ?></label>
<input type="checkbox" class="mw_option_field custom-control-input" id="skip_saving_emails_<?php echo $params['id']; ?>" parent-reload="true" name="skip_saving_emails" value="y" data-value-unchecked="n" data-value-checked="y" option-group="<?php print $mod_id ?>" <?php if (get_option('skip_saving_emails', $mod_id) == 'y'): ?>checked<?php endif; ?> />
<label class="custom-control-label" for="skip_saving_emails_<?php echo $params['id']; ?>"><?php _e("Skip saving emails in my website database."); ?></label>
</div>
</div>

Expand All @@ -74,7 +75,7 @@
</div>

<div class="collapse" id="contact-form-settings">
<module type="users/terms/edit" terms-group="contact_form"/>
<module type="users/terms/edit" terms-group="contact_form" />
</div>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion userfiles/modules/users/terms/admin.php
Expand Up @@ -22,6 +22,7 @@
$(document).ready(function () {
mw.options.form('.<?php print $config['module_class'] ?>', function () {
mw.notification.success("<?php _ejs("Saved"); ?>.");
mw.reload_module_everywhere('users/terms');
});
});
</script>
Expand All @@ -41,4 +42,4 @@
<label class="control-label"><?php _e("URL of terms and conditions"); ?></label>
<small class="text-muted d-block mb-2"><?php _e("Уou need to create this page and type in the address field"); ?>.</small>
<input type="text" class="mw_option_field form-control" name="terms_url" option-group="<?php print $mod_id ?>" value="<?php print $terms_url; ?>" placeholder="<?php print site_url('terms') ?>"/>
</div>
</div>

0 comments on commit 02bc85e

Please sign in to comment.