$arResult["OK_MESSAGE"] = ""; /******************************************************************** Action ********************************************************************/ $action = strToLower($_REQUEST["action"]); $arError = array(); if ($_SERVER['REQUEST_METHOD'] == "POST" && !empty($action)) { $APPLICATION->ResetException(); if (!check_bitrix_sessid()) { $arError[] = array("id" => "BAD_SESSID", "text" => GetMessage("F_ERR_SESS_FINISH")); } elseif ($action != "save" && $action != "send") { } elseif ($action == "save" && !CForumPrivateMessage::CheckPermissions($arParams["MID"])) { $arError[] = array("id" => "bad_permission", "text" => GetMessage("PM_NOT_RIGHT")); } elseif ($action == "save") { $arrVars = array("POST_SUBJ" => $_REQUEST["POST_SUBJ"], "POST_MESSAGE" => $_REQUEST["POST_MESSAGE"], "USE_SMILES" => $_REQUEST["USE_SMILES"]); if (!CForumPrivateMessage::Update($arParams["MID"], $arrVars)) { $str = $APPLICATION->GetException(); if ($str && $str->GetString()) { $arError[] = array("id" => "bad_update", "text" => $str->GetString()); } else { $arError[] = array("id" => "bad_update", "text" => "Error!"); } } else { if ($arParams['AUTOSAVE']) { $arParams['AUTOSAVE']->Reset(); } } } elseif ($action == "send") { $USER_INFO = array(); if (!empty($_REQUEST["USER_ID"])) { if (intval($_REQUEST["USER_ID"]) > 0) {
public static function Delete($ID) { global $DB, $USER; $ID = IntVal($ID); $list = array(); $list = CForumPrivateMessage::GetList(array(), array("ID" => $ID)); $arFields = $list->GetNext(); $result = false; foreach (GetModuleEvents("forum", "onBeforePMDelete", true) as $arEvent) { if (ExecuteModuleEventEx($arEvent, array($ID, &$arFields)) === false) { return $result; } } $eventID = "onAfterPMDelete"; if ($arFields["FOLDER_ID"] == 4) { $DB->Query("DELETE FROM b_forum_private_message WHERE ID=" . $ID); $result = true; } else { $eventID = "onAfterPMTrash"; if (CForumPrivateMessage::Update($ID, array("FOLDER_ID" => 4, "IS_READ" => "Y", "USER_ID" => $USER->GetId()))) { $result = true; } } if ($result) { foreach (GetModuleEvents("forum", $eventID, true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($ID, &$arFields)); } } return $result; }
$strOK .= str_replace("#MID#", $MID, GetMessage("PM_OK_DELETE")); } } } elseif (($arResult["action"] == "copy" || $arResult["action"] == "move") && intVal($_REQUEST["folder_id"]) <= 0) { $arError[] = array("id" => "BAD_DATA", "text" => GetMessage("PM_ERR_MOVE_NO_FOLDER")); } elseif ($arResult["action"] == "copy" || $arResult["action"] == "move") { $folder_id = intVal($_REQUEST["folder_id"]); foreach ($message as $MID) { $arrVars = array("FOLDER_ID" => intVal($folder_id), "USER_ID" => $USER->GetId()); if ($folder_id == 4 || $arResult["action"] != "move") { $arrVars["IS_READ"] = "Y"; } if (!CForumPrivateMessage::CheckPermissions($MID)) { $arError[] = array("id" => "BAD_PERMISSION_" . $MID, "text" => str_replace("#MID#", $MID, GetMessage("PM_ERR_MOVE_NO_PERM"))); } elseif ($arResult["action"] == "move") { if (!CForumPrivateMessage::Update($MID, $arrVars)) { $err = $APPLICATION->GetException(); $arError[] = array("id" => "BAD_MOVE_" . $MID, "text" => $err->GetString()); } else { $strOK .= str_replace("#MID#", $MID, GetMessage("PM_OK_MOVE")) . "\n"; } } else { if (!CForumPrivateMessage::Copy($MID, $arrVars)) { $err = $APPLICATION->GetException(); $arError[] = array("id" => "BAD_MOVE_" . $MID, "text" => $err->GetString()); } else { $strOK .= str_replace("#MID#", $MID, GetMessage("PM_OK_COPY")) . "\n"; } } } }
$path = str_replace("//", "/", $componentRelativePath . "/user" . $arResult["MESSAGE"]["AUTHOR_ID"]); if ($arComponentDescription["CACHE_PATH"] == "Y") { $path = "/" . SITE_ID . $path; } if (!empty($path)) { BXClearCache(true, $path); } } if (!empty($arResult["MESSAGE"]["AUTHOR_EMAIL"])) { $event = new CEvent(); $arSiteInfo = $event->GetSiteFieldsArray(SITE_ID); $arFields = array("FROM_NAME" => $arResult["MESSAGE"]["~RECIPIENT_NAME"], "FROM_USER_ID" => $USER->GetId(), "FROM_EMAIL" => $arSiteInfo["DEFAULT_EMAIL_FROM"], "TO_NAME" => $arResult["MESSAGE"]["~AUTHOR_NAME"], "TO_USER_ID" => $arResult["MESSAGE"]["AUTHOR_ID"], "TO_EMAIL" => $arResult["MESSAGE"]["AUTHOR_EMAIL"], "SUBJECT" => $arNotification["POST_SUBJ"], "MESSAGE" => $parser->convert4mail($arNotification["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" => $newMID)) . "\n"); if ($event->Send("NEW_FORUM_PRIVATE_MESSAGE", SITE_ID, $arFields)) { $arOK[] = array("id" => "send", "text" => GetMessage("PM_NOTIFICATION_SEND")); $arrVars = array("REQUEST_IS_READ" => "N"); CForumPrivateMessage::Update($arResult["MESSAGE"]["ID"], $arrVars); } } } } if (empty($arError)) { if (!empty($next)) { LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_PM_READ"], array("FID" => $arParams["FID"], "MID" => $next["ID"]))); } else { LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_PM_LIST"], array("FID" => $arParams["FID"]))); } } if (!empty($arError)) { $e = new CAdminException(array_reverse($arError)); $GLOBALS["APPLICATION"]->ThrowException($e); $err = $GLOBALS['APPLICATION']->GetException();