19 declare(strict_types=1);
32 public function __construct(
bool $a_is_personal_workspace =
false)
35 $this->db = $DIC->database();
36 $this->
lng = $DIC->language();
38 $this->senderFactory = $DIC[
"mail.mime.sender.factory"];
43 public function send(): void
45 $is_message_enabled = (bool) $this->
settings->get(
"mail_notification_message",
'0');
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 56 [
'integer',
'timestamp',
'text',
'integer'],
57 [1, date(
'Y-m-d H:i:s', time() - 60 * 60 * 24),
'unread', 1]
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'];
67 $users[$user_id][] = $row;
69 $sender = $this->senderFactory->system();
71 foreach ($users as $user_id => $mail_data) {
82 if (count($mail_data) === 1) {
84 $user_lang->txt(
'mail_at_the_ilias_installation'),
90 $user_lang->txt(
'mails_at_the_ilias_installation'),
98 foreach ($mail_data as
$mail) {
99 $this->
appendBody(
"----------------------------------------------------------------------------------------------");
102 $this->
appendBody($user_lang->txt(
'date') .
": " . $mail[
'send_time']);
105 $senderName = ilMail::_getIliasMailerName();
109 $this->
appendBody($user_lang->txt(
'sender') .
": " . $senderName);
111 $this->
appendBody($user_lang->txt(
'subject') .
": " . $mail[
'm_subject']);
114 if ($is_message_enabled) {
115 $this->
appendBody($user_lang->txt(
'message') .
": " . $mail[
'm_message']);
120 $this->
appendBody(
"----------------------------------------------------------------------------------------------");
122 $this->
appendBody($user_lang->txt(
'follow_link_to_read_mails') .
" ");
125 $mailbox_link .=
"/goto.php?target=mail&client_id=" .
CLIENT_ID;
136 $mmail->To($mailOptions->getExternalEmailAddresses());
139 $mmail->Body($this->
getBody());
Class ilMailOptions this class handles user mails.
appendBody(string $a_body)
Class ilMailMimeSenderFactory.
Base class for course/group mail notifications.
__construct(bool $a_is_personal_workspace=false)
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
initLanguage(int $a_usr_id)
ilMailMimeSenderFactory $senderFactory
getLanguageText(string $a_keyword)
setRecipients(array $a_rcp)
__construct(Container $dic, ilPlugin $plugin)
static _getAutoGeneratedMessageString(ilLanguage $lang=null)
setSubject(string $a_subject)
static _getInstallationSignature()
static _lookupLogin(int $a_user_id)