Commit 33a173af authored by Patrick Schmalstig's avatar Patrick Schmalstig
Browse files

Implemented MANTIS-5524 (Add rules confirmation e-mail)

parent 67c1ff24
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -357,6 +357,12 @@ _DESCRIPTION_I_AGREE_RULES=Either our rules (Terms of Service) have changed sinc
DESCRIPTION_I_AGREE_RULES_USE=Before you may use our site you must agree to our rules (Terms of Service). Read through the rules (Terms of Service), tick (check) the necessary declarations, then at the bottom either agree & proceed, or disagree.
DESCRIPTION_I_AGREE_RULES_UPDATED=Our rules (Terms of Service) have changed since you last visited our site. Before you may continue to use our site you must agree to our updated rules (Terms of Service). Read through the rules (Terms of Service), tick (check) the necessary declarations, then at the bottom either agree & proceed, or disagree.
DESCRIPTION_I_AGREE_RULES_DECLINED=You cannot use our site if you do not agree to our updated rules (Terms of Service). You have been redirected to the page where you can delete your account if you choose. Otherwise, you will be prompted again to read and agree to the rules (Terms of Service) if you go to another page.
RULES_CONFIRMATION_MAIL_SUBJECT=Confirmation of rules (Terms of Service) agreed to
RULES_CONFIRMATION_MAIL_HEADER=To comply with data protection laws in some jurisdictions, we are providing you with a physical confirmation of the rules (Terms of Service) and declarations to which you agreed on the site '{1}'. You agreed to these on {2} (UTC). Please keep this e-mail for your records.
RULES_CONFIRMATION_MAIL_HEADER_RULES=You agreed to the following rules (Terms of Service):
RULES_CONFIRMATION_MAIL_HEADER_PRIVACY_POLICY=You agreed to the following Privacy Policy:
RULES_CONFIRMATION_MAIL_HEADER_DECLARATIONS=You made the following legally-binding declarations:
RULES_CONFIRMATION_MAIL_FOOTER=Your declarations have been logged with your member account. In the event the agreement terms change, you may be prompted on the site to read the updated agreement and make updated declarations before you may continue using the site.
MUST_BE_EMAIL_DOMAIN=Only e-mail addresses on the following domains are accepted:<br />{1}
_MUST_BE_EMAIL_DOMAIN=The given e-mail address is not on a domain name that we accept.
MM_APPLY_TWICE=Could not perform multi-moderation, as the multi-moderation is not available for the topic's current forum. It's likely the topic has been moved since you loaded it.
+48 −17
Original line number Diff line number Diff line
@@ -296,10 +296,25 @@ class Module_join
     */
    public function step3() : object
    {
        $declarations_made = $this->parse_declarations();

        list($message) = cns_join_actual($declarations_made);

        $this->dispatch_declarations_mail($declarations_made, get_param_string('email', '', INPUT_FILTER_GET_IDENTIFIER));

        return inform_screen($this->title, $message);
    }

    protected function parse_declarations() : string
    {
        require_lang('cns');

        // Bail if the member did not properly make declarations
        if ((get_option('show_first_join_page') == '1') && (!$this->declarations_made())) {
            warn_exit(do_lang_tempcode('DESCRIPTION_I_AGREE_RULES'));
        }

        // Parse params for declarations made
        $declarations_made = '';
        $declarations = $this->get_declarations();
        foreach ($declarations as $i => $declaration) {
@@ -311,9 +326,37 @@ class Module_join
            }
        }

        list($message) = cns_join_actual($declarations_made);
        return $declarations_made;
    }

        return inform_screen($this->title, $message);
    /**
     * Send a mail confirmation of declarations made to the member.
     *
     * @param  LONG_TEXT $declarations_made A list of declarations made, one per line
     * @param  SHORT_TEXT $email_address The e-mail address of the member
     */
    protected function dispatch_declarations_mail(string $declarations_made, string $email_address)
    {
        require_lang('cns');

        // Send mail confirmation of rules and declarations to the member which were agreed
        if ($email_address != '') {
            require_code('temporal');
            require_code('mail');

            $username = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
            $rules = request_page('_rules', true, get_comcode_zone('_rules'), null, true);
            $privacy_policy = request_page('privacy', false, get_comcode_zone('privacy'), null, true);
            $subject = do_lang('RULES_CONFIRMATION_MAIL_SUBJECT');
            $body = do_template('RULES_CONFIRMATION_MAIL', [
                'AGREEMENT_DATE_TIME' => get_timezoned_date_time(time(), false, true),
                'RULES' => $rules,
                'PRIVACY_POLICY' => $privacy_policy,
                'DECLARATIONS' => explode("\n", $declarations_made),
            ], null, false, null, '.txt', 'text');

            dispatch_mail($subject, $body->evaluate(), '', [$email_address], [$username]);
        }
    }

    /**
@@ -469,23 +512,11 @@ class Module_join
            access_denied('NOT_AS_GUEST');
        }

        if ((get_option('show_first_join_page') == '1') && (!$this->declarations_made())) {
            warn_exit(do_lang_tempcode('DESCRIPTION_I_AGREE_RULES'));
        }

        $declarations_made = '';
        $declarations = $this->get_declarations();
        foreach ($declarations as $i => $declaration) {
            if (post_param_string('confirm_' . strval($i), '') == $declaration) {
                if ($declarations_made != '') {
                    $declarations_made .= "\n";
                }
                $declarations_made .= $declaration;
            }
        }

        $declarations_made = $this->parse_declarations();
        $GLOBALS['FORUM_DRIVER']->set_custom_field(get_member(), 'agreed_declarations', $declarations_made);

        $this->dispatch_declarations_mail($declarations_made, $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member()));

        return inform_screen($this->title, do_lang_tempcode('SUCCESS'));
    }
}
+26 −0
Original line number Diff line number Diff line
{!RULES_CONFIRMATION_MAIL_HEADER,{$SITE_NAME*},{AGREEMENT_DATE_TIME*}}

---

{!RULES_CONFIRMATION_MAIL_HEADER_RULES}
[html]{RULES}[/html]

{+START,IF_NON_EMPTY,{PRIVACY_POLICY}}
---

{!RULES_CONFIRMATION_MAIL_HEADER_PRIVACY_POLICY}
[html]{PRIVACY_POLICY}[/html]

{+END}
---

{!RULES_CONFIRMATION_MAIL_HEADER_DECLARATIONS}
[list]
	{+START,LOOP,DECLARATIONS}
		[*]{_loop_var@}
	{+END}
[/list]

---

{!RULES_CONFIRMATION_MAIL_FOOTER}
 No newline at end of file