From 0c9a0011e7b5c08e7f7bad91fa4b3a6d3ed0ff0b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 18 Feb 2021 11:08:05 +0100 Subject: [PATCH] Fix use of localized recipient email addresses in contact form --- .../option/ContactOptionAction.class.php | 2 +- .../recipient/ContactRecipient.class.php | 33 ++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/lib/data/contact/option/ContactOptionAction.class.php b/wcfsetup/install/files/lib/data/contact/option/ContactOptionAction.class.php index 042990c091..21ecda03ba 100644 --- a/wcfsetup/install/files/lib/data/contact/option/ContactOptionAction.class.php +++ b/wcfsetup/install/files/lib/data/contact/option/ContactOptionAction.class.php @@ -111,7 +111,7 @@ class ContactOptionAction extends CustomOptionAction implements ISortableAction // build mail $email = new Email(); - $email->addRecipient(new Mailbox($recipient->email)); + $email->addRecipient($recipient->getMailbox()); $email->setSubject($defaultLanguage->get('wcf.contact.mail.subject')); $email->setBody(new MimePartFacade([ new RecipientAwareTextMimePart('text/html', 'email_contact', 'wcf', $messageData), diff --git a/wcfsetup/install/files/lib/data/contact/recipient/ContactRecipient.class.php b/wcfsetup/install/files/lib/data/contact/recipient/ContactRecipient.class.php index 457c26cf4f..00a1d06699 100644 --- a/wcfsetup/install/files/lib/data/contact/recipient/ContactRecipient.class.php +++ b/wcfsetup/install/files/lib/data/contact/recipient/ContactRecipient.class.php @@ -1,6 +1,7 @@ get($this->name); + return $this->getName(); } /** @@ -49,4 +50,34 @@ class ContactRecipient extends DatabaseObject { $this->data['isAdministrator'] = MAIL_ADMIN_ADDRESS; } } + + /** + * Returns the localized name of this recipient. + * + * @since 5.3 + */ + public function getName(): string { + return WCF::getLanguage()->get($this->name); + } + + /** + * Returns the localized email address of this recipient. + * + * @since 5.3 + */ + public function getEmail(): string { + return WCF::getLanguage()->get($this->email); + } + + /** + * Returns a localized Mailbox for this recipient. + * + * @since 5.3 + */ + public function getMailbox(): Mailbox { + return new Mailbox( + $this->getEmail(), + $this->getName() + ); + } } -- 2.20.1