ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPDMailGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2005 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 #require_once "./include/inc.mail.php";
25 require_once './Services/User/classes/class.ilObjUser.php';
26 require_once "Services/Mail/classes/class.ilMail.php";
27 
36 {
37 
41  function getPDMailHTML($a_mail_id, $a_mobj_id)
42  {
43  global $lng, $rbacsystem, $ilias;
44 
45  $lng->loadLanguageModule("mail");
46 
47  //get the mail from user
48  $umail = new ilMail($_SESSION["AccountId"]);
49 
50  // catch hack attempts
51  if (!$rbacsystem->checkAccess("mail_visible",$umail->getMailObjectReferenceId()))
52  {
53  $ilias->raiseError($lng->txt("permission_denied"),$ilias->error_obj->WARNING);
54  }
55 
56  $umail->markRead(array($a_mail_id));
57  $mail_data = $umail->getMail($a_mail_id);
58 
59  // SET MAIL DATA
60  $counter = 1;
61 
62  $tpl = new ilTemplate("tpl.pd_mail.html", true, true, "Services/Mail");
63 
64  // attachments
65  if($mail_data["attachments"])
66  {
67  foreach($mail_data["attachments"] as $file)
68  {
69  $tpl->setCurrentBlock("a_row");
70  $tpl->setVariable("HREF_DOWNLOAD",
71  "ilias.php?baseClass=ilMailGUI&type=deliverFile&mail_id=".$_GET["mail_id"].
72  "&filename=".md5($file));
73  $tpl->setVariable("FILE_NAME", $file);
74  $tpl->setVariable("TXT_DOWNLOAD", $lng->txt("download"));
75  $tpl->parseCurrentBlock();
76  }
77  $tpl->setCurrentBlock("attachment");
78  $tpl->setVariable("TXT_ATTACHMENT", $lng->txt("attachments"));
79  $tpl->parseCurrentBlock();
80  }
81 
82  // FROM
83  $tpl->setVariable("TXT_FROM", $lng->txt("from"));
84  $tmp_user = new ilObjUser($mail_data["sender_id"]);
85  if($mail_data['sender_id'] != ANONYMOUS_USER_ID)
86  {
87  // image
88  $tpl->setCurrentBlock("pers_image");
89  $tpl->setVariable("IMG_SENDER", $tmp_user->getPersonalPicturePath("xsmall"));
90  $tpl->setVariable("ALT_SENDER", $tmp_user->getFullname());
91  $tpl->parseCurrentBlock();
92  if(ilObjUser::_lookupPref($mail_data['sender_id'], 'public_profile') == 'y')
93  {
94  $tpl->setVariable("FROM", $tmp_user->getFullname());
95  }
96 
97  if(!($login = $tmp_user->getLogin()))
98  {
99  $login = $mail_data["import_name"]." (".$lng->txt("user_deleted").")";
100  }
101  $tpl->setVariable("MAIL_LOGIN",$login);
102  }
103  else
104  {
105  // image
106  $tpl->setCurrentBlock('pers_image');
107  $tpl->setVariable('IMG_SENDER', $tmp_user->getPersonalPicturePath('xsmall'));
108  $tpl->setVariable('ALT_SENDER', ilMail::_getAnonymousName());
109  $tpl->parseCurrentBlock();
110 
111  $tpl->setVariable('MAIL_LOGIN', ilMail::_getAnonymousName());
112 
113  }
114 
115  // TO
116  $tpl->setVariable("TXT_TO", $lng->txt("mail_to"));
117  $tpl->setVariable("TO", $umail->formatNamesForOutput($mail_data['rcp_to']));
118 
119  // CC
120  if($mail_data["rcp_cc"])
121  {
122  $tpl->setCurrentBlock("cc");
123  $tpl->setVariable("TXT_CC",$lng->txt("cc"));
124  $tpl->setVariable("CC", $umail->formatNamesForOutput($mail_data['rcp_cc']));
125  $tpl->parseCurrentBlock();
126  }
127  // SUBJECT
128  $tpl->setVariable("TXT_SUBJECT",$lng->txt("subject"));
129  $tpl->setVariable("SUBJECT",htmlspecialchars($mail_data["m_subject"]));
130 
131  // DATE
132  $tpl->setVariable("TXT_DATE", $lng->txt("date"));
133  $tpl->setVariable("DATE", ilDatePresentation::formatDate(new ilDateTime($mail_data['send_time'],IL_CAL_DATETIME)));
134 
135 
136  // ATTACHMENTS
137  /*
138  if($mail_data["attachments"])
139  {
140  $tpl->setCurrentBlock("attachment");
141  $tpl->setCurrentBlock("a_row");
142  $counter = 1;
143  foreach($mail_data["attachments"] as $file)
144  {
145  $tpl->setVariable("A_CSSROW",++$counter%2 ? 'tblrow1' : 'tblrow2');
146  $tpl->setVariable("FILE",$file);
147  $tpl->setVariable("FILE_NAME",$file);
148  $tpl->parseCurrentBlock();
149  }
150  $tpl->setVariable("TXT_ATTACHMENT",$lng->txt("attachments"));
151  $tpl->setVariable("TXT_DOWNLOAD",$lng->txt("download"));
152  $tpl->parseCurrentBlock();
153  }*/
154 
155  // MESSAGE
156  $tpl->setVariable("TXT_MESSAGE", $lng->txt("message"));
157 
158  // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
159  $tpl->setVariable("MAIL_MESSAGE", nl2br(ilUtil::makeClickable(htmlspecialchars(
160  ilUtil::securePlainString($mail_data["m_message"])))));
161 
162  return $tpl->get();
163  }
164 }
165 ?>