ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 (protected bool $is_in_wsp=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 $sender_factory
 
- 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 = []
 
ilWorkspaceTree $wsp_tree
 
ilWorkspaceAccessHandler $wsp_access_handler
 

Additional Inherited Members

- Data Fields inherited from ilMailNotification
final const int 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

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

Constructor & Destructor Documentation

◆ __construct()

ilMailSummaryNotification::__construct ( bool  $a_is_personal_workspace = false)

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

29 {
30 global $DIC;
31 $this->db = $DIC->database();
32 $this->lng = $DIC->language();
33 $this->settings = $DIC->settings();
34 $this->sender_factory = $DIC->mail()->mime()->senderFactory();
35
36 parent::__construct($a_is_personal_workspace);
37 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

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 39 of file class.ilMailSummaryNotification.php.

39 : void
40 {
41 $is_message_enabled = (bool) $this->settings->get('mail_notification_message', '0');
42
43 $res = $this->db->queryF(
44 'SELECT mail.* FROM mail_options
45 INNER JOIN mail ON mail.user_id = mail_options.user_id
46 INNER JOIN mail_obj_data ON mail_obj_data.obj_id = mail.folder_id
47 INNER JOIN usr_data ud ON ud.usr_id = mail.user_id
48 WHERE mail_options.cronjob_notification = %s
49 AND mail.send_time >= %s
50 AND mail.m_status = %s
51 AND ud.active = %s',
52 ['integer', 'timestamp', 'text', 'integer'],
53 [1, date('Y-m-d H:i:s', time() - 60 * 60 * 24), 'unread', 1]
54 );
55
56 $users = [];
57 $user_id = 0;
58
59 while ($row = $this->db->fetchAssoc($res)) {
60 if ($user_id === 0 || (int) $row['user_id'] !== $user_id) {
61 $user_id = (int) $row['user_id'];
62 }
63 $users[$user_id][] = $row;
64 }
65 $sender = $this->sender_factory->system();
66
67 foreach ($users as $user_id => $mail_data) {
68 $this->initLanguage($user_id);
69 $user_lang = $this->getLanguage();
70
71 $this->initMail();
72
73 $this->setRecipients([$user_id]);
74 $this->setSubject($this->getLanguageText('mail_notification_subject'));
75
76 $this->setBody(ilMail::getSalutation($user_id, $user_lang));
77 $this->appendBody("\n\n");
78 if (count($mail_data) === 1) {
79 $this->appendBody(sprintf(
80 $user_lang->txt('mail_at_the_ilias_installation'),
81 count($mail_data),
83 ));
84 } else {
85 $this->appendBody(sprintf(
86 $user_lang->txt('mails_at_the_ilias_installation'),
87 count($mail_data),
89 ));
90 }
91 $this->appendBody("\n\n");
92
93 $counter = 1;
94 foreach ($mail_data as $mail) {
95 $this->appendBody(
96 '----------------------------------------------------------------------------------------------'
97 );
98 $this->appendBody("\n\n");
99 $this->appendBody('#' . $counter . "\n\n");
100 $this->appendBody($user_lang->txt('date') . ': ' . $mail['send_time']);
101 $this->appendBody("\n");
102 if ((int) $mail['sender_id'] === ANONYMOUS_USER_ID) {
103 $sender_name = ilMail::_getIliasMailerName();
104 } else {
105 $sender_name = ilObjUser::_lookupLogin((int) $mail['sender_id']);
106 }
107 $this->appendBody($user_lang->txt('sender') . ': ' . $sender_name);
108 $this->appendBody("\n");
109 $this->appendBody($user_lang->txt('subject') . ': ' . $mail['m_subject']);
110 $this->appendBody("\n\n");
111
112 if ($is_message_enabled) {
113 $this->appendBody($user_lang->txt('message') . ': ' . $mail['m_message']);
114 $this->appendBody("\n\n");
115 }
116 ++$counter;
117 }
118 $this->appendBody(
119 '----------------------------------------------------------------------------------------------'
120 );
121 $this->appendBody("\n\n");
122 $this->appendBody($user_lang->txt('follow_link_to_read_mails') . ' ');
123 $this->appendBody("\n");
124 $mailbox_link = rtrim(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 $mail_options = new ilMailOptions($user_id);
136 $mmail->To($mail_options->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)
static _getIliasMailerName()
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
static _getInstallationSignature()
static _getAutoGeneratedMessageString(?ilLanguage $lang=null)
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
$counter

References $counter, ilMailNotification\$mail, $res, ilMailNotification\$sender, $user_id, ilMail\_getAutoGeneratedMessageString(), ilUtil\_getHttpPath(), ilMail\_getIliasMailerName(), 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 24 of file class.ilMailSummaryNotification.php.

◆ $lng

ilLanguage ilMailSummaryNotification::$lng
protected

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

◆ $sender_factory

ilMailMimeSenderFactory ilMailSummaryNotification::$sender_factory
protected

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

◆ $settings

ilSetting ilMailSummaryNotification::$settings
protected

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


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