20 Main\Loader::includeModule(
'im');
31 IM_NOTIFY_FEATURE_PUSH,
32 IM_NOTIFY_FEATURE_MAIL,
35 'imposed_tariff_restrictions_on_the_mailbox' => [
36 'NAME' =>
Loc::getMessage(
'MAIL_NOTIFY_IMPOSE_TARIFF_RESTRICTIONS_ON_THE_MAILBOX'),
42 IM_NOTIFY_FEATURE_PUSH,
43 IM_NOTIFY_FEATURE_MAIL,
44 IM_NOTIFY_FEATURE_SITE,
51 private static function getNotifyMessageForNewMessageSetInMail($mailboxId, $messageCount, $absoluteUrl =
false): string
53 $url = htmlspecialcharsbx(sprintf(
"/mail/list/%u", $mailboxId));
58 $url = $uri->toAbsolute()->getLocator();
63 '#COUNT#' => $messageCount,
69 private static function getNotifyMessageForNewMessageInMail($message, $absoluteUrl =
false): string
71 $url = htmlspecialcharsbx($message[
'__href']);
76 $url = $uri->toAbsolute()->getLocator();
79 if ($message[
'SUBJECT'])
81 return Loc::getMessage(
'MAIL_NOTIFY_NEW_SINGLE_MESSAGE_IN_MAIL_CLIENT_1',
83 '#SUBJECT#' => $message[
'SUBJECT'],
90 return Loc::getMessage(
'MAIL_NOTIFY_NEW_SINGLE_MESSAGE_IN_MAIL_CLIENT_EMPTY_SUBJECT',
98 private static function getNotifyMessageForTariffRestrictionsMailbox($mailboxId, $email, $forEmailNotification =
false): string
100 $url = htmlspecialcharsbx(sprintf(
"/mail/list/%u", $mailboxId));
102 if ($forEmailNotification)
104 $uri =
new Uri($url);
105 $url = $uri->toAbsolute()->getLocator();
107 $text =
Loc::getMessage(
'MAIL_NOTIFY_FULL_MAILBOX_TARIFF_RESTRICTIONS_HAVE_BEEN_IMPOSED',
110 '#VIEW_URL#' => $url,
116 $text =
Loc::getMessage(
'MAIL_NOTIFY_MAILBOX_TARIFF_RESTRICTIONS_HAVE_BEEN_IMPOSED',
119 '#VIEW_URL#' => $url,
127 private static function notifyForNewMessagesInMail($userId, $fields): void
129 $message = $fields[
'message'];
132 'MESSAGE_TYPE' => IM_MESSAGE_SYSTEM,
133 'NOTIFY_TYPE' => IM_NOTIFY_SYSTEM,
134 'NOTIFY_MODULE' =>
'mail',
135 'NOTIFY_EVENT' => self::notifierSchemeTypeMail,
137 'NOTIFY_MESSAGE_OUT' => empty($message)
138 ? self::getNotifyMessageForNewMessageSetInMail($fields[
'mailboxId'], $fields[
'count'],
true)
139 : self::getNotifyMessageForNewMessageInMail($message, true),
140 'NOTIFY_MESSAGE' => empty($message)
141 ? self::getNotifyMessageForNewMessageSetInMail($fields[
'mailboxId'], $fields[
'count'])
142 : self::getNotifyMessageForNewMessageInMail($message),
147 private static function notifyForTariffRestrictions($mailboxId): void
149 $mailbox = MailboxTable::getList([
160 if (isset($mailbox[
'USER_ID']) && isset($mailbox[
'EMAIL']))
163 'MESSAGE_TYPE' => IM_MESSAGE_SYSTEM,
164 'NOTIFY_TYPE' => IM_NOTIFY_SYSTEM,
165 'NOTIFY_MODULE' =>
'mail',
166 'NOTIFY_EVENT' => self::notifierSchemeTypeMailTariffRestrictions,
168 'NOTIFY_MESSAGE_OUT' => self::getNotifyMessageForTariffRestrictionsMailbox($mailboxId, $mailbox[
'EMAIL'],
true),
169 'NOTIFY_MESSAGE' => self::getNotifyMessageForTariffRestrictionsMailbox($mailboxId, $mailbox[
'EMAIL']),
170 'TO_USER_ID' => $mailbox[
'USER_ID'],
175 public static function add($userId, $type, $fields, $mailboxId =
null)
177 if (Main\Loader::includeModule(
'im'))
179 if ($type ==
'new_message')
181 $mailboxId = $fields[
'mailboxId'];
185 $mailboxOwnerId = (int)$fields[
'mailboxOwnerId'] ?? 0;
193 $userIds[] = $userId;
196 foreach ($userIds as $id)
198 self::notifyForNewMessagesInMail($id, $fields);
201 else if ($type ==
'imposed_tariff_restrictions_on_the_mailbox')
203 self::notifyForTariffRestrictions($mailboxId);
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)