/** * Determines the addresses of sender and recipients, and returns whether * that succeeded. * * @return bool * * @global array The localization of the plugins. * @global string The (X)HTML fragment with error messages. */ protected function determineAddresses() { global $plugin_tx, $e; $from = ''; $from_name = ''; foreach ($this->form->getFields() as $field) { $field = Field::make($field); if ($field->getType() == 'from_name') { $from_name = stsl($_POST['advfrm-' . $field->getName()]); } elseif ($field->getType() == 'from') { $from = stsl($_POST['advfrm-' . $field->getName()]); } } if ($this->isConfirmation && empty($from)) { $e .= '<li>' . $plugin_tx['advancedform']['error_missing_sender'] . '</li>' . PHP_EOL; return false; } if ($this->isConfirmation) { $this->mail->set('From', $this->form->getReceiver()); $this->mail->set('FromName', $this->form->getReceiverName()); $this->mail->AddAddress($from, $from_name); } else { $this->mail->set('From', $from); $this->mail->set('FromName', $from_name); $this->mail->AddAddress($this->form->getReceiver(), $this->form->getReceiverName()); foreach (explode(';', $this->form->getCC()) as $cc) { if (trim($cc) != '') { $this->mail->AddCC($cc); } } foreach (explode(';', $this->form->getBCC()) as $bcc) { if (trim($bcc) != '') { $this->mail->AddBCC($bcc); } } } return true; }