public static function Update($ID, $arFields) { global $DB; $ID = IntVal($ID); $arFields1 = array(); foreach ($arFields as $key => $value) { if (substr($key, 0, 1) == "=") { $arFields1[substr($key, 1)] = $value; unset($arFields[$key]); } } if (!CBlogCandidate::CheckFields("UPDATE", $arFields, $ID)) { return false; } $strUpdate = $DB->PrepareUpdate("b_blog_user2blog", $arFields); foreach ($arFields1 as $key => $value) { if (strlen($strUpdate) > 0) { $strUpdate .= ", "; } $strUpdate .= $key . "=" . $value . " "; } if (strlen($strUpdate) > 0) { $strSql = "UPDATE b_blog_user2blog SET " . "\t" . $strUpdate . " " . "WHERE ID = " . $ID . " "; $DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__); unset($GLOBALS["BLOG_CANDIDATE"]["BLOG_CANDIDATE_CACHE_" . $ID]); return $ID; } return False; }
$arResult["Post"] = $arPost; $arResult["PostPerm"] = CBlogPost::GetBlogUserPostPerms($arParams["ID"], $arResult["USER_ID"]); if ($arPost["AUTHOR_ID"] == $arBlog["OWNER_ID"]) { $arResult["urlToBlog"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_BLOG"], array("blog" => $arBlog["URL"], "user_id" => $arPost["AUTHOR_ID"])); } else { $arOwnerBlog = CBlog::GetByOwnerID($arPost["AUTHOR_ID"], $arParams["GROUP_ID"]); $arResult["urlToBlog"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_BLOG"], array("blog" => $arOwnerBlog["URL"], "user_id" => $arPost["AUTHOR_ID"])); } $arResult["urlToPost"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_POST"], array("blog" => $arBlog["URL"], "post_id" => CBlogPost::GetPostID($arResult["Post"]["ID"], $arResult["Post"]["CODE"], $arParams["ALLOW_POST_CODE"]), "user_id" => $arPost["AUTHOR_ID"])); if ($_GET["become_friend"] == "Y" && $arResult["PostPerm"] < BLOG_PERMS_READ) { if ($USER->IsAuthorized()) { $dbCandidate = CBlogCandidate::GetList(array(), array("BLOG_ID" => $arBlog["ID"], "USER_ID" => $arResult["USER_ID"])); if ($arCandidate = $dbCandidate->Fetch()) { $arResult["MESSAGE"] = GetMessage("B_B_MES_REQUEST_ALREADY") . "<br />"; } else { if (CBlogCandidate::Add(array("BLOG_ID" => $arBlog["ID"], "USER_ID" => $arResult["USER_ID"]))) { $arResult["MESSAGE"] = GetMessage("B_B_MES_REQUEST_ADDED") . "<br />"; $BlogUser = CBlogUser::GetByID($user_id, BLOG_BY_USER_ID); $BlogUser = CBlogTools::htmlspecialcharsExArray($BlogUser); $dbUser = CUser::GetByID($user_id); $arUser = $dbUser->GetNext(); $AuthorName = CBlogUser::GetUserName($BlogUser["ALIAS"], $arUser["NAME"], $arUser["LAST_NAME"], $arUser["LOGIN"]); $dbUser = CUser::GetByID($arResult["BLOG"]["OWNER_ID"]); $arUserBlog = $dbUser->GetNext(); if (strlen($serverName) <= 0) { if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0) { $serverName = SITE_SERVER_NAME; } else { $serverName = COption::GetOptionString("main", "server_name", ""); } if (strlen($serverName) <= 0) {
$arF1 = $arF2 = $arMailFields; $arF1["EMAIL_TO"] = $arUserBlog["EMAIL"]; $arF2["EMAIL_TO"] = $arUser["EMAIL"]; CEvent::Send("BLOG_YOUR_BLOG_TO_USER", SITE_ID, $arF1); CEvent::Send("BLOG_BLOG_TO_YOU", SITE_ID, $arF2); } else { $frnd_er = 2; } } } } } elseif ($_GET["become_friend"] == "N") { CBlogUser::DeleteFromUserGroup($user_id, $arResult["BLOG"]["ID"], BLOG_BY_USER_ID); $dbCandidate = CBlogCandidate::GetList(array(), array("BLOG_ID" => $arResult["BLOG"]["ID"], "USER_ID" => $user_id)); if ($arCandidate = $dbCandidate->Fetch()) { CBlogCandidate::Delete($arCandidate["ID"]); } $frnd_ok = 7; } } else { $arResult["ERROR_MESSAGE"][] = GetMessage("BLOG_BLOG_BLOG_NO_BLOG"); CHTTP::SetStatus("404 Not Found"); } if (IntVal($frnd_er) > 0) { LocalRedirect($APPLICATION->GetCurPageParam("frnd_res_er=" . $frnd_er, array("frnd_res_er", "sessid", "frnd_res_ok"))); } elseif (IntVal($frnd_ok) > 0) { LocalRedirect($APPLICATION->GetCurPageParam("frnd_res_ok=" . $frnd_ok, array("frnd_res_er", "sessid", "frnd_res_ok"))); } } elseif (intval($_GET["frnd_res_er"]) > 0 || intval($_GET["frnd_res_ok"]) > 0) { if (intval($_GET["frnd_res_er"]) > 0) { switch (IntVal($_GET["frnd_res_er"])) {
} } } } else { $errorMessage .= GetMessage("BLOG_BLOG_SESSID_WRONG") . "<br />"; } } $arResult["ERROR_MESSAGE"] = $errorMessage; $arResult["OK_MESSAGE"] = $okMessage; $canUseAlias = COption::GetOptionString("blog", "allow_alias", "Y"); if ($canUseAlias == "Y") { $arOrderBy = array("ALIAS" => "ASC", "USER_LAST_NAME" => "ASC", "USER_NAME" => "ASC"); } else { $arOrderBy = array("USER_LAST_NAME" => "ASC", "USER_NAME" => "ASC"); } $dbUsers = CBlogCandidate::GetList($arOrderBy, array("BLOG_ID" => $arBlog["ID"]), false, false, array("ID", "USER_ID", "BLOG_USER_ALIAS", "USER_LOGIN", "USER_NAME", "USER_LAST_NAME")); $arResult["Candidate"] = array(); while ($arUsers = $dbUsers->GetNext()) { $arUsers["urlToUser"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arUsers["USER_ID"])); $arUsers["NameFormated"] = CBlogUser::GetUserName($arUsers["BLOG_USER_ALIAS"], $arUsers["USER_NAME"], $arUsers["USER_LAST_NAME"], $arUsers["USER_LOGIN"]); $arUsers["urlToEdit"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER_SETTINGS_EDIT"], array("user_id" => $arUsers["USER_ID"], "blog" => $arBlog["URL"])); $arUsers["urlToDelete"] = htmlspecialcharsex($APPLICATION->GetCurPageParam("del_id=" . $arUsers["USER_ID"] . '&' . bitrix_sessid_get(), array("del_id", "sessid"))); $arResult["Candidate"][] = $arUsers; } $dbUsers = CBlogUser::GetList($arOrderBy, array("GROUP_BLOG_ID" => $arBlog["ID"]), array("ID", "USER_ID", "ALIAS", "USER_LOGIN", "USER_NAME", "USER_LAST_NAME")); $arResult["Users"] = array(); while ($arUsers = $dbUsers->GetNext()) { $arUsers["urlToUser"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arUsers["USER_ID"])); $arUsers["NameFormated"] = CBlogUser::GetUserName($arUsers["BLOG_USER_ALIAS"], $arUsers["USER_NAME"], $arUsers["USER_LAST_NAME"], $arUsers["USER_LOGIN"]); $arUsers["urlToEdit"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER_SETTINGS_EDIT"], array("user_id" => $arUsers["USER_ID"], "blog" => $arBlog["URL"])); $arUsers["urlToDelete"] = htmlspecialcharsex($APPLICATION->GetCurPageParam("del_id=" . $arUsers["USER_ID"] . '&' . bitrix_sessid_get(), array("del_id", "sessid")));
$USER_ID = $USER->GetID(); $PostPerm = CBlogPost::GetBlogUserPostPerms($ID, $USER_ID); $arPost = CBlogPost::GetByID($ID); $arBlog = CBlog::GetByID($arPost["BLOG_ID"]); $dbBlog = CBlog::GetList(array(), array("URL" => $BLOG_URL), false, array("nTopCount" => 1)); if (($arBlogUrl = $dbBlog->Fetch()) || strlen($BLOG_URL) <= 0) { $APPLICATION->SetTitle($arPost["TITLE"]); $APPLICATION->AddChainItem($arBlogUrl["NAME"], CBlog::PreparePath($arBlogUrl["URL"])); //Заявка на чтение блога if ($_GET["become_friend"] == "Y" && $PostPerm < BLOG_PERMS_READ) { if ($USER->IsAuthorized()) { $dbCandidate = CBlogCandidate::GetList(array(), array("BLOG_ID" => $arBlog["ID"], "USER_ID" => $USER_ID)); if ($arCandidate = $dbCandidate->Fetch()) { echo '<font class="text">' . GetMessage("B_B_MES_REQUEST_ALREADY") . '</font>'; } else { if (CBlogCandidate::Add(array("BLOG_ID" => $arBlog["ID"], "USER_ID" => $USER_ID))) { echo '<font class="text">' . GetMessage("B_B_MES_REQUEST_ADDED") . '</font>'; } else { echo ShowError(GetMessage("B_B_MES_REQUEST_ERROR")); } } } else { echo '<font class="text">' . GetMessage("B_B_MES_REQUEST_AUTH") . '</font>'; } } if ($PostPerm > BLOG_PERMS_DENY) { if (!empty($arPost) && ($arBlogUrl["ID"] == $arBlog["ID"] || strlen($BLOG_URL) <= 0)) { if ($arPost["PUBLISH_STATUS"] == "P" || $PostPerm == BLOG_PERMS_FULL || $arPost["AUTHOR_ID"] == $USER_ID) { $cache = new CPHPCache(); $cache_id = "blog_message_" . serialize($arParams) . "_" . $PostPerm; $cache_path = "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/post/" . $arPost["ID"] . "/";
} } } if (count($arUserID) <= 0) { $dbSearchUser = CUser::GetList($b = "", $o = "", array("NAME" => $friend)); while ($arSearchUser = $dbSearchUser->Fetch()) { $arUserID[] = $arSearchUser["ID"]; } } if (count($arUserID) > 0) { for ($i = 0; $i < count($arUserID); $i++) { $dbCandidate = CBlogCandidate::GetList(array(), array("BLOG_ID" => $arBlog["ID"], "USER_ID" => $arUserID[$i])); if ($dbCandidate->Fetch()) { $okMessage .= str_replace("#NAME#", "[" . $arUserID[$i] . "] " . $friend, GetMessage("BLOG_BLOG_ADD_F_POS_ALREADY_WANT")) . ".<br>"; } else { if (CBlogCandidate::Add(array("BLOG_ID" => $arBlog["ID"], "USER_ID" => $arUserID[$i]))) { $okMessage .= str_replace("#NAME#", "[" . $arUserID[$i] . "] " . $friend, GetMessage("BLOG_BLOG_ADD_F_POS_ADDED")) . ".<br>"; } else { $errorMessage .= str_replace("#NAME#", "[" . $arUserID[$i] . "] " . $friend, GetMessage("BLOG_BLOG_ADD_F_POS_ADD_ERROR")) . ".<br>"; } } } } else { $errorMessage .= str_replace("#NAME#", $friend, GetMessage("BLOG_BLOG_ADD_F_POS_NOT_FOUND")) . ".<br>"; } } } } $sessKey = randString(10); $_SESSION[$sessKey] = array(); $_SESSION[$sessKey]["ERROR"] = $errorMessage;