28 $extranetSiteId =
false;
29 if (Loader::includeModule(
'extranet'))
31 $extranetSiteId = \CExtranet::getExtranetSiteId();
35 $res = \CSocNetLog::getSite($logId);
36 while ($logSite = $res->fetch())
38 $logSiteId[] = $logSite[
"LID"];
43 && count($logSiteId) == 1
44 && $logSiteId[0] == $extranetSiteId
52 if (!Loader::includeModule(
'mail'))
58 !isset($fields[
"logEntryId"])
59 || intval($fields[
"logEntryId"]) <= 0
60 || !isset($fields[
"userId"])
61 || !isset($fields[
"logEntryUrl"])
62 || $fields[
"logEntryUrl"] ==
''
68 if (!is_array($fields[
"userId"]))
70 $fields[
"userId"] = array($fields[
"userId"]);
73 if (!isset($fields[
"siteId"]))
75 $fields[
"siteId"] = SITE_ID;
78 $nameTemplate = \CSite::getNameFormat(
"", $fields[
"siteId"]);
81 if (!empty($fields[
"authorId"]))
83 $res = \CUser::getById($fields[
"authorId"]);
84 if ($author = $res->fetch())
86 $authorName = \CUser::formatName(
98 if (check_email($authorName))
100 $authorName =
'"'.$authorName.
'"';
103 foreach($fields[
"userId"] as $key => $val)
105 if (intval($val) == intval($fields[
"authorId"]))
107 unset($fields[
"userId"][$key]);
112 if (empty($fields[
"userId"]))
118 !isset($fields[
"type"])
119 || !in_array(mb_strtoupper($fields[
"type"]), array(
"LOG_ENTRY",
"LOG_COMMENT"))
122 $fields[
"type"] =
"LOG_COMMENT";
125 $arEmail = \Bitrix\Mail\User::getUserData($fields[
"userId"], $nameTemplate);
131 $arLogEntry = \CSocNetLog::getByID(intval($fields[
"logEntryId"]));
137 $logEntryTitle = str_replace(array(
"\r\n",
"\n"),
" ", ($arLogEntry[
"TITLE"] !=
'__EMPTY__' ? $arLogEntry[
"TITLE"] : $arLogEntry[
"MESSAGE"]));
138 $logEntryTitle = truncateText($logEntryTitle, 100);
140 switch(mb_strtoupper($fields[
"type"]))
143 $mailMessageId =
"<LOG_COMMENT_".$fields[
"logCommentId"].
"@".
$GLOBALS[
"SERVER_NAME"].
">";
144 $mailTemplateType =
"SONET_LOG_NEW_COMMENT";
147 $mailMessageId =
"<LOG_ENTRY_".$fields[
"logEntryId"].
"@".
$GLOBALS[
"SERVER_NAME"].
">";
148 $mailTemplateType =
"SONET_LOG_NEW_ENTRY";
151 $mailMessageInReplyTo =
"<LOG_ENTRY_".$fields[
"logEntryId"].
"@".
$GLOBALS[
"SERVER_NAME"].
">";
152 $defaultEmailFrom = \Bitrix\Mail\User::getDefaultEmailFrom();
154 foreach ($arEmail as $userId => $user)
156 $email = $user[
"EMAIL"];
157 $nameFormatted = str_replace(array(
'<',
'>',
'"'),
'', $user[
"NAME_FORMATTED"]);
167 $res = \Bitrix\Mail\User::getReplyTo(
171 $fields[
"logEntryId"],
172 $fields[
"logEntryUrl"]
176 list($replyTo, $backUrl) = $res;
183 $authorName = str_replace(array(
'<',
'>',
'"'),
'', $authorName);
188 "=Reply-To" => $authorName.
' <'.$replyTo.
'>',
189 "=Message-Id" => $mailMessageId,
190 "=In-Reply-To" => $mailMessageInReplyTo,
191 "EMAIL_FROM" => $authorName.
' <'.$defaultEmailFrom.
'>',
192 "EMAIL_TO" => (!empty($nameFormatted) ?
''.$nameFormatted.
' <'.$email.
'>' : $email),
193 "RECIPIENT_ID" => $userId,
194 "COMMENT_ID" => (isset($fields[
"logCommentId"]) ? intval($fields[
"logCommentId"]) :
false),
195 "LOG_ENTRY_ID" => intval($fields[
"logEntryId"]),
196 "LOG_ENTRY_TITLE" => $logEntryTitle,
197 "URL" => $fields[
"logEntryUrl"]
251 public static function detectTags($fieldList, $codeList = array())
253 static $parser =
null;
258 !is_array($fieldList)
259 || !is_array($codeList)
265 foreach($codeList as $code)
269 || empty($fieldList[$code])
275 if ($parser ===
null)
277 $parser = new \CTextParser();
280 $result = array_merge($result, $parser->detectTags($fieldList[$code]));
283 return array_unique($result);