ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilPDMailGUI Class Reference

Mail User Interface class. More...

+ Collaboration diagram for ilPDMailGUI:

Public Member Functions

 __construct ()
 
 getPDMailHTML (int $a_mail_id, int $a_mobj_id)
 

Protected Attributes

ILIAS $ilias
 
ilRbacSystem $rbacsystem
 
ilLanguage $lng
 
ilObjUser $user
 

Private Attributes

readonly GlobalHttpState $http
 
readonly Refinery $refinery
 

Detailed Description

Mail User Interface class.

(only a start, mail scripts code should go here)

Author
Peter Gabriel pgabr.nosp@m.iel@.nosp@m.datab.nosp@m.ay.d.nosp@m.e

Definition at line 29 of file class.ilPDMailGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilPDMailGUI::__construct ( )

Definition at line 38 of file class.ilPDMailGUI.php.

References $DIC, ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\user().

39  {
40  global $DIC;
41  $this->lng = $DIC->language();
42  $this->rbacsystem = $DIC->rbac()->system();
43  $this->ilias = $DIC['ilias'];
44  $this->user = $DIC->user();
45  $this->http = $DIC->http();
46  $this->refinery = $DIC->refinery();
47  }
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.
header include for all ilias files.
+ Here is the call graph for this function:

Member Function Documentation

◆ getPDMailHTML()

ilPDMailGUI::getPDMailHTML ( int  $a_mail_id,
int  $a_mobj_id 
)

Definition at line 49 of file class.ilPDMailGUI.php.

References ilMail\_getIliasMailerName(), ANONYMOUS_USER_ID, ilDatePresentation\formatDate(), ilUtil\getImagePath(), ilObjectFactory\getInstanceByObjId(), ILIAS\FileDelivery\http(), IL_CAL_DATETIME, ILIAS\Repository\lng(), ilUtil\makeClickable(), ILIAS\Repository\refinery(), ilUtil\securePlainString(), and ILIAS\Repository\user().

