ILIAS  release_8 Revision v8.24
ilMailSummaryNotification Class Reference
+ Inheritance diagram for ilMailSummaryNotification:
+ Collaboration diagram for ilMailSummaryNotification:

Public Member Functions

 __construct (bool $a_is_personal_workspace=false)
 
 send ()
 
- Public Member Functions inherited from ilMailNotification
 __construct (bool $a_is_personal_workspace=false)
 
 setType (int $a_type)
 
 getType ()
 
 setSender (int $a_usr_id)
 
 getSender ()
 
 setRecipients (array $a_rcp)
 
 getRecipients ()
 
 setAttachments (array $a_att)
 
 getAttachments ()
 
 setLangModules (array $a_modules)
 
 getUserLanguage (int $a_usr_id)
 
 setRefId (int $a_id)
 
 getRefId ()
 
 getObjId ()
 
 setObjId (int $a_obj_id)
 
 getObjType ()
 
 setAdditionalInformation (array $a_info)
 
 getAdditionalInformation ()
 
 sendMail (array $a_rcp, bool $a_parse_recipients=true)
 
 getBlockBorder ()
 

Protected Attributes

ilLanguage $lng
 
ilDBInterface $db
 
ilSetting $settings
 
ilMailMimeSenderFactory $senderFactory
 
- Protected Attributes inherited from ilMailNotification
int $type
 
int $sender
 
ilMail $mail = null
 
string $subject = ''
 
string $body = ''
 
array $attachments = []
 
ilLanguage $language
 
array $lang_modules = []
 
array $recipients = []
 
int $ref_id
 
int $obj_id = 0
 
string $obj_type = ''
 
array $additional_info = []
 
bool $is_in_wsp
 
ilWorkspaceTree $wsp_tree
 
ilWorkspaceAccessHandler $wsp_access_handler
 

Additional Inherited Members

- Data Fields inherited from ilMailNotification
const SUBJECT_TITLE_LENGTH = 60
 
- Protected Member Functions inherited from ilMailNotification
 setSubject (string $a_subject)
 
 getSubject ()
 
 setBody (string $a_body)
 
 appendBody (string $a_body)
 
 getBody ()
 
 initLanguage (int $a_usr_id)
 
 initLanguageByIso2Code (string $a_code='')
 
 setLanguage (ilLanguage $a_language)
 
 getLanguage ()
 
 getLanguageText (string $a_keyword)
 
 getObjectTitle (bool $a_shorten=false)
 
 initMail ()
 
 getMail ()
 
 createPermanentLink (array $a_params=[], string $a_append='')
 
 userToString (int $a_usr_id)
 
 isRefIdAccessible (int $a_user_id, int $a_ref_id, string $a_permission="read")
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMailSummaryNotification::__construct ( bool  $a_is_personal_workspace = false)

Reimplemented from ilMailNotification.

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

