ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
4require_once 'Services/Mail/classes/class.ilMail.php';
5
13{
17 protected $ilias;
18
22 protected $rbacsystem;
23
27 protected $lng;
28
32 protected $user;
33
37 public function __construct()
38 {
39 global $DIC;
40
41 $this->lng = $DIC->language();
42 $this->rbacsystem = $DIC->rbac()->system();
43 $this->ilias = $DIC['ilias'];
44 $this->user = $DIC->user();
45 }
46
50 public function getPDMailHTML($a_mail_id, $a_mobj_id)
51 {
52 $this->lng->loadLanguageModule('mail');
53
54 //get the mail from user
55 $umail = new ilMail($this->user->getId());
56
57 // catch hack attempts
58 if (!$this->rbacsystem->checkAccess('internal_mail', $umail->getMailObjectReferenceId())) {
59 $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->WARNING);
60 }
61
62 $umail->markRead(array($a_mail_id));
63 $mail_data = $umail->getMail($a_mail_id);
64
65 $tpl = new ilTemplate('tpl.pd_mail.html', true, true, 'Services/Mail');
66
67 if ($mail_data['attachments']) {
68 foreach ($mail_data['attachments'] as $file) {
69 $tpl->setCurrentBlock('a_row');
70 $tpl->setVariable(
71 'HREF_DOWNLOAD',
72 'ilias.php?baseClass=ilMailGUI&amp;type=deliverFile&amp;mail_id=' . $_GET['mail_id'] .
73 '&amp;filename=' . md5($file)
74 );
75 $tpl->setVariable('FILE_NAME', $file);
76 $tpl->setVariable('TXT_DOWNLOAD', $this->lng->txt('download'));
77 $tpl->parseCurrentBlock();
78 }
79 $tpl->setCurrentBlock('attachment');
80 $tpl->setVariable('TXT_ATTACHMENT', $this->lng->txt('attachments'));
81 $tpl->parseCurrentBlock();
82 }
83
84 $tpl->setVariable('TXT_FROM', $this->lng->txt('from'));
85
89 $sender = ilObjectFactory::getInstanceByObjId($mail_data['sender_id'], false);
90 if ($sender && $sender->getId() != ANONYMOUS_USER_ID) {
91 $tpl->setCurrentBlock('pers_image');
92 $tpl->setVariable('IMG_SENDER', $sender->getPersonalPicturePath('xsmall'));
93 $tpl->setVariable('ALT_SENDER', htmlspecialchars($sender->getPublicName()));
94 $tpl->parseCurrentBlock();
95
96 $tpl->setVariable('PUBLIC_NAME', $sender->getPublicName());
97 } elseif (!$sender) {
98 $tpl->setVariable('PUBLIC_NAME', $mail_data['import_name'] . ' (' . $this->lng->txt('user_deleted') . ')');
99 } else {
100 $tpl->setCurrentBlock('pers_image');
101 $tpl->setVariable('IMG_SENDER', ilUtil::getImagePath('HeaderIconAvatar.svg'));
102 $tpl->setVariable('ALT_SENDER', htmlspecialchars(ilMail::_getIliasMailerName()));
103 $tpl->parseCurrentBlock();
104 $tpl->setVariable('PUBLIC_NAME', ilMail::_getIliasMailerName());
105 }
106
107 $tpl->setVariable('TXT_TO', $this->lng->txt('mail_to'));
108 $tpl->setVariable('TO', $umail->formatNamesForOutput($mail_data['rcp_to']));
109
110 if ($mail_data['rcp_cc']) {
111 $tpl->setCurrentBlock('cc');
112 $tpl->setVariable('TXT_CC', $this->lng->txt('cc'));
113 $tpl->setVariable('CC', $umail->formatNamesForOutput($mail_data['rcp_cc']));
114 $tpl->parseCurrentBlock();
115 }
116
117 $tpl->setVariable('TXT_SUBJECT', $this->lng->txt('subject'));
118 $tpl->setVariable('SUBJECT', htmlspecialchars($mail_data['m_subject']));
119
120 $tpl->setVariable('TXT_DATE', $this->lng->txt('date'));
121 $tpl->setVariable('DATE', ilDatePresentation::formatDate(new ilDateTime($mail_data['send_time'], IL_CAL_DATETIME)));
122
123 $tpl->setVariable('TXT_MESSAGE', $this->lng->txt('message'));
124 // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
125 $tpl->setVariable('MAIL_MESSAGE', nl2br(ilUtil::makeClickable(htmlspecialchars(ilUtil::securePlainString($mail_data['m_message'])))));
126
127 return $tpl->get();
128 }
129}
user()
Definition: user.php:4
$tpl
Definition: ilias.php:10
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date @access public.
@classDescription Date and time handling
This class handles base functions for mail handling.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Mail User Interface class.
__construct()
ilPDMailGUI constructor.
special template class to simplify handling of ITX/PEAR
static makeClickable($a_text, $detectGotoLinks=false)
makeClickable In Texten enthaltene URLs und Mail-Adressen klickbar machen
static securePlainString($a_str)
Remove unsecure characters from a plain text string.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
redirection script todo: (a better solution should control the processing via a xml file)
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
global $DIC
Definition: saml.php:7