本文整理汇总了PHP中CSocNetUserRelations::GetRelatedUsers方法的典型用法代码示例。如果您正苦于以下问题:PHP CSocNetUserRelations::GetRelatedUsers方法的具体用法?PHP CSocNetUserRelations::GetRelatedUsers怎么用?PHP CSocNetUserRelations::GetRelatedUsers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSocNetUserRelations
的用法示例。
在下文中一共展示了CSocNetUserRelations::GetRelatedUsers方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: OnUserRelationsChange
function OnUserRelationsChange($user_id)
{
if (CModule::IncludeModule('search')) {
CSearchUser::DeleteByUserID($user_id);
}
$provider = new CSocNetGroupAuthProvider();
$provider->DeleteByUser($user_id);
$provider = new CSocNetUserAuthProvider();
$provider->DeleteByUser($user_id);
$dbFriend = CSocNetUserRelations::GetRelatedUsers($user_id, SONET_RELATIONS_FRIEND);
while ($arFriend = $dbFriend->Fetch()) {
$friendID = $user_id == $arFriend["FIRST_USER_ID"] ? $arFriend["SECOND_USER_ID"] : $arFriend["FIRST_USER_ID"];
$provider->DeleteByUser($friendID);
}
}
示例2: array
}
if (count($arResult["UserPropertiesMain"]["DATA"]) > 0) {
$arResult["UserPropertiesMain"]["SHOW"] = "Y";
}
if (count($arResult["UserPropertiesContact"]["DATA"]) > 0) {
$arResult["UserPropertiesContact"]["SHOW"] = "Y";
}
if (count($arResult["UserPropertiesPersonal"]["DATA"]) > 0) {
$arResult["UserPropertiesPersonal"]["SHOW"] = "Y";
}
}
if (!$arParams["SHORT_FORM"]) {
// USER FRIENDS
$arResult["Friends"] = false;
if (CSocNetUser::IsFriendsAllowed() && $arResult["CurrentUserPerms"]["Operations"]["viewfriends"]) {
$dbFriends = CSocNetUserRelations::GetRelatedUsers($arResult["User"]["ID"], SONET_RELATIONS_FRIEND, array("nTopCount" => $arParams["ITEMS_COUNT"]));
if ($dbFriends) {
$arResult["Friends"] = array();
$arResult["Friends"]["Count"] = CSocNetUserRelations::GetList(array(), array("USER_ID" => $arResult["User"]["ID"], "RELATION" => SONET_RELATIONS_FRIEND), array());
$arResult["Friends"]["List"] = false;
while ($arFriends = $dbFriends->GetNext()) {
if ($arResult["Friends"]["List"] == false) {
$arResult["Friends"]["List"] = array();
}
$pref = IntVal($arResult["User"]["ID"]) == $arFriends["FIRST_USER_ID"] ? "SECOND" : "FIRST";
$pu = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arFriends[$pref . "_USER_ID"]));
$canViewProfile = CSocNetUserPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), $arFriends[$pref . "_USER_ID"], "viewprofile", CSocNetUser::IsCurrentUserModuleAdmin());
if (intval($arParams["THUMBNAIL_LIST_SIZE"]) > 0) {
if (intval($arFriends[$pref . "_USER_PERSONAL_PHOTO"]) <= 0) {
switch ($arFriends[$pref . "_USER_PERSONAL_GENDER"]) {
case "M":
示例3: UpdateCodes
public function UpdateCodes($USER_ID)
{
global $DB;
if (CSocNetUser::IsFriendsAllowed()) {
$USER_ID = intval($USER_ID);
$dbFriends = CSocNetUserRelations::GetRelatedUsers($USER_ID, SONET_RELATIONS_FRIEND);
while ($arFriends = $dbFriends->Fetch()) {
$friendID = $USER_ID == $arFriends["FIRST_USER_ID"] ? $arFriends["SECOND_USER_ID"] : $arFriends["FIRST_USER_ID"];
$DB->Query("INSERT INTO b_user_access (USER_ID, PROVIDER_ID, ACCESS_CODE) VALUES \n\t\t\t\t\t(" . $friendID . ", '" . $DB->ForSQL($this->id) . "', 'SU" . $USER_ID . "_" . SONET_RELATIONS_TYPE_FRIENDS . "')");
$dbFriends2 = CSocNetUserRelations::GetRelatedUsers($friendID, SONET_RELATIONS_FRIEND);
while ($arFriends2 = $dbFriends2->Fetch()) {
$friendID2 = $friendID == $arFriends2["FIRST_USER_ID"] ? $arFriends2["SECOND_USER_ID"] : $arFriends2["FIRST_USER_ID"];
if ($friendID2 != $USER_ID) {
$DB->Query("INSERT INTO b_user_access (USER_ID, PROVIDER_ID, ACCESS_CODE) VALUES \n\t\t\t\t\t\t\t(" . $friendID2 . ", '" . $DB->ForSQL($this->id) . "', 'SU" . $USER_ID . "_" . SONET_RELATIONS_TYPE_FRIENDS2 . "')");
}
}
}
}
}
示例4: ReceiveMessage
public function ReceiveMessage($senderJId, array $arMessage, CXMPPClient $senderClient)
{
if (!$senderClient->IsAuthenticated()) {
return false;
}
if (strlen($senderJId) <= 0) {
return false;
}
if (!array_key_exists("iq", $arMessage)) {
return false;
}
if ($arMessage['iq']['query']['.']['xmlns'] != 'jabber:iq:roster' && ($arMessage['iq']['query']['.']['xmlns'] != 'jabber:iq:private' || $arMessage['iq']['query']['roster']['.']['xmlns'] != 'roster:delimiter')) {
return false;
}
if ($arMessage['iq']['query']['.']['xmlns'] == 'jabber:iq:roster') {
$arResult = array("iq" => array("." => array("type" => "result", "to" => $senderJId, "id" => $arMessage['iq']['.']['id']), "query" => array("." => array("xmlns" => $arMessage['iq']['query']['.']['xmlns']))));
if ($this->intranet) {
$clientDomain = $senderClient->GetClientDomain();
if (!array_key_exists($clientDomain, $this->rosterCache)) {
$this->rosterCache[$clientDomain] = array();
}
if (!array_key_exists($clientDomain, $this->rosterCacheAlt)) {
$this->rosterCacheAlt[$clientDomain] = array();
}
if ($senderClient->IsSubGroupsSupported() && count($this->rosterCache[$clientDomain]) <= 0 || !$senderClient->IsSubGroupsSupported() && count($this->rosterCacheAlt[$clientDomain]) <= 0) {
$arDepCache = array();
$arDepCacheValue = array();
$dbUsers = CUser::GetList($b = "LAST_NAME", $o = "asc", array("ACTIVE" => "Y", "!UF_DEPARTMENT" => false), array('SELECT' => array('UF_*')));
while ($arUser = $dbUsers->Fetch()) {
$arT = array("." => array("subscription" => "both", "name" => CUser::FormatName($this->nameTemplate, $arUser), "jid" => CXMPPUtility::GetJId($arUser, $clientDomain)));
if (is_array($arUser['UF_DEPARTMENT']) && count($arUser['UF_DEPARTMENT']) > 0) {
$arNewDep = array_diff($arUser['UF_DEPARTMENT'], $arDepCache);
if (count($arNewDep) > 0) {
$dbRes = CIBlockSection::GetList(array('SORT' => 'ASC'), array('ID' => $arNewDep));
while ($arSect = $dbRes->Fetch()) {
$arDepCache[] = $arSect['ID'];
$dbRes1 = CIBlockSection::GetNavChain($arSect['IBLOCK_ID'], $arSect['ID']);
while ($arSect1 = $dbRes1->Fetch()) {
if ($senderClient->IsSubGroupsSupported()) {
if (strlen($arDepCacheValue[$arSect['ID']]) > 0) {
$arDepCacheValue[$arSect['ID']] .= "/";
}
$arDepCacheValue[$arSect['ID']] .= htmlspecialcharsbx($arSect1['NAME']);
} else {
if (strlen($arDepCacheValue[$arSect['ID']]) > 0) {
$arDepCacheValue[$arSect['ID']] = "/" . $arDepCacheValue[$arSect['ID']];
}
$arDepCacheValue[$arSect['ID']] = htmlspecialcharsbx($arSect1['NAME']) . $arDepCacheValue[$arSect['ID']];
}
}
}
}
foreach ($arUser['UF_DEPARTMENT'] as $key => $sect) {
if (strlen($arDepCacheValue[$sect]) > 0) {
$arT["group"][] = array("#" => $arDepCacheValue[$sect]);
if (!is_array($GLOBALS["BX_JHGDHGFJKDFSDG67"])) {
$GLOBALS["BX_JHGDHGFJKDFSDG67"] = array();
}
if (!is_array($GLOBALS["BX_JHGDHGFJKDFSDG67"][$clientDomain])) {
$GLOBALS["BX_JHGDHGFJKDFSDG67"][$clientDomain] = array();
}
if (!in_array($arDepCacheValue[$sect], $GLOBALS["BX_JHGDHGFJKDFSDG67"][$clientDomain])) {
$GLOBALS["BX_JHGDHGFJKDFSDG67"][$clientDomain][] = $arDepCacheValue[$sect];
}
}
}
}
if ($senderClient->IsSubGroupsSupported()) {
$this->rosterCache[$clientDomain][] = $arT;
} else {
$this->rosterCacheAlt[$clientDomain][] = $arT;
}
}
}
if ($senderClient->IsSubGroupsSupported()) {
foreach ($this->rosterCache[$clientDomain] as $ar) {
if ($senderClient->GetJId() != $ar["."]["jid"]) {
$arResult["iq"]["query"]["item"][] = $ar;
}
}
} else {
foreach ($this->rosterCacheAlt[$clientDomain] as $ar) {
if ($senderClient->GetJId() != $ar["."]["jid"]) {
$arResult["iq"]["query"]["item"][] = $ar;
}
}
}
} else {
$ar = array();
$dbFriends = CSocNetUserRelations::GetRelatedUsers($senderClient->GetId(), SONET_RELATIONS_FRIEND);
while ($arFriends = $dbFriends->GetNext()) {
$pref = $senderClient->GetId() == $arFriends["FIRST_USER_ID"] ? "SECOND" : "FIRST";
$name = CUser::FormatName($this->nameTemplate, array("NAME" => $arFriends[$pref . "_USER_NAME"], "LAST_NAME" => $arFriends[$pref . "_USER_LAST_NAME"], "SECOND_NAME" => $arFriends[$pref . "_USER_SECOND_NAME"], "LOGIN" => $arFriends[$pref . "_USER_LOGIN"]), true);
$arT = array("." => array("subscription" => "both", "name" => $name, "jid" => CXMPPUtility::GetJId(array("LOGIN" => $arFriends[$pref . "_USER_LOGIN"]), $senderClient->GetClientDomain())));
$ar[] = $arT;
}
$arResult["iq"]["query"]["item"] = $ar;
}
$senderClient->Send($arResult);
$server = CXMPPServer::GetServer();
//.........这里部分代码省略.........
示例5: ConfirmRequestToBeFriend
//.........这里部分代码省略.........
"URL" => false,
"MODULE_ID" => false,
"CALLBACK_FUNC" => false,
"USER_ID" => $arResult["FIRST_USER_ID"]
),
false
);
if (intval($logID) > 0)
{
CSocNetLog::Update($logID, array("TMP_ID" => $logID));
$perm = CSocNetUserPerms::GetOperationPerms($senderUserID, "viewfriends");
if (in_array($perm, array(SONET_RELATIONS_TYPE_FRIENDS2, SONET_RELATIONS_TYPE_FRIENDS)))
CSocNetLogRights::Add($logID, array("SA", "U".$senderUserID, "S".SONET_ENTITY_USER.$senderUserID."_".$perm));
elseif ($perm == SONET_RELATIONS_TYPE_NONE)
CSocNetLogRights::Add($logID, array("SA", "U".$senderUserID));
elseif ($perm == SONET_RELATIONS_TYPE_AUTHORIZED)
CSocNetLogRights::Add($logID, array("SA", "AU"));
elseif ($perm == SONET_RELATIONS_TYPE_ALL)
CSocNetLogRights::Add($logID, array("SA", "G2"));
$tmpID = $logID;
}
$logID = CSocNetLog::Add(
array(
"ENTITY_TYPE" => SONET_ENTITY_USER,
"ENTITY_ID" => $arResult["FIRST_USER_ID"],
"EVENT_ID" => "system_friends",
"=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(),
"TITLE_TEMPLATE" => false,
"TITLE" => "friend",
"MESSAGE" => $senderUserID,
"URL" => false,
"MODULE_ID" => false,
"CALLBACK_FUNC" => false,
"USER_ID" => $senderUserID,
"TMP_ID" => (intval($tmpID) > 0 ? $tmpID : false),
),
false
);
if (intval($logID) > 0)
{
$perm = CSocNetUserPerms::GetOperationPerms($arResult["FIRST_USER_ID"], "viewfriends");
if (in_array($perm, array(SONET_RELATIONS_TYPE_FRIENDS2, SONET_RELATIONS_TYPE_FRIENDS)))
CSocNetLogRights::Add($logID, array("SA", "U".$arResult["FIRST_USER_ID"], "S".SONET_ENTITY_USER.$arResult["FIRST_USER_ID"]."_".$perm));
elseif ($perm == SONET_RELATIONS_TYPE_NONE)
CSocNetLogRights::Add($logID, array("SA", "U".$arResult["FIRST_USER_ID"]));
elseif ($perm == SONET_RELATIONS_TYPE_AUTHORIZED)
CSocNetLogRights::Add($logID, array("SA", "AU"));
elseif ($perm == SONET_RELATIONS_TYPE_ALL)
CSocNetLogRights::Add($logID, array("SA", "G2"));
CSocNetLog::SendEvent($logID, "SONET_NEW_EVENT", $tmpID);
}
}
else
{
$errorMessage = "";
if ($e = $APPLICATION->GetException())
$errorMessage = $e->GetString();
if (StrLen($errorMessage) <= 0)
$errorMessage = GetMessage("SONET_UR_ERROR_UPDATE_RELATION");
$GLOBALS["APPLICATION"]->ThrowException($errorMessage, "ERROR_CREATE_RELATION");
return false;
}
}
else
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_NO_FRIEND_REQUEST"), "ERROR_NO_FRIEND_REQUEST");
return false;
}
$arUserID = array(
$arResult["FIRST_USER_ID"],
$arResult["SECOND_USER_ID"]
);
$dbFriends = CSocNetUserRelations::GetRelatedUsers($arResult["FIRST_USER_ID"], SONET_RELATIONS_FRIEND);
while ($arFriends = $dbFriends->Fetch())
{
$pref = (($arResult["FIRST_USER_ID"] == $arFriends["FIRST_USER_ID"]) ? "SECOND" : "FIRST");
$arUserID[] = $arResult[$pref."_USER_ID"];
}
$dbFriends = CSocNetUserRelations::GetRelatedUsers($arResult["SECOND_USER_ID"], SONET_RELATIONS_FRIEND);
while ($arFriends = $dbFriends->Fetch())
{
$pref = (($arResult["FIRST_USER_ID"] == $arFriends["FIRST_USER_ID"]) ? "SECOND" : "FIRST");
$arUserID[] = $arResult[$pref."_USER_ID"];
}
$arUserID = array_unique($arUserID);
CSocNetUserRelations::__SpeedFileCheckMessages($senderUserID);
return true;
}
示例6: array
$suffix = "female";
break;
default:
$suffix = "unknown";
}
$arFriends[$pref . "_USER_PERSONAL_PHOTO"] = COption::GetOptionInt("socialnetwork", "default_user_picture_" . $suffix, false, SITE_ID);
}
$arImage = CFile::ResizeImageGet($arFriends[$pref . "_USER_PERSONAL_PHOTO"], array("width" => $arParams["THUMBNAIL_LIST_SIZE"], "height" => $arParams["THUMBNAIL_LIST_SIZE"]), BX_RESIZE_IMAGE_EXACT, false);
}
$arResult["Friends"]["List"][] = array("ID" => $arFriends["ID"], "USER_ID" => $arFriends[$pref . "_USER_ID"], "USER_NAME" => $arFriends[$pref . "_USER_NAME"], "USER_LAST_NAME" => $arFriends[$pref . "_USER_LAST_NAME"], "USER_SECOND_NAME" => $arFriends[$pref . "_USER_SECOND_NAME"], "USER_LOGIN" => $arFriends[$pref . "_USER_LOGIN"], "USER_PERSONAL_PHOTO" => $arFriends[$pref . "_USER_PERSONAL_PHOTO"], "USER_PERSONAL_PHOTO" => $arFriends[$pref . "_USER_PERSONAL_PHOTO"], "USER_PERSONAL_PHOTO_IMG" => $arImage, "USER_PROFILE_URL" => $pu, "SHOW_PROFILE_LINK" => $canViewProfile, "USER_NAME_FORMATTED" => $NameFormatted, "USER_WORK_POSITION" => $arFriends[$pref . "_USER_WORK_POSITION"]);
}
$arResult["Friends"]["NAV_STRING"] = $dbFriends->GetPageNavStringEx($navComponentObject, GetMessage("SONET_UFE_FRIENDS_NAV"), "", false);
}
if (!IsModuleInstalled("im")) {
$arResult["Banned"] = false;
$dbBan = CSocNetUserRelations::GetRelatedUsers($arResult["User"]["ID"], SONET_RELATIONS_BAN, $arNavParams, $bActiveOnly);
if ($dbBan) {
$arResult["Banned"] = array();
$arResult["Banned"]["List"] = false;
while ($arBan = $dbBan->GetNext()) {
if ($arResult["Banned"]["List"] == false) {
$arResult["Banned"]["List"] = array();
}
$pref = IntVal($arResult["User"]["ID"]) == $arBan["FIRST_USER_ID"] ? "SECOND" : "FIRST";
$pu = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arBan[$pref . "_USER_ID"]));
$canViewProfile = CSocNetUserPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), $arBan[$pref . "_USER_ID"], "viewprofile", CSocNetUser::IsCurrentUserModuleAdmin());
$bInitiated = $GLOBALS["USER"]->GetID() == $arBan["FIRST_USER_ID"] && $arBan["INITIATED_BY"] == "F" || $GLOBALS["USER"]->GetID() == $arBan["SECOND_USER_ID"] && $arBan["INITIATED_BY"] == "S";
if (!$arResult["CurrentUserPerms"]["IsCurrentUser"]) {
$rel = CSocNetUserRelations::GetRelation($GLOBALS["USER"]->GetID(), $arBan[$pref . "_USER_ID"]);
} else {
$rel = SONET_RELATIONS_FRIEND;
示例7: elseif
$arCurrentUserPerms = CSocNetUserPerms::InitUserPerms($GLOBALS["USER"]->GetID(), $arUser["ID"], CSocNetUser::IsCurrentUserModuleAdmin());
if (!$arCurrentUserPerms || !$arCurrentUserPerms["IsCurrentUser"]) {
echo CUtil::PhpToJsObject(array('ERROR' => 'USER_NO_PERMS'));
die;
}
if (in_array($_POST['ACTION'], array('BAN', 'UNBAN', 'EX'))) {
if ($_POST['ACTION'] == 'BAN') {
$relation_type = SONET_RELATIONS_FRIEND;
} elseif ($_POST['ACTION'] == 'UNBAN') {
$relation_type = SONET_RELATIONS_BAN;
} elseif ($_POST['ACTION'] == 'EX') {
$relation_type = SONET_RELATIONS_FRIEND;
}
$arRelationID = array();
$arRelationUserID = array();
$rsRelation = CSocNetUserRelations::GetRelatedUsers($user_id, $relation_type);
while ($arRelation = $rsRelation->Fetch()) {
if (!in_array($arRelation["FIRST_USER_ID"], $arFriendID) && !in_array($arRelation["SECOND_USER_ID"], $arFriendID)) {
continue;
}
$arRelationID[] = $arRelation["ID"];
$arRelationUserID[] = $arRelation[($user_id == $arRelation["FIRST_USER_ID"] ? "SECOND" : "FIRST") . "_USER_ID"];
}
if (count(array_diff($arFriendID, $arRelationUserID)) > 0) {
echo CUtil::PhpToJsObject(array('ERROR' => 'FRIEND_ID_INCORRECT_2'));
die;
}
if ($_POST['ACTION'] == "BAN") {
foreach ($arRelationUserID as $relation_user_id) {
if (!CSocNetUserRelations::BanUser($user_id, $relation_user_id)) {
echo CUtil::PhpToJsObject(array('ERROR' => 'USER_ACTION_FAILED: ' . (($e = $APPLICATION->GetException()) ? $e->GetString() : "")));
示例8: UpdateCodes
public function UpdateCodes($USER_ID)
{
global $DB;
if(CSocNetUser::IsFriendsAllowed())
{
$USER_ID = intval($USER_ID);
$dbFriends = CSocNetUserRelations::GetRelatedUsers($USER_ID, SONET_RELATIONS_FRIEND);
while ($arFriends = $dbFriends->Fetch())
{
$friendID = (($USER_ID == $arFriends["FIRST_USER_ID"]) ? $arFriends["SECOND_USER_ID"] : $arFriends["FIRST_USER_ID"]);
$DB->Query("INSERT INTO b_user_access (USER_ID, PROVIDER_ID, ACCESS_CODE) VALUES
(".$friendID.", '".$DB->ForSQL($this->id)."', 'SU".$USER_ID."_".SONET_RELATIONS_TYPE_FRIENDS."')");
$arFriends2Exist = array();
$dbRes = $DB->Query("SELECT USER_ID FROM b_user_access WHERE PROVIDER_ID = '".$DB->ForSQL($this->id)."' AND ACCESS_CODE = 'SU".$USER_ID."_".SONET_RELATIONS_TYPE_FRIENDS2."'");
while ($arRes = $dbRes->Fetch())
$arFriends2Exist[] = $arRes["USER_ID"];
$dbFriends2 = CSocNetUserRelations::GetRelatedUsers($friendID, SONET_RELATIONS_FRIEND);
while ($arFriends2 = $dbFriends2->Fetch())
{
$friendID2 = (($friendID == $arFriends2["FIRST_USER_ID"]) ? $arFriends2["SECOND_USER_ID"] : $arFriends2["FIRST_USER_ID"]);
if ($friendID2 != $USER_ID && !in_array($friendID2, $arFriends2Exist))
$DB->Query("INSERT INTO b_user_access (USER_ID, PROVIDER_ID, ACCESS_CODE) VALUES
(".$friendID2.", '".$DB->ForSQL($this->id)."', 'SU".$USER_ID."_".SONET_RELATIONS_TYPE_FRIENDS2."')");
}
}
}
}
示例9: ConfirmRequestToBeFriend
function ConfirmRequestToBeFriend($senderUserID, $relationID, $bAutoSubscribe = true)
{
global $APPLICATION;
$senderUserID = IntVal($senderUserID);
if ($senderUserID <= 0) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_EMPTY_SENDER_USER_ID"), "ERROR_SENDER_USER_ID");
return false;
}
$relationID = IntVal($relationID);
if ($relationID <= 0) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_EMPTY_TARGET_USER_ID"), "ERROR_RELATION_ID");
return false;
}
$dbResult = CSocNetUserRelations::GetList(array(), array("ID" => $relationID, "SECOND_USER_ID" => $senderUserID, "RELATION" => SONET_RELATIONS_REQUEST), false, false, array("ID", "FIRST_USER_ID", "SECOND_USER_ID"));
if ($arResult = $dbResult->Fetch()) {
$rsUser = CUser::GetByID(intval($arResult["FIRST_USER_ID"]));
$arUser = $rsUser->Fetch();
if (!is_array($arUser) || $arUser["ACTIVE"] != "Y") {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_INVALID_TARGET_USER_ID"), "ERROR_INVALID_TARGET_USER_ID");
return false;
}
$arFields = array("RELATION" => SONET_RELATIONS_FRIEND, "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "INITIATED_BY" => "S");
if (CSocNetUserRelations::Update($arResult["ID"], $arFields)) {
if ($bAutoSubscribe) {
CSocNetLogEvents::AutoSubscribe($senderUserID, SONET_ENTITY_USER, $arResult["FIRST_USER_ID"]);
CSocNetLogEvents::AutoSubscribe($arResult["FIRST_USER_ID"], SONET_ENTITY_USER, $senderUserID);
}
if (CModule::IncludeModule("im")) {
CIMNotify::DeleteByTag("SOCNET|INVITE_USER|" . intval($senderUserID) . "|" . intval($arResult["ID"]));
$arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => $arResult["FIRST_USER_ID"], "FROM_USER_ID" => $senderUserID, "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "socialnetwork", "NOTIFY_EVENT" => "inout_user", "NOTIFY_TAG" => "SOCNET|INVITE_USER_CONFIRM", "NOTIFY_MESSAGE" => GetMessage("SONET_UR_AGREE_FRIEND_MESSAGE"));
CIMNotify::Add($arMessageFields);
}
} else {
$errorMessage = "";
if ($e = $APPLICATION->GetException()) {
$errorMessage = $e->GetString();
}
if (StrLen($errorMessage) <= 0) {
$errorMessage = GetMessage("SONET_UR_ERROR_UPDATE_RELATION");
}
$GLOBALS["APPLICATION"]->ThrowException($errorMessage, "ERROR_CREATE_RELATION");
return false;
}
} else {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_NO_FRIEND_REQUEST"), "ERROR_NO_FRIEND_REQUEST");
return false;
}
$arUserID = array($arResult["FIRST_USER_ID"], $arResult["SECOND_USER_ID"]);
$dbFriends = CSocNetUserRelations::GetRelatedUsers($arResult["FIRST_USER_ID"], SONET_RELATIONS_FRIEND);
while ($arFriends = $dbFriends->Fetch()) {
$pref = $arResult["FIRST_USER_ID"] == $arFriends["FIRST_USER_ID"] ? "SECOND" : "FIRST";
$arUserID[] = $arResult[$pref . "_USER_ID"];
}
$dbFriends = CSocNetUserRelations::GetRelatedUsers($arResult["SECOND_USER_ID"], SONET_RELATIONS_FRIEND);
while ($arFriends = $dbFriends->Fetch()) {
$pref = $arResult["FIRST_USER_ID"] == $arFriends["FIRST_USER_ID"] ? "SECOND" : "FIRST";
$arUserID[] = $arResult[$pref . "_USER_ID"];
}
$arUserID = array_unique($arUserID);
CSocNetUserRelations::__SpeedFileCheckMessages($senderUserID);
return true;
}
示例10: SetFeature
//.........这里部分代码省略.........
}
}
if (intval($entityID) > 0 && array_key_exists($entityType, $arSocNetAllowedSubscribeEntityTypesDesc) && array_key_exists("CLASS_DESC_GET", $arSocNetAllowedSubscribeEntityTypesDesc[$entityType]) && array_key_exists("METHOD_DESC_GET", $arSocNetAllowedSubscribeEntityTypesDesc[$entityType])) {
$arEntityTmp = call_user_func(array($arSocNetAllowedSubscribeEntityTypesDesc[$entityType]["CLASS_DESC_GET"], $arSocNetAllowedSubscribeEntityTypesDesc[$entityType]["METHOD_DESC_GET"]), $entityID);
}
foreach ($event_id as $op => $arEvent) {
$arRelatedUsers = array();
if (is_array($arEvent)) {
foreach ($arEvent as $event) {
if (!CSocNetEventUserView::Delete($entityType, $entityID, $feature, $event)) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_ERROR_DELETE"), "ERROR_DELETE");
return false;
}
if (!$feature || !$permX) {
$perm = CSocNetFeaturesPerms::GetOperationPerm($entityType, $entityID, $feature, $op);
} else {
$perm = $permX;
}
if ($entityType == SONET_SUBSCRIBE_ENTITY_GROUP && $arEntityTmp && $arEntityTmp["VISIBLE"] == "N" && $perm > SONET_ROLES_USER) {
$perm = SONET_ROLES_USER;
} elseif ($entityType == SONET_SUBSCRIBE_ENTITY_USER) {
$perm_profile = CSocNetUserPerms::GetOperationPerms($entityID, "viewprofile");
if ($perm < $perm_profile) {
$perm = $perm_profile;
}
}
if (array_key_exists($entityType, $CacheRelatedUsers) && array_key_exists($entityID, $CacheRelatedUsers[$entityType]) && array_key_exists($perm, $CacheRelatedUsers[$entityType][$entityID])) {
$arRelatedUsers = $CacheRelatedUsers[$entityType][$entityID][$perm];
} else {
if ($entityType == SONET_SUBSCRIBE_ENTITY_USER) {
switch ($perm) {
case SONET_RELATIONS_TYPE_FRIENDS:
$arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $entityID);
$dbFriends = CSocNetUserRelations::GetRelatedUsers($entityID, SONET_RELATIONS_FRIEND);
while ($arFriends = $dbFriends->Fetch()) {
$friendID = $entityID == $arFriends["FIRST_USER_ID"] ? $arFriends["SECOND_USER_ID"] : $arFriends["FIRST_USER_ID"];
$arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $friendID);
}
break;
case SONET_RELATIONS_TYPE_FRIENDS2:
$arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $entityID);
$dbFriends = CSocNetUserRelations::GetRelatedUsers($entityID, SONET_RELATIONS_FRIEND);
while ($arFriends = $dbFriends->Fetch()) {
$friendID = $entityID == $arFriends["FIRST_USER_ID"] ? $arFriends["SECOND_USER_ID"] : $arFriends["FIRST_USER_ID"];
$arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $friendID);
$dbFriends2 = CSocNetUserRelations::GetRelatedUsers($friendID, SONET_RELATIONS_FRIEND);
while ($arFriends2 = $dbFriends2->Fetch()) {
$friendID2 = $friendID == $arFriends2["FIRST_USER_ID"] ? $arFriends2["SECOND_USER_ID"] : $arFriends2["FIRST_USER_ID"];
if ($friendID2 != $entityID) {
$arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $friendID2, "user_im_id" => $friendID);
}
}
}
break;
case SONET_RELATIONS_TYPE_NONE:
$arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $entityID);
break;
case SONET_RELATIONS_TYPE_AUTHORIZED:
$arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => 0);
break;
case SONET_RELATIONS_TYPE_ALL:
$arRelatedUsers = false;
break;
}
if (!empty($arRelatedUsers)) {
$arRelatedUsers = array_unique($arRelatedUsers);
示例11: GetMyUsers
function GetMyUsers($user_id = false)
{
if (!$user_id) {
$user_id = $GLOBALS["USER"]->GetID();
}
$arUsersMy = false;
if (CSocNetUser::IsFriendsAllowed()) {
$arUsersMy = array();
$dbFriends = CSocNetUserRelations::GetRelatedUsers($user_id, SONET_RELATIONS_FRIEND);
if ($dbFriends) {
while ($arFriends = $dbFriends->Fetch()) {
$pref = $user_id == $arFriends["FIRST_USER_ID"] ? "SECOND" : "FIRST";
$arUsersMy[] = $arFriends[$pref . "_USER_ID"];
}
}
}
return $arUsersMy;
}
示例12: array
}
}
}
if (strlen($errorMessage) > 0) {
$arResult["ErrorMessage"] = $errorMessage;
}
}
if ($arResult["CurrentUserPerms"] && $arResult["CurrentUserPerms"]["Operations"]["viewprofile"] && $arResult["CurrentUserPerms"]["Operations"]["viewfriends"]) {
$arNavParams = array("nPageSize" => $arParams["ITEMS_COUNT"], "bDescPageNumbering" => false);
$arNavigation = CDBResult::GetNavParams($arNavParams);
$arResult["Urls"]["Search"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_SEARCH"], array());
$arResult["Urls"]["LogUsers"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_LOG"], array());
$arResult["Urls"]["LogUsers"] .= (StrPos($arResult["Urls"]["LogUsers"], "?") !== false ? "&" : "?") . "flt_entity_type=" . SONET_ENTITY_USER;
$arResult["CanViewLog"] = $arParams["GROUP_ID"] <= 0 && $arResult["User"]["ID"] == $GLOBALS["USER"]->GetID();
$arResult["Friends"] = false;
$dbFriends = CSocNetUserRelations::GetRelatedUsers($arResult["User"]["ID"], SONET_RELATIONS_FRIEND, $arNavParams);
if ($dbFriends) {
$arResult["Friends"] = array();
$arResult["Friends"]["List"] = false;
while ($arFriends = $dbFriends->GetNext()) {
if ($arResult["Friends"]["List"] == false) {
$arResult["Friends"]["List"] = array();
}
$pref = IntVal($arResult["User"]["ID"]) == $arFriends["FIRST_USER_ID"] ? "SECOND" : "FIRST";
$pu = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arFriends[$pref . "_USER_ID"]));
$canViewProfile = CSocNetUserPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), $arFriends[$pref . "_USER_ID"], "viewprofile", CSocNetUser::IsCurrentUserModuleAdmin());
if (!$arResult["CurrentUserPerms"]["IsCurrentUser"]) {
$rel = CSocNetUserRelations::GetRelation($GLOBALS["USER"]->GetID(), $arFriends[$pref . "_USER_ID"]);
} else {
$rel = SONET_RELATIONS_FRIEND;
}
示例13: GetUsersFromUserGroup
public function GetUsersFromUserGroup($group, $documentId)
{
$iblockId = COption::GetOptionInt("intranet", "iblock_tasks", 0);
$documentId = intval($documentId);
if ($documentId <= 0) {
return array();
}
$group = strtolower($group);
if ($group == "author") {
$db = CIBlockElement::GetList(array(), array("ID" => $documentId, "SHOW_NEW" => "Y", "IBLOCK_ID" => $iblockId), false, false, array("ID", "IBLOCK_ID", "CREATED_BY"));
if ($ar = $db->Fetch()) {
return array($ar["CREATED_BY"]);
}
return array();
} elseif ($group == "responsible") {
$db = CIBlockElement::GetList(array(), array("ID" => $documentId, "SHOW_NEW" => "Y", "IBLOCK_ID" => $iblockId), false, false, array("ID", "IBLOCK_ID", "PROPERTY_TASKASSIGNEDTO"));
if ($ar = $db->Fetch()) {
return array($ar["PROPERTY_TASKASSIGNEDTO_VALUE"]);
}
return array();
} elseif ($group == "trackers") {
$arR = array();
$dbElementPropValueList = CIBlockElement::GetProperty($iblockId, $documentId, "sort", "asc", array("CODE" => "TASKTRACKERS"));
while ($arElementPropValue = $dbElementPropValueList->Fetch()) {
$arR[] = $arElementPropValue["VALUE"];
}
return $arR;
}
$arR = array();
$dbTaskList = CIBlockElement::GetList(array(), array("ID" => $documentId, "SHOW_NEW" => "Y", "IBLOCK_ID" => $iblockId), false, false, array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "PROPERTY_TASKASSIGNEDTO"));
if ($arTask = $dbTaskList->Fetch()) {
$dbSectionsChain = CIBlockSection::GetNavChain($arTask["IBLOCK_ID"], $arTask["IBLOCK_SECTION_ID"]);
if ($arSect = $dbSectionsChain->Fetch()) {
if ($arSect["XML_ID"] == "users_tasks") {
if ($group == strtolower(SONET_RELATIONS_TYPE_FRIENDS)) {
$db = CSocNetUserRelations::GetRelatedUsers($arTask["PROPERTY_TASKASSIGNEDTO_VALUE"], SONET_RELATIONS_TYPE_FRIENDS);
while ($ar = $db->Fetch()) {
if ($ar["FIRST_USER_ID"] == $arTask["PROPERTY_TASKASSIGNEDTO_VALUE"]) {
$arR[] = $ar["SECOND_USER_ID"];
} else {
$arR[] = $ar["FIRST_USER_ID"];
}
}
}
} else {
if ($group == strtolower(SONET_ROLES_OWNER)) {
$arGroup = CSocNetGroup::GetByID($arSect["XML_ID"]);
if ($arGroup) {
$arR[] = $arGroup["OWNER_ID"];
}
} elseif ($group == strtolower(SONET_ROLES_MODERATOR)) {
$db = CSocNetUserToGroup::GetList(array(), array("GROUP_ID" => $arSect["XML_ID"], "<=ROLE" => SONET_ROLES_MODERATOR, "USER_ACTIVE" => "Y"), false, false, array("USER_ID"));
while ($ar = $db->Fetch()) {
$arR[] = $ar["USER_ID"];
}
} elseif ($group == strtolower(SONET_ROLES_USER)) {
$db = CSocNetUserToGroup::GetList(array(), array("GROUP_ID" => $arSect["XML_ID"], "<=ROLE" => SONET_ROLES_USER, "USER_ACTIVE" => "Y"), false, false, array("USER_ID"));
while ($ar = $db->Fetch()) {
$arR[] = $ar["USER_ID"];
}
}
}
}
}
return $arR;
}
示例14: array
$strNameFormatted = CUser::FormatName($arParams['NAME_TEMPLATE'], $arTmpUser, $bUseLogin);
$arStructureUser = array("USER_ID" => $arUser["ID"], "USER_NAME" => $arUser["NAME"], "USER_LAST_NAME" => $arUser["LAST_NAME"], "USER_SECOND_NAME" => $arUser["SECOND_NAME"], "USER_LOGIN" => $arUser["LOGIN"], "USER_NAME_FORMATTED" => $strNameFormatted, "USER_PROFILE_URL" => $pu, "SHOW_PROFILE_LINK" => $canViewProfile, "PATH_TO_MESSAGES_CHAT" => str_replace("#user_id#", $arUser["ID"], $arParams["PATH_TO_MESSAGES_CHAT"]), "IS_ONLINE" => $arUser["IS_ONLINE"] == "Y");
if (is_array($arUser["UF_DEPARTMENT"]) && !empty($arUser["UF_DEPARTMENT"])) {
foreach ($arUser["UF_DEPARTMENT"] as $dep_id) {
$arResult["UsersInStructure"][$dep_id][] = $arStructureUser;
}
} else {
$arResult["UsersInStructure"]["others"][] = $arStructureUser;
}
}
}
}
//Friends
$arResult["Friends"] = false;
if (CSocNetUser::IsFriendsAllowed() && (!CModule::IncludeModule('extranet') || !CExtranet::IsExtranetSite())) {
$dbFriends = CSocNetUserRelations::GetRelatedUsers($arResult["UserSelf"]["ID"], SONET_RELATIONS_FRIEND);
if ($dbFriends) {
$arResult["Friends"] = array();
while ($arFriends = $dbFriends->GetNext()) {
$pref = IntVal($arResult["UserSelf"]["ID"]) == $arFriends["FIRST_USER_ID"] ? "SECOND" : "FIRST";
$pu = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arFriends[$pref . "_USER_ID"]));
$canViewProfile = CSocNetUserPerms::CanPerformOperation($arResult["UserSelf"]["ID"], $arFriends[$pref . "_USER_ID"], "viewprofile", CSocNetUser::IsCurrentUserModuleAdmin());
$arTmpUser = array("NAME" => $arFriends["~" . $pref . "_USER_NAME"], "LAST_NAME" => $arFriends["~" . $pref . "_USER_LAST_NAME"], "SECOND_NAME" => $arFriends["~" . $pref . "_USER_SECOND_NAME"], "LOGIN" => $arFriends["~" . $pref . "_USER_LOGIN"]);
$strNameFormatted = CUser::FormatName($arParams['NAME_TEMPLATE'], $arTmpUser, $bUseLogin);
$arResult["Friends"][] = array("USER_ID" => $arFriends[$pref . "_USER_ID"], "USER_NAME" => $arFriends[$pref . "_USER_NAME"], "USER_LAST_NAME" => $arFriends[$pref . "_USER_LAST_NAME"], "USER_SECOND_NAME" => $arFriends[$pref . "_USER_SECOND_NAME"], "USER_LOGIN" => $arFriends[$pref . "_USER_LOGIN"], "USER_NAME_FORMATTED" => $strNameFormatted, "USER_PROFILE_URL" => $pu, "SHOW_PROFILE_LINK" => $canViewProfile, "PATH_TO_MESSAGES_CHAT" => str_replace("#user_id#", $arFriends[$pref . "_USER_ID"], $arParams["PATH_TO_MESSAGES_CHAT"]), "IS_ONLINE" => $arFriends[$pref . "_USER_IS_ONLINE"] == "Y");
}
}
} elseif (CModule::IncludeModule('extranet') && CExtranet::IsExtranetSite()) {
$arResult["Friends"] = array();
$arUsersInListID = array();
$arMyGroupsUsers = CExtranet::GetMyGroupsUsersFull(SITE_ID, true);
示例15: GetUsersFromUserGroup
public function GetUsersFromUserGroup($group, $documentId)
{
$diskId = self::processGetDiskIdByDocId((int) $documentId);
if ($diskId !== null) {
return self::proxyToDisk(__FUNCTION__, array($group, $diskId));
}
$arResult = array();
$arParameters = array("IBlockId" => 0, "OwnerType" => "", "OwnerId" => 0);
if (strLen($documentId) <= 0) {
return $arResult;
}
$res = explode("_", $documentId);
if (count($res) == 4) {
$arParameters = array("IBlockId" => $res[1], "OwnerType" => $res[2], "OwnerId" => $res[3]);
} elseif (intVal($documentId) > 0) {
$db_res = CIBlockElement::GetList(array(), array("ID" => $documentId, "SHOW_NEW" => "Y", "SHOW_HISTORY" => "Y"), false, false, array("ID", "IBLOCK_ID", "CREATED_BY", "IBLOCK_SECTION_ID"));
$arElement = $db_res->Fetch();
if (!$arElement) {
return false;
}
$arParameters["IBlockId"] = $arElement["IBLOCK_ID"];
$arParameters["CreatedBy"] = $arElement["CREATED_BY"];
$dbSectionsChain = CIBlockSection::GetNavChain($arElement["IBLOCK_ID"], $arElement["IBLOCK_SECTION_ID"]);
if ($arSect = $dbSectionsChain->Fetch()) {
$arParameters["OwnerType"] = intVal($arSect["SOCNET_GROUP_ID"]) > 0 ? "group" : "user";
$arParameters["OwnerId"] = intVal($arSect["SOCNET_GROUP_ID"]) > 0 ? $arSect["SOCNET_GROUP_ID"] : $arSect["CREATED_BY"];
}
}
$sGroup = strtoupper($group);
if ($sGroup == "AUTHOR") {
return array($arParameters["CreatedBy"]);
} elseif ($sGroup == SONET_RELATIONS_TYPE_NONE) {
return array($arParameters["OwnerId"]);
} elseif ($arParameters["OwnerId"] <= 0) {
return array();
}
if ($arParameters["OwnerType"] == "user") {
$db_res = CSocNetUserRelations::GetRelatedUsers($arParameters["OwnerId"], SONET_RELATIONS_FRIEND);
if ($db_res && ($res = $db_res->Fetch())) {
do {
if ($res["FIRST_USER_ID"] == $arParameters["OwnerId"]) {
$arResult[] = $res["SECOND_USER_ID"];
} else {
$arResult[] = $res["FIRST_USER_ID"];
}
} while ($res = $db_res->Fetch());
}
} else {
if ($sGroup == SONET_ROLES_OWNER) {
$arGroup = CSocNetGroup::GetByID($arParameters["OwnerId"]);
if ($arGroup) {
$arResult[] = $arGroup["OWNER_ID"];
}
} elseif ($sGroup == SONET_ROLES_MODERATOR) {
$db = CSocNetUserToGroup::GetList(array(), array("GROUP_ID" => $arParameters["OwnerId"], "<=ROLE" => SONET_ROLES_MODERATOR, "USER_ACTIVE" => "Y"), false, false, array("USER_ID"));
while ($ar = $db->Fetch()) {
$arResult[] = $ar["USER_ID"];
}
} elseif ($sGroup == SONET_ROLES_USER) {
$db = CSocNetUserToGroup::GetList(array(), array("GROUP_ID" => $arParameters["OwnerId"], "<=ROLE" => SONET_ROLES_USER, "USER_ACTIVE" => "Y"), false, false, array("USER_ID"));
while ($ar = $db->Fetch()) {
$arResult[] = $ar["USER_ID"];
}
}
}
return $arResult;
}