} foreach ($arEventID as $event_id) { $arFields["EVENT_ID"] = $event_id; $dbResultTmp = CSocNetLogEvents::GetList(array(), $arFields, false, false, array("ID", "TRANSPORT")); $arFieldsSet = array_merge($arFields, $arFieldsVal); if ($arResultTmp = $dbResultTmp->Fetch()) { if ($arFieldsVal["TRANSPORT"] == "I") { CSocNetLogEvents::Delete($arResultTmp["ID"]); } else { $idTmp = CSocNetLogEvents::Update($arResultTmp["ID"], $arFieldsSet); } } elseif ($arFieldsVal["TRANSPORT"] != "I") { if (!array_key_exists("TRANSPORT", $arFieldsSet)) { $arFieldsSet["TRANSPORT"] = "I"; } $idTmp = CSocNetLogEvents::Add($arFieldsSet); } } } } } } elseif ($action == "change_follow" && $GLOBALS["USER"]->IsAuthorized()) { if ($strRes = CSocNetLogFollow::Set($GLOBALS["USER"]->GetID(), "L" . intval($_REQUEST["log_id"]), $_REQUEST["follow"] == "Y" ? "Y" : "N")) { $arResult["SUCCESS"] = "Y"; } else { $arResult["SUCCESS"] = "N"; } } header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET); echo CUtil::PhpToJSObject($arResult); }
public static function Subscribe($USER_ID) { CModule::IncludeModule("socialnetwork"); $arManagers = CTimeMan::GetUserManagers($USER_ID); $arManagers[] = $USER_ID; $arManagers = array_unique($arManagers); if (is_array($arManagers) && count($arManagers) > 0) { foreach ($arManagers as $mID) { $dbEvents = CSocNetLogEvents::GetList(array(), array("USER_ID" => $mID, "EVENT_ID" => "report", "ENTITY_ID" => $USER_ID)); if (!($event = $dbEvents->Fetch())) { $arFields = array("USER_ID" => $mID, "ENTITY_TYPE" => "R", "ENTITY_ID" => $USER_ID, "EVENT_ID" => "report", "TRANSPORT" => "X", "VISIBLE" => "I"); CSocNetLogEvents::Add($arFields); $arFields["EVENT_ID"] = "report_comment"; CSocNetLogEvents::Add($arFields); } } } }
$arLogEvent = array("USER_ID" => $arResult["USER_ID"], "ENTITY_TYPE" => $arResult["ENTITY_TYPE"], "ENTITY_ID" => $arResult["ENTITY_ID"], "ENTITY_CB" => $arResult["ENTITY_CB"], "ENTITY_MY" => $arResult["ENTITY_MY"], "MAIL_EVENT" => $arResult["MAIL_EVENT"], "TRANSPORT" => $arResult["TRANSPORT"], "VISIBLE" => $arResult["VISIBLE"]); if (strlen($arResult["SITE_ID"]) > 0) { $arLogEvent["SITE_ID"] = $arResult["SITE_ID"]; } else { $arLogEvent["SITE_ID"] = false; } $arLogEventToAdd = array_merge($arLogEvent, array("EVENT_ID" => "blog_post")); CSocNetLogEvents::Add($arLogEventToAdd); $arLogEventToAdd = array_merge($arLogEvent, array("EVENT_ID" => "blog_comment")); CSocNetLogEvents::Add($arLogEventToAdd); $arLogEventToAdd = array_merge($arLogEvent, array("EVENT_ID" => "blog_post_micro")); CSocNetLogEvents::Add($arLogEventToAdd); } // set system_friends and system_groups for user system $dbResult = CSocNetLogEvents::GetList(array("ENTITY_ID" => "DESC"), array("ENTITY_TYPE" => "U", "EVENT_ID" => array("system_friends", "system_groups")), false, false, array("ID")); while ($arResult = $dbResult->Fetch()) { CSocNetLogEvents::Delete($arResult["ID"]); } $dbResult = CSocNetLogEvents::GetList(array("ENTITY_ID" => "DESC"), array("ENTITY_TYPE" => "U", "EVENT_ID" => "system")); while ($arResult = $dbResult->Fetch()) { $arLogEvent = array("USER_ID" => $arResult["USER_ID"], "ENTITY_TYPE" => $arResult["ENTITY_TYPE"], "ENTITY_ID" => $arResult["ENTITY_ID"], "ENTITY_CB" => $arResult["ENTITY_CB"], "ENTITY_MY" => $arResult["ENTITY_MY"], "MAIL_EVENT" => $arResult["MAIL_EVENT"], "TRANSPORT" => $arResult["TRANSPORT"], "VISIBLE" => $arResult["VISIBLE"]); if (strlen($arResult["SITE_ID"]) > 0) { $arLogEvent["SITE_ID"] = $arResult["SITE_ID"]; } else { $arLogEvent["SITE_ID"] = false; } $arLogEventToAdd = array_merge($arLogEvent, array("EVENT_ID" => "system_friends")); CSocNetLogEvents::Add($arLogEventToAdd); $arLogEventToAdd = array_merge($arLogEvent, array("EVENT_ID" => "system_groups")); CSocNetLogEvents::Add($arLogEventToAdd); }
} if (!$bFound) { $arEventID = array($event_id_tmp); } foreach ($arEventID as $event_id) { if ($subscribe_transport != "I" || $subscribe_visible != "I") { $idTmp = CSocNetLogEvents::Add(array("USER_ID" => $GLOBALS["USER"]->GetID(), "ENTITY_TYPE" => $arParams["ENTITY_TYPE"], "ENTITY_ID" => $arParams["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP ? $arResult["Group"]["ID"] : $arResult["User"]["ID"], "ENTITY_CB" => "N", "EVENT_ID" => $event_id, "SITE_ID" => array_key_exists("HAS_SITE_ID", $arSocNetAllowedSubscribeEntityTypesDesc[$arParams["ENTITY_TYPE"]]) && $arSocNetAllowedSubscribeEntityTypesDesc[$arParams["ENTITY_TYPE"]]["HAS_SITE_ID"] == "Y" && defined("SITE_ID") && strlen(SITE_ID) > 0 ? SITE_ID : false, "MAIL_EVENT" => $_REQUEST[$event_id_tmp . "_active"] == "M" ? "Y" : "N", "TRANSPORT" => $subscribe_transport, "VISIBLE" => $subscribe_visible)); if (!$idTmp) { if ($e = $APPLICATION->GetException()) { $errorMessage .= $e->GetString(); } break; } } if (array_key_exists("TransportCB", $arEventTmp) && ($subscribe_transport_cb != "I" || $subscribe_visible_cb != "I")) { $idTmp = CSocNetLogEvents::Add(array("USER_ID" => $GLOBALS["USER"]->GetID(), "ENTITY_TYPE" => $arParams["ENTITY_TYPE"], "ENTITY_ID" => $arParams["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP ? $arResult["Group"]["ID"] : $arResult["User"]["ID"], "ENTITY_CB" => "Y", "EVENT_ID" => $event_id, "SITE_ID" => $arParams["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP && defined("SITE_ID") && strlen(SITE_ID) > 0 ? SITE_ID : false, "MAIL_EVENT" => $_REQUEST[$event_id_tmp . "_active"] == "M" ? "Y" : "N", "TRANSPORT" => $subscribe_transport_cb, "VISIBLE" => $subscribe_visible_cb)); if (!$idTmp) { if ($e = $APPLICATION->GetException()) { $errorMessage .= $e->GetString(); } break; } } } if (strlen($errorMessage) > 0) { break; } } if (strlen($errorMessage) > 0) { $arResult["ErrorMessage"] = $errorMessage; } else {
function AutoSubscribe($userID, $entityType, $entityID) { $dbRes = CSocNetLogEvents::GetList(array(), array("USER_ID" => $userID, "ENTITY_TYPE" => $entityType, "ENTITY_ID" => $entityID)); if ($dbRes->Fetch()) { return; } $SiteID = false; if ($entityType == SONET_SUBSCRIBE_ENTITY_GROUP) { if ($arGroupTmp = CSocNetGroup::GetByID($entityID)) { $SiteID = $arGroupTmp["SITE_ID"]; } } $arLogEvent = array("USER_ID" => $userID, "ENTITY_TYPE" => $entityType, "ENTITY_ID" => $entityID, "EVENT_ID" => 'system', "SITE_ID" => $SiteID); CSocNetLogEvents::Add($arLogEvent); if ($entityType == SONET_SUBSCRIBE_ENTITY_USER) { $arLogEvent = array("USER_ID" => $userID, "ENTITY_TYPE" => $entityType, "ENTITY_ID" => $entityID, "EVENT_ID" => 'system_friends', "SITE_ID" => $SiteID, "MAIL_EVENT" => "Y"); CSocNetLogEvents::Add($arLogEvent); } $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures(); foreach ($arSocNetFeaturesSettings as $key => $value) { $arLogEvent = array("USER_ID" => $userID, "ENTITY_TYPE" => $entityType, "ENTITY_ID" => $entityID, "EVENT_ID" => $key, "SITE_ID" => $SiteID, "MAIL_EVENT" => "Y"); CSocNetLogEvents::Add($arLogEvent); } }