Documentation

Add

int
CSocNetUserRelations::Add(
 array arFields
);

The method creates new binding between users. Non-static method.

Parameters

Parameter Description Available from version
arFields Array of binding parameters. Can have the following keys:
FIRST_USER_ID - first user ID,
SECOND_USER_ID - second user ID,
RELATION - binding type: SONET_RELATIONS_FRIEND - users are friends, SONET_RELATIONS_REQUEST - one of users have sent to another user a friends request, SONET_RELATIONS_BAN - one of users have included another user to blacklist,
DATE_CREATE - date when binding was created,
DATE_UPDATE - date when binding was modified,
MESSAGE - message from binding creator,
INITIATED_BY - flag, specifying user who initiated the binding: F - first user, S - second user.

Returned value

Returns binding ID code on success and false otherwise.

Example:

Returns social network user ID on success.

<?
// Adding bindings
$arFields = array(
    "FIRST_USER_ID" => 11111,
    "SECOND_USER_ID" => 22222,
    "RELATION" => SONET_RELATIONS_FRIEND,
    "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(),
    "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(),
    "MESSAGE" => 'Test',
    "INITIATED_BY" => "S",
);
$userAdd = CSocNetUserRelations::Add($arFields);
echo '=<pre>'; print_r($userAdd); echo '</pre>=';
?>


© «Bitrix24», 2001-2024
Up