Skip to content
Snippets Groups Projects
Commit 3f48bcc6 authored by David Siegfried's avatar David Siegfried Committed by Jan-Hendrik Willms
Browse files

prevent warning in StudipMail and fix return types, fixes #4607

Closes #4607

Merge request studip/studip!3416
parent cf22cb99
No related branches found
No related tags found
No related merge requests found
...@@ -81,6 +81,7 @@ class StudipMail ...@@ -81,6 +81,7 @@ class StudipMail
*/ */
public static function getAbuseEmail() public static function getAbuseEmail()
{ {
$mail_localhost = $GLOBALS['MAIL_LOCALHOST'] ?: $_SERVER['SERVER_NAME'];
return $GLOBALS['MAIL_ABUSE'] ?: "abuse@{$mail_localhost}"; return $GLOBALS['MAIL_ABUSE'] ?: "abuse@{$mail_localhost}";
} }
...@@ -166,7 +167,7 @@ class StudipMail ...@@ -166,7 +167,7 @@ class StudipMail
} }
/** /**
* @return unknown_type * @return string
*/ */
public function getSenderName() public function getSenderName()
{ {
...@@ -184,7 +185,7 @@ class StudipMail ...@@ -184,7 +185,7 @@ class StudipMail
} }
/** /**
* @return unknown_type * @return string
*/ */
public function getReplyToEmail() public function getReplyToEmail()
{ {
...@@ -202,7 +203,7 @@ class StudipMail ...@@ -202,7 +203,7 @@ class StudipMail
} }
/** /**
* @return unknown_type * @return string
*/ */
public function getReplyToName() public function getReplyToName()
{ {
...@@ -220,7 +221,7 @@ class StudipMail ...@@ -220,7 +221,7 @@ class StudipMail
} }
/** /**
* @return unknown_type * @return string
*/ */
public function getSubject() public function getSubject()
{ {
...@@ -263,7 +264,7 @@ class StudipMail ...@@ -263,7 +264,7 @@ class StudipMail
/** /**
* @param $mail * @param $mail
* @return unknown_type * @return bool
*/ */
public function isRecipient($mail) public function isRecipient($mail)
{ {
...@@ -343,7 +344,7 @@ class StudipMail ...@@ -343,7 +344,7 @@ class StudipMail
/** /**
* @param $name * @param $name
* @return unknown_type * @return bool
*/ */
public function isAttachment($name) public function isAttachment($name)
{ {
...@@ -361,7 +362,7 @@ class StudipMail ...@@ -361,7 +362,7 @@ class StudipMail
} }
/** /**
* @return unknown_type * @return string
*/ */
public function getBodyText() public function getBodyText()
{ {
...@@ -379,7 +380,7 @@ class StudipMail ...@@ -379,7 +380,7 @@ class StudipMail
} }
/** /**
* @return unknown_type * @return string
*/ */
public function getBodyHtml() public function getBodyHtml()
{ {
...@@ -403,7 +404,7 @@ class StudipMail ...@@ -403,7 +404,7 @@ class StudipMail
* send the mail using the given transporter object, or the * send the mail using the given transporter object, or the
* set default transporter * set default transporter
* *
* @param email_message_class $transporter * @param email_message_class|null $transporter
* @return bool * @return bool
*/ */
public function send(email_message_class $transporter = null) public function send(email_message_class $transporter = null)
...@@ -420,10 +421,16 @@ class StudipMail ...@@ -420,10 +421,16 @@ class StudipMail
if($this->getReplyToEmail()){ if($this->getReplyToEmail()){
$transporter->SetEncodedEmailHeader('Reply-To', $this->getReplyToEmail(), self::quoteString($this->getReplyToName())); $transporter->SetEncodedEmailHeader('Reply-To', $this->getReplyToEmail(), self::quoteString($this->getReplyToName()));
} }
$recipients_by_type = [];
foreach($this->getRecipients() as $recipient) { foreach($this->getRecipients() as $recipient) {
if (!isset($recipients_by_type[$recipient['type']])) {
$recipients_by_type[$recipient['type']] = [];
}
$recipients_by_type[$recipient['type']][$recipient['mail']] = self::quoteString($recipient['name']); $recipients_by_type[$recipient['type']][$recipient['mail']] = self::quoteString($recipient['name']);
} }
foreach($recipients_by_type as $type => $recipients){
foreach ($recipients_by_type as $type => $recipients){
$transporter->SetMultipleEncodedEmailHeader($type, $recipients); $transporter->SetMultipleEncodedEmailHeader($type, $recipients);
} }
$transporter->SetEncodedHeader('Subject', $this->getSubject()); $transporter->SetEncodedHeader('Subject', $this->getSubject());
...@@ -456,8 +463,8 @@ class StudipMail ...@@ -456,8 +463,8 @@ class StudipMail
} }
foreach($this->getAttachments() as $attachment){ foreach($this->getAttachments() as $attachment){
$part = [ $part = [
'FileName' => $attachment['file_name'], 'FileName' => $attachment['file_name'] ?? null,
'Data' => $attachment['data'], 'Data' => $attachment['data'] ?? null,
'Name' => $attachment['name'], 'Name' => $attachment['name'],
'Content-Type' => $attachment['type'], 'Content-Type' => $attachment['type'],
'Disposition' => $attachment['disposition'], 'Disposition' => $attachment['disposition'],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment