Documentation

GetRelatedUsers

CDBResult
CSocNetUserRelations::GetRelatedUsers(
 int userID,
 char relation,
 array arNavStartParams = false,
 bool bActiveOnly = N
);

The method returns list of users, binded with the specified user via the specified binding type. Static method.

Parameters

Parameter Description Available from version
userID User ID.
relation Binding type: SONET_RELATIONS_FRIEND - friends, SONET_RELATIONS_REQUEST - friends request, SONET_RELATIONS_BAN - blacklist.
arNavStartParams Array, defining list of returned values for pagewise navigation.
bActiveOnly Active status flag. Optional parameter. Set to N by default.

Returned value

The method returns CDBResult object, containing list of bindings of specified type.

See Also

Examples

<?
// Create array of friends for the current user of те more than 20.
$arrFriends = array();
$currentUserId = intval($GLOBALS["USER"]->GetID());

$arNavParams = array("nPageSize" => 20, "bDescPageNumbering" => false);
$dbFriends = CSocNetUserRelations::GetRelatedUsers($currentUserId, SONET_RELATIONS_FRIEND, $arNavParams);
while ($arFriends = $dbFriends->GetNext())
{
	$pref = (($currentUserId == $arFriends["FIRST_USER_ID"]) ? "SECOND" : "FIRST");
	$arrFriends[$arFriends[$pref."_USER_ID"]] = $arFriends[$pref."_USER_NAME"]." ".$arFriends[$pref."_USER_LAST_NAME"];
}
?>


© «Bitrix24», 2001-2024
Up