ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilPDMailGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/Mail/classes/class.ilMail.php';
5 
13 {
17  public function getPDMailHTML($a_mail_id, $a_mobj_id)
18  {
19  global $lng, $rbacsystem, $ilias;
20 
21  $lng->loadLanguageModule('mail');
22 
23  //get the mail from user
24  $umail = new ilMail($GLOBALS['DIC']['ilUser']->getId());
25 
26  // catch hack attempts
27  if(!$rbacsystem->checkAccess('internal_mail', $umail->getMailObjectReferenceId()))
28  {
29  $ilias->raiseError($lng->txt('permission_denied'), $ilias->error_obj->WARNING);
30  }
31 
32  $umail->markRead(array($a_mail_id));
33  $mail_data = $umail->getMail($a_mail_id);
34 
35  $tpl = new ilTemplate('tpl.pd_mail.html', true, true, 'Services/Mail');
36 
37  // attachments
38  if($mail_data['attachments'])
39  {
40  foreach($mail_data['attachments'] as $file)
41  {
42  $tpl->setCurrentBlock('a_row');
43  $tpl->setVariable('HREF_DOWNLOAD',
44  'ilias.php?baseClass=ilMailGUI&amp;type=deliverFile&amp;mail_id=' . $_GET['mail_id'] .
45  '&amp;filename=' . md5($file));
46  $tpl->setVariable('FILE_NAME', $file);
47  $tpl->setVariable('TXT_DOWNLOAD', $lng->txt('download'));
48  $tpl->parseCurrentBlock();
49  }
50  $tpl->setCurrentBlock('attachment');
51  $tpl->setVariable('TXT_ATTACHMENT', $lng->txt('attachments'));
52  $tpl->parseCurrentBlock();
53  }
54 
55  $tpl->setVariable('TXT_FROM', $lng->txt('from'));
56 
60  $sender = ilObjectFactory::getInstanceByObjId($mail_data['sender_id'], false);
61  if($sender && $sender->getId() != ANONYMOUS_USER_ID)
62  {
63  $tpl->setCurrentBlock('pers_image');
64  $tpl->setVariable('IMG_SENDER', $sender->getPersonalPicturePath('xsmall'));
65  $tpl->setVariable('ALT_SENDER', htmlspecialchars($sender->getPublicName()));
66  $tpl->parseCurrentBlock();
67 
68  $tpl->setVariable('PUBLIC_NAME', $sender->getPublicName());
69  }
70  else if(!$sender)
71  {
72  $tpl->setVariable('PUBLIC_NAME', $mail_data['import_name'] . ' (' . $lng->txt('user_deleted') . ')');
73  }
74  else
75  {
76  $tpl->setCurrentBlock('pers_image');
77  $tpl->setVariable('IMG_SENDER', ilUtil::getImagePath('HeaderIconAvatar.svg'));
78  $tpl->setVariable('ALT_SENDER', htmlspecialchars(ilMail::_getIliasMailerName()));
79  $tpl->parseCurrentBlock();
80  $tpl->setVariable('PUBLIC_NAME', ilMail::_getIliasMailerName());
81  }
82 
83  $tpl->setVariable('TXT_TO', $lng->txt('mail_to'));
84  $tpl->setVariable('TO', $umail->formatNamesForOutput($mail_data['rcp_to']));
85 
86  if($mail_data['rcp_cc'])
87  {
88  $tpl->setCurrentBlock('cc');
89  $tpl->setVariable('TXT_CC', $lng->txt('cc'));
90  $tpl->setVariable('CC', $umail->formatNamesForOutput($mail_data['rcp_cc']));
91  $tpl->parseCurrentBlock();
92  }
93 
94  $tpl->setVariable('TXT_SUBJECT', $lng->txt('subject'));
95  $tpl->setVariable('SUBJECT', htmlspecialchars($mail_data['m_subject']));
96 
97  $tpl->setVariable('TXT_DATE', $lng->txt('date'));
98  $tpl->setVariable('DATE', ilDatePresentation::formatDate(new ilDateTime($mail_data['send_time'], IL_CAL_DATETIME)));
99 
100  $tpl->setVariable('TXT_MESSAGE', $lng->txt('message'));
101  // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
102  $tpl->setVariable('MAIL_MESSAGE', nl2br(ilUtil::makeClickable(htmlspecialchars(ilUtil::securePlainString($mail_data['m_message'])))));
103 
104  return $tpl->get();
105  }
106 }
static securePlainString($a_str)
Remove unsecure characters from a plain text string.
const IL_CAL_DATETIME
$_GET["client_id"]
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $tpl
Definition: ilias.php:8
Mail User Interface class.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
This class handles base functions for mail handling.
static makeClickable($a_text, $detectGotoLinks=false)
makeClickable In Texten enthaltene URLs und Mail-Adressen klickbar machen
special template class to simplify handling of ITX/PEAR
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file