...Человеческий поиск в разработке...
- Модуль: blog
- Путь к файлу: ~/bitrix/modules/blog/lib/internals/mailhandler.php
- Класс: BitrixBlogInternalsMailHandler
- Вызов: MailHandler::handleReplyReceivedBlogPost
static function handleReplyReceivedBlogPost(BitrixMainEvent $event) { $siteId = intval($event->getParameter('site_id')); $postId = intval($event->getParameter('entity_id')); $userId = intval($event->getParameter('from')); $message = trim($event->getParameter('content')); $attachments = $event->getParameter('attachments'); if ( $message == '' && count($attachments) > 0 ) { $message = Loc::getMessage('BLOG_MAILHANDLER_ATTACHMENTS'); } if ( $postId <= 0 || $userId <= 0 || $message == '' ) { return false; } $res = CBlogPost::getList( array(), array( "ID" => $postId ), false, false, array("BLOG_ID", "AUTHOR_ID", "BLOG_OWNER_ID") ); if (!($blogPost = $res->fetch())) { return false; } $perm = BLOG_PERMS_DENY; if ($blogPost["AUTHOR_ID"] == $userId) { $perm = BLOG_PERMS_FULL; } else { $postPerm = CBlogPost::getSocNetPostPerms($postId, false, $userId, $blogPost["AUTHOR_ID"]); if ($postPerm > Permissions::DENY) { $perm = CBlogComment::getSocNetUserPerms($postId, $blogPost["AUTHOR_ID"], $userId); } } if ($perm == Permissions::DENY) { return false; } if (!BitrixBlogItemComment::checkDuplicate(array( 'MESSAGE' => $message, 'BLOG_ID' => $blogPost["BLOG_ID"], 'POST_ID' => $postId, 'AUTHOR_ID' => $userId, ))) { return false; } $fields = Array( "POST_ID" => $postId, "BLOG_ID" => $blogPost["BLOG_ID"], "TITLE" => '', "POST_TEXT" => $message, "AUTHOR_ID" => $userId, "DATE_CREATE" => convertTimeStamp(time() + CTimeZone::getOffset(), "FULL") ); if (!empty($siteId)) { $fields["SEARCH_GROUP_ID"] = BitrixMainConfigOption::get("socialnetwork", "userbloggroup_id", false, $siteId); } if ($perm == Permissions::PREMODERATE) { $fields["PUBLISH_STATUS"] = BLOG_PUBLISH_STATUS_READY; } $ufCode = ( isModuleInstalled("webdav") || isModuleInstalled("disk") ? "UF_BLOG_COMMENT_FILE" : "UF_BLOG_COMMENT_DOC" ); $fields[$ufCode] = array(); $type = false; $attachmentRelations = array(); foreach ($attachments as $key => $attachedFile) { $resultId = CSocNetLogComponent::saveFileToUF($attachedFile, $type, $userId); if ($resultId) { $fields[$ufCode][] = $resultId; $attachmentRelations[$key] = $resultId; } } $fields["POST_TEXT"] = preg_replace_callback( "/[ATTACHMENTs*=s*([^]]*)]/is".BX_UTF_PCRE_MODIFIER, function ($matches) use ($attachmentRelations) { if (isset($attachmentRelations[$matches[1]])) { return "[DISK FILE ID=".$attachmentRelations[$matches[1]]."]"; } }, $fields["POST_TEXT"] ); if (Loader::includeModule('disk')) { BitrixDiskUfFileUserType::setValueForAllowEdit("BLOG_COMMENT", true); } $commentId = CBlogComment::add($fields); if ($commentId) { BitrixBlogItemComment::actionsAfter(array( 'MESSAGE' => $message, 'BLOG_ID' => $blogPost["BLOG_ID"], 'BLOG_OWNER_ID' => $blogPost["BLOG_OWNER_ID"], 'POST_ID' => $postId, 'POST_TITLE' => htmlspecialcharsBack($blogPost["TITLE"]), 'POST_AUTHOR_ID' => $blogPost["AUTHOR_ID"], 'COMMENT_ID' => $commentId, 'AUTHOR_ID' => $userId, )); } return $commentId; }