$USER_INFO = CForumUser::GetByLogin($_REQUEST["USER_ID"]); } if (empty($USER_INFO)) { $rUser = $USER->GetByID(intval($_REQUEST['USER_ID'])); if ($rUser && ($arUser = $rUser->Fetch())) { $arUserFields["USER_ID"] = intval($_REQUEST['USER_ID']); $USER_ID = CForumUser::Add($arUserFields); $USER_INFO = CForumUser::GetByUSER_ID($USER_ID); } } } if (empty($USER_INFO)) { $arError[] = array("id" => "bad_user_info", "text" => str_replace("##", htmlspecialcharsEx($_REQUEST["USER_ID"]), GetMessage("PM_USER_NOT_FOUND"))); } else { $arrVars = array("AUTHOR_ID" => $USER->GetID(), "POST_SUBJ" => $_REQUEST["POST_SUBJ"], "POST_MESSAGE" => $_REQUEST["POST_MESSAGE"], "USE_SMILES" => $_REQUEST["USE_SMILES"], "USER_ID" => $USER_INFO["USER_ID"], "COPY_TO_OUTBOX" => $_REQUEST["COPY_TO_OUTBOX"], "REQUEST_IS_READ" => $_REQUEST["REQUEST_IS_READ"]); $arParams["MID"] = CForumPrivateMessage::Send($arrVars); if (intVal($arParams["MID"]) <= 0) { $err = $APPLICATION->GetException(); $arError[] = array("id" => "bad_send", "text" => $err->GetString()); } elseif ($arParams["version"] == 2) { $db_res = CForumPrivateMessage::GetListEx(array(), array("ID" => $arParams["MID"])); if (!($db_res && ($res = $db_res->GetNext()))) { ""; } elseif (!empty($res["RECIPIENT_EMAIL"])) { $event = new CEvent(); $arSiteInfo = $event->GetSiteFieldsArray(SITE_ID); if (!isset(${"parser_" . LANGUAGE_ID})) { ${"parser_" . LANGUAGE_ID} = new forumTextParser(LANGUAGE_ID); } $POST_MESSAGE = ${"parser_" . LANGUAGE_ID}->convert4mail(str_replace("#SERVER_NAME#", SITE_SERVER_NAME, $_REQUEST["POST_MESSAGE"])); $arFields = array("FROM_NAME" => $res["AUTHOR_NAME"], "FROM_USER_ID" => $USER->GetID(), "FROM_EMAIL" => $USER->GetEmail(), "TO_NAME" => $res["RECIPIENT_NAME"], "TO_USER_ID" => $res["RECIPIENT_ID"], "TO_EMAIL" => $res["RECIPIENT_EMAIL"], "SUBJECT" => $_REQUEST["POST_SUBJ"], "MESSAGE" => $POST_MESSAGE, "MESSAGE_DATE" => date("d.m.Y H:i:s"), "MESSAGE_LINK" => "http://" . SITE_SERVER_NAME . CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_PM_READ"], array("FID" => "1", "MID" => $arParams["MID"])) . " \n");
if ($err) { $arError[] = array("id" => "bad_" . $action . "_" . $MID, "text" => $err->GetString()); } } else { $arOk[] = array("id" => $action . "_" . $MID, "text" => str_replace("#MID#", $MID, GetMessage("PM_OK_MOVE"))); } } } elseif ($action == "send_notification" && $arParams["version"] == 2 && $arResult["MESSAGE"]["REQUEST_IS_READ"] == "Y") { $arNotification["POST_SUBJ"] = GetMessage("SYSTEM_POST_SUBJ"); $arNotification["POST_MESSAGE"] = GetMessage("SYSTEM_POST_MESSAGE"); $arNotification["FIELDS"] = array("USER_NAME" => $arResult["MESSAGE"]["~RECIPIENT_NAME"], "USER_ID" => $arResult["MESSAGE"]["RECIPIENT_ID"], "USER_LINK" => CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_PROFILE_VIEW"], array("UID" => $arResult["MESSAGE"]["RECIPIENT_ID"])), "SUBJECT" => $arResult["MESSAGE"]["~POST_SUBJ"], "MESSAGE" => $arResult["MESSAGE"]["~POST_MESSAGE"], "MESSAGE_DATE" => $arResult["MESSAGE"]["POST_DATE"], "MESSAGE_LINK" => CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_PM_READ"], array("FID" => "1", "MID" => $arResult["MESSAGE"]["ID"])), "SERVER_NAME" => SITE_SERVER_NAME); foreach ($arNotification["FIELDS"] as $key => $val) { $arNotification["POST_MESSAGE"] = str_replace("#" . $key . "#", $val, $arNotification["POST_MESSAGE"]); } $arFields = array("AUTHOR_ID" => $USER->GetID(), "USER_ID" => $arResult["MESSAGE"]["AUTHOR_ID"], "POST_SUBJ" => $arNotification["POST_SUBJ"], "POST_MESSAGE" => $arNotification["POST_MESSAGE"], "USE_SMILES" => "Y"); if ($newMID = CForumPrivateMessage::Send($arFields)) { BXClearCache(true, "/bitrix/forum/user/" . $arResult["MESSAGE"]["AUTHOR_ID"] . "/"); $arComponentPath = array("bitris:forum"); foreach ($arComponentPath as $path) { $componentRelativePath = CComponentEngine::MakeComponentPath($path); $arComponentDescription = CComponentUtil::GetComponentDescr($path); if (strLen($componentRelativePath) <= 0 || !is_array($arComponentDescription)) { continue; } elseif (!array_key_exists("CACHE_PATH", $arComponentDescription)) { continue; } $path = str_replace("//", "/", $componentRelativePath . "/user" . $arResult["MESSAGE"]["AUTHOR_ID"]); if ($arComponentDescription["CACHE_PATH"] == "Y") { $path = "/" . SITE_ID . $path; } if (!empty($path)) {