From: Mischa POSLAWSKY Date: Mon, 25 Jan 2021 22:55:24 +0000 (+0100) Subject: widget/contact: subject and recipient address from call options X-Git-Tag: v5.2~9 X-Git-Url: http://git.shiar.nl/minimedit.git/commitdiff_plain/e6a16fe920961e805c1b6a901692229e33006e3e widget/contact: subject and recipient address from call options Custom variables instead of hardcoding each case. --- diff --git a/widget/contact.php b/widget/contact.php index c6e7022..6ccb79a 100644 --- a/widget/contact.php +++ b/widget/contact.php @@ -9,17 +9,18 @@ if ($_POST) { else { unset($_REQUEST['login']); } - $error = mailform($_REQUEST); + $error = mailform($_REQUEST, $Page->place); if (!empty($error)) { print "

$error

\n\n"; } } -function mailform($input = []) +function mailform($input = [], $config = []) { - $source = empty($input['subject']) ? 'reactie' : $input['subject']; + $source = $config['subject'] ?? + (empty($input['subject']) ? 'reactie' : $input['subject']); $domain = preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']); - $rcpt = "info@$domain"; + $rcpt = $config['rcpt'] ?? "info@$domain"; $subject = "Formulier {$_SERVER['HTTP_HOST']}: $source"; if (!$input) { @@ -39,7 +40,6 @@ switch ($source) { if (empty($input['naam']) or empty($input['huis'])) { return 'De bedoeling is juist dat je opgeeft wie er komt.'; } - $rcpt .= ', Heleen '; break; default: if (empty($input['email']) or !preg_match('/.+@.+\..+/', $input['email'])) {