ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
MailNotification.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25use ilMail;
26
28{
29 private function buildFolderTitle(FolderDto $folder_object): string
30 {
31 $folder_title = $folder_object->getFolderTitle();
32 $folder_translation = $this->getLanguage()->txt('deleted');
33
34 if ($folder_title !== null && $folder_title !== '') {
35 $lang_key = 'mail_' . $folder_title;
36 $folder_translation = $this->getLanguage()->txt($lang_key);
37
38 if ($folder_translation === '-' . $lang_key . '-') {
39 $folder_translation = $folder_title;
40 }
41 }
42
43 return $folder_translation;
44 }
45
46 protected function initLanguageByIso2Code(string $a_code = ''): void
47 {
48 parent::initLanguageByIso2Code($a_code);
49 $this->getLanguage()->loadLanguageModule('user');
50 }
51
52 public function send(): void
53 {
54 foreach ($this->getRecipients() as $rcp) {
55 try {
56 $this->handleCurrentRecipient($rcp);
57 } catch (ilMailException) {
58 continue;
59 }
60 $this->initMimeMail();
62 $this->setSubject($this->getLanguage()->txt('orphaned_mail_subject'));
63
65 $this->appendBody("\n\n");
66 $this->appendBody($this->getLanguage()->txt('orphaned_mail_body'));
67 $this->appendBody("\n\n");
68
69 $this->appendOrphanedMailsBody();
70
72 $this->sendMimeMail($this->getCurrentRecipient());
73 }
74 }
75
76 public function appendOrphanedMailsBody(): void
77 {
78 $additional_information = $this->getAdditionalInformation();
80 $mail_folders = $additional_information['mail_folders'];
81
82 $folder_rendered = false;
83
84 foreach ($mail_folders as $folder_object) {
85 if ($folder_rendered) {
86 $this->appendBody("\n");
87 }
88
89 $this->appendBody($this->buildFolderTitle($folder_object) . ':');
90 $this->appendBody("\n");
91 foreach ($folder_object->getOrphanedMailObjects() as $mail_object) {
92 $this->appendBody('- ' . ($mail_object->getMailSubject() ?? $this->getLanguage()->txt('not_available')));
93 $this->appendBody("\n");
94 }
95
96 $folder_rendered = true;
97 }
98 }
99}
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
static _getInstallationSignature()