18 $GLOBALS[
"APPLICATION"]->ThrowException(
"System error 870164",
"ERROR");
24 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_EMPTY_FIRST_USER_ID"),
"EMPTY_FIRST_USER_ID");
32 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_ERROR_NO_FIRST_USER_ID"),
"ERROR_NO_FIRST_USER_ID");
39 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_EMPTY_SECOND_USER_ID"),
"EMPTY_SECOND_USER_ID");
47 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_ERROR_NO_SECOND_USER_ID"),
"ERROR_NO_SECOND_USER_ID");
54 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_EMPTY_RELATION"),
"EMPTY_RELATION");
59 $GLOBALS[
"APPLICATION"]->ThrowException(str_replace(
"#ID#",
$arFields[
"RELATION"],
GetMessage(
"SONET_UR_ERROR_NO_RELATION")),
"ERROR_NO_RELATION");
64 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_ERROR_RELATION_FRIENDS2"),
"ERROR_RELATION_FRIENDS2");
73 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_EMPTY_DATE_CREATE"),
"EMPTY_DATE_CREATE");
79 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_EMPTY_DATE_UPDATE"),
"EMPTY_DATE_UPDATE");
90 if (!CSocNetGroup::__ValidateID(
$ID))
96 $rsUser2UserOld =
$DB->Query(
"SELECT * FROM b_sonet_user_relations WHERE ID = ".
$ID.
"");
97 if($arUser2UserOld = $rsUser2UserOld->Fetch())
103 $db_events =
GetModuleEvents(
"socialnetwork",
"OnBeforeSocNetUserRelationsDelete");
104 while ($arEvent = $db_events->Fetch())
108 $events =
GetModuleEvents(
"socialnetwork",
"OnSocNetUserRelationsDelete");
109 while ($arEvent = $events->Fetch())
115 $bSuccess =
$DB->Query(
"DELETE FROM b_sonet_user_relations WHERE ID = ".
$ID.
"",
true);
121 $GLOBALS[
"DB"]->Query(
"DELETE FROM b_sonet_event_user_view WHERE
124 (USER_ID = ".$arRelation[
"FIRST_USER_ID"].
" AND ENTITY_ID = ".$arRelation[
"SECOND_USER_ID"].
")
125 OR (USER_ID = ".$arRelation[
"SECOND_USER_ID"].
" AND ENTITY_ID = ".$arRelation[
"FIRST_USER_ID"].
")
126 OR (ENTITY_ID = ".$arRelation[
"FIRST_USER_ID"].
" AND USER_IM_ID = ".$arRelation[
"SECOND_USER_ID"].
")
127 OR (ENTITY_ID = ".$arRelation[
"SECOND_USER_ID"].
" AND USER_IM_ID = ".$arRelation[
"FIRST_USER_ID"].
")
128 OR (USER_ID = ".$arRelation[
"FIRST_USER_ID"].
" AND USER_IM_ID = ".$arRelation[
"SECOND_USER_ID"].
")
129 OR (USER_ID = ".$arRelation[
"SECOND_USER_ID"].
" AND USER_IM_ID = ".$arRelation[
"FIRST_USER_ID"].
")
140 if (!CSocNetGroup::__ValidateID($userID))
143 $userID = intval($userID);
146 $rsUser2UserOld =
$DB->Query(
"SELECT * FROM b_sonet_user_relations WHERE FIRST_USER_ID = ".$userID.
" OR SECOND_USER_ID = ".$userID.
"");
147 while($arUser2UserOld = $rsUser2UserOld->Fetch())
154 $bSuccess =
$DB->Query(
"DELETE FROM b_sonet_user_relations WHERE FIRST_USER_ID = ".$userID.
" OR SECOND_USER_ID = ".$userID.
"",
true);
157 $DB->Query(
"DELETE FROM b_sonet_event_user_view WHERE
160 USER_ID = ".$userID.
"
161 OR ENTITY_ID = ".$userID.
"
162 OR USER_IM_ID = ".$userID.
"
177 if (!CSocNetGroup::__ValidateID(
$ID))
195 $user1ID = intval($user1ID);
198 $user2ID = intval($user2ID);
203 "SELECT ID, FIRST_USER_ID, SECOND_USER_ID, RELATION, DATE_CREATE, DATE_UPDATE, MESSAGE, INITIATED_BY ".
204 "FROM b_sonet_user_relations ".
205 "WHERE FIRST_USER_ID = ".$user1ID.
" AND SECOND_USER_ID = ".$user2ID.
" ".
206 " OR FIRST_USER_ID = ".$user2ID.
" AND SECOND_USER_ID = ".$user1ID.
" ";
215 public static function GetRelatedUsers($userID, $relation, $arNavStartParams =
false, $bActiveOnly =
"N")
219 $userID = intval($userID);
226 if (is_array($arNavStartParams) && intval($arNavStartParams[
"nTopCount"]) > 0)
232 "DATE_UPDATE" =>
"DESC"
238 "USER_ID" => $userID,
239 "RELATION" => $relation,
240 "ACTIVE_ONLY" => $bActiveOnly
244 array(
"ID",
"FIRST_USER_ID",
"SECOND_USER_ID",
"DATE_CREATE",
"DATE_UPDATE",
"INITIATED_BY",
245 "FIRST_USER_NAME",
"FIRST_USER_LAST_NAME",
"FIRST_USER_PERSONAL_PHOTO",
"FIRST_USER_PERSONAL_GENDER",
"FIRST_USER_SECOND_NAME",
"FIRST_USER_LOGIN",
"FIRST_USER_EMAIL",
"FIRST_USER_IS_ONLINE",
246 "SECOND_USER_NAME",
"SECOND_USER_LAST_NAME",
"SECOND_USER_PERSONAL_PHOTO",
"SECOND_USER_PERSONAL_GENDER",
"SECOND_USER_SECOND_NAME",
"SECOND_USER_LOGIN",
"SECOND_USER_EMAIL",
"SECOND_USER_IS_ONLINE"
260 static $arSocNetURNCache =
array();
261 static $arSocNetUserRelationsCache1 =
array();
263 $firstUserID = intval($firstUserID);
264 if ($firstUserID <= 0)
269 $secondUserID = intval($secondUserID);
270 if ($secondUserID <= 0)
275 if (array_key_exists($firstUserID, $arSocNetURNCache))
277 if (array_key_exists($secondUserID, $arSocNetURNCache[$firstUserID]))
279 return $arSocNetURNCache[$firstUserID][$secondUserID];
281 elseif(
count($arSocNetURNCache[$firstUserID]) != 100)
286 elseif (array_key_exists($secondUserID, $arSocNetURNCache))
288 if (array_key_exists($firstUserID, $arSocNetURNCache[$secondUserID]))
290 return $arSocNetURNCache[$secondUserID][$firstUserID];
292 elseif(
count($arSocNetURNCache[$secondUserID]) != 100)
299 $arSocNetURNCache[$firstUserID] =
array();
303 if (
$arResult[
"FIRST_USER_ID"] == $firstUserID)
314 $arSocNetURNCache[$secondUserID] =
array();
318 if (
$arResult[
"FIRST_USER_ID"] == $secondUserID)
320 $arSocNetURNCache[$secondUserID][
$arResult[
"SECOND_USER_ID"]] =
$arResult[
"RELATION"];
328 if (!array_key_exists($firstUserID.
"_".$secondUserID, $arSocNetUserRelationsCache1))
331 "SELECT UR.RELATION ".
332 "FROM b_sonet_user_relations UR ".
333 "WHERE UR.FIRST_USER_ID = ".$firstUserID.
" ".
334 " AND UR.SECOND_USER_ID = ".$secondUserID.
" ".
336 "SELECT UR.RELATION ".
337 "FROM b_sonet_user_relations UR ".
338 "WHERE UR.FIRST_USER_ID = ".$secondUserID.
" ".
339 " AND UR.SECOND_USER_ID = ".$firstUserID.
" ";
344 $arSocNetUserRelationsCache1[$firstUserID.
"_".$secondUserID] =
$arResult[
"RELATION"];
348 $arSocNetUserRelationsCache1[$firstUserID.
"_".$secondUserID] =
false;
352 return $arSocNetUserRelationsCache1[$firstUserID.
"_".$secondUserID];
355 public static function IsFriends($firstUserID, $secondUserID)
358 static $arSocNetUserRelationsCache =
array();
360 $firstUserID = intval($firstUserID);
361 if ($firstUserID <= 0)
366 $secondUserID = intval($secondUserID);
367 if ($secondUserID <= 0)
372 if (!array_key_exists($firstUserID.
"_".$secondUserID, $arSocNetUserRelationsCache))
376 "FROM b_sonet_user_relations UR ".
377 "WHERE UR.FIRST_USER_ID = ".$firstUserID.
" ".
378 " AND UR.SECOND_USER_ID = ".$secondUserID.
" ".
382 "FROM b_sonet_user_relations UR ".
383 "WHERE UR.FIRST_USER_ID = ".$secondUserID.
" ".
384 " AND UR.SECOND_USER_ID = ".$firstUserID.
" ".
390 $arSocNetUserRelationsCache[$firstUserID.
"_".$secondUserID] =
true;
394 $arSocNetUserRelationsCache[$firstUserID.
"_".$secondUserID] =
false;
398 return $arSocNetUserRelationsCache[$firstUserID.
"_".$secondUserID];
401 public static function IsFriends2($firstUserID, $secondUserID)
404 static $arSocNetUser2RelationsCache =
array();
406 $firstUserID = intval($firstUserID);
407 if ($firstUserID <= 0)
412 $secondUserID = intval($secondUserID);
413 if ($secondUserID <= 0)
418 if (!array_key_exists($firstUserID.
"_".$secondUserID, $arSocNetUser2RelationsCache))
422 "FROM b_sonet_user_relations UR, b_sonet_user_relations UR1 ".
423 "WHERE UR.FIRST_USER_ID = ".$firstUserID.
" ".
424 " AND UR.SECOND_USER_ID = UR1.FIRST_USER_ID ".
426 " AND UR1.SECOND_USER_ID = ".$secondUserID.
" ".
430 "FROM b_sonet_user_relations UR, b_sonet_user_relations UR1 ".
431 "WHERE UR.FIRST_USER_ID = ".$firstUserID.
" ".
432 " AND UR.SECOND_USER_ID = UR1.SECOND_USER_ID ".
434 " AND UR1.FIRST_USER_ID = ".$secondUserID.
" ".
438 "FROM b_sonet_user_relations UR, b_sonet_user_relations UR1 ".
439 "WHERE UR.SECOND_USER_ID = ".$firstUserID.
" ".
440 " AND UR.FIRST_USER_ID = UR1.FIRST_USER_ID ".
442 " AND UR1.SECOND_USER_ID = ".$secondUserID.
" ".
446 "FROM b_sonet_user_relations UR, b_sonet_user_relations UR1 ".
447 "WHERE UR.SECOND_USER_ID = ".$firstUserID.
" ".
448 " AND UR.FIRST_USER_ID = UR1.SECOND_USER_ID ".
450 " AND UR1.FIRST_USER_ID = ".$secondUserID.
" ".
456 $arSocNetUser2RelationsCache[$firstUserID.
"_".$secondUserID] =
true;
460 $arSocNetUser2RelationsCache[$firstUserID.
"_".$secondUserID] =
false;
464 return $arSocNetUser2RelationsCache[$firstUserID.
"_".$secondUserID];
470 public static function SendEvent($relationID, $mailType =
"INVITE_FRIEND")
472 $relationID = intval($relationID);
473 if ($relationID <= 0)
478 array(
"ID" => $relationID),
481 array(
"ID",
"FIRST_USER_ID",
"SECOND_USER_ID",
"RELATION",
"DATE_CREATE",
"MESSAGE",
"INITIATED_BY",
"FIRST_USER_NAME",
"FIRST_USER_LAST_NAME",
"FIRST_USER_LOGIN",
"FIRST_USER_EMAIL",
"FIRST_USER_LID",
"SECOND_USER_NAME",
"SECOND_USER_LAST_NAME",
"SECOND_USER_LOGIN",
"SECOND_USER_EMAIL",
"SECOND_USER_LID")
483 $arRelation = $dbRelation->Fetch();
487 $fromUserPref =
"FIRST";
488 $toUserPref =
"SECOND";
489 if ($arRelation[
"INITIATED_BY"] ==
"S")
491 $fromUserPref =
"SECOND";
492 $toUserPref =
"FIRST";
495 $mailTemplate =
"SONET_INVITE_FRIEND";
496 if ($mailType ==
"AGREE_FRIEND")
497 $mailTemplate =
"SONET_AGREE_FRIEND";
498 elseif ($mailType ==
"BAN_FRIEND")
499 $mailTemplate =
"SONET_BAN_FRIEND";
501 $defSiteID = $arRelation[$toUserPref.
"_USER_LID"];
508 $url = str_replace(
"#USER_ID#", $arRelation[$toUserPref.
"_USER_ID"], COption::GetOptionString(
"socialnetwork",
"user_request_page",
509 (
IsModuleInstalled(
"intranet")) ?
"/company/personal/user/#USER_ID#/requests/" :
"/club/user/#USER_ID#/requests/",
$siteID));
512 $url = COption::GetOptionString(
"socialnetwork",
"messages_path",
"/company/personal/messages/",
$siteID);
515 "RELATION_ID" => $relationID,
516 "SENDER_USER_ID" => $arRelation[$fromUserPref.
"_USER_ID"],
517 "SENDER_USER_NAME" => $arRelation[$fromUserPref.
"_USER_NAME"],
518 "SENDER_USER_LAST_NAME" => $arRelation[$fromUserPref.
"_USER_LAST_NAME"],
519 "SENDER_EMAIL_TO" => $arRelation[$fromUserPref.
"_USER_EMAIL"],
520 "RECIPIENT_USER_ID" => $arRelation[$toUserPref.
"_USER_ID"],
521 "RECIPIENT_USER_NAME" => $arRelation[$toUserPref.
"_USER_NAME"],
522 "RECIPIENT_USER_LAST_NAME" => $arRelation[$toUserPref.
"_USER_LAST_NAME"],
523 "RECIPIENT_USER_EMAIL_TO" => $arRelation[$toUserPref.
"_USER_EMAIL"],
524 "MESSAGE" => $arRelation[
"MESSAGE"],
541 $senderUserID = intval($senderUserID);
542 if ($senderUserID <= 0)
544 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_EMPTY_SENDER_USER_ID"),
"ERROR_SENDER_USER_ID");
548 $targetUserID = intval($targetUserID);
549 if ($targetUserID <= 0)
551 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_EMPTY_TARGET_USER_ID"),
"ERROR_TARGET_USER_ID");
556 "FIRST_USER_ID" => $senderUserID,
557 "SECOND_USER_ID" => $targetUserID,
559 "=DATE_CREATE" =>
$GLOBALS[
"DB"]->CurrentTimeFunction(),
560 "=DATE_UPDATE" =>
$GLOBALS[
"DB"]->CurrentTimeFunction(),
562 "INITIATED_BY" =>
"F",
570 "FIRST_USER_ID" => $senderUserID,
571 "SECOND_USER_ID" => $targetUserID
596 if (CModule::IncludeModule(
"im"))
598 $dbSenderUser = CUser::GetByID($senderUserID);
599 $arSenderUser = $dbSenderUser->Fetch();
600 $senderUser = CUser::FormatName(CSite::GetNameFormat(), $arSenderUser,
true);
602 $arMessageFields =
array(
604 "TO_USER_ID" => (
int)$targetUserID,
605 "FROM_USER_ID" => (
int)$senderUserID,
607 "NOTIFY_MODULE" =>
"socialnetwork",
608 "NOTIFY_EVENT" =>
"invite_user_btn",
609 "NOTIFY_TAG" =>
"SOCNET|INVITE_USER|". (
int)$targetUserID .
"|".
$ID,
610 "NOTIFY_TITLE" => Loc::getMessage(
'SONET_U_INVITE_CONFIRM_TITLE', [
"#USER#" => $senderUser]),
611 "NOTIFY_MESSAGE" => fn (?
string $languageId =
null) => Loc::getMessage(
612 'SONET_U_INVITE_CONFIRM_TEXT',
616 "NOTIFY_BUTTONS" => Array(
617 Array(
'TITLE' =>
GetMessage(
'SONET_U_INVITE_CONFIRM'),
'VALUE' =>
'Y',
'TYPE' =>
'accept'),
618 Array(
'TITLE' =>
GetMessage(
'SONET_U_INVITE_REJECT'),
'VALUE' =>
'N',
'TYPE' =>
'cancel'),
622 $dbSite = CSite::GetByID(
SITE_ID);
623 $arSite = $dbSite->Fetch();
625 if ($serverName ==
'')
627 if (defined(
"SITE_SERVER_NAME") && SITE_SERVER_NAME <>
'')
629 $serverName = SITE_SERVER_NAME;
633 $serverName = COption::GetOptionString(
"main",
"server_name",
"");
635 if ($serverName ==
'')
637 $serverName =
$_SERVER[
"SERVER_NAME"];
640 $serverName = (CMain::IsHTTPS() ?
"https" :
"http").
"://".$serverName;
642 $requestUrl = COption::GetOptionString(
"socialnetwork",
"user_request_page",
643 (
IsModuleInstalled(
"intranet")) ?
"/company/personal/user/#USER_ID#/requests/" :
"/club/user/#USER_ID#/requests/",
SITE_ID);
645 $requestUrl = $serverName.str_replace(
array(
"#USER_ID#",
"#user_id#"), $targetUserID, $requestUrl);
647 $arMessageFields[
'NOTIFY_MESSAGE_OUT'] = fn (?
string $languageId =
null) =>
649 'SONET_U_INVITE_CONFIRM_TEXT',
653 .
"\n\n".Loc::getMessage(
'SONET_U_INVITE_CONFIRM',
null, $languageId).
": ".$requestUrl.
'?INVITE_USER='.
$ID.
'&CONFIRM=Y'
654 .
"\n\n".Loc::getMessage(
'SONET_U_INVITE_REJECT',
null, $languageId).
": ".$requestUrl.
'?INVITE_USER='.
$ID.
'&CONFIRM=N'
657 CIMNotify::Add($arMessageFields);
669 $senderUserID = intval($senderUserID);
670 if ($senderUserID <= 0)
672 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_EMPTY_SENDER_USER_ID"),
"ERROR_SENDER_USER_ID");
676 $relationID = intval($relationID);
677 if ($relationID <= 0)
679 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_EMPTY_TARGET_USER_ID"),
"ERROR_RELATION_ID");
687 "SECOND_USER_ID" => $senderUserID,
692 array(
"ID",
"FIRST_USER_ID",
"SECOND_USER_ID")
697 $rsUser = CUser::GetByID(intval(
$arResult[
"FIRST_USER_ID"]));
698 $arUser = $rsUser->Fetch();
699 if (!is_array($arUser) || $arUser[
"ACTIVE"] !==
"Y")
701 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_INVALID_TARGET_USER_ID"),
"ERROR_INVALID_TARGET_USER_ID");
707 "=DATE_UPDATE" =>
$GLOBALS[
"DB"]->CurrentTimeFunction(),
708 "INITIATED_BY" =>
"S",
719 if (CModule::IncludeModule(
"im"))
721 CIMNotify::DeleteByTag(
"SOCNET|INVITE_USER|".intval($senderUserID).
"|".intval(
$arResult[
"ID"]));
722 $arMessageFields =
array(
724 "TO_USER_ID" =>
$arResult[
"FIRST_USER_ID"],
725 "FROM_USER_ID" => $senderUserID,
727 "NOTIFY_MODULE" =>
"socialnetwork",
728 "NOTIFY_EVENT" =>
"inout_user",
729 "NOTIFY_TAG" =>
"SOCNET|INVITE_USER_CONFIRM",
730 "NOTIFY_MESSAGE" => fn (?
string $languageId =
null) => Loc::getMessage(
'SONET_UR_AGREE_FRIEND_MESSAGE',
null, $languageId),
732 CIMNotify::Add($arMessageFields);
749 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_NO_FRIEND_REQUEST"),
"ERROR_NO_FRIEND_REQUEST");
759 while ($arFriends = $dbFriends->Fetch())
761 $pref = ((
$arResult[
"FIRST_USER_ID"] == $arFriends[
"FIRST_USER_ID"]) ?
"SECOND" :
"FIRST");
762 $arUserID[] =
$arResult[$pref.
"_USER_ID"];
766 while ($arFriends = $dbFriends->Fetch())
768 $pref = ((
$arResult[
"FIRST_USER_ID"] == $arFriends[
"FIRST_USER_ID"]) ?
"SECOND" :
"FIRST");
769 $arUserID[] =
$arResult[$pref.
"_USER_ID"];
772 $arUserID = array_unique($arUserID);
783 $senderUserID = intval($senderUserID);
784 if ($senderUserID <= 0)
786 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_EMPTY_SENDER_USER_ID"),
"ERROR_SENDER_USER_ID");
790 $relationID = intval($relationID);
791 if ($relationID <= 0)
793 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_EMPTY_TARGET_USER_ID"),
"ERROR_RELATION_ID");
801 "SECOND_USER_ID" => $senderUserID,
806 array(
"ID",
"FIRST_USER_ID")
813 if (CModule::IncludeModule(
"im"))
815 CIMNotify::DeleteByTag(
"SOCNET|INVITE_USER|".intval($senderUserID).
"|".intval(
$arResult[
"ID"]));
816 $arMessageFields =
array(
818 "TO_USER_ID" =>
$arResult[
"FIRST_USER_ID"],
819 "FROM_USER_ID" => $senderUserID,
821 "NOTIFY_MODULE" =>
"socialnetwork",
822 "NOTIFY_EVENT" =>
"inout_user",
823 "NOTIFY_TAG" =>
"SOCNET|INVITE_USER_REJECT",
824 "NOTIFY_MESSAGE" => fn (?
string $languageId =
null) => Loc::getMessage(
'SONET_UR_REJECT_FRIEND_MESSAGE',
null, $languageId),
826 CIMNotify::Add($arMessageFields);
843 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_NO_FRIEND_REQUEST"),
"ERROR_NO_FRIEND_REQUEST");
856 $senderUserID = intval($senderUserID);
857 if ($senderUserID <= 0)
859 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_EMPTY_SENDER_USER_ID"),
"ERROR_SENDER_USER_ID");
863 $targetUserID = intval($targetUserID);
864 if ($targetUserID <= 0)
866 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_EMPTY_TARGET_USER_ID"),
"ERROR_TARGET_USER_ID");
873 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_RELATION_NOT_FOUND"),
"ERROR_RELATION_NOT_FOUND");
879 if (CModule::IncludeModule(
"im"))
881 $rsUser = CUser::GetByID($senderUserID);
883 if ($arUser = $rsUser->Fetch())
885 $gender_suffix = match ($arUser[
"PERSONAL_GENDER"])
893 $arMessageFields =
array(
895 "FROM_USER_ID" => $senderUserID,
896 "TO_USER_ID" => $targetUserID,
898 "NOTIFY_MODULE" =>
"socialnetwork",
899 "NOTIFY_EVENT" =>
"inout_user",
900 "NOTIFY_TAG" =>
"SOCNET|FRIENDS|". (
int)$arRelation[
"ID"],
901 "NOTIFY_MESSAGE" => fn (?
string $languageId =
null) => Loc::getMessage(
"SONET_UR_IM_UNFRIEND" . $gender_suffix,
null, $languageId),
903 CIMNotify::Add($arMessageFields);
907 $GLOBALS[
"DB"]->Query(
"DELETE FROM b_sonet_event_user_view WHERE
910 (USER_ID = ".$arRelation[
"FIRST_USER_ID"].
" AND ENTITY_ID = ".$arRelation[
"SECOND_USER_ID"].
")
911 OR (USER_ID = ".$arRelation[
"SECOND_USER_ID"].
" AND ENTITY_ID = ".$arRelation[
"FIRST_USER_ID"].
")
912 OR (ENTITY_ID = ".$arRelation[
"FIRST_USER_ID"].
" AND USER_IM_ID = ".$arRelation[
"SECOND_USER_ID"].
")
913 OR (ENTITY_ID = ".$arRelation[
"SECOND_USER_ID"].
" AND USER_IM_ID = ".$arRelation[
"FIRST_USER_ID"].
")
914 OR (USER_ID = ".$arRelation[
"FIRST_USER_ID"].
" AND USER_IM_ID = ".$arRelation[
"SECOND_USER_ID"].
")
915 OR (USER_ID = ".$arRelation[
"SECOND_USER_ID"].
" AND USER_IM_ID = ".$arRelation[
"FIRST_USER_ID"].
")
935 public static function BanUser($senderUserID, $targetUserID)
939 $senderUserID = intval($senderUserID);
940 if ($senderUserID <= 0)
942 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_EMPTY_SENDER_USER_ID"),
"ERROR_SENDER_USER_ID");
946 $targetUserID = intval($targetUserID);
947 if ($targetUserID <= 0)
949 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_EMPTY_TARGET_USER_ID"),
"ERROR_TARGET_USER_ID");
952 elseif (CSocNetUser::IsUserModuleAdmin($targetUserID,
false))
954 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_ERROR_CREATE_RELATION"),
"ERROR_TARGET_USER_ID");
959 "SELECT UR.ID, UR.FIRST_USER_ID, UR.SECOND_USER_ID, UR.RELATION ".
960 "FROM b_sonet_user_relations UR ".
961 "WHERE UR.FIRST_USER_ID = ".$senderUserID.
" ".
962 " AND UR.SECOND_USER_ID = ".$targetUserID.
" ".
964 "SELECT UR.ID, UR.FIRST_USER_ID, UR.SECOND_USER_ID, UR.RELATION ".
965 "FROM b_sonet_user_relations UR ".
966 "WHERE UR.FIRST_USER_ID = ".$targetUserID.
" ".
967 " AND UR.SECOND_USER_ID = ".$senderUserID.
" ";
972 if ($arResult[
"RELATION"] != SONET_RELATIONS_BAN)
975 "RELATION" => SONET_RELATIONS_BAN,
976 "=DATE_UPDATE" => $GLOBALS[
"DB"]->CurrentTimeFunction(),
978 if ($arResult[
"FIRST_USER_ID"] == $senderUserID)
979 $arFields[
"INITIATED_BY"] =
"F";
981 $arFields[
"INITIATED_BY"] =
"S";
983 if (CSocNetUserRelations::Update($arResult[
"ID"], $arFields))
985 $arMessageFields = array(
986 "FROM_USER_ID" => $senderUserID,
987 "TO_USER_ID" => $targetUserID,
988 "MESSAGE" => fn (?string $languageId = null) => Loc::getMessage(
"SONET_UR_BANUSER_MESSAGE", null, $languageId),
989 "=DATE_CREATE" => $GLOBALS[
"DB"]->CurrentTimeFunction(),
990 "MESSAGE_TYPE" => SONET_MESSAGE_SYSTEM
993 CSocNetMessages::Add($arMessageFields);
995 if ($arResult[
"RELATION"] == SONET_RELATIONS_FRIEND)
996 $GLOBALS[
"DB"]->Query(
"DELETE FROM b_sonet_event_user_view WHERE
997 ENTITY_TYPE = '".SONET_ENTITY_USER.
"'
999 (USER_ID = ".$arRelation[
"FIRST_USER_ID"].
" AND ENTITY_ID = ".$arRelation[
"SECOND_USER_ID"].
")
1000 OR (USER_ID = ".$arRelation[
"SECOND_USER_ID"].
" AND ENTITY_ID = ".$arRelation[
"FIRST_USER_ID"].
")
1001 OR (ENTITY_ID = ".$arRelation[
"FIRST_USER_ID"].
" AND USER_IM_ID = ".$arRelation[
"SECOND_USER_ID"].
")
1002 OR (ENTITY_ID = ".$arRelation[
"SECOND_USER_ID"].
" AND USER_IM_ID = ".$arRelation[
"FIRST_USER_ID"].
")
1003 OR (USER_ID = ".$arRelation[
"FIRST_USER_ID"].
" AND USER_IM_ID = ".$arRelation[
"SECOND_USER_ID"].
")
1004 OR (USER_ID = ".$arRelation[
"SECOND_USER_ID"].
" AND USER_IM_ID = ".$arRelation[
"FIRST_USER_ID"].
")
1010 if ($e = $APPLICATION->GetException())
1011 $errorMessage = $e->GetString();
1012 if ($errorMessage ==
'')
1013 $errorMessage = GetMessage(
"SONET_UR_ERROR_UPDATE_RELATION");
1015 $GLOBALS[
"APPLICATION"]->ThrowException($errorMessage,
"ERROR_UPDATE_RELATION");
1021 $GLOBALS[
"APPLICATION"]->ThrowException(GetMessage(
"SONET_UR_ALREADY_BAN"),
"ERROR_ALREADY_BAN");
1028 "FIRST_USER_ID" => $senderUserID,
1029 "SECOND_USER_ID" => $targetUserID,
1031 "=DATE_CREATE" =>
$GLOBALS[
"DB"]->CurrentTimeFunction(),
1032 "=DATE_UPDATE" =>
$GLOBALS[
"DB"]->CurrentTimeFunction(),
1033 "INITIATED_BY" =>
"F",
1037 $arMessageFields =
array(
1038 "FROM_USER_ID" => $senderUserID,
1039 "TO_USER_ID" => $targetUserID,
1040 "MESSAGE" => fn (?
string $languageId =
null) => Loc::getMessage(
"SONET_UR_BANUSER_MESSAGE",
null, $languageId),
1041 "=DATE_CREATE" =>
$GLOBALS[
"DB"]->CurrentTimeFunction(),
1067 $senderUserID = intval($senderUserID);
1068 if ($senderUserID <= 0)
1070 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_EMPTY_SENDER_USER_ID"),
"ERROR_SENDER_USER_ID");
1074 $relationID = intval($relationID);
1075 if ($relationID <= 0)
1077 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_EMPTY_RELATION"),
"ERROR_RELATIONID");
1084 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_ERROR_NO_RELATION"),
"ERROR_NO_RELATION");
1090 ($arRelation[
"FIRST_USER_ID"] == $senderUserID && $arRelation[
"INITIATED_BY"] ==
"F"
1091 || $arRelation[
"SECOND_USER_ID"] == $senderUserID && $arRelation[
"INITIATED_BY"] ==
"S"))
1095 $arMessageFields =
array(
1096 "FROM_USER_ID" => $senderUserID,
1097 "TO_USER_ID" => ($arRelation[
"FIRST_USER_ID"] == $senderUserID ? $arRelation[
"SECOND_USER_ID"] : $arRelation[
"FIRST_USER_ID"]),
1098 "MESSAGE" => fn (?
string $languageId =
null) => Loc::getMessage(
"SONET_UR_UNBANUSER_MESSAGE",
null, $languageId),
1099 "=DATE_CREATE" =>
$GLOBALS[
"DB"]->CurrentTimeFunction(),
1119 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SONET_UR_UNBAN_ERROR"),
"ERROR_UNBAN");
1128 $userID = intval($userID);
1134 "SELECT COUNT(ID) as CNT ".
1135 "FROM b_sonet_user_relations ".
1136 "WHERE SECOND_USER_ID = ".$userID.
" ".
1152 $userID = intval($userID);
1174 $userID = intval($userID);
1191 $userID = intval($userID);
1205 if ($module ==
"socialnetwork")
1207 $arTag = explode(
"|", $tag);
1208 if (
count($arTag) == 4 && $arTag[1] ==
'INVITE_USER')
1212 self::ConfirmRequestToBeFriend($arTag[2], $arTag[3]);
1217 self::RejectRequestToBeFriend($arTag[2], $arTag[3]);
static AutoSubscribe($userID, $entityType, $entityID)
static GetEventSite($userID, $event, $defSiteID)
static OnBeforeConfirmNotify($module, $tag, $value, $arParams)
static __SpeedFileDelete($userID)
static GetRelatedUsers($userID, $relation, $arNavStartParams=false, $bActiveOnly="N")
static SpeedFileExists($userID)
static ConfirmRequestToBeFriend($senderUserID, $relationID, $bAutoSubscribe=true)
static __SpeedFileCheckMessages($userID)
static CheckFields($ACTION, &$arFields, $ID=0)
static BanUser($senderUserID, $targetUserID)
static GetRelation($firstUserID, $secondUserID)
static UnBanMember($senderUserID, $relationID)
static SendRequestToBeFriend($senderUserID, $targetUserID, $message)
static SendEvent($relationID, $mailType="INVITE_FRIEND")
static IsFriends2($firstUserID, $secondUserID)
static RejectRequestToBeFriend($senderUserID, $relationID)
static IsFriends($firstUserID, $secondUserID)
static GetByUserID($user1ID, $user2ID)
static DeleteNoDemand($userID)
static __SpeedFileCreate($userID)
static DeleteRelation($senderUserID, $targetUserID)
static OnUserRelationsChange($user_id)
static GetList($arOrder=Array("ID"=> "DESC"), $arFilter=Array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
static GetRelationsTop($userID, $number=100)
static Update($ID, $arFields)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
while($arParentIBlockProperty=$dbParentIBlockProperty->Fetch()) $errorMessage
$_SERVER["DOCUMENT_ROOT"]
ExecuteModuleEventEx($arEvent, $arParams=[])
IsModuleInstalled($module_id)
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
GetMessage($name, $aReplace=null)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
global $arSocNetAllowedRelations
const SONET_RELATIONS_FRIEND
const SONET_RELATIONS_REQUEST
const SONET_RELATIONS_TYPE_FRIENDS2
const SONET_MESSAGE_SYSTEM
const SONET_RELATIONS_BAN
$GLOBALS['_____370096793']