ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilMailCronOrphanedMailsNotification.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once './Services/Mail/classes/class.ilMimeMailNotification.php';
5include_once './Services/Mail/classes/class.ilMimeMail.php';
6
12{
16 public function __construct($a_is_personal_workspace = false)
17 {
18 parent::__construct($a_is_personal_workspace);
19 }
20
24 protected function initLanguageByIso2Code($a_code = '')
25 {
26 parent::initLanguageByIso2Code($a_code);
27 $this->getLanguage()->loadLanguageModule('user');
28 }
29
33 public function send()
34 {
35 foreach ($this->getRecipients() as $rcp) {
36 try {
37 $this->handleCurrentRecipient($rcp);
38 } catch (ilMailException $e) {
39 continue;
40 }
41 $this->initMimeMail();
43 $this->setSubject($this->getLanguage()->txt('orphaned_mail_subject'));
44
46 $this->appendBody("\n\n");
47 $this->appendBody($this->getLanguage()->txt('orphaned_mail_body'));
48 $this->appendBody("\n\n");
49
50 $body = $this->getOrphandMailsBody();
51 $this->appendBody($body);
53 $this->sendMimeMail($this->getCurrentRecipient());
54 }
55 }
56
57 private function buildFolderTitle(ilMailCronOrphanedMailsFolderObject $folder_object) : string
58 {
59 $folder_title = $folder_object->getFolderTitle();
60 $folder_translation = $this->getLanguage()->txt('deleted');
61
62 if ($folder_title !== null && $folder_title !== '') {
63 $lang_key = 'mail_' . $folder_title;
64 $folder_translation = $this->getLanguage()->txt($lang_key);
65
66 if ($folder_translation === '-' . $lang_key . '-') {
67 $folder_translation = $folder_title;
68 }
69 }
70
71 return $folder_translation;
72 }
73
74 public function getOrphandMailsBody()
75 {
76 $additional_information = $this->getAdditionalInformation();
78 $mail_folders = $additional_information['mail_folders'];
79
80 $folder_rendered = false;
81
82 foreach ($mail_folders as $folder_object) {
83 if ($folder_rendered) {
84 $this->appendBody("\n");
85 }
86
87 $this->appendBody($this->buildFolderTitle($folder_object) . ':');
88 $this->appendBody("\n");
89 foreach ($folder_object->getOrphanedMailObjects() as $mail_object) {
90 $this->appendBody('- ' . $mail_object->getMailSubject() ?? $this->getLanguage()->txt('not_available'));
91 $this->appendBody("\n");
92 }
93
94 $folder_rendered = true;
95 }
96 }
97}
An exception for terminatinating execution or to throw for unit testing.
buildFolderTitle(ilMailCronOrphanedMailsFolderObject $folder_object)
Class ilMailException.
appendBody($a_body)
Append body text.
getRecipients()
get array of recipients
static _getInstallationSignature()
static getSalutation($a_usr_id, ilLanguage $a_language=null)
Base class for mime mail notifications.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc