ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
13include_once "Services/Mail/classes/class.ilMail.php";
14
15class ilFormatMail extends ilMail
16{
17
24 public function __construct($a_user_id)
25 {
26 parent::__construct($a_user_id);
27 }
28
35 {
36 if(empty($this->mail_data))
37 {
38 return false;
39 }
40# debug($this->mail_data["m_message"]);
41 $bodylines = explode(chr(13).chr(10), $this->mail_data["m_message"]);
42# var_dump("<pre>",$bodylines,"</pre");
43 for ($i = 0; $i < count($bodylines); $i++)
44 {
45 $bodylines[$i] = "> ".$bodylines[$i];
46 }
47 return $this->mail_data["m_message"] = implode(chr(13).chr(10), $bodylines);
48 }
49
56 {
57 if(empty($this->mail_data))
58 {
59 return false;
60 }
61 return $this->mail_data["m_subject"] = "RE: ".$this->mail_data["m_subject"];
62 }
63
70 {
71 global $ilUser;
72
73 if(empty($this->mail_data))
74 {
75 return '';
76 }
77
78 $newCC = array();
79
80 foreach (explode(',', $this->mail_data['rcp_to']) as $to)
81 {
82 if (trim($to) != '' && $ilUser->getLogin() != trim($to))
83 {
84 $newCC[] = trim($to);
85 }
86 }
87
88 foreach (explode(',', $this->mail_data['rcp_cc']) as $cc)
89 {
90 if (trim($cc) != '' && $ilUser->getLogin() != trim($cc))
91 {
92 $newCC[] = trim($cc);
93 }
94 }
95
96 return ($this->mail_data['rcp_cc'] = implode(', ', $newCC));
97 }
98
105 {
106 if(empty($this->mail_data))
107 {
108 return false;
109 }
110
111 require_once './Services/User/classes/class.ilObjUser.php';
112
113 $user = new ilObjUser($this->mail_data["sender_id"]);
114 return $this->mail_data["rcp_to"] = $user->getLogin();
115 }
122 {
123 if(empty($this->mail_data))
124 {
125 return false;
126 }
127 return $this->mail_data["m_subject"] = "[FWD: ".$this->mail_data["m_subject"]."]";
128 }
129
137 function appendSearchResult($a_names,$a_type)
138 {
139 if(empty($this->mail_data))
140 {
141 return false;
142 }
143 $name_str = implode(',',$a_names);
144 switch($a_type)
145 {
146 case 'to':
147 $this->mail_data["rcp_to"] = trim($this->mail_data["rcp_to"]);
148 if($this->mail_data["rcp_to"])
149 {
150 $this->mail_data["rcp_to"] = $this->mail_data["rcp_to"].",";
151 }
152 $this->mail_data["rcp_to"] = $this->mail_data["rcp_to"] . $name_str;
153 break;
154
155 case 'cc':
156 $this->mail_data["rcp_cc"] = trim($this->mail_data["rcp_cc"]);
157 if($this->mail_data["rcp_cc"])
158 {
159 $this->mail_data["rcp_cc"] = $this->mail_data["rcp_cc"].",";
160 }
161 $this->mail_data["rcp_cc"] = $this->mail_data["rcp_cc"] . $name_str;
162 break;
163
164 case 'bc':
165 $this->mail_data["rcp_bcc"] = trim($this->mail_data["rcp_bcc"]);
166 if($this->mail_data["rcp_bcc"])
167 {
168 $this->mail_data["rcp_bcc"] = $this->mail_data["rcp_bcc"].",";
169 }
170 $this->mail_data["rcp_bcc"] = $this->mail_data["rcp_bcc"] . $name_str;
171 break;
172
173 }
174 return $this->mail_data;
175 }
182 function formatLinebreakMessage($a_message)
183 {
184 $formatted = array();
185
186# debug($a_message);
187 $linebreak = $this->mail_options->getLinebreak();
188 // SPLIT INTO LINES returns always an array
189 $lines = explode(chr(10),$a_message);
190 for($i=0;$i<count($lines);$i++)
191 {
192 if(substr($lines[$i],0,1) != '>')
193 {
194 $formatted[] = wordwrap($lines[$i],$linebreak,chr(10));
195 }
196 else
197 {
198 $formatted[] = $lines[$i];
199 }
200 }
201 $formatted = implode(chr(10),$formatted);
202# debug($formatted);
203 return $formatted;
204 }
205
206
207
214 {
215 return $this->mail_data["m_message"] .= chr(13).chr(10).$this->mail_options->getSignature();
216 }
217
221 public function prependSignature()
222 {
223 return $this->mail_options->getSignature().chr(13).chr(10).chr(13).chr(10).$this->mail_data["m_message"];
224 }
225} // END class.ilFormatMail
226?>
Class UserMail this class handles user mails.
appendSignature()
append signature to mail body @access public
formatReplyRecipientsForCC()
get reply recipients for cc @access public
formatReplyRecipient()
get reply recipient @access public
appendSearchResult($a_names, $a_type)
append search result to recipient @access public
formatReplySubject()
format a reply subject @access public
formatLinebreakMessage($a_message)
format message according to linebreak option
__construct($a_user_id)
Constructor setup an mail object.
formatForwardSubject()
format a forward subject @access public
formatReplyMessage()
format a reply message @access public
Class Mail this class handles base functions for mail handling.
global $ilUser
Definition: imgupload.php:15