ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilFormatMail.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
34 include_once "Services/Mail/classes/class.ilMail.php";
35 
36 class ilFormatMail extends ilMail
37 {
38 
45  function ilFormatMail($a_user_id)
46  {
47  parent::ilMail($a_user_id);
48  }
49 
55  function formatReplyMessage()
56  {
57  if(empty($this->mail_data))
58  {
59  return false;
60  }
61 # debug($this->mail_data["m_message"]);
62  $bodylines = explode(chr(13).chr(10), $this->mail_data["m_message"]);
63 # var_dump("<pre>",$bodylines,"</pre");
64  for ($i = 0; $i < count($bodylines); $i++)
65  {
66  $bodylines[$i] = "> ".$bodylines[$i];
67  }
68  return $this->mail_data["m_message"] = implode(chr(13).chr(10), $bodylines);
69  }
70 
76  function formatReplySubject()
77  {
78  if(empty($this->mail_data))
79  {
80  return false;
81  }
82  return $this->mail_data["m_subject"] = "RE: ".$this->mail_data["m_subject"];
83  }
84 
91  {
92  global $ilUser;
93 
94  if(empty($this->mail_data))
95  {
96  return '';
97  }
98 
99  $newCC = array();
100 
101  foreach (explode(',', $this->mail_data['rcp_to']) as $to)
102  {
103  if (trim($to) != '' && $ilUser->getLogin() != trim($to))
104  {
105  $newCC[] = trim($to);
106  }
107  }
108 
109  foreach (explode(',', $this->mail_data['rcp_cc']) as $cc)
110  {
111  if (trim($cc) != '' && $ilUser->getLogin() != trim($cc))
112  {
113  $newCC[] = trim($cc);
114  }
115  }
116 
117  return ($this->mail_data['rcp_cc'] = implode(', ', $newCC));
118  }
119 
126  {
127  if(empty($this->mail_data))
128  {
129  return false;
130  }
131 
132  require_once './Services/User/classes/class.ilObjUser.php';
133 
134  $user = new ilObjUser($this->mail_data["sender_id"]);
135  return $this->mail_data["rcp_to"] = $user->getLogin();
136  }
143  {
144  if(empty($this->mail_data))
145  {
146  return false;
147  }
148  return $this->mail_data["m_subject"] = "[FWD: ".$this->mail_data["m_subject"]."]";
149  }
150 
158  function appendSearchResult($a_names,$a_type)
159  {
160  if(empty($this->mail_data))
161  {
162  return false;
163  }
164  $name_str = implode(',',$a_names);
165  switch($a_type)
166  {
167  case 'to':
168  $this->mail_data["rcp_to"] = trim($this->mail_data["rcp_to"]);
169  if($this->mail_data["rcp_to"])
170  {
171  $this->mail_data["rcp_to"] = $this->mail_data["rcp_to"].",";
172  }
173  $this->mail_data["rcp_to"] = $this->mail_data["rcp_to"] . $name_str;
174  break;
175 
176  case 'cc':
177  $this->mail_data["rcp_cc"] = trim($this->mail_data["rcp_cc"]);
178  if($this->mail_data["rcp_cc"])
179  {
180  $this->mail_data["rcp_cc"] = $this->mail_data["rcp_cc"].",";
181  }
182  $this->mail_data["rcp_cc"] = $this->mail_data["rcp_cc"] . $name_str;
183  break;
184 
185  case 'bc':
186  $this->mail_data["rcp_bcc"] = trim($this->mail_data["rcp_bcc"]);
187  if($this->mail_data["rcp_bcc"])
188  {
189  $this->mail_data["rcp_bcc"] = $this->mail_data["rcp_bcc"].",";
190  }
191  $this->mail_data["rcp_bcc"] = $this->mail_data["rcp_bcc"] . $name_str;
192  break;
193 
194  }
195  return $this->mail_data;
196  }
203  function formatLinebreakMessage($a_message)
204  {
205  $formatted = array();
206 
207 # debug($a_message);
208  $linebreak = $this->mail_options->getLinebreak();
209  // SPLIT INTO LINES returns always an array
210  $lines = explode(chr(10),$a_message);
211  for($i=0;$i<count($lines);$i++)
212  {
213  if(substr($lines[$i],0,1) != '>')
214  {
215  $formatted[] = wordwrap($lines[$i],$linebreak,chr(10));
216  }
217  else
218  {
219  $formatted[] = $lines[$i];
220  }
221  }
222  $formatted = implode(chr(10),$formatted);
223 # debug($formatted);
224  return $formatted;
225  }
226 
227 
228 
234  function appendSignature()
235  {
236  return $this->mail_data["m_message"] .= chr(13).chr(10).$this->mail_options->getSignature();
237  }
238 } // END class.ilFormatMail
239 ?>