33 {
34 global $DIC;
35 $this->db = $DIC->database();
36 $this->lng = $DIC->language();
37 $this->settings = $DIC->settings();
38 $this->senderFactory = $DIC["mail.mime.sender.factory"];
39
40 parent::__construct($a_is_personal_workspace);
41 }
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\lng(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

Member Function Documentation

◆ send()

ilMailSummaryNotification::send ( )

Definition at line 43 of file class.ilMailSummaryNotification.php.

43 : void
44 {
45 $is_message_enabled = (bool) $this->settings->get("mail_notification_message", '0');
46
47 $res = $this->db->queryF(
48 'SELECT mail.* FROM mail_options
49 INNER JOIN mail ON mail.user_id = mail_options.user_id
50 INNER JOIN mail_obj_data ON mail_obj_data.obj_id = mail.folder_id
51 INNER JOIN usr_data ud ON ud.usr_id = mail.user_id
52 WHERE mail_options.cronjob_notification = %s
53 AND mail.send_time >= %s
54 AND mail.m_status = %s
55 AND ud.active = %s',
56 ['integer', 'timestamp', 'text', 'integer'],
57 [1, date('Y-m-d H:i:s', time() - 60 * 60 * 24), 'unread', 1]
58 );
59
60 $users = [];
61 $user_id = 0;
62
63 while ($row = $this->db->fetchAssoc($res)) {
64 if ($user_id === 0 || (int) $row['user_id'] !== $user_id) {
65 $user_id = (int) $row['user_id'];
66 }
67 $users[$user_id][] = $row;
68 }
69 $sender = $this->senderFactory->system();
70
71 foreach ($users as $user_id => $mail_data) {
72 $this->initLanguage($user_id);
73 $user_lang = $this->getLanguage();
74
75 $this->initMail();
76
77 $this->setRecipients([$user_id]);
78 $this->setSubject($this->getLanguageText('mail_notification_subject'));
79
80 $this->setBody(ilMail::getSalutation($user_id, $user_lang));
81 $this->appendBody("\n\n");
82 if (count($mail_data) === 1) {
83 $this->appendBody(sprintf(
84 $user_lang->txt('mail_at_the_ilias_installation'),
85 count($mail_data),
87 ));
88 } else {
89 $this->appendBody(sprintf(
90 $user_lang->txt('mails_at_the_ilias_installation'),
91 count($mail_data),
93 ));
94 }
95 $this->appendBody("\n\n");
96
97 $counter = 1;
98 foreach ($mail_data as $mail) {
99 $this->appendBody("----------------------------------------------------------------------------------------------");
100 $this->appendBody("\n\n");
101 $this->appendBody('#' . $counter . "\n\n");
102 $this->appendBody($user_lang->txt('date') . ": " . $mail['send_time']);
103 $this->appendBody("\n");
104 if ((int) $mail['sender_id'] === ANONYMOUS_USER_ID) {
105 $senderName = ilMail::_getIliasMailerName();
106 } else {
107 $senderName = ilObjUser::_lookupLogin((int) $mail['sender_id']);
108 }
109 $this->appendBody($user_lang->txt('sender') . ": " . $senderName);
110 $this->appendBody("\n");
111 $this->appendBody($user_lang->txt('subject') . ": " . $mail['m_subject']);
112 $this->appendBody("\n\n");
113
114 if ($is_message_enabled) {
115 $this->appendBody($user_lang->txt('message') . ": " . $mail['m_message']);
116 $this->appendBody("\n\n");
117 }
118 ++$counter;
119 }
120 $this->appendBody("----------------------------------------------------------------------------------------------");
121 $this->appendBody("\n\n");
122 $this->appendBody($user_lang->txt('follow_link_to_read_mails') . " ");
123 $this->appendBody("\n");
124 $mailbox_link = ilUtil::_getHttpPath();
125 $mailbox_link .= "/goto.php?target=mail&client_id=" . CLIENT_ID;
126
127 $this->appendBody($mailbox_link);
128 $this->appendBody("\n\n");
131
132 $mmail = new ilMimeMail();
133 $mmail->From($sender);
134
135 $mailOptions = new ilMailOptions($user_id);
136 $mmail->To($mailOptions->getExternalEmailAddresses());
137
138 $mmail->Subject($this->getSubject());
139 $mmail->Body($this->getBody());
140 $mmail->Send();
141 }
142 }
getLanguageText(string $a_keyword)
setSubject(string $a_subject)
Class ilMailOptions this class handles user mails.
static _getAutoGeneratedMessageString(ilLanguage $lang=null)
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
static _getInstallationSignature()
static _lookupLogin(int $a_user_id)
static _getHttpPath()
const CLIENT_ID
Definition: constants.php:41
const ANONYMOUS_USER_ID
Definition: constants.php:27
$res
Definition: ltiservices.php:69

References ilMailNotification\$mail, $res, ilMailNotification\$sender, ilMail\_getAutoGeneratedMessageString(), ilUtil\_getHttpPath(), ilMail\_getInstallationSignature(), ilObjUser\_lookupLogin(), ANONYMOUS_USER_ID, ilMailNotification\appendBody(), CLIENT_ID, ilMailNotification\getBody(), ilMailNotification\getLanguage(), ilMailNotification\getLanguageText(), ilMail\getSalutation(), ilMailNotification\getSubject(), ilMailNotification\initLanguage(), ilMailNotification\initMail(), ILIAS\Repository\int(), ilMailNotification\setBody(), ilMailNotification\setRecipients(), ilMailNotification\setSubject(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilMailSummaryNotification::$db
protected

Definition at line 28 of file class.ilMailSummaryNotification.php.

◆ $lng

ilLanguage ilMailSummaryNotification::$lng
protected

Definition at line 27 of file class.ilMailSummaryNotification.php.

◆ $senderFactory

ilMailMimeSenderFactory ilMailSummaryNotification::$senderFactory
protected

Definition at line 30 of file class.ilMailSummaryNotification.php.

◆ $settings

ilSetting ilMailSummaryNotification::$settings
protected

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


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