public static function Add($arFields) { global $DB; $arFields1 = array(); foreach ($arFields as $key => $value) { if (substr($key, 0, 1) == "=") { $arFields1[substr($key, 1)] = $value; unset($arFields[$key]); } } if (!CBlogCandidate::CheckFields("ADD", $arFields)) { return false; } $arInsert = $DB->PrepareInsert("b_blog_user2blog", $arFields); foreach ($arFields1 as $key => $value) { if (strlen($arInsert[0]) > 0) { $arInsert[0] .= ", "; } $arInsert[0] .= $key; if (strlen($arInsert[1]) > 0) { $arInsert[1] .= ", "; } $arInsert[1] .= $value; } $ID = False; if (strlen($arInsert[0]) > 0) { $strSql = "INSERT INTO b_blog_user2blog(" . $arInsert[0] . ") " . "VALUES(" . $arInsert[1] . ")"; $DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__); $ID = IntVal($DB->LastID()); } if ($ID) { $arCandidat = CBlogCandidate::GetByID($ID); if ($arCandidat) { $arBlog = CBlog::GetByID($arCandidat["BLOG_ID"]); if (strlen($arBlog["AUTO_GROUPS"]) > 0) { $arAutoGroups = unserialize($arBlog["AUTO_GROUPS"]); if (is_array($arAutoGroups) && count($arAutoGroups) > 0) { $arBlogUser = CBlogUser::GetByID($arCandidat["USER_ID"], BLOG_BY_USER_ID); if (!$arBlogUser) { CBlogUser::Add(array("USER_ID" => $arCandidat["USER_ID"], "=LAST_VISIT" => $GLOBALS["DB"]->GetNowFunction(), "=DATE_REG" => $GLOBALS["DB"]->GetNowFunction(), "ALLOW_POST" => "Y")); } CBlogUser::AddToUserGroup($arCandidat["USER_ID"], $arCandidat["BLOG_ID"], $arAutoGroups, "", BLOG_BY_USER_ID, BLOG_CHANGE); CBlogCandidate::Delete($ID); } } } } return $ID; }