ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilFormatMail.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
13 include_once "Services/Mail/classes/class.ilMail.php";
14 
15 class ilFormatMail extends ilMail
16 {
17 
24  public function __construct($a_user_id)
25  {
26  parent::__construct($a_user_id);
27  }
28 
34  public function formatReplyMessage()
35  {
36  if (empty($this->mail_data)) {
37  return false;
38  }
39 
40  $bodylines = preg_split("/\r\n|\n|\r/", $this->mail_data["m_message"]);
41  for ($i = 0; $i < count($bodylines); $i++) {
42  $bodylines[$i] = "> " . $bodylines[$i];
43  }
44 
45  return $this->mail_data["m_message"] = implode(chr(10), $bodylines);
46  }
47 
53  public function formatReplySubject()
54  {
55  if (empty($this->mail_data)) {
56  return false;
57  }
58  return $this->mail_data["m_subject"] = "RE: " . $this->mail_data["m_subject"];
59  }
60 
66  public function formatReplyRecipientsForCC()
67  {
68  global $DIC;
69 
70  if (empty($this->mail_data)) {
71  return '';
72  }
73 
74  $newCC = array();
75 
76  $currentUserLogin = $DIC->user()->getLogin();
77 
78  foreach (explode(',', $this->mail_data['rcp_to']) as $to) {
79  if (trim($to) != '' && $currentUserLogin != trim($to)) {
80  $newCC[] = trim($to);
81  }
82  }
83 
84  foreach (explode(',', $this->mail_data['rcp_cc']) as $cc) {
85  if (trim($cc) != '' && $currentUserLogin != trim($cc)) {
86  $newCC[] = trim($cc);
87  }
88  }
89 
90  return ($this->mail_data['rcp_cc'] = implode(', ', $newCC));
91  }
92 
98  public function formatReplyRecipient()
99  {
100  if (empty($this->mail_data)) {
101  return false;
102  }
103 
104  require_once './Services/User/classes/class.ilObjUser.php';
105 
106  $user = new ilObjUser($this->mail_data["sender_id"]);
107  return $this->mail_data["rcp_to"] = $user->getLogin();
108  }
114  public function formatForwardSubject()
115  {
116  if (empty($this->mail_data)) {
117  return false;
118  }
119  return $this->mail_data["m_subject"] = "[FWD: " . $this->mail_data["m_subject"] . "]";
120  }
121 
129  public function appendSearchResult($a_names, $a_type)
130  {
131  if (empty($this->mail_data)) {
132  return false;
133  }
134  $name_str = implode(',', $a_names);
135  switch ($a_type) {
136  case 'to':
137  $this->mail_data["rcp_to"] = trim($this->mail_data["rcp_to"]);
138  if ($this->mail_data["rcp_to"]) {
139  $this->mail_data["rcp_to"] = $this->mail_data["rcp_to"] . ",";
140  }
141  $this->mail_data["rcp_to"] = $this->mail_data["rcp_to"] . $name_str;
142  break;
143 
144  case 'cc':
145  $this->mail_data["rcp_cc"] = trim($this->mail_data["rcp_cc"]);
146  if ($this->mail_data["rcp_cc"]) {
147  $this->mail_data["rcp_cc"] = $this->mail_data["rcp_cc"] . ",";
148  }
149  $this->mail_data["rcp_cc"] = $this->mail_data["rcp_cc"] . $name_str;
150  break;
151 
152  case 'bc':
153  $this->mail_data["rcp_bcc"] = trim($this->mail_data["rcp_bcc"]);
154  if ($this->mail_data["rcp_bcc"]) {
155  $this->mail_data["rcp_bcc"] = $this->mail_data["rcp_bcc"] . ",";
156  }
157  $this->mail_data["rcp_bcc"] = $this->mail_data["rcp_bcc"] . $name_str;
158  break;
159 
160  }
161  return $this->mail_data;
162  }
169  public function formatLinebreakMessage($a_message)
170  {
171  $formatted = array();
172 
173  $linebreak = $this->mail_options->getLinebreak();
174 
175  $lines = explode(chr(10), $a_message);
176  for ($i=0;$i<count($lines);$i++) {
177  if (substr($lines[$i], 0, 1) != '>') {
178  $formatted[] = wordwrap($lines[$i], $linebreak, chr(10));
179  } else {
180  $formatted[] = $lines[$i];
181  }
182  }
183  $formatted = implode(chr(10), $formatted);
184 
185  return $formatted;
186  }
187 
188 
189 
195  public function appendSignature()
196  {
197  return $this->mail_data["m_message"] .= chr(13) . chr(10) . $this->mail_options->getSignature();
198  }
199 
203  public function prependSignature()
204  {
205  return $this->mail_options->getSignature() . chr(13) . chr(10) . chr(13) . chr(10) . $this->mail_data["m_message"];
206  }
207 } // END class.ilFormatMail
formatReplyRecipientsForCC()
get reply recipients for cc public
global $DIC
Definition: saml.php:7
formatReplyMessage()
format a reply message public
appendSearchResult($a_names, $a_type)
append search result to recipient public
$a_type
Definition: workflow.php:92
formatReplyRecipient()
get reply recipient public
Class UserMail this class handles user mails.
__construct($a_user_id)
Constructor setup an mail object.
formatLinebreakMessage($a_message)
format message according to linebreak option
This class handles base functions for mail handling.
Create styles array
The data for the language used.
appendSignature()
append signature to mail body public
$i
Definition: disco.tpl.php:19
formatReplySubject()
format a reply subject public
formatForwardSubject()
format a forward subject public