49  : string
50  {
51  $this->lng->loadLanguageModule('mail');
52 
53  //get the mail from user
54  $umail = new ilMail($this->user->getId());
55 
56  // catch hack attempts
57  if (!$this->rbacsystem->checkAccess('internal_mail', $umail->getMailObjectReferenceId())) {
58  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->WARNING);
59  }
60 
61  $umail->markRead([$a_mail_id]);
62  $mail_data = $umail->getMail($a_mail_id);
63 
64  $tpl = new ilTemplate('tpl.pd_mail.html', true, true, 'Services/Mail');
65 
66  if ($mail_data['attachments']) {
67  $mailId = 0;
68  if ($this->http->wrapper()->query()->has('mail_id')) {
69  $mailId = $this->http->wrapper()->query()->retrieve('mail_id', $this->refinery->kindlyTo()->int());
70  }
71  foreach ($mail_data['attachments'] as $file) {
72  $tpl->setCurrentBlock('a_row');
73  $tpl->setVariable(
74  'HREF_DOWNLOAD',
75  'ilias.php?baseClass=ilMailGUI&type=deliverFile&mail_id='
76  . $mailId .
77  '&filename=' . md5($file)
78  );
79  $tpl->setVariable('FILE_NAME', $file);
80  $tpl->setVariable('TXT_DOWNLOAD', $this->lng->txt('download'));
81  $tpl->parseCurrentBlock();
82  }
83  $tpl->setCurrentBlock('attachment');
84  $tpl->setVariable('TXT_ATTACHMENT', $this->lng->txt('attachments'));
85  $tpl->parseCurrentBlock();
86  }
87 
88  $tpl->setVariable('TXT_FROM', $this->lng->txt('from'));
89 
90  $sender = ilObjectFactory::getInstanceByObjId($mail_data['sender_id'], false);
91  if ($sender instanceof ilObjUser && $sender->getId() !== 0 && $sender->getId() !== ANONYMOUS_USER_ID) {
92  $tpl->setCurrentBlock('pers_image');
93  $tpl->setVariable('IMG_SENDER', $sender->getPersonalPicturePath('xsmall'));
94  $tpl->setVariable('ALT_SENDER', htmlspecialchars($sender->getPublicName()));
95  $tpl->parseCurrentBlock();
96 
97  $tpl->setVariable('PUBLIC_NAME', $sender->getPublicName());
98  } elseif (!$sender instanceof ilObjUser) {
99  $tpl->setVariable(
100  'PUBLIC_NAME',
101  trim(($mail_data['import_name'] ?? '') . ' (' . $this->lng->txt('user_deleted') . ')')
102  );
103  } else {
104  $tpl->setCurrentBlock('pers_image');
105  $tpl->setVariable('IMG_SENDER', ilUtil::getImagePath('logo/HeaderIconAvatar.svg'));
106  $tpl->setVariable('ALT_SENDER', htmlspecialchars(ilMail::_getIliasMailerName()));
107  $tpl->parseCurrentBlock();
108  $tpl->setVariable('PUBLIC_NAME', ilMail::_getIliasMailerName());
109  }
110 
111  $tpl->setVariable('TXT_TO', $this->lng->txt('mail_to'));
112  $tpl->setVariable('TO', $umail->formatNamesForOutput((string) $mail_data['rcp_to']));
113 
114  if ($mail_data['rcp_cc']) {
115  $tpl->setCurrentBlock('cc');
116  $tpl->setVariable('TXT_CC', $this->lng->txt('mail_cc'));
117  $tpl->setVariable('CC', $umail->formatNamesForOutput((string) $mail_data['rcp_cc']));
118  $tpl->parseCurrentBlock();
119  }
120 
121  $tpl->setVariable('TXT_SUBJECT', $this->lng->txt('subject'));
122  $tpl->setVariable('SUBJECT', htmlspecialchars($mail_data['m_subject']));
123 
124  $tpl->setVariable('TXT_DATE', $this->lng->txt('date'));
125  $tpl->setVariable(
126  'DATE',
127  ilDatePresentation::formatDate(new ilDateTime($mail_data['send_time'], IL_CAL_DATETIME))
128  );
129 
130  $tpl->setVariable('TXT_MESSAGE', $this->lng->txt('message'));
131  // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
132  $tpl->setVariable(
133  'MAIL_MESSAGE',
134  nl2br(ilUtil::makeClickable(htmlspecialchars(ilUtil::securePlainString($mail_data['m_message']))))
135  );
136 
137  return $tpl->get();
138  }
const IL_CAL_DATETIME
const ANONYMOUS_USER_ID
Definition: constants.php:27
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
static _getIliasMailerName()
static http()
Fetches the global http state from ILIAS.
static securePlainString(string $a_str)
header include for all ilias files.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static makeClickable(string $a_text, bool $detectGotoLinks=false)
+ Here is the call graph for this function:

Field Documentation

◆ $http

readonly GlobalHttpState ilPDMailGUI::$http
private

Definition at line 31 of file class.ilPDMailGUI.php.

◆ $ilias

ILIAS ilPDMailGUI::$ilias
protected

Definition at line 33 of file class.ilPDMailGUI.php.

◆ $lng

ilLanguage ilPDMailGUI::$lng
protected

Definition at line 35 of file class.ilPDMailGUI.php.

◆ $rbacsystem

ilRbacSystem ilPDMailGUI::$rbacsystem
protected

Definition at line 34 of file class.ilPDMailGUI.php.

◆ $refinery

readonly Refinery ilPDMailGUI::$refinery
private

Definition at line 32 of file class.ilPDMailGUI.php.

◆ $user

ilObjUser ilPDMailGUI::$user
protected

Definition at line 36 of file class.ilPDMailGUI.php.


The documentation for this class was generated from the following file: