3namespace Bitrix\Blog\Internals;
5use Bitrix\Blog\Item\Blog;
8use Bitrix\Main\Localization\Loc;
10use Bitrix\Blog\Item\Permissions;
12Loc::loadMessages(__FILE__);
31 $postId = intval(
$event->getParameter(
'entity_id'));
34 $attachments =
$event->getParameter(
'attachments');
38 &&
count($attachments) > 0
41 $message = Loc::getMessage(
'BLOG_MAILHANDLER_ATTACHMENTS');
53 $res = \CBlogPost::getList(
60 array(
"BLOG_ID",
"AUTHOR_ID",
"BLOG_OWNER_ID")
63 if (!($blogPost =
$res->fetch()))
70 if ($blogPost[
"AUTHOR_ID"] ==
$userId)
76 $postPerm = \CBlogPost::getSocNetPostPerms($postId,
false,
$userId, $blogPost[
"AUTHOR_ID"]);
79 $perm = \CBlogComment::getSocNetUserPerms($postId, $blogPost[
"AUTHOR_ID"],
$userId);
90 'BLOG_ID' => $blogPost[
"BLOG_ID"],
100 "BLOG_ID" => $blogPost[
"BLOG_ID"],
104 "DATE_CREATE" => convertTimeStamp(time() + \CTimeZone::getOffset(),
"FULL")
118 isModuleInstalled(
"webdav")
119 || isModuleInstalled(
"disk")
120 ?
"UF_BLOG_COMMENT_FILE"
121 :
"UF_BLOG_COMMENT_DOC"
126 $attachmentRelations =
array();
128 foreach ($attachments as
$key => $attachedFile)
130 $resultId = \CSocNetLogComponent::saveFileToUF($attachedFile,
$type,
$userId);
133 $fields[$ufCode][] = $resultId;
134 $attachmentRelations[
$key] = $resultId;
138 $fields[
"POST_TEXT"] = preg_replace_callback(
139 "/\[ATTACHMENT\s*=\s*([^\]]*)\]/isu",
140 function (
$matches) use ($attachmentRelations)
142 if (isset($attachmentRelations[
$matches[1]]))
144 return "[DISK FILE ID=".$attachmentRelations[
$matches[1]].
"]";
150 if (Loader::includeModule(
'disk'))
152 \Bitrix\Disk\Uf\FileUserType::setValueForAllowEdit(
"BLOG_COMMENT",
true);
155 $commentId = \CBlogComment::add(
$fields);
161 'BLOG_ID' => $blogPost[
"BLOG_ID"],
162 'BLOG_OWNER_ID' => $blogPost[
"BLOG_OWNER_ID"],
163 'POST_ID' => $postId,
164 'POST_TITLE' => htmlspecialcharsBack($blogPost[
"TITLE"]),
165 'POST_AUTHOR_ID' => $blogPost[
"AUTHOR_ID"],
166 'COMMENT_ID' => $commentId,
183 $subject = trim(
$event->getParameter(
'subject'));
184 $attachments =
$event->getParameter(
'attachments');
189 &&
count($attachments) > 0
192 $message = Loc::getMessage(
'BLOG_MAILHANDLER_ATTACHMENTS');
204 if (!Loader::includeModule(
'socialnetwork'))
213 "GROUP_ID" =>
Config\Option::get(
"socialnetwork",
"userbloggroup_id",
false,
$siteId),
228 "BLOG_ID" => $blog[
"ID"],
230 "=DATE_CREATE" => $helper->getCurrentDateTimeFunction(),
231 "=DATE_PUBLISH" => $helper->getCurrentDateTimeFunction(),
235 "DETAIL_TEXT_TYPE" =>
"text",
239 "HAS_SOCNET_ALL" =>
"N",
250 $fields[
"TITLE"] = Loc::getMessage(
"BLOG_MAILHANDLER_EMPTY_TITLE_PLACEHOLDER");
255 isModuleInstalled(
"webdav")
256 || isModuleInstalled(
"disk")
257 ?
"UF_BLOG_POST_FILE"
263 $attachmentRelations =
array();
265 foreach ($attachments as
$key => $attachedFile)
267 $resultId = \CSocNetLogComponent::saveFileToUF($attachedFile,
$type,
$userId);
270 $fields[$ufCode][] = $resultId;
271 $attachmentRelations[
$key] = $resultId;
275 $fields[
"HAS_PROPS"] = (!empty($attachmentRelations) ?
"Y" :
"N");
277 $fields[
"DETAIL_TEXT"] = preg_replace_callback(
278 "/\[ATTACHMENT\s*=\s*([^\]]*)\]/isu",
279 function (
$matches) use ($attachmentRelations)
282 isset($attachmentRelations[
$matches[1]])
283 ?
"[DISK FILE ID=".$attachmentRelations[
$matches[1]].
"]"
290 if (Loader::includeModule(
'disk'))
292 \Bitrix\Disk\Uf\FileUserType::setValueForAllowEdit(
"BLOG_POST",
true);
295 $postId = \CBlogPost::add(
$fields);
305 $paramsNotify =
array(
309 "PATH_TO_SMILE" =>
Config\Option::get(
"socialnetwork",
"smile_page",
'',
$siteId),
310 "PATH_TO_POST" => $pathToPost,
312 "NAME_TEMPLATE" => \CSite::getNameFormat(
null,
$siteId),
314 "SEND_COUNTER_TO_AUTHOR" =>
"Y"
316 \CBlogPost::notify(
$fields, $blog, $paramsNotify);
318 if (Loader::includeModule(
'im'))
321 "post_id" => $postId,
325 $processedPathData = \CSocNetLogTools::processPath(
array(
"POST_URL" => $postUrl),
$userId,
$siteId);
326 $serverName = $processedPathData[
"SERVER_NAME"];
327 $postUrl = $processedPathData[
"URLS"][
"POST_URL"];
329 \CIMNotify::add(
array(
332 "NOTIFY_MODULE" =>
"blog",
333 "NOTIFY_EVENT" =>
"post_mail",
334 "NOTIFY_TAG" =>
"BLOG|POST|".$postId,
336 "NOTIFY_MESSAGE" => fn (?
string $languageId =
null) => Loc::getMessage(
337 "BLOG_MAILHANDLER_NEW_POST",
339 "#TITLE#" =>
"<a href=\"".$postUrl.
"\">".
$fields[
"TITLE"].
"</a>",
343 "NOTIFY_MESSAGE_OUT" => fn (?
string $languageId =
null) => Loc::getMessage(
344 "BLOG_MAILHANDLER_NEW_POST",
349 ) .
' '.$serverName.$postUrl
355 'blogId' => $blog[
'ID'],
357 if (!empty($categoryIdList))
359 foreach ($categoryIdList as $categoryId)
361 \CBlogPostCategory::add([
362 'BLOG_ID' =>
$fields[
'BLOG_ID'],
363 'POST_ID' => $postId,
364 'CATEGORY_ID' => $categoryId
371 'CATEGORY_ID' => implode(
',', $categoryIdList),
const BLOG_PUBLISH_STATUS_READY
const BLOG_PUBLISH_STATUS_PUBLISH
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static handleReplyReceivedBlogPost(\Bitrix\Main\Event $event)
static handleForwardReceivedBlogPost(\Bitrix\Main\Event $event)
static getByUser(array $params)
static getConnection($name="")
static get($moduleId, $name, $default="", $siteId=false)
static parseTagsFromFields(array $params=[])
static makePathFromTemplate($template, $arParams=array())
static killAllTags($text)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
BXClearCache($full=false, $initdir='')
TruncateText($strText, $intLen)
if(empty($signedUserToken)) $key
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"