Fix use of localized recipient email addresses in contact form
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 18 Feb 2021 10:08:05 +0000 (11:08 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 18 Feb 2021 10:08:05 +0000 (11:08 +0100)
wcfsetup/install/files/lib/data/contact/option/ContactOptionAction.class.php
wcfsetup/install/files/lib/data/contact/recipient/ContactRecipient.class.php

index 042990c0910a306d1280a2c4d32569f5f4e4b200..21ecda03bab4908cef9fefd78a1cbf481f522f43 100644 (file)
@@ -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),
index 457c26cf4f36fd49ccd3e90a23cee8a4159a591e..00a1d066994b524daacd8982e116df0146ecc784 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\data\contact\recipient;
 use wcf\data\DatabaseObject;
+use wcf\system\email\Mailbox;
 use wcf\system\WCF;
 
 /**
@@ -37,7 +38,7 @@ class ContactRecipient extends DatabaseObject {
         * @inheritDoc
         */
        public function __toString() {
-               return WCF::getLanguage()->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()
+               );
+       }
 }