ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilFormatMail.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25class ilFormatMail extends ilMail
26{
27 public function formatReplyRecipientsForCC(): string
28 {
29 global $DIC;
30
31 if (empty($this->mail_data)) {
32 return '';
33 }
34
35 $new_cc = [];
36
37 $current_usr_login = $DIC->user()->getLogin();
38
39 foreach (explode(',', (string) $this->mail_data['rcp_to']) as $to) {
40 $to = trim($to);
41 if ($to !== '' && $current_usr_login !== $to) {
42 $new_cc[] = $to;
43 }
44 }
45
46 foreach (explode(',', (string) $this->mail_data['rcp_cc']) as $cc) {
47 $cc = trim($cc);
48 if ($cc !== '' && $current_usr_login !== $cc) {
49 $new_cc[] = $cc;
50 }
51 }
52
53 return $this->mail_data['rcp_cc'] = implode(', ', $new_cc);
54 }
55
56 public function formatReplyRecipient(): string
57 {
58 if (empty($this->mail_data)) {
59 return '';
60 }
61
62 $user = new ilObjUser((int) $this->mail_data['sender_id']);
63 return $this->mail_data['rcp_to'] = $user->getLogin();
64 }
65
69 public function appendSearchResult(array $a_names, string $a_type): array
70 {
71 $name_str = implode(',', $a_names);
72
73 $key = 'rcp_to';
74 if ($a_type === 'cc') {
75 $key = 'rcp_cc';
76 } elseif ($a_type === 'bc') {
77 $key = 'rcp_bcc';
78 }
79
80 if (!isset($this->mail_data[$key]) || !is_string($this->mail_data[$key])) {
81 $this->mail_data[$key] = '';
82 } else {
83 $this->mail_data[$key] = trim($this->mail_data[$key]);
84 }
85
86 if ($this->mail_data[$key] !== '') {
87 $this->mail_data[$key] .= ',';
88 }
89 $this->mail_data[$key] .= $name_str;
90
91 return $this->mail_data;
92 }
93
94 public function appendSignature(string $message): string
95 {
96 return $message . (chr(13) . chr(10) . $this->mail_options->getSignature());
97 }
98
99 public function prependSignature(string $message): string
100 {
101 return $this->mail_options->getSignature() .
102 chr(13) .
103 chr(10) .
104 chr(13) .
105 chr(10) .
106 $message;
107 }
108
109 public function formatReplyMessage(string $message): string
110 {
111 $bodylines = preg_split("/\r\n|\n|\r/", $message);
112 foreach ($bodylines as $i => $value) {
113 $bodylines[$i] = '> ' . $value;
114 }
115
116 return implode(chr(10), $bodylines);
117 }
118
119 public function formatReplySubject(string $subject): string
120 {
121 return 'RE: ' . $subject;
122 }
123
124 public function formatForwardSubject(string $subject): string
125 {
126 return '[FWD: ' . $subject . ']';
127 }
128}
formatReplyMessage(string $message)
prependSignature(string $message)
formatReplySubject(string $subject)
formatForwardSubject(string $subject)
appendSearchResult(array $a_names, string $a_type)
appendSignature(string $message)
array $mail_data
User class.
global $DIC
Definition: shib_login.php:26
$message
Definition: xapiexit.php